1

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?

1
  • 2
    You 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.
    – wasamasa
    Sep 20, 2015 at 14:25

1 Answer 1

2

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)

    1. OVERVIEW: Show only top-level headlines.

    2. CONTENTS: Show all headlines of all levels, but no body text.

    3. 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:

  1. 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.
  2. 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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.