Skip to content

How to narrow view by level on search query #509

Description

@ivanperez-keera

I use the org-ql's sparse tree search to get a glimpse of everything I have to work on at a glance.

Sometimes, when I use a search, it'd be helpful to hide anything deeper than a certain level, to just see the main "categories" or projects I have open.

For example, given a file:

* A
** A.1
*** TODO A.1.3
** A.2
** TODO A.2.1
     SCHEDULED: <2026-03-25>
* B
** B.1

If I run org-ql-sparse-tree with the query (todo "TODO"), the following would show up:

* A
** A.1
*** TODO A.1.3
** A.2
** TODO A.2.1
* B

I want to further reduce that to 2 levels only, so that I only see the main categories that I'm actively working on:

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

(or ideally, B wouldn't show up, but it's hard to hide top-level stuff in a query)

Note that neither A.1 nor A.2 match my original query; it's headlines inside them that do.

Is there a way to do this? I tried org-content but that just expands a bunch of stuff that didn't match the original query.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions