@Juancho correctly suggested to use occur
to provide the functionality you desire.
Use add-hook
on the occur-mode-find-occurrence-hook
.
- To see how
occur-mode-find-occurrence-hook
works, try this:
Add the code blocks below into your large org-mode file.
> This code block adds the functionality to `occur`. #+BEGIN_SRC elisp :results none :exports none (defun my/occur-org-cycle () (outline-hide-sublevels 1) (org-cycle) (org-switch-to-buffer-other-window "*Occur*") ) (add-hook 'occur-mode-find-occurrence-hook 'my/occur-org-cycle) #+END_SRC > This code block removes the functionality from `occur` #+BEGIN_SRC elisp :results none :exports none (remove-hook 'occur-mode-find-occurrence-hook 'my/occur-org-cycle) #+END_SRC
Click inside the first code block and press C-c C-c to add a hook to
occur
. Answeryes
if prompted.Call
occur
using M-s o ^*Navigate your headlines from the new
*Occur*
buffer and they should expand and collapse as you described.To revert back to the default behavior, click inside the second code block and execute by pressing C-c C-c. Answer
yes
if prompted.
To add this functionality permanently, you will need modify and add the code into your emacs configuration file. Unfortunately, I'm still working that step out.
Thanks for asking a great question!
This code was tested using
GNU Emacs 25.2.1 (x86_64-unknown-cygwin, GTK+ Version 3.22.10)
Org mode version 9.0.9