emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: 9.4 Regression in handling of empty #+TAGS: [9.4 (9.4-elpaplus @ /home/ionasal/.emacs.d/elpa/org-plus-contrib-20200914/)]
@ 2020-09-15 17:56 Allen Li
  2020-09-17  4:16 ` [PATCH] org.el: Fix regression in handling of empty #+TAGS Kyle Meyer
  0 siblings, 1 reply; 3+ messages in thread
From: Allen Li @ 2020-09-15 17:56 UTC (permalink / raw)
  To: emacs-orgmode

Previously, placing an empty #+TAGS: in a file would override
org-file-tags for the file.  In 9.4, an empty #+TAGS: is ignored and
org-file-tags is used.

The relevant code in org.el:

      (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)
		 org-tag-alist))))

This regression is undesirable because I have a set of common
org-file-tags for most files, but one particular file where
automatically detecting the existing tags in the file works better (the
default behavior when org-current-tag-alist is empty).

Emacs  : GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.22, cairo version 1.17.3)
 of 2020-08-28
Package: Org mode version 9.4 (9.4-elpaplus @ /home/ionasal/.emacs.d/elpa/org-plus-contrib-20200914/)


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

* [PATCH] org.el: Fix regression in handling of empty #+TAGS
  2020-09-15 17:56 Bug: 9.4 Regression in handling of empty #+TAGS: [9.4 (9.4-elpaplus @ /home/ionasal/.emacs.d/elpa/org-plus-contrib-20200914/)] Allen Li
@ 2020-09-17  4:16 ` Kyle Meyer
  2020-09-20  5:02   ` Kyle Meyer
  0 siblings, 1 reply; 3+ messages in thread
From: Kyle Meyer @ 2020-09-17  4:16 UTC (permalink / raw)
  To: Allen Li; +Cc: emacs-orgmode

Allen Li writes:

> Previously, placing an empty #+TAGS: in a file would override
> org-file-tags for the file.  In 9.4, an empty #+TAGS: is ignored and
> org-file-tags is used.
>
> The relevant code in org.el:
>
>       (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)
> 		 org-tag-alist))))
>
> This regression is undesirable because I have a set of common
> org-file-tags for most files, but one particular file where
> automatically detecting the existing tags in the file works better (the
> default behavior when org-current-tag-alist is empty).

Thanks reporting.  That change in behavior came with b4e91b7e9 (New
function: org-collect-keywords, 2020-04-26), and I'm not seeing anything
in that commit that indicates it was intentional.

The following patch should restore the previous behavior.  I'll apply it
in a couple of days if no objections come in.

-- >8 --
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 <darkfeline@felesatra.moe>
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 efdf4e3fc..a1930a012 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4279,10 +4279,10 @@ (defun org-set-regexps-and-options (&optional tags-only)
       (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 @@ (ert-deftest test-org/set-regexps-and-options ()
 	    (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")

base-commit: 73c929e3b507db9ee2867d35d10c8f393ff4d38d
-- 
2.28.0




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

* Re: [PATCH] org.el: Fix regression in handling of empty #+TAGS
  2020-09-17  4:16 ` [PATCH] org.el: Fix regression in handling of empty #+TAGS Kyle Meyer
@ 2020-09-20  5:02   ` Kyle Meyer
  0 siblings, 0 replies; 3+ messages in thread
From: Kyle Meyer @ 2020-09-20  5:02 UTC (permalink / raw)
  To: Allen Li; +Cc: emacs-orgmode

Kyle Meyer writes:

> The following patch should restore the previous behavior.  I'll apply it
> in a couple of days if no objections come in.
>
> -- >8 --
> Subject: [PATCH] org.el: Fix regression in handling of empty #+TAGS

Pushed (3eccc537c).


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

end of thread, other threads:[~2020-09-20  5:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-15 17:56 Bug: 9.4 Regression in handling of empty #+TAGS: [9.4 (9.4-elpaplus @ /home/ionasal/.emacs.d/elpa/org-plus-contrib-20200914/)] Allen Li
2020-09-17  4:16 ` [PATCH] org.el: Fix regression in handling of empty #+TAGS Kyle Meyer
2020-09-20  5:02   ` 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).