[ESS] Making M-n r (for ess-swv-knit) available in polymode

Josh O'Brien joshmobrien at gmail.com
Thu Apr 3 23:46:08 CEST 2014


Great to hear that you're improving polymode even more, and thanks to you both!

I've already adapted Mathieu's code, and it's working nicely for me.

The only complication (and not a very big one!) is that the first time
I run ess-swv-knit (using "M-n r"), I'm asked to "Set `ess-dialect':
{R | S+ | stata | julia | SAS | XLS | ViSta}".  I might have thought I
could avoid this question by adding a line to my .emacs reading: (setq
ess-dialect "R"), but that doesn't seem to work. Oh well, not  a big
deal.

Thanks again,

Josh


On Thu, Apr 3, 2014 at 2:30 PM, Vitalie Spinu <spinuvit at gmail.com> wrote:
>
> I have resumed working on polymomde and will release it to MELPA
> soon. You will have good shortcuts by default, including pandoc.
>
> For now Mathieu's setup is the way to go.
>
>    Vitalie
>
>  >>> Mathieu Basille on Thu, 03 Apr 2014 17:02:02 -0400 wrote:
>
>  > Hey Josh,
>
>  > I use the following keyboard setup for polymode:
>
>  > ;; F5 to weave / C-F5 to compile to HTML / C-S-F5 to tangle
>  > (define-key polymode-mode-map [(f5)] 'ess-swv-weave)
>  > (define-key polymode-mode-map [(control f5)] 'ess-swv-pandoc)
>  > (define-key polymode-mode-map [(control shift f5)] 'ess-swv-tangle)
>
>  > With the home-made 'ess-swv-pandoc' function below:
>
>  > ;; Function ess-swv-pandoc to use knitr::pandoc with options in
>  > ;; .emacs.d/config.pandoc
>  > (defun ess-swv-pandoc ()
>  >   "Run Pandoc on the associated .md file."
>  >   (interactive)
>  >   (let* ((rmd-buf (current-buffer)))
>  >     (save-excursion
>  >       (let* ((sprocess (ess-get-process ess-current-process-name))
>  >              (sbuffer (process-buffer sprocess))
>  >              (md-filename (file-name-sans-extension (buffer-file-name)))
>  >              (buf-coding (symbol-name buffer-file-coding-system))
>  >              (pandoc-cmd
>  >            (format "require(knitr); pandoc(\"%s.md\", format =
>  >            \"html\", config =
>  >            \"/home/mathieu/.emacs.d/config.pandoc\")"
>  >            md-filename)))
>  >      (message "Running pandoc on %s.md" md-filename)
>  >         (ess-execute pandoc-cmd 'buffer nil nil)
>  >         (switch-to-buffer rmd-buf)
>  >         (ess-show-buffer (buffer-name sbuffer) nil)))))
>
>  > Of course, you'd have to adjust it to your own setup (and keyboard preferences,
>  > e.g. M-n r instead), but it might get you started.
>
>  > Mathieu.
>
>  > Le 04/03/2014 04:34 PM, Josh O'Brien a écrit :
>  >> Hello,
>  >>
>  >> When I open a *.Rnw document_without_ having loaded markdown mode and
>  >> polymode, I am able to knit and PDF-ify the document by doing first "M-n r"
>  >> (for ess-swv-knit) and then "M-n P".
>  >>
>  >> When markdown mode and polymode _are_ loaded (using the emacs commands
>  >> copied below), I get very nice document highlighting, but neither of those
>  >> keyboard shortcut works. Typing "M-n r" just gets me the message "M-n r is
>  >> undefined", and likewise when I type "M-n P".
>  >>
>  >> Is there something wrong with the commands I'm using to load markdown mode
>  >> and/or polymode? Alternatively, is there some way I can make polymode aware
>  >> of my intended meaning of those two keyboard shortcuts?
>  >>
>  >> For the record, I am using GNU Emacs 24.3.1 and ess-version: 13.09 [svn:
>  >> 5778 (2013-09-27)] on a Windows 7 machine.
>  >>
>  >> Here is the code that I use to load markdown mode and Vitalie Spinu's
>  >> polymode.
>  >>
>  >> ;; Markdown mode, needed by Vitalie's polymode.
>  >> ;; From http://jblevins.org/projects/markdown-mode/> (autoload 'markdown-mode "markdown-mode"
>  >> "Major mode for editing Markdown files" t)
>  >> (add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
>  >> (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
>  >> (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
>  >>
>  >> ;; Add polymode to load path
>  >> ;; From https://github.com/vitoshka/polymode> (add-to-list 'load-path (expand-file-name "~/.emacs.d/polymode"))
>  >> (add-to-list 'load-path (expand-file-name "~/.emacs.d/polymode/modes"))
>  >> (require 'poly-R)
>  >> (require 'poly-markdown)
>  >>
>  >>
>  >> Thanks,
>  >>
>  >> Josh
>  >>
>  >> [[alternative HTML version deleted]]
>  >>
>  >> ______________________________________________
>  >> ESS-help at r-project.org mailing list
>  >> https://stat.ethz.ch/mailman/listinfo/ess-help>



More information about the ESS-help mailing list