In org-mode 9.3.6 and GNU Emacs 26.3, marking a task as done in org-agenda also reveals the task in its buffer. Only the task subheader itself is shown. Here's an example:

Before (buffer left, agenda right): enter image description here After changing task state to DONE in agenda: enter image description here I'd like to know if this behavior can be modified so that 1) org-mode does not reveal the task in its buffer or 2) org-mode reveals the full parent-child header structure with the task. For example, something like this:

enter image description here Any help is very much appreciated - thanks!


The state change is done by the function org-agenda-todo which goes to the buffer and does (org-show-context 'agenda). The doc string for org-show-context says:

Make sure point and context are visible. Optional argument KEY, when non-nil, is a symbol. See ‘org-show-context-detail’ for allowed values and how much is to be shown.

That leads us to the variable org-show-context-detail whose doc string in turn says:

org-show-context-detail is a variable defined in ‘org.el’.
Its value is
((agenda . local)
 (bookmark-jump . lineage)
 (isearch . lineage)
 (default . ancestors))

  You can customize this variable.

This variable was introduced, or its default value was changed, in
version 26.1 of Emacs.

Alist between context and visibility span when revealing a location.

Some actions may move point into invisible
locations.  As a consequence, Org always expose a neighborhood
around point.  How much is shown depends on the initial action,
or context.  Valid contexts are

  agenda         when exposing an entry from the agenda
  org-goto       when using the command ‘org-goto’ (‘C-c C-j’)
  occur-tree     when using the command ‘org-occur’ (‘C-c / /’)
  tags-tree      when constructing a sparse tree based on tags matches
  link-search    when exposing search matches associated with a link
  mark-goto      when exposing the jump goal of a mark
  bookmark-jump  when exposing a bookmark location
  isearch        when exiting from an incremental search
  default        default for all contexts not set explicitly

Allowed visibility spans are

  minimal        show current headline; if point is not on headline,
                 also show entry

  local          show current headline, entry and next headline

  ancestors      show current headline and its direct ancestors; if
                 point is not on headline, also show entry

  lineage        show current headline, its direct ancestors and all
                 their children; if point is not on headline, also show
                 entry and first child

  tree           show current headline, its direct ancestors and all
                 their children; if point is not on headline, also show
                 entry and all children

  canonical      show current headline, its direct ancestors along with
                 their entries and children; if point is not located on
                 the headline, also show current entry and all children

As special cases, a nil or t value means show all contexts in
‘minimal’ or ‘canonical’ view, respectively.

Some views can make displayed information very compact, but also
make it harder to edit the location of the match.  In such
a case, use the command ‘org-reveal’ (‘C-c C-r’) to show
more context.

So you can customize the agenda pair and make the visibility span of the agenda context something other than local. E.g. you can make it minimal with something like this:

(setq org-show-context-detail (assq-delete-all 'agenda org-show-context-detail))
(add-to-list 'org-show-context-detail '(agenda . minimal))

The listed visibility spans are the only values provided however, so if you don't like any of them, you will have to implement your own.

  • Excellent! Thanks for the tips. As a bonus, I learned a little bit more about alists than I otherwise would have. To completely get rid of this behavior I had to comment out (org-show-context) in org-agenda-todo, because for the life of me, I can't figure out where visibility spans are stored or how to modify them. Apr 4 '20 at 12:15
  • org-show-set-visibility evidently. Apr 4 '20 at 12:33

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.