Note that there are some explanatory texts on larger screens.

plurals
  1. POEMACS folding/unfolding R code
    text
    copied!<p>Is there an Emacs minor-mode (or piece of elisp code) that lets you selectively hide/show environments while in Sweave (Sweave = R + LaTeX)? </p> <p>For instance, I would like to move to the beginning of a code block (&lt;&lt;>>), hit a keystroke, and have the contents of the environment hidden from view.</p> <p>Is this possible? I just tried hs-minor-mode, allout-mode, and outline-minor-mode, but most of them don't recognize R environments.</p> <p>I also tryed org-mode that works great for folding/unfolding but, do not support the LaTeX highlighting code for expression like: \cite{}; \ref{}; \ce{} ...</p> <p>Best Riccardo</p> <p><strong>--EDIT--</strong></p> <p>I tried for some day to use emacs-folding-mode but, because I work on a very long code (more than 2000 rows), folding mode "goes crazy" and for example misunderstand the mining of some special character (i.e. $), that has very different use both in R than LaTeX. I think the problem is intrinsic to Sweave, because in the same buffer I have R code and LaTeX code together.</p> <p>So, now I'm testing emacs outline minor mode. But when I move through R from LaTeX (and vice versa) all the outlined part were unfolded despite I write in my .emacs:</p> <pre><code>(defun turn-on-outline-minor-mode () (outline-minor-mode 1)) (add-hook 'ess-mode-hook 'turn-on-outline-minor-mode) (add-hook 'LaTeX-mode-hook 'turn-on-outline-minor-mode) (add-hook 'latex-mode-hook 'turn-on-outline-minor-mode) (setq outline-minor-mode-prefix "\C-c\C-o") </code></pre> <p>Do you have any suggestions??</p> <p>Regards</p> <p>--EDIT 2--</p> <p>It seems to work:</p> <pre><code>(load "folding" 'nomessage 'noerror) (folding-mode-add-find-file-hook) (add-hook 'LaTeX-mode-hook 'folding-mode) (add-hook 'ess-mode-hook 'folding-mode) (folding-add-to-marks-list 'ess-mode "#{{{ " "#}}}" " ") </code></pre> <p>I don't know if is right that, when you leave the chunk, it is automatically unfolded.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload