From 15eb6dba42e3b0fc0c9a8062ef2a4933c697941b Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 3 Nov 2009 15:36:06 +0100 Subject: [PATCH] Fix bug with sparse trees and ARCHIVE tag Chris Randle writes: > I've just noticed that creating a sparse tree with `C-c / r' is > not displaying matches in my org file. It hasn't always been this > way, I *think* things were working OK around 6.29, but it's hard > to be sure. > > I've managed to pare my org file down to a few lines that > demonstrate the problem > > =============================== > > * Customers > ** Customer A > *** Billing > **** Support during September :ARCHIVE: > ** Customer B > 07964-xxxxxx > > *** Problem with Laptop > ** Customer C > *** Current Details > > *** Test of 07968 showing up > ** Customer D > 01673-xxxxxx > 07968-xxxxxx > > *** Laptop slowdown fix > spoolsv.exe at 99% > > =================================== > > Setting a sparse tree by regexp 0796[48] returns "3 match(es) for > regexp 0796[48]", but the tree doesn't expand at the hit > locations. If I manually expand the tree at the locations of the > hits, the results are highlighted. It makes no difference if the > hits are in a headline or in notes beneath a headline. > > Remove the ARCHIVE tag from the "Support during September" > headline with `C-c C-x a' and redo the sparse tree. Everything > now appears expanded as I'd expect. Hmm, maybe the outline behavior of hide-subtree has changed??? Anyway, we now just use our own function for this. --- lisp/ChangeLog | 2 ++ lisp/org.el | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 430e09466..8fa73a285 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -3,6 +3,8 @@ * org.el (org-tab-ind-state): New variable. (org-cycle-level): New function. (org-cycle-level-after-item/entry-creation): New option. + (org-flag-subtree): New function. + (org-hide-archived-subtrees): Call `org-flag-subtree'. * org-list.el (org-cycle-item-indentation): New function. diff --git a/lisp/org.el b/lisp/org.el index 1fb0afc53..903df630a 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -3443,9 +3443,17 @@ collapsed state." (let* ((re (concat ":" org-archive-tag ":"))) (goto-char beg) (while (re-search-forward re end t) - (and (org-on-heading-p) (hide-subtree)) + (and (org-on-heading-p) (org-flag-subtree t)) (org-end-of-subtree t))))) +(defun org-flag-subtree (flag) + (save-excursion + (org-back-to-heading t) + (outline-end-of-heading) + (outline-flag-region (point) + (progn (org-end-of-subtree t) (point)) + flag))) + (defalias 'org-advertized-archive-subtree 'org-archive-subtree) (eval-and-compile