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

Alex Branham @lex@br@nh@m @ending from gm@il@com
Mon Jan 7 17:43:36 CET 2019

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