Next: , Previous: , Up: Document Structure   [Contents][Index]

2.11 The Orgstruct minor mode

If you like the intuitive way the Org mode structure editing and list formatting works, you might want to use these commands in other modes like Text mode or Mail mode as well. The minor mode orgstruct-mode makes this possible. Toggle the mode with M-x orgstruct-mode RET, or turn it on by default, for example in Message mode, with one of:

(add-hook 'message-mode-hook 'turn-on-orgstruct)
(add-hook 'message-mode-hook 'turn-on-orgstruct++)

When this mode is active and the cursor is on a line that looks to Org like a headline or the first line of a list item, most structure editing commands will work, even if the same keys normally have different functionality in the major mode you are using. If the cursor is not in one of those special lines, Orgstruct mode lurks silently in the shadows.

When you use orgstruct++-mode, Org will also export indentation and autofill settings into that mode, and detect item context after the first line of an item.

You can also use Org structure editing to fold and unfold headlines in any file, provided you defined orgstruct-heading-prefix-regexp: the regular expression must match the local prefix to use before Org’s headlines. For example, if you set this variable to ";; " in Emacs Lisp files, you will be able to fold and unfold headlines in Emacs Lisp commented lines. Some commands like org-demote are disabled when the prefix is set, but folding/unfolding will work correctly.