If all you want is selective showing of sections and navigation between headings, you don't need Org mode. All you need is Outline mode. Outline mode is basically the header level and section visibility management of Org mode. In fact, Org mode was originally the author's extensions to Outline mode, and grew, and grew, and grew… Even today, org-mode
is derived from outline-mode
.
Outline mode exists both as a major mode and as a minor mode. The minor mode can be used in any major mode. You can configure it to use a header format that's compatible with your program syntax, and many major modes do so, by setting the outline-regexp
variable to a regexp that matches the start of a header. For example, this is the default value in Emacs Lisp mode:
";;;\\(;* [^ \t\n]\\|###autoload\\)\\|("
i.e. section headers start with three or more semicolons and a single space, or an opening parenthesis in the left margin. The variable outline-level
contains the name of a function to determine the depth of a header; the default value is the length of the string matched by outline-regexp
, and Emacs Lisp mode overrides it to assign a larger depth to (
and ;;;###autoload
.
If you don't like the default header format, set the variable outline-regexp
in a file local variable declaration. This is what I use — my section headers all consists of ;;;
followed by the classic sequence of stars:
;;; Local Variables:
;;; outline-regexp: ";;;\\*+\\|\\`"
;;; End:
If you want Outline minor mode to be automatically turned on when you load the file, add the following line in the Local Variables section — note that this will warn you about unsafe code in Emacs ≤23.x.
;;; eval: (outline-minor-mode 1)
The commands for outline minor mode use the rather inconvenient C-c @
prefix by default. I move it to M-o
(I never use the facemenu bindings), you may prefer another key, or to replicate Org mode's bindings (which have diverged quite a bit from Outline mode).