emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Fix org-in-archived-heading-p when tag contains ARCHIVE as a substring
@ 2020-12-09  9:07 Ihor Radchenko
  2020-12-11  4:27 ` Kyle Meyer
  0 siblings, 1 reply; 2+ messages in thread
From: Ihor Radchenko @ 2020-12-09  9:07 UTC (permalink / raw)
  To: emacs-orgmode

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-Fix-org-in-archived-heading-p.patch --]
[-- Type: text/x-diff, Size: 2188 bytes --]

From c62cbd6ac6cf6a845703b3f7cfb64fa68e39079a Mon Sep 17 00:00:00 2001
From: Ihor Radchenko <yantar92@gmail.com>
Date: Wed, 9 Dec 2020 16:59:58 +0800
Subject: [PATCH] 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.
---
Range-diff:
1:  c62cbd6ac = 1:  c62cbd6ac Fix org-in-archived-heading-p

 lisp/org.el              | 5 ++---
 testing/lisp/test-org.el | 7 ++++++-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index d4fb18465..e44cdf1ca 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -19285,10 +19285,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))))))
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 5172afeec..a18d42a98 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -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.
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-11  4:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-09  9:07 [PATCH] Fix org-in-archived-heading-p when tag contains ARCHIVE as a substring Ihor Radchenko
2020-12-11  4:27 ` Kyle Meyer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).