4

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.

  • 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). – John Kitchin Jun 7 '17 at 14:01
1

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.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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