Fix org-in-archived-heading-p

* lisp/org.el (org-in-archived-heading-p): When called on a heading
with a tag containing org-archive-tag string as a substring, that
heading was incorrectly recognised as archived.  Changed matching
against the whole :tag1:tag2:...: string to matching against tag list
as returned by `org-get-tags'.
* testing/lisp/test-org.el (test-org/in-archived-heading-p): Add test
when one of the heading tags contains org-archive-tag as a substring.
This commit is contained in:
Ihor Radchenko 2020-12-09 16:59:58 +08:00 committed by Kyle Meyer
parent cf02219e72
commit a03f17e49f
2 changed files with 8 additions and 4 deletions

View File

@ -20282,10 +20282,9 @@ This function also checks ancestors of the current headline,
unless optional argument NO-INHERITANCE is non-nil."
(cond
((org-before-first-heading-p) nil)
((let ((tags (nth 5 (org-heading-components))))
((let ((tags (org-get-tags nil 'local)))
(and tags
(let ((case-fold-search nil))
(string-match-p org-archive-tag tags)))))
(cl-some (apply-partially #'string= org-archive-tag) tags))))
(no-inheritance nil)
(t
(save-excursion (and (org-up-heading-safe) (org-in-archived-heading-p))))))

View File

@ -2103,7 +2103,12 @@
(should-not
(org-test-with-temp-text "* Headline :ARCHIVE:\n** Level 2\nBody"
(goto-char (point-max))
(org-in-archived-heading-p t))))
(org-in-archived-heading-p t)))
;; Archive tag containing ARCHIVE as substring
(should-not
(org-test-with-temp-text "* Headline :NOARCHIVE:\n** Level 2\nBody"
(goto-char (point-max))
(org-in-archived-heading-p))))
(ert-deftest test-org/entry-blocked-p ()
;; Check other dependencies.