3

When using org build subtree navigation functions to move around, I want to show all the content of current one recursively, and hide any other subtrees that having a higher or same level of the current one. How to achieve this ? Thanks !

1

Edited in response to first comment

Not quite sure if this is what you want, but here's a function that will show the current subtree (and its children) and fold all other headings to their top level:

(defun ess/org-show-just-me (&rest _)
  "Fold all other trees, then show entire current subtree."
  (interactive)
  (org-overview)
  (org-reveal)
  (org-show-subtree))

Now you can add advices for each command you want to use this function together with:

(advice-add 'org-forward-heading-same-level :after #'ess/org-show-just-me)
(advice-add 'org-backward-heading-same-level :after #'ess/org-show-just-me)

Another alternative is to use org-narrow-to-subtree to hide all other content than the current subtree. It is bound to C-x n s by default. To go back, use widen, bound to C-x n w. A great alternative is narrow-or-widen-dwim.

You could add widen followed by org-narrow-to-subtree to a function and create this as an advice in the same way as the example above.

  • I know about org-narrow-to-subtree, but I want to show and hide content automatically every time I use a build in function like org-forward-heading-same-level to move around. I'll read about narrow-or-widen-dwim soon. Thanks ! – stackunderflow Dec 15 '16 at 11:12
  • Okay, I've updated the answer and hopefully it does what you want. – Erik Sjöstrand Dec 15 '16 at 14:39

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.