4

Is there a way to setup org-mode so that the expansion state of everything within a file is automatically saved when closing the file or quitting?

The Org-Mode FAQ says this is not possible, but maybe someone has a hand-rolled solution.

1

I was wondering the same when I started using emacs.

There is the initial visibility business, but I presume that you already know about this.

I spent some time looking, but could not find a way to implement this directly. One way to implement this might be to write a custom property and change it when expanding/hiding subtrees, but this would take a lot of effort to write.

That said, after a while I found that it wasn't really much of a deal for me. I use helm/helm-swoop/worp-goto to quickly find things in my file. (Highly reccomended btw), can be downloaded from melpa

I also use this function to hide everything except the current header:

  (defun org-show-current-heading-tidily ()
      (interactive)
      "Show next entry, keeping other entries closed."
      (if (save-excursion (end-of-line) (outline-invisible-p))
          (progn (org-show-entry) (show-children))
        (outline-back-to-heading)
        (unless (and (bolp) (org-on-heading-p))
          (org-up-heading-safe)
          (hide-subtree)
          (error "Boundary reached"))
        (org-overview)
        (org-reveal t)
        (org-show-entry)
        (show-children)))

  (local-set-key (kbd "C-=") 'org-show-current-heading-tidily)

If curious, this is my full .emacs file: http://paste.fedoraproject.org/184916/14237726/raw/

  • I'm glad it helped =] – Leo Ufimtsev Feb 13 '15 at 15:32

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.