I use org-mode to handle my tasks and projects in multiple files.
In the weekly agenda, it is possible to jump to the location of each TODO entry using <TAB>
or <RET>
. If the target file was not previously open, it is loaded an the cursor is set to the correct headline and the entire document is unfolded, including drawers.
I would very much prefer to see only a sparse tree with everything but the correct headline folded (subtree visibility does not matter).
It is possible to collapse the entire tree by cycling global visibility using C-u <TAB
, but then I have to find the heading again.
I know I can hide the rest by narrowing the buffer as described here: Emacs, How can I display only current task and hide others in org-mode? but then I loose context (parent heading, easy access to siblings) and the drawers are still open.
Ideally, I would like to have a command that shows the following:
- The top level headings
- The current headline, and all it's parents up to the top level
- The current headline's children
Edit:
A slighty modified version of the functions user3173715 posted seems to do the trick:
(defun org-show-current-heading-tidily ()
"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)))
org-startup-folded
,org-startup-options
, andorg-agenda-inhibit-startup
. – Danorg-agenda-inhibit-startup
toggled it almost does what I want, thank you! Strangely, the heading's siblings are hidden, and only the first child node is shown, but this is definitely an improvement! – Patrick B.