[ESS] R code folding with hideshow-org.el

Short, Tom TShort at epri.com
Thu Apr 2 02:40:44 CEST 2009


Shane Celis has extended hideshow.el to work more like org-mode (a great
do-it-all outliner and organizer). You can use TAB to toggle folding of
functions and other code sections. It does this without messing up ESS's
indentation functionality. Shift-TAB toggles the folding of the whole
buffer (great way to see your top-level functions). See more here,
including a screencast:

http://gnufool.blogspot.com/2009/03/make-hideshow-behave-more-like-org-m
ode.html

To make this work with R/ESS, I added this to my .emacs:

(require 'hideshow)
(require 'hideshow-org)
(add-to-list 'hs-special-modes-alist
             '(ess-mode "{" "}" "/[*/]" nil
hs-c-like-adjust-block-beginning))
(global-set-key "\C-ch" 'hs-org/minor-mode) ;; toggles hideshow-org
(add-hook 'ess-mode-hook 'hs-org/minor-mode) ;; starts for ESS files

The last line doesn't work initially for me (no autostart), but if I
start it manually once, then it seems to work fine. I don't know why.

- Tom

Tom Short




More information about the ESS-help mailing list