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 DhguECCuPF9mQwAA0tVLHw (envelope-from ) for ; Wed, 19 Aug 2020 04:44:16 +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 mLBRCyCuPF/OJQAAbx9fmQ (envelope-from ) for ; Wed, 19 Aug 2020 04:44:16 +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 EE86C9403CB for ; Wed, 19 Aug 2020 04:44:14 +0000 (UTC) Received: from localhost ([::1]:42840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8FxL-0003KA-N4 for larch@yhetil.org; Wed, 19 Aug 2020 00:44:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8Fwr-0003K2-Tj for emacs-orgmode@gnu.org; Wed, 19 Aug 2020 00:43:42 -0400 Received: from pb-smtp21.pobox.com ([173.228.157.53]:54027) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8Fwp-0008A6-5L for emacs-orgmode@gnu.org; Wed, 19 Aug 2020 00:43:41 -0400 Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id C1CE9EDEEF; Wed, 19 Aug 2020 00:43:34 -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=oxxME3r8dcJaNsj5MOuO0IVjGDs=; b=NBt4EO 1x+igNftQPkrZEoRS/zjGz6dNqcIsM6sm66ChkW7snoibJZa8Nh+GjLL9w4vZCdV 7pGfSZDtH4qPox1L+/y1SXYhZVYUX1gOi/hhYzgb7ETDt2E4Sor65k2aLbery1xI zT72es6afTBGtgKaFPokpXMEN5EQ4SB8twtJc= Received: from pb-smtp21.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id B88FDEDEEE; Wed, 19 Aug 2020 00:43:34 -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=zKDFbNKGrhqA/VX46hSelj2QA4UgPiafnPFO3qGbKT4=; b=2+pCJbR/ruWLPbXY4+/zeL6GcaS3q+aNHhZ1UJAoFsFeqhQBi6mIz743MUXQynp44TUTgKEumdioiHZaPg89wANueAtsob0GZnOCBmwsDyxRho8/CgozMggK4IPaE/nsLmvmK3ARE8alxmgLNNJrw0vpsH4xEOhQXyAy2CVAMQA= 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-smtp21.pobox.com (Postfix) with ESMTPSA id 73FBBEDEED; Wed, 19 Aug 2020 00:43:30 -0400 (EDT) (envelope-from kyle@kyleam.com) From: Kyle Meyer To: Allen Li Subject: Re: Bug: org-set-tags-command deletes inherited tags [9.3.7 (9.3.7-18-g093b47-elpaplus @ /home/ionasal/.emacs.d/elpa/org-plus-contrib-20200810/)] In-Reply-To: <80a6yry3sg.fsf@felesatra.moe> References: <80a6yry3sg.fsf@felesatra.moe> Date: Wed, 19 Aug 2020 00:43:28 -0400 Message-ID: <87o8n7w8i7.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 87BE3846-E1D6-11EA-AF07-843F439F7C89-24757444!pb-smtp21.pobox.com Received-SPF: pass client-ip=173.228.157.53; envelope-from=kyle@kyleam.com; helo=pb-smtp21.pobox.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/19 00:43:35 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, URIBL_BLOCKED=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=NBt4EO 1; dkim=pass header.d=kyleam.com header.s=mesmtp header.b=2+pCJbR/; 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: gen0loDkC2zv Thanks for the patch. Allen Li writes: > Example Org file: > > * Parent :foo:bar:baz: > ** Child :foo:bar:spam: > > Invoking org-set-tags-command with point on Child prepopulates the > minibuffer prompt with only the tags :spam: > > This is because org-get-tags doesn't distinguish between inherited only > tags and inherited tags which are also explicitly set on a heading, so > org-set-tags-command treats :foo:bar: as inherited only rather than also > set locally on the heading. > > This is undesirable because having tags set directly on a heading has > different semantics even if they are also inherited (e.g., the TAGS > special property, or when headings will be refiled to a different > location later). I agree, that's undesirable and likely unintended. > Subject: [PATCH] org.el: Don't exclude local tags that are also inherited > > * lisp/org.el (org-set-tags-command): Don't exclude local tags even if inherited. > --- > lisp/org.el | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) It'd be good to add something along the lines of your example as a case in test-org/set-tags-command. > diff --git a/lisp/org.el b/lisp/org.el > index fb95590fc..49d7d24f2 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -11880,9 +11880,7 @@ in Lisp code use `org-set-tags' instead." > (org-global-tags-completion-table > (org-agenda-files))) > (or org-current-tag-alist (org-get-buffer-tags))))) > - (current-tags > - (cl-remove-if (lambda (tag) (get-text-property 0 'inherited tag)) > - all-tags)) > + (current-tags (org-get-tags nil t)) > (inherited-tags > (cl-remove-if-not (lambda (tag) (get-text-property 0 'inherited tag)) > all-tags)) That looks good as far as fixing the misbehavior you report. I wonder though whether there's a deeper org-get-tags issue here worth considering. Its documentation says ... the returned list of tags contains tags in this order: file tags, tags inherited from parent headlines, local tags. But it's not specified what happens when a tag is both local and inherited. The current implementation drops the local tag variant through its delete-dups call: (delete-dups (append (org-remove-uninherited-tags itags) ltags)) I would have expected the local tag to get priority here. If that were the case (e.g., something like below), that would also solve the issue you describe. Thoughts? -- >8 -- diff --git a/lisp/org.el b/lisp/org.el index fb95590fc..3dac42b7b 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -12310,8 +12310,10 @@ (defun org-get-tags (&optional pos local) (org--get-local-tags)) itags))) (setq itags (append org-file-tags itags)) - (delete-dups - (append (org-remove-uninherited-tags itags) ltags)))))))) + (nreverse + (delete-dups + (nreverse (nconc (org-remove-uninherited-tags itags) + ltags)))))))))) (defun org-get-buffer-tags () "Get a table of all tags used in the buffer, for completion."