By default, S-tab
cycles between OVERVIEW
, CONTENTS
and SHOW ALL
these three states. But I want it to just cycle between CONTENTS
and SHOW ALL
. How can I realize it?
-
2You don't really want to do this for a number of reasons. First of all, Org does quite a lot in its functions, second, it doesn't have anything resembling an API, so using anything except the new exporters programmatically is a royal pain in the ass.– wasamasaSep 20, 2015 at 14:25
1 Answer
I do not think this is straightforward. You definitely need a custom function. The docstring for org-cycle has the following:
[...]
When this function is called with a prefix argument, rotate the entire buffer through 3 states (global cycling)
OVERVIEW: Show only top-level headlines.
CONTENTS: Show all headlines of all levels, but no body text.
SHOW ALL: Show everything.
When called with two ‘C-u C-u’ prefixes, switch to the startup visibility, determined by the variable ‘org-startup-folded’, and by any VISIBILITY properties in the buffer. When called with three ‘C-u C-u C-u’ prefixed, show the entire buffer, including any drawers.
[...]
I suggest the following scheme:
- You need to set an initial visibility. There are two ways to go about it, either set
org-startup-folded
or put a#+startup: content
line somewhere in the buffer. - Next you use a function like the following to cycle the buffer. Calling the function below shows the default setting from step (1), providing a prefix argument shows everything, including drawers.
(defun my-cycle (&optional arg)
"Cycle between CONTENTS and SHOW ALL"
(interactive "P")
(if (equal arg '(4))
(show-all)
(org-set-startup-visibility)))
Note that overriding the default keybinding is very hard since Org does too many smart things under the hood. It's very hard to make sure everything will keep working as expected if you fiddle with how org-cycle
behaves.