52

I am learning org mode, and just found out about sparse trees (C-c / t and its kin). How can I go back to the original, unsparse, view of my org document?

I found out by trial and error that TAB-cycling the top node works, is there a better way?

2
  • 3
    See a similar question here: stackoverflow.com/q/6666862/753817
    – Sigma
    Sep 17, 2012 at 8:10
  • C-u C-u TAB runs org-set-startup-visibility which is a similar approach to reverting the buffer or re-running org-mode. Apr 7, 2022 at 18:39

9 Answers 9

61

C-c C-c should clear out the sparse-tree hiding and highlighting, but as far as I know, you can't just go back to the "last view" you had of it. If you want to go back to the full-view, use Shift-Tab to cycle all entries.

0
14

So, it's now 2018 and (AFAIK) this feature still doesn't exist.

The best workaround I've found so far, is to create an indirect buffer (C-x 4 c) and then run org-sparse-tree in there. The original window remains unaffected, so you keep your view, and changes to the indirect buffer will update the original buffer (and vice-versa). When you're done, you just close the indirect buffer.

1
  • 6
    It's now 2020, and this seems like the best workaround so far.
    – Frank M
    Mar 30, 2020 at 19:24
9

I usually just run the org-mode command which seems to get me back to square one.

2
  • This didn't seem to do anything for me. The "\\" sparse markings are still there.
    – Frank M
    Mar 30, 2020 at 19:22
  • This works for me (macOS; doom emacs). Oct 2, 2022 at 15:10
7

Ben K. was on the right track. Indirect buffers are one of emacs' most powerful features.

This function does what I would have expected org-show-todo-tree to do: create a new buffer showing undone TODO items, don't screw up my org file's tree state, and clear the unnecessary occur highlighting.

(defun org-todo-buffer ()
  "Create new indirect buffer with sparse tree of undone TODO items"
  (interactive)
  (clone-indirect-buffer "*org TODO undone*" t)
  (org-show-todo-tree nil) ; mimics interactive usage
  (org-remove-occur-highlights)
)

In this new buffer you can change TODO item states which are reflected in your org file, and you can simply kill the indirect buffer when you are done with it.

6

Coming to this very late, I noticed that selecting all tags then un-highlighting/un-narrowing seems to do the right thing.

C-c \ *
C-c C-c
4

TAB-cycling anywhere only hides the entries highlighted by org-sparse-tree.

To remove the overlays, you need to actually edit the buffer.

3

As you said, you can there by visibility cycling with S-TAB, but I personally don't like visibility cycling because I'm never sure where I am in the cycle.

So I just created this simple org-agenda-custom-command that shows everything without highlighting. Just add it to your .emacs file.

 (setq org-agenda-custom-commands
        ; ... other commands
        `(("z"  "All" occur-tree "."
           ((org-show-entry-below t)
            (org-highlight-sparse-tree-matches nil)))))

There probably is a better way to do this, and the beauty of SO is someone will tell us :).

0

What I usually do to work around this is to use C-x C-v RET (find-alternate-file) or M-x revert-buffer. This works only if you don't have unsaved edits.

1
  • Shift-Tab will remove the filter without the need to reload. Jul 26, 2019 at 3:38
0

I found that the (setq org-agenda-custom-commands.. answer works the best for me.

Use with (sorry, it wasn't obvious to me):

C-c a z

Your Answer

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

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