7

In my org file, I have a lot of headlines that I'd like to keep folded most of the time - and some that I want expanded, but the state of each expanded headline is lost when I close emacs.

Is there a way to restore the state upon re-opening the file?

PS: I'm not looking for the default expansion state as in Keep the headlines expanded in Org-Mode, nor I want to set the default visibility of each headline manually through properties - I want to remember the state of the whole file, heterogenous as it may be.

1
  • 4
    There is not a way to do this that exists in org-mode. You would have to save the state to a file, setup some file variables to reload the state when the org file is opened, and probably a hook function to save the state on exiting. You can get the state with (org-outline-overlay-data) and restore it with (org-set-outline-overlay-data). Commented Jun 7, 2017 at 14:01

1 Answer 1

4

You'd need to persist the result of org-outline-overlay-data on save/exit, then restore it on open/start with org-set-outline-overlay-data.

You can see an example of this in this answer.

(Sorry this should've been a comment but I don't have the rep yet.)

1
  • 1
    Seems like there is no way to even do this anymore, due to recent changes. Very unfortunate.
    – TTimo
    Commented Sep 17, 2021 at 16:38

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.