Parcourir la source

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.
Carsten Dominik il y a 15 ans
Parent
commit
15eb6dba42
2 fichiers modifiés avec 11 ajouts et 1 suppressions
  1. 2 0
      lisp/ChangeLog
  2. 9 1
      lisp/org.el

+ 2 - 0
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.
 

+ 9 - 1
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