From 3eccc537cdc0d39c33df668bba4278384f59aa5f Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Thu, 17 Sep 2020 00:16:14 -0400 Subject: [PATCH] org.el: Fix regression in handling of empty #+TAGS * lisp/org.el (org-set-regexps-and-options): Allow an empty #+TAGS value to override org-tag-alist, as it did before v9.4. * testing/lisp/test-org.el (test-org/set-regexps-and-options): Add test. As of b4e91b7e9 (New function: org-collect-keywords, 2020-04-26), a "#+TAGS" header can no longer be used to override a value of org-tag-alist. This breaks the workflow where a set of tags for most files is defined via org-file-tags and then, in a particular file, an empty #+TAGS header is used to ignore org-file-tags and trigger collecting tags from the buffer instead. Rework the handling to restore this behavior. Reported-by: Allen Li Ref: https://orgmode.org/list/80y2laly9v.fsf@felesatra.moe --- lisp/org.el | 8 ++++---- testing/lisp/test-org.el | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 964536c74..42de4b964 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -4279,10 +4279,10 @@ related expressions." (setq org-current-tag-alist (org--tag-add-to-alist org-tag-persistent-alist - (let ((tags (mapconcat #'identity - (cdr (assoc "TAGS" alist)) - "\n"))) - (if (org-string-nw-p tags) (org-tag-string-to-alist tags) + (let ((tags (cdr (assoc "TAGS" alist)))) + (if tags + (org-tag-string-to-alist + (mapconcat #'identity tags "\n")) org-tag-alist)))) (setq org-tag-groups-alist (org-tag-alist-to-groups org-current-tag-alist)) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 1d48bae72..38bab1af9 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -2457,6 +2457,11 @@ SCHEDULED: <2014-03-04 tue.>" (org-test-with-temp-text "#+TAGS: [ A : B C ]" (org-mode-restart) org-tag-groups-alist)))) + (should-not + (let ((org-tag-alist '(("A")))) + (org-test-with-temp-text "#+TAGS:" + (org-mode-restart) + org-current-tag-alist))) ;; FILETAGS keyword. (should (equal '("A" "B" "C")