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

Mathieu Basille basille.web at ase-research.org
Fri Apr 4 01:42:47 CEST 2014


Le 04/03/2014 05:30 PM, Vitalie Spinu a écrit :
>
> I have resumed working on polymomde and will release it to MELPA
> soon. You will have good shortcuts by default, including pandoc.

This is great news! I look forward to have the new versions of polymode!

Mathieu.


> 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>
>

-- 

~$ whoami
Mathieu Basille, PhD

~$ locate --details
University of Florida \\
Fort Lauderdale Research and Education Center
(+1) 954-577-6314
http://ase-research.org/basille

~$ fortune
« Le tout est de tout dire, et je manque de mots
Et je manque de temps, et je manque d'audace. »
  -- Paul Éluard



More information about the ESS-help mailing list