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 OGYYF8q4+1/yXgAA0tVLHw (envelope-from ) for ; Mon, 11 Jan 2021 02:32:42 +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 OLLQEsq4+18/VwAAbx9fmQ (envelope-from ) for ; Mon, 11 Jan 2021 02:32:42 +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 292B89402A9 for ; Mon, 11 Jan 2021 02:32:42 +0000 (UTC) Received: from localhost ([::1]:48064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyn0a-0007YT-6i for larch@yhetil.org; Sun, 10 Jan 2021 21:32:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kymzn-0007YI-O5 for emacs-orgmode@gnu.org; Sun, 10 Jan 2021 21:31:53 -0500 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]:38372) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kymzl-0008UR-5L for emacs-orgmode@gnu.org; Sun, 10 Jan 2021 21:31:51 -0500 Received: by mail-ej1-x629.google.com with SMTP id 6so22578809ejz.5 for ; Sun, 10 Jan 2021 18:31:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:thread-topic:thread-index:date:message-id :references:in-reply-to:reply-to:accept-language:content-language :mime-version; bh=Rv9ib91B1YBI/er8dFAmvhUj3Xos16g+qOi7AUs1bXI=; b=BXcoA5NtYKjdyowpjGf2KZJ9SId9VlgFwyBSZQKqfPA8v5CNws5DIIlzijrhJr9NXM U1eZ9adPyLb7KcCrM7ejZ3QnHIpGhhHnfIOXyveTtBBCo99Wr1Ol77twuKSS6eckVpNd jhoE8fkBBRTZ9HHP29xLtHA6gX5ZHtdI8AlCt4HdsFsyW55i4Fz2WtnegE5ZAqrS3vK8 8o8vTiQOWSd/mDRY5rwhKLsSZu1BxCuPymeqtzo9+Tx6yMHbjK4iQJRcjCavdyHeEIqM 7ySQRGZAYk00WDmi593u6kaqZ/30aVhe39hew35ohk+rorClUcW3GWmGsuRhqaUUVjn+ 62Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:thread-topic:thread-index :date:message-id:references:in-reply-to:reply-to:accept-language :content-language:mime-version; bh=Rv9ib91B1YBI/er8dFAmvhUj3Xos16g+qOi7AUs1bXI=; b=CkK1hIqBc5tHrXu/OEbj/O8caOKjq7Nra2LxAezH15Mq0nJppdHVZkjPPDxvVciw7T WQ/REM0lRWEUXqTSAXl970K3mPV/0N3bqwKvLTIPkaz/MOTbl7dqLpLXQ8QDFNtk2jT0 rGFeR+4ZXBaSd5/QH9cCtba+4BVNP/X4kOZDQQ1x5jDxwSnwVp2My/d3epDTYyiOk4Ku VWpd5Lj36w+D5r4smhxKpws0onKMQZ9He1rqzHGh2V/tVPKmE90LdJ4j+4eVdYulk1mA FInaqEduy7J/TZDb8G9Y8JoP3tEKs3Z2nuOfCUGoVbqcGOEQKSKUUpZ8Xq+oOoaKwXSw hkwg== X-Gm-Message-State: AOAM530FGSza+97AwkzA/mrwmz1Q2SbBJ+r2d0uulODt36OHHxIIZTNo AkIq6Jm5k5XxTzfV77Z5sw== X-Google-Smtp-Source: ABdhPJwReh+D5hqH3rCiQKglABMsnejR6JDLZL0FObIMFWWJ1qSAtQF6WVEs+OWCuRs8CCmE4KiRoA== X-Received: by 2002:a17:906:edb2:: with SMTP id sa18mr8944951ejb.264.1610332307037; Sun, 10 Jan 2021 18:31:47 -0800 (PST) Received: from VI1PR1001MB1070.EURPRD10.PROD.OUTLOOK.COM ([2603:1026:300:5a::5]) by smtp.gmail.com with ESMTPSA id r21sm6972886eds.91.2021.01.10.18.31.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Jan 2021 18:31:45 -0800 (PST) Received: from dark (183.246.146.135) by HK2PR06CA0008.apcprd06.prod.outlook.com (2603:1096:202:2e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Mon, 11 Jan 2021 02:24:47 +0000 From: Christopher Miles To: Kyle Meyer Subject: Re: [PATCH] I updated patch by deleteing duplicate tags Thread-Topic: [PATCH] I updated patch by deleteing duplicate tags Thread-Index: AQHW1cT5VlMPkqXw50ywC2Yyyw2F3aohj12AgAA7O4A= X-MS-Exchange-MessageSentRepresentingType: 1 Date: Mon, 11 Jan 2021 02:24:49 +0000 Message-ID: References: <87sg78phnc.fsf@kyleam.com> In-Reply-To: <87sg78phnc.fsf@kyleam.com> Accept-Language: zh-TW, en-US Content-Language: en-US X-MS-Exchange-Organization-AuthAs: Internal X-MS-Exchange-Organization-AuthMechanism: 06 X-MS-Exchange-Organization-AuthSource: VI1PR1001MB1070.EURPRD10.PROD.OUTLOOK.COM X-MS-Has-Attach: yes X-MS-Exchange-Organization-Network-Message-Id: 0ca3ef04-8407-40ae-088f-08d8b5d81193 X-MS-Exchange-Organization-SCL: -1 X-MS-TNEF-Correlator: X-MS-Exchange-Organization-RecordReviewCfmType: 0 x-clientproxiedby: HK2PR06CA0008.apcprd06.prod.outlook.com (2603:1096:202:2e::20) To VI1PR1001MB1070.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:800:69::18) Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::629; envelope-from=numbchild@gmail.com; helo=mail-ej1-x629.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Reply-To: Christopher Miles Cc: Org-mode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -4.00 Authentication-Results: aspmx1.migadu.com; none X-Migadu-Queue-Id: 292B89402A9 X-Spam-Score: -4.00 X-Migadu-Scanner: scn0.migadu.com X-TUID: /VY7rz13r2Oz --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Kyle Meyer writes: > Thanks for the patch. > > stardiviner writes: > >> On Wed, Dec 2, 2020 at 5:30 PM stardiviner wrote: >> >>> The default [C-c C-q] completing tags only retrieve tags from current >>> buffer locally. >>> >>> By this patch, will merge both buffer-local tags and user defined global >>> `org-tags-alist`. > > It does a bit more than that. It uses org-global-tags-completion-table, > which considers tags in all agenda files by default and takes into > account org-tag-alist (as well as org-tag-persistent-alist) via the use > of the org-current-tag-alist variable. > That's what I want. Why obviously user pre-defined tags can't be used globa= lly. Right? It should be. >>> This is more reasonable. > > I'd guess that depends on the user. I personally wouldn't like to see > tags from all of my agenda files, and I'm fine not seeing > org-tag{-persistent}-alist ones that aren't in the current buffer given > that they have fast selection keys. Currently tags selection is now slow, even with 100 pre-defined tags. Shoul= d be fine. Tags sometimes is abundant. So if it is slow, then it means the comma= nd =3Dorg-set-tags-command=3D should be optimized. > >> Subject: [PATCH] org.el: Complete tags from both global and buffer local >> >> * lisp/org.el: (org-fast-tag-selection): merge buffer local tags with >> global alist of tags. > > Convention/consistency nits: spurious ":" after ".el" and > s/merge/Merge/. Updated. Thanks > >> --- >> lisp/org.el | 11 +++++++---- >> 1 file changed, 7 insertions(+), 4 deletions(-) >> >> diff --git a/lisp/org.el b/lisp/org.el >> index 0e12e4b15..287b8c407 100644 >> --- a/lisp/org.el >> +++ b/lisp/org.el >> @@ -12256,10 +12256,13 @@ (defun org-fast-tag-selection (current inherit= ed table &optional todo-table) >> (condition-case nil >> (setq tg (completing-read >> "Tag: " >> - (or buffer-tags >> - (with-current-buffer buf >> - (setq buffer-tags >> - (org-get-buffer-tags)))))) >> + (delq nil >> + (delete-dups >> + (append (or buffer-tags >> + (with-current-buffer buf >> + (setq buffer-tags >> + (org-get-buffer-tags)))) >> + (org-global-tags-completion-table)))))) > > This change in behavior should come with a NEWS entry and a > documentation update. What the manual currently says is now stale: > > - {{{kbd(TAB)}}} :: >=20=20=20 > #+kindex: TAB > Enter a tag in the minibuffer, even if the tag is not in the > predefined list. You can complete on all tags present in the > buffer. You can also add several tags: just separate them with > a comma. > > As I mentioned above, though, I'm not sure always adding agenda tags is > desirable. However, I think it'd probably be safe to look at > org-complete-tags-always-offer-all-agenda-tags as an indication of > whether the user wants this behavior. org-set-tags-command already > considers that option when it generates the table that it passes to > org-fast-tag-selection. So perhaps we could just consider the table > when calling completing-read for the tab key (something along the lines > of the patch at the end of the email). > Indeed, I add condition on ~org-complete-tags-always-offer-all-agenda-tags~= now. > Conceptually that's been discussed/tried before, but it was then backed > out of: > > * https://orgmode.org/list/F753E612-2D5D-4BA7-AF0C-D49C7A8DDA24@pobox.c= om/T/#u > * 647396464 (org.el: Include tags from `org-tag-alist' when completing > with the TAB key, 2012-03-27) > * d4ddcbb8b (Revert "org.el: Include tags from `org-tag-alist' when > completing with the TAB key.", 2012-04-10) > * acc7a0b2b (org.el: Include `org-tag-alist' in the list for tag > completions, 2012-03-27) > I checked this mailing list thread, the original commit use ~(mapcar 'car t= able)~. It's more simple. I updated my code to this. My patch only changed the ~completing-read~ part. And I found ido support o= ption is been removed in Org. I think this is right decision. > At a quick glance, I think the patch below avoids the problems that led > to 647396464 being reverted, but that'd need to be checked more > carefully. > > > diff --git a/lisp/org.el b/lisp/org.el > index 5b0ae389c..9383719e3 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -12139,7 +12139,7 @@ (defun org-fast-tag-selection (current inherited = table &optional todo-table) > fulltable)))) > (buf (current-buffer)) > (expert (eq org-fast-tag-selection-single-key 'expert)) > - (buffer-tags nil) > + (tab-tags nil) > (fwidth (+ maxlen 3 1 3)) > (ncol (/ (- (window-width) 4) fwidth)) > (i-face 'org-done) > @@ -12274,16 +12274,22 @@ (defun org-fast-tag-selection (current inherite= d table &optional todo-table) > (setq current nil) > (when exit-after-next (setq exit-after-next 'now))) > ((=3D c ?\t) > + (unless tab-tags > + (setq tab-tags > + (delq nil > + (mapcar (lambda (x) > + (let ((item (car-safe x))) > + (and (stringp item) > + (list item)))) > + (org--tag-add-to-alist > + (with-current-buffer buf > + (org-get-buffer-tags)) > + table))))) > (condition-case nil > - (setq tg (completing-read > - "Tag: " > - (or buffer-tags > - (with-current-buffer buf > - (setq buffer-tags > - (org-get-buffer-tags)))))) > + (setq tg (completing-read "Tag: " tab-tags)) > (quit (setq tg ""))) > (when (string-match "\\S-" tg) > - (cl-pushnew (list tg) buffer-tags :test #'equal) > + (cl-pushnew (list tg) tab-tags :test #'equal) > (if (member tg current) > (setq current (delete tg current)) > (push tg current))) Hmm, I tested your upper patch, works same. But looks safer. So I applied y= our patch in my patch. Actually it's totally your code.... Hahaha Anyway, I re-generated patch. Bother you to review it. :smile: =2D-=20 [ stardiviner ] I try to make every word tell the meaning that I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org.el-Complete-tags-from-both-global-and-buffer-loc.patch Content-Transfer-Encoding: quoted-printable Content-Description: new patch From=2085d11170985a612a8e6c847f56a5c5bf121b97d2 Mon Sep 17 00:00:00 2001 From: stardiviner Date: Wed, 2 Dec 2020 17:24:29 +0800 Subject: [PATCH] org.el: Complete tags from both global and buffer local * lisp/org.el (org-fast-tag-selection): Merge buffer local tags with global alist of tags. And it obey the option org-complete-tags-always-offer-all-agenda-tags. * doc/org-manual.org: Update the TAB key doc in tags selection UI. * etc/ORG-NEWS: Mention the change in org-set-tags-command. =2D-- doc/org-manual.org | 6 +++--- etc/ORG-NEWS | 5 +++++ lisp/org.el | 24 ++++++++++++++---------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index b015b502c..01cec4b8d 100644 =2D-- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -4860,9 +4860,9 @@ In this interface, you can also use the following spe= cial keys: =20 #+kindex: TAB Enter a tag in the minibuffer, even if the tag is not in the =2D predefined list. You can complete on all tags present in the =2D buffer. You can also add several tags: just separate them with =2D a comma. + predefined list. You can complete on all tags present in the buffer + and globally pre-defined tags from ~org-tag{-persistent}-alist~. + You can also add several tags: just separate them with a comma. =20 - {{{kbd(SPC)}}} :: =20 diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 5e5f1954d..5e68d27c0 100644 =2D-- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -149,6 +149,11 @@ Example: A new =3Du=3D mode flag for Calc formulas in Org tables has been added to enable Calc units simplification mode. =20 +*** =3Dorg-set-tags-command=3D select tags from ~org-global-tags-completio= n-table~ + +Let =3Dorg-set-tags-command=3D complete tags from global tags list (both +buffer-local tags and ~org-tag{-persistent}-alist~). + ** Miscellaneous *** =3Dorg-goto-first-child=3D now works before first heading =20 diff --git a/lisp/org.el b/lisp/org.el index 5b0ae389c..ba816dfa6 100644 =2D-- a/lisp/org.el +++ b/lisp/org.el @@ -12139,7 +12139,7 @@ (defun org-fast-tag-selection (current inherited ta= ble &optional todo-table) fulltable)))) (buf (current-buffer)) (expert (eq org-fast-tag-selection-single-key 'expert)) =2D (buffer-tags nil) + (tab-tags nil) (fwidth (+ maxlen 3 1 3)) (ncol (/ (- (window-width) 4) fwidth)) (i-face 'org-done) @@ -12274,16 +12274,20 @@ (defun org-fast-tag-selection (current inherited = table &optional todo-table) (setq current nil) (when exit-after-next (setq exit-after-next 'now))) ((=3D c ?\t) =2D (condition-case nil =2D (setq tg (completing-read =2D "Tag: " =2D (or buffer-tags =2D (with-current-buffer buf =2D (setq buffer-tags =2D (org-get-buffer-tags)))))) =2D (quit (setq tg ""))) + (unless tab-tags + (setq tab-tags + (delq nil + (mapcar (lambda (x) + (let ((item (car-safe x))) + (and (stringp item) + (list item)))) + (org--tag-add-to-alist + (with-current-buffer buf + (org-get-buffer-tags)) + table))))) + (setq tg (completing-read "Tag: " tab-tags)) (when (string-match "\\S-" tg) =2D (cl-pushnew (list tg) buffer-tags :test #'equal) + (cl-pushnew (list tg) tab-tags :test #'equal) (if (member tg current) (setq current (delete tg current)) (push tg current))) =2D-=20 2.29.2 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl/7tucACgkQG13xyVro msN9vQf6AskJElbCyTvX3fLCPIetSkHTjfwsfwbpEfHlV9XYrzzARjtsyqQTgam8 aeBcm+sYLojoJ/0B34qNFhadcPU1q95oLgjDTdGykq6Ivk8oowZeJh/bLdliQ4sq 0gr0OjkXsAeRRl4KWSshfnshYuEWVcfvRPlf0J7jK/wS8q3I7L73fIlbhTK5YuD7 y07U9g6YNUEFI1KuNoby0eLCr+5pDNEJ+PpyY/XmvQHKGQr/9wm9qeDYDNEJYggz qf7T8i799AdCszj07gr3lNUycRMNKx57wjGZEWlKkN9ntCIF/B+sRFNoBtPMGL/x k43YP0HwAesISGLRfoMzVWOIrXWwgA== =QDp2 -----END PGP SIGNATURE----- --==-=-=--