-
Notifications
You must be signed in to change notification settings - Fork 166
Description
A lot of programming modes in Emacs support outline-minor-mode out of the box, and all important text modes (org, md and tex) do it too, but ESS does not. This minor mode allows super fast navigation in files with well-structured sections and could be a good complement to imenu (imenu is great for navigating a package but almost useless for a data treatment pipeline with few functions).
I don't know for the other languages supported by ESS, but in R, RStudio has defined a sensible convention for outlines: https://posit.co/blog/rstudio-v1-4-preview-little-things/.
It is trivial to support this convention in Emacs. I have the following piece in my init.el (inside a use-package block) that works perfectly and have completely changed my interaction with R files:
:hook
;; Outlining like in RStudio
(ess-r-mode . (lambda ()
(setq outline-regexp "^[ \t]*#+ +.*\\(----\\|====\\|####\\)")
(defun outline-level ()
(cond ((looking-at "^[ \t]*# ") 1)
((looking-at "^[ \t]*## ") 2)
((looking-at "^[ \t]*### ") 3)
((looking-at "^[ \t]*#### ") 4)
(t 1000)))))Sure, it could be possible to have a more complete outlining like in python-mode or elisp-mode with support for functions and control flow, but it is likely secondary compared to supporting standard sections.