1

I am generating a sparse tree typically using a regex (, / r ). What I am trying to do is get an overview of where in my document a match occurs, not the exact positions of the matches. So, if I have a heading with several kilobytes of plain text underneath that contains a match, I don't want my sparse tree to show the plain text, only the relevant heading.

So, given a doc:

* H1
** H2.1
Foo
etc
** H2.2
Bar
** H2.3
Foo
etc
etc

And a sparse tree generated for regex foo, I would want to see something like

* H1
** H2.1
...
** H2.3

1 Answer 1

1

Looks like outline-hide-body does exactly what you want:

Hide all body lines in buffer, leaving all headings visible.

Note that this does not hide the lines preceding the first heading line.

So after creating the sparse tree use M-x outline-hide-body RET.

Or create a custom command that calls org-occur and hides the body lines afterwards:

(defun my-org-occur-and-hide-content ()
  "Interactively call `org-occur' and hide body lines after."
  (interactive)
  (call-interactively #'org-occur)
  (outline-hide-body))

Call it with M-x my-org-occur-and-hide-content RET.

Result with the example from the question:

enter image description here

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.