From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id UHkkA0HjYl/uUgAA0tVLHw (envelope-from ) for ; Thu, 17 Sep 2020 04:17:05 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id SBC9OkDjYl98TAAAbx9fmQ (envelope-from ) for ; Thu, 17 Sep 2020 04:17:04 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 148E09404D8 for ; Thu, 17 Sep 2020 04:17:03 +0000 (UTC) Received: from localhost ([::1]:49570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kIlLx-0004yY-3J for larch@yhetil.org; Thu, 17 Sep 2020 00:17:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIlLQ-0004yG-Os for emacs-orgmode@gnu.org; Thu, 17 Sep 2020 00:16:28 -0400 Received: from pb-smtp20.pobox.com ([173.228.157.52]:55335) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIlLM-0003Ob-0b for emacs-orgmode@gnu.org; Thu, 17 Sep 2020 00:16:27 -0400 Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 11885EB78D; Thu, 17 Sep 2020 00:16:19 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:in-reply-to:references:date:message-id:mime-version :content-type; s=sasl; bh=PYm9V3H28DzwT0UXtkpZCDlyuII=; b=PQEC92 /XRgcwNMeWc4doN5ueFTVu9G5uzgql5cBHRfrKNAStUJfwqqadKVeDQGf/f9YiHe sPMHSauDrhpP/GwrDsFqNMpcO/iAnYe+SGENWSnQRIORfkbKk8A+0lIvm4fwqymz FcDg500m6FbulYmZU4amAsEkUFhegQfTa4NDE= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 09B3FEB78C; Thu, 17 Sep 2020 00:16:19 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=kyleam.com; h=from:to:cc:subject:in-reply-to:references:date:message-id:mime-version:content-type; s=mesmtp; bh=da8dodaMBAy6lZ2106I/tyM83lRJuyZ+YUn6aLk02U4=; b=nVy/DIQfwtjSAK6LMt+y//BDsWiHU0cJv3agqm3mpZmROuKkSPqWZSXnB7SNtym4omEA5+4UwqwF1HWOF+hxzCHhyIfDSceCc0iEb3KFaqGPKbUnr21iyo3fE7RKt5GSNyjNBsMATfI0c7pPJRLJN9+G4C7PzKHDh89dqcPAZGk= Received: from localhost (unknown [45.33.91.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id 5B4EBEB78B; Thu, 17 Sep 2020 00:16:16 -0400 (EDT) (envelope-from kyle@kyleam.com) From: Kyle Meyer To: Allen Li Subject: [PATCH] org.el: Fix regression in handling of empty #+TAGS In-Reply-To: <80y2laly9v.fsf@felesatra.moe> References: <80y2laly9v.fsf@felesatra.moe> Date: Thu, 17 Sep 2020 00:16:14 -0400 Message-ID: <87bli582cx.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 87B8EF62-F89C-11EA-886A-F0EA2EB3C613-24757444!pb-smtp20.pobox.com Received-SPF: pass client-ip=173.228.157.52; envelope-from=kyle@kyleam.com; helo=pb-smtp20.pobox.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/17 00:16:19 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=pobox.com header.s=sasl header.b=PQEC92 /; dkim=pass header.d=kyleam.com header.s=mesmtp header.b=nVy/DIQf; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -1.21 X-TUID: ERsMWmTZMc6b 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 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