From: Ihor Radchenko <yantar92@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Fix org-in-archived-heading-p when tag contains ARCHIVE as a substring
Date: Wed, 09 Dec 2020 17:07:44 +0800 [thread overview]
Message-ID: <87o8j3e49r.fsf@localhost> (raw)
[-- 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
next reply other threads:[~2020-12-09 9:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-09 9:07 Ihor Radchenko [this message]
2020-12-11 4:27 ` [PATCH] Fix org-in-archived-heading-p when tag contains ARCHIVE as a substring Kyle Meyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o8j3e49r.fsf@localhost \
--to=yantar92@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).