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.
This commit is contained in:
Nicolas Goaziou 2014-12-16 10:28:34 +01:00
parent eac147621e
commit 389274c1c4
1 changed files with 8 additions and 7 deletions

View File

@ -4750,11 +4750,12 @@ Otherwise, these types are allowed:
(defun org-hide-archived-subtrees (beg end) (defun org-hide-archived-subtrees (beg end)
"Re-hide all archived subtrees after a visibility state change." "Re-hide all archived subtrees after a visibility state change."
(save-excursion (org-with-wide-buffer
(let* ((re (concat ":" org-archive-tag ":"))) (let ((case-fold-search nil)
(re (concat org-outline-regexp-bol ".*:" org-archive-tag ":")))
(goto-char beg) (goto-char beg)
(while (re-search-forward re end t) (while (and (< (point) end) (re-search-forward re end t))
(when (org-at-heading-p) (when (member org-archive-tag (org-get-tags))
(org-flag-subtree t) (org-flag-subtree t)
(org-end-of-subtree t)))))) (org-end-of-subtree t))))))