[ESS] ess-noweb-font-lock-mode: emacs hangs using uncomment-region with math environments

Braun, Michael br@unm @ending from m@il@@mu@edu
Tue Jan 8 16:02:48 CET 2019


Thanks.  polymode does appear to resolve the font-lock problem with my .Rnw files.

But it is not clear to me the best way to set up the various poly-packages.  I have not found a good “migration guide” online.  Could you offer some additional suggestions on what to add to my Preferences.el file? (I am using Aquamacs 3.5, based on Emacs 25.3.50.1). Or perhaps others could share their own configurations?

Below are the relevant lines in my current Preferences.el file. Other than the first three, which I added today to try polymode, the rest were cobbled together from various online sources over the years.  Can you help me understand which variables would still apply to ESS and polymode, which are no longer necessary, and others that I should add?  I am particularly interested in enabling preview-latex support for .Rnw files, like I have for .tex. I was never able to get that to work right before.

Again, thanks for the support, and the continued development.  It’s much appreciated.

Michael

—— My Preferences.el file — — 

(load "ess-autoloads”) 
(require 'poly-R)
(poly-noweb+R-mode)
;;(setq inferior-R-program "/Library/Frameworks/R.framework/Resources/bin/R”)

(add-hook 'ess-mode-hook
 	  (lambda ()
 	    (ess-set-style 'C++ 'quiet)
 	    (add-hook 'local-write-file-hooks
 		      (lambda () (ess-nuke-trailing-whitespace))
 		      (setq ess-nuke-trailing-whitespace-p 't)
 		      )
 	    (setq ess-first-continued-statement-offset 2
 		  ess-continued-statement-offset 0
 		  ess-arg-function-offset t)
 	    ))

 (setq ess-swv-plug-into-AUCTeX-p t)

(defun ess-swv-add-TeX-commands ()
;;   various Knit and LaTex commands here
)

;; Presumably these next functions enables AUCTeX and Preview support for .Rnw files,
;;   but I’ve never been able to get that to work.
(setq ess-swv-processor 'knitr)
(setq ess-swv-pdflatex-commands ‘pdflatex)

;; ESS Markdown.  Again, is this function redundant to a simple (require ‘poly-markdown) ?
(defun rmd-mode ()
  "ESS Markdown mode for rmd files"
  (interactive)
  (R-mode)
  (require 'poly-R)
  (require 'poly-markdown)
  (poly-markdown+r-mode))

(setq auto-mode-alist (cons '("\\.Rmd\\'" . rmd-mode)
			    auto-mode-alist))
(setq auto-mode-alist (cons '("\\.rmd\\'" . rmd-mode)
			    auto-mode-alist))



--------------------------
Michael Braun, Ph.D.
Associate Professor of Marketing, and
  Corrigan Research Professor
Cox School of Business
Southern Methodist University
Dallas, TX 75275
braunm _at_ smu.edu






> On Jan 7, 2019, at 10:43 AM, Alex Branham <alex.branham using gmail.com> wrote:
> 
> Hi Michael -
> 
> ESS's noweb implementation has many bugs like this that are hard to fix.
> We're encouraging users of mixed major-mode buffers to move to polymode,
> which is more actively developed.
> 
> https://polymode.github.io/
> 
> Hope that helps,
> Alex
> 
> On Sun 06 Jan 2019 at 21:50, Braun, Michael via ESS-help <ess-help using r-project.org> wrote:
> 
>> In a .Rnw file, when calling uncomment-region on a region that contains a LaTeX math environment (such as align), Emacs will hang, requiring a Force Quit.  I am using Aquamacs Emacs 3.5, ESS 18.10.2, and MacOS 10.14.2, but this problem has persisted since at least Aquamacs 3.2 and ESS 16.10.   I’ve been wrestling with this issue since at least 2016, but now it’s time to get some help.
>> 
>> To replicate, save the following content in a file with a .Rnw extension. Then, select a region that includes the equation, and run comment-region, and then uncomment-region.  I have these functions are bound to M-; or C-c ; .
>> 
>> ------
>> \documentclass{article}
>> \usepackage{amsmath}
>> 
>> \begin{document}
>> 
>> On the following equation, try comment-region, and then uncomment-region.
>> The uncomment-region call is what hangs the process.
>> 
>> \begin{align}
>>  1+1=2
>> \end{align}
>> 
>> \end{document}
>> -------
>> 
>> My longstanding workaround is to either toggle ess-noweb-font-lock-mode off, or toggle font-lock-mode on, right after opening the file.  This makes the problem with uncomment-region disappear. But then I lose the ESS font-lock features.
>> 
>> Interestingly, this does not crash Emacs  if the file is saved with a .tex extension.  Also, in a .tex file, comment-region prefixes lines with %, but in a .Rnw file, the comment prefix is %%. I’m not sure if that’s relevant, but it might be, and I’d like to find a way to change that behavior as well.
>> 
>> Any thoughts?
>> 
>> Thanks,
>> 
>> Michael Braun
>> braunm _at_ smu.edu
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> ______________________________________________
>> ESS-help using r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/ess-help



More information about the ESS-help mailing list