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 Answer
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 likeorg-forward-heading-same-level
to move around. I'll read aboutnarrow-or-widen-dwim
soon. Thanks ! Dec 15, 2016 at 11:12 -
Okay, I've updated the answer and hopefully it does what you want. Dec 15, 2016 at 14:39
-
This helped a lot to find a workaroud for this question. Jun 12, 2020 at 11:06