6

In org-mode, when I cycle through the visibility of the document via the TAB key (org-cycle), the text sometimes gets repositioned.

If there is enough text below the headline such that it will not all fit within the window when it is expanded, Emacs will reposition the headline line (the line my cursor is currently on) to the top of the window.

How can I make org-cycle cycle through visibility, but not move the text in the window?

0

2 Answers 2

3

The TAB key runs the command org-cycle, which does a whole bunch of stuff under the hood. In the context you're talking about, org-cycle cycles through the visibility of the buffer, hiding and showing the entries.

Long story short, org-cycle runs org-cycle-hook. The first part of the docstring reads:

Documentation:

Hook that is run after org-cycle has changed the buffer visibility...

One of the functions in that hook, org-optimize-window-after-visibility-change, is responsible for repositioning the text in the window. To stop it from doing so, add the following to your init file:

(remove-hook 'org-cycle-hook
             #'org-optimize-window-after-visibility-change)
0
0

Btw, in Org9.4, the function responsible for optimizing window is changed to org-cycle-optimize-window-after-visibility-change, so you should do:

(remove-hook 'org-cycle-hook
               'org-cycle-optimize-window-after-visibility-change)

Your Answer

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

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