From 389274c1c47664d0ba0924507efdf6d09c4e7b4c Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Tue, 16 Dec 2014 10:28:34 +0100 Subject: [PATCH] Fix `org-hide-archived-subtrees' * lisp/org.el (org-hide-archived-subtrees): Prevent an error when END argument doesn't match the end of a subtree. Prevent false positives. Also, archive tag is case-sensitive. --- lisp/org.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index e35992234..c051fb4a5 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -4750,13 +4750,14 @@ Otherwise, these types are allowed: (defun org-hide-archived-subtrees (beg end) "Re-hide all archived subtrees after a visibility state change." - (save-excursion - (let* ((re (concat ":" org-archive-tag ":"))) - (goto-char beg) - (while (re-search-forward re end t) - (when (org-at-heading-p) - (org-flag-subtree t) - (org-end-of-subtree t)))))) + (org-with-wide-buffer + (let ((case-fold-search nil) + (re (concat org-outline-regexp-bol ".*:" org-archive-tag ":"))) + (goto-char beg) + (while (and (< (point) end) (re-search-forward re end t)) + (when (member org-archive-tag (org-get-tags)) + (org-flag-subtree t) + (org-end-of-subtree t)))))) (declare-function outline-end-of-heading "outline" ()) (declare-function outline-flag-region "outline" (from to flag))