0

By pressing [Enter] on an entry in org-agenda, the sparse tree containing the entry shows up.

The variable org-show-context-detail controls how to see such a sparse tree (docs). Pairs "context -> detail-level" are setup on it. As I understand from the docs, the context "agenda" is the one that controls the jump from the agenda view to the tree.

I tried setting all the detail-level values (minimal, local, ancestors, lineage, tree, canonical) and none of them seems to do what I need (minimal gets close, though):

Given a tree like this;

* A
** A.1
** A.2

* B
** B.1
** B.2
*** B.2.i
*** B.2.ii

* C
** C.1
*** C.1.i

Setting the detail-level to minimal, if I go from the agenda to the tree by pressing [Enter] or Tab in an entry that contains B.2.ii, I get:

* A...
* B
** B.2...
*** B.2.ii
* C...

I would like to hide all siblings of first level headlines, to get something like:

* B
** B.2
*** B.2.ii

Or maybe show just the immediate parent of the matched headline:

** B.2
*** B.2.ii

Is there a way to accomplish these two desired views?

I saw this entry Reveal entry's parents recursively, but not siblings here, but I couldn't make an analogy to my situation (which, as I understand, would be setting up "canonical" detail-level for the agenda context.)

1

Pressing [Enter] on an item in the agenda does not show a sparse tree (do C-h i g(org)Sparse trees to see where sparse trees are used): what it does is it visits the file from which the item came, puts point on the item and then decides (depending on the agenda setting in org-show-context-detail) how much of the context to show if point is not already visible. If point is already visible, then Org mode assumes that everything is fine and does not do anything.

Try this: in the file, do S-TAB until everything is folded as much as possible. Then go to the agenda and press [Enter] on the item. That will reveal the context as specified in the org-show-context-detail variable. You can try all the different settings, but none of them do what you want, because the top level headings are always shown, even when the file has been folded as much as possible. The closest you can get I think is this:

#+STARTUP: overview

* A...
* B...
** B.2...
*** TODO B.2.ii
SCHEDULED: <2021-11-01 Mon>

* C...

by setting the agenda context to ancestors.

The only way to get what you want I believe is to modify org-show-set-visibility to interpret a new detail setting and then set the agenda context to that new detail setting. But I don't see a way to do it without code modifications. You might want to submit an enhancement request to the Org mode mailing list (although there is no guarantee that anybody will implement it).

1
  • I ended up applying the ancestors, and splitting my single org file with many first-level headlines in many files with a single first-level headline. Put them in a folder, and add the hole folder to the agenda. So when I visit the files, there is always only one first-level headline. :)
    – onlycparra
    Nov 3 at 17:30

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.