benhsu
benhsu

Reputation: 5546

How do I revert a sparse-tree view in org mode?

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?

Upvotes: 52

Views: 10826

Answers (9)

Paul Schulz
Paul Schulz

Reputation: 1

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

Upvotes: 0

John Lunzer
John Lunzer

Reputation: 361

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.

Upvotes: 7

ahnkle
ahnkle

Reputation: 477

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

Upvotes: 6

Lei Zhao
Lei Zhao

Reputation: 1156

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.

Upvotes: 0

Ben K.
Ben K.

Reputation: 161

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.

Upvotes: 15

Roy Truelove
Roy Truelove

Reputation: 22466

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

Upvotes: 9

studgeek
studgeek

Reputation: 14920

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 :).

Upvotes: 3

jdd
jdd

Reputation: 4336

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.

Upvotes: 63

bzg
bzg

Reputation: 2605

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

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

Upvotes: 5

Related Questions