[ESS] Emacs 28 and Sweave files
Brett Presnell
pre@ne|| @end|ng |rom u||@edu
Sun Sep 11 17:13:45 CEST 2022
Hi Vincent. Until I read your email I hadn't realized that I was no
longer set up for processing all the stuff I have in Rnw files, so I'm
glad you brought it up. I guess that for the past several years I've
been using org mode so much (and R markdown for teaching) that I somehow
hadn't needed to process any Rnw files, but it's still almost hard to
believe.
Anyway, I looked into it briefly just now, and I think the following
works. Put something like what I have below into your .emacs. (You may
also need to remove anything that was previously activated when you
loaded a .Rnw file?) After that has been activated, poly-noweb+r-mode
should be loaded when you open a .Rnw file, but if not, you can manually
activate it with "M-x poly-noweb+r-mode".
Then to weave the file, you type "M-n e". Initially you will be
prompted to choose an exporter (with tab completion), and here I use
pdflatex. Then you will be prompted to choose a weaver, and here I
choose knitr-ess. After that it should knit and process the file to get
the pdf output.
By default polymode gives rather odd names to the exported files (in
this case it seems to insert "-wover-exported" between the base file
name and the ".pdf"). You can change this, but at the moment I've
forgotten how as I've just be living with it with my Rmarkdown files.
Hope this helps.
(require 'poly-markdown)
(require 'poly-R)
(add-to-list 'auto-mode-alist '("\\.Rnw" . poly-noweb+r-mode))
(add-to-list 'auto-mode-alist '("\\.rnw" . poly-noweb+r-mode))
(add-to-list 'auto-mode-alist '("\\.Rmd" . poly-markdown+r-mode))
(add-to-list 'auto-mode-alist '("\\.rmd" . poly-markdown+r-mode))
(setq polymode-display-output-file nil) ; Prevent auto-viewing of output
(defun toggle-polymode-display-output-file ()
(interactive)
"Toggle the value of polymode-display-output-file between nil and t."
(message
"setting polymode-display-output-file `%s'"
(not polymode-display-output-file))
(setq polymode-display-output-file (not polymode-display-output-file)))
(define-key polymode-minor-mode-map (kbd "M-n d")
'toggle-polymode-display-output-file)
Vincent Goulet via ESS-help <ess-help using r-project.org> writes:
> [External Email]
>
> Hi all,
>
> A large part of my work in Emacs involves editing Sweave (.Rnw)
> files. I was very much used to the tried, tested and true ess-noweb
> mode for this purpose.
>
> Now, in the development version of ESS that is required for Emacs 28,
> all the noweb stuff was gutted out and we're told to use polymode
> instead. For one thing, I think it's a pity that such fundamental
> interaction between R and Emacs (wasn't the whole concept of Sweave
> based off Emacs functionality?) is no longer part of ESS. I'd
> certainly vote for the return of noweb files support. (I understand
> that polymode brought improved support for RMarkdown files.)
>
> I'm probably late to the party, but can anyone give me a primer on
> polymode for Rnw files? (Not Rmd files, some oldies like me still rely
> on LaTeX and Sweave -- not even knitr!)
>
> I followed the polymode installation instructions and added the 'mode:
> poly-noweb' file variable to a .Rnw file. If I do 'M-n w' or 'M-n e'
> (what's the difference?), I'm first asked to select a weaver or an
> exporter. What's the answer? Pressing TAB does not offer any choice.
>
> What if I just want to compile the LaTeX file? In Emacs 27, ESS was
> connected to AUCTeX and the weave step was integrated into the
> compilation step (C-c C-c). Anything as streamlined with polymode?
>
> I also stumble into the following issues. First, as soon as I try to
> do anything in a .Rnw file, I get these error messages:
>
> Error during redisplay: (internal--syntax-propertize 2) signaled
> (error "Variable binding depth exceeds max-specpdl-size")
> Error running timer ‘show-paren-function’: (error
> "internal--syntax-propertize did not move syntax-propertize--done")
>
> Second, I ended up a few times with the following markers at the end
> of the file name in the modeline and in the mode display:
> HeadTail. I'm not too sure how to reproduce, but does this ring any
> bell here?
>
> System info:
> Emacs Modified for macOS 28.1-modified-1, based on
> GNU Emacs 28.1 (build 1, aarch64-apple-darwin21.1.0, NS appkit-2113.00
> Version 12.0.1 (Build 21A559)) of 2022-05-11
> polymode 0.2.2 installed through MELPA
>
> Thanks in advance!
>
> v.
> ______________________________________________
> ESS-help using r-project.org mailing list
More information about the ESS-help
mailing list