org-sparse-tree function lists selected information with the headline structure above it. This is useful when the meaning of org headings depends on context:

SPC m T (org-show-todo-tree)

enter image description here

org-agenda function prints the headings out of context, which can make the headings incomprehensible:

SPC a o o s Phrase: TODO (org-agenda, list all entries with keyword "TODO")

enter image description here

As far as I know, org-sparse-tree only works on one org file at a time. While org-agenda is derived from multiple org files.

Is there a way to display an agenda as a sparse tree? (when the agenda is derived from multiple files)

Alternatively, I could combine all my org project files into one. Is that the "org-mode way"? If not, I will customize org-mode after gaining more org-mode experience.

I am using Emacs 25.2.1 with Spacemacs, evil, and ivy on Linux.

The remainder of this question describes what I have tried so far.

googled: org-mode agenda sparse tree

I tried the org-occur-in-agenda-files function:

SPC a o /

Org-files matching: tasks.org
Searched 5 buffers; no matches for "tasks.org"

What should be entered after the "Org-files matching" prompt?

From my ~/.spacemacs file:

(setq org-agenda-files (list



This google search found none: "org-occur-in-agenda-files" "Org-files matching"


This works:
Search all the org files with org-agenda, and if a heading needs context, ENT on the heading, which opens the heading in the same window.
SPC b b (ivy-switch-buffer) *Org Agenda* returns window to the agenda.
Is there a faster way to jump back to agenda?
C-c & (org-mark-ring-goto) does not jump back to agenda.

This works:
Search all the org files with org-agenda, and if a heading needs context, mouse-3 on the heading, which opens the heading in another window.
But if another window is already open, that window's buffer is displaced.
Is there a way to open the agenda heading in a new window?

1 Answer 1


Have you tried the C-c a for org-agenda and then / that is the Multi-occur option?

According to the Org-mode Tutorial on topic Advanced Searching:

Org-mode uses Emacs' multi-occur command to search for any lines in the agenda files containing a regular expression. Simply type C-c a / followed by a word or regular expression and you will be presented a buffer with all lines that match the query, with each line conveniently linked to its original location.

Still in the same topic:

The commands we have examined so far typically search multiple files and display the resulting heading in a separate agenda buffer. But sometimes, you might want to search for various types of data within a single file, so as to see all the matching headlines and entries in context.

The way to accomplish this is via a sparse tree view (C-c /), which collapses the outline in the current file, showing only the portions that match a query.

So, if you want to make your search on all files you should start with Multi-occur and then use sparse trees on specific files.

Also, if you use Spacemacs I recommend you to make use of some shortcuts that starts with , (comma). You will find that, for example, org-agenda is accessible with just , a (comma, a), instead of SPC a o o.

Other examples:

org-show-todo-tree: , T = SPC m T

org-sparse-tree: , / = SPC m /

org-clock-in: , I = SPC m I


The remainder of this question describes what I have tried so far.

googled: org-mode agenda sparse tree

  • I forgot about the orgmode.org/worg/org-tutorials/index.html Worg's "Advanced searching" tutorial is a great resource. And thanks for showing how to accesses org-agenda with ", a". I appended UPDATE_1 to the question.
    – wolfv
    Jun 18, 2017 at 9:53
  • You're welcome! What about multi-occur? It helped you out or you still need some other specific functionality? Jun 18, 2017 at 10:11
  • 1
    Multi-occur is not what I needed. SPC a o / (org-occur-in-agenda-files) narrows the agenda results, but it does not display context. Partial work around is described in main question under UPDATE_1. Please read my questions under UPDATE_1.
    – wolfv
    Jun 18, 2017 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.