* [PATCH] [C-c C-q] completing tags from both buffer-local and global alist of tags
@ 2020-12-02 9:30 stardiviner
2020-12-03 2:40 ` [PATCH] I updated patch by deleteing duplicate tags stardiviner
0 siblings, 1 reply; 10+ messages in thread
From: stardiviner @ 2020-12-02 9:30 UTC (permalink / raw)
To: Org-mode
[-- Attachment #1.1: Type: text/plain, Size: 449 bytes --]
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`.
This is more reasonable.
[stardiviner] <Hack this world!> GPG key ID: 47C32433
IRC(freeenode): stardiviner Twitter: @numbchild
Key fingerprint = 9BAA 92BC CDDD B9EF 3B36 CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.github.io/
[-- Attachment #1.2: Type: text/html, Size: 1292 bytes --]
[-- Attachment #2: 0001-org.el-Complete-tags-from-both-global-and-buffer-loc.patch --]
[-- Type: text/x-patch, Size: 1116 bytes --]
From c1f88411835f34a8c571547bf8156c98f18d2b2e Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
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.
---
lisp/org.el | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 0e12e4b15..0249a43c3 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -12256,10 +12256,11 @@ (defun org-fast-tag-selection (current inherited 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))))))
+ (append (or buffer-tags
+ (with-current-buffer buf
+ (setq buffer-tags
+ (org-get-buffer-tags))))
+ (org-global-tags-completion-table))))
(quit (setq tg "")))
(when (string-match "\\S-" tg)
(cl-pushnew (list tg) buffer-tags :test #'equal)
--
2.29.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] I updated patch by deleteing duplicate tags
2020-12-02 9:30 [PATCH] [C-c C-q] completing tags from both buffer-local and global alist of tags stardiviner
@ 2020-12-03 2:40 ` stardiviner
2021-01-07 2:37 ` Christopher Miles
2021-01-10 22:10 ` Kyle Meyer
0 siblings, 2 replies; 10+ messages in thread
From: stardiviner @ 2020-12-03 2:40 UTC (permalink / raw)
To: Org-mode
[-- Attachment #1.1: Type: text/plain, Size: 791 bytes --]
[stardiviner] <Hack this world!> GPG key ID: 47C32433
IRC(freeenode): stardiviner Twitter: @numbchild
Key fingerprint = 9BAA 92BC CDDD B9EF 3B36 CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.github.io/
On Wed, Dec 2, 2020 at 5:30 PM stardiviner <numbchild@gmail.com> 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`.
>
> This is more reasonable.
>
>
> [stardiviner] <Hack this world!> GPG key ID: 47C32433
> IRC(freeenode): stardiviner Twitter: @numbchild
> Key fingerprint = 9BAA 92BC CDDD B9EF 3B36 CB99 B8C4 B8E5 47C3 2433
> Blog: http://stardiviner.github.io/
>
[-- Attachment #1.2: Type: text/html, Size: 2133 bytes --]
[-- Attachment #2: 0001-org.el-Complete-tags-from-both-global-and-buffer-loc.patch --]
[-- Type: text/x-patch, Size: 1164 bytes --]
From 95060ad30d2c7fd5db432b2058627ee48d1586b0 Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
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.
---
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 inherited 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))))))
(quit (setq tg "")))
(when (string-match "\\S-" tg)
(cl-pushnew (list tg) buffer-tags :test #'equal)
--
2.29.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] I updated patch by deleteing duplicate tags
2020-12-03 2:40 ` [PATCH] I updated patch by deleteing duplicate tags stardiviner
@ 2021-01-07 2:37 ` Christopher Miles
2021-01-10 22:10 ` Kyle Meyer
1 sibling, 0 replies; 10+ messages in thread
From: Christopher Miles @ 2021-01-07 2:37 UTC (permalink / raw)
To: Org-mode
[-- Attachment #1: Type: text/plain, Size: 1230 bytes --]
Bump this thread. Any ideas about this functionality? Any objection or suggestion?
stardiviner <numbchild@gmail.com> writes:
> [stardiviner] <Hack this world!> GPG key ID: 47C32433
> IRC(freeenode): stardiviner Twitter: @numbchild
> Key fingerprint = 9BAA 92BC CDDD B9EF 3B36 CB99 B8C4 B8E5 47C3 2433
> Blog: http://stardiviner.github.io/
>
>
> On Wed, Dec 2, 2020 at 5:30 PM stardiviner <numbchild@gmail.com> 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`.
>>
>> This is more reasonable.
>>
>>
>> [stardiviner] <Hack this world!> GPG key ID: 47C32433
>> IRC(freeenode): stardiviner Twitter: @numbchild
>> Key fingerprint = 9BAA 92BC CDDD B9EF 3B36 CB99 B8C4 B8E5 47C3 2433
>> Blog: http://stardiviner.github.io/
>>
--
[ 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] I updated patch by deleteing duplicate tags
2020-12-03 2:40 ` [PATCH] I updated patch by deleteing duplicate tags stardiviner
2021-01-07 2:37 ` Christopher Miles
@ 2021-01-10 22:10 ` Kyle Meyer
2021-01-11 2:24 ` Christopher Miles
1 sibling, 1 reply; 10+ messages in thread
From: Kyle Meyer @ 2021-01-10 22:10 UTC (permalink / raw)
To: stardiviner; +Cc: Org-mode
Thanks for the patch.
stardiviner writes:
> On Wed, Dec 2, 2020 at 5:30 PM stardiviner <numbchild@gmail.com> 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.
>> 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.
> 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/.
> ---
> 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 inherited 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)}}} ::
#+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).
Conceptually that's been discussed/tried before, but it was then backed
out of:
* https://orgmode.org/list/F753E612-2D5D-4BA7-AF0C-D49C7A8DDA24@pobox.com/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)
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 inherited table &optional todo-table)
(setq current nil)
(when exit-after-next (setq exit-after-next 'now)))
((= 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)))
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] I updated patch by deleteing duplicate tags
2021-01-10 22:10 ` Kyle Meyer
@ 2021-01-11 2:24 ` Christopher Miles
2021-01-13 3:26 ` Kyle Meyer
0 siblings, 1 reply; 10+ messages in thread
From: Christopher Miles @ 2021-01-11 2:24 UTC (permalink / raw)
To: Kyle Meyer; +Cc: Org-mode
[-- Attachment #1.1: Type: text/plain, Size: 6765 bytes --]
Kyle Meyer <kyle@kyleam.com> writes:
> Thanks for the patch.
>
> stardiviner writes:
>
>> On Wed, Dec 2, 2020 at 5:30 PM stardiviner <numbchild@gmail.com> 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 globally.
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. Should be
fine. Tags sometimes is abundant. So if it is slow, then it means the command
=org-set-tags-command= 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 inherited 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)}}} ::
>
> #+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.com/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 table)~.
It's more simple. I updated my code to this.
My patch only changed the ~completing-read~ part. And I found ido support option
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 inherited table &optional todo-table)
> (setq current nil)
> (when exit-after-next (setq exit-after-next 'now)))
> ((= 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 your
patch in my patch. Actually it's totally your code.... Hahaha
Anyway, I re-generated patch. Bother you to review it. :smile:
--
[ 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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: new patch --]
[-- Type: text/x-patch, Size: 3844 bytes --]
From 85d11170985a612a8e6c847f56a5c5bf121b97d2 Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
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.
---
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
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -4860,9 +4860,9 @@ In this interface, you can also use the following special keys:
#+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.
+ 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.
- {{{kbd(SPC)}}} ::
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 5e5f1954d..5e68d27c0 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -149,6 +149,11 @@ Example:
A new =u= mode flag for Calc formulas in Org tables has been added to
enable Calc units simplification mode.
+*** =org-set-tags-command= select tags from ~org-global-tags-completion-table~
+
+Let =org-set-tags-command= complete tags from global tags list (both
+buffer-local tags and ~org-tag{-persistent}-alist~).
+
** Miscellaneous
*** =org-goto-first-child= now works before first heading
diff --git a/lisp/org.el b/lisp/org.el
index 5b0ae389c..ba816dfa6 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,20 @@ (defun org-fast-tag-selection (current inherited table &optional todo-table)
(setq current nil)
(when exit-after-next (setq exit-after-next 'now)))
((= c ?\t)
- (condition-case nil
- (setq tg (completing-read
- "Tag: "
- (or buffer-tags
- (with-current-buffer buf
- (setq buffer-tags
- (org-get-buffer-tags))))))
- (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)
- (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)))
--
2.29.2
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] I updated patch by deleteing duplicate tags
2021-01-11 2:24 ` Christopher Miles
@ 2021-01-13 3:26 ` Kyle Meyer
2021-01-13 9:30 ` Christopher Miles
0 siblings, 1 reply; 10+ messages in thread
From: Kyle Meyer @ 2021-01-13 3:26 UTC (permalink / raw)
To: Christopher Miles; +Cc: Org-mode
Christopher Miles writes:
> Kyle Meyer <kyle@kyleam.com> writes:
>
>> stardiviner writes:
>>>> 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 globally.
> Right? It should be.
My point was that it's not just adding these pre-defined lists (#1);
it's also adding tags from agenda files (#2). I think we certainly
don't want to do #2 unconditionally. On the other hand, #1 is probably
okay, but as I said in my last email, I could see not wanting that
either.
Anyway, the patch I proposed (which you've adapted for your latest
round), avoids #2 by guarding the behavior behind the existing
org-complete-tags-always-offer-all-agenda-tags option, and I think
that's a good path forward.
> 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.
s/obey/&s/
> * doc/org-manual.org: Update the TAB key doc in tags selection UI.
>
> * etc/ORG-NEWS: Mention the change in org-set-tags-command.
> ---
> 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
> --- a/doc/org-manual.org
> +++ b/doc/org-manual.org
> @@ -4860,9 +4860,9 @@ In this interface, you can also use the following special keys:
>
> #+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.
> + predefined list. You can complete on all tags present in the buffer
> + and globally pre-defined tags from ~org-tag{-persistent}-alist~.
Please spell these two options out: ~org-tag-alist~ and
~org-tag-persistent-alist~.
> + You can also add several tags: just separate them with a comma.
>
> - {{{kbd(SPC)}}} ::
>
> diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
> index 5e5f1954d..5e68d27c0 100644
> --- a/etc/ORG-NEWS
> +++ b/etc/ORG-NEWS
> @@ -149,6 +149,11 @@ Example:
> A new =u= mode flag for Calc formulas in Org tables has been added to
> enable Calc units simplification mode.
>
> +*** =org-set-tags-command= select tags from ~org-global-tags-completion-table~
> +
> +Let =org-set-tags-command= complete tags from global tags list (both
> +buffer-local tags and ~org-tag{-persistent}-alist~).
Same note about avoiding shorthand for the option names.
Also, please rewrite this to make it clear that this is relevant for TAB
in the fast completion interface. It's probably also worth mentioning
that org-complete-tags-always-offer-all-agenda-tags is now honored.
And, very minor, but any reason for the mix of =...= and ~...~ markup
here?
> diff --git a/lisp/org.el b/lisp/org.el
> index 5b0ae389c..ba816dfa6 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,20 @@ (defun org-fast-tag-selection (current inherited table &optional todo-table)
> (setq current nil)
> (when exit-after-next (setq exit-after-next 'now)))
> ((= c ?\t)
> - (condition-case nil
Unlike the patch I sent, you've dropped the condition-case here, which I
don't think was intentional.
Thanks.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] I updated patch by deleteing duplicate tags
2021-01-13 3:26 ` Kyle Meyer
@ 2021-01-13 9:30 ` Christopher Miles
2021-01-14 5:24 ` Kyle Meyer
0 siblings, 1 reply; 10+ messages in thread
From: Christopher Miles @ 2021-01-13 9:30 UTC (permalink / raw)
To: Kyle Meyer; +Cc: Org-mode
[-- Attachment #1.1: Type: text/plain, Size: 4925 bytes --]
Kyle Meyer <kyle@kyleam.com> writes:
> Christopher Miles writes:
>
>> Kyle Meyer <kyle@kyleam.com> writes:
>>
>>> stardiviner writes:
>>>>> 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 globally.
>> Right? It should be.
>
> My point was that it's not just adding these pre-defined lists (#1);
> it's also adding tags from agenda files (#2). I think we certainly
> don't want to do #2 unconditionally. On the other hand, #1 is probably
> okay, but as I said in my last email, I could see not wanting that
> either.
>
> Anyway, the patch I proposed (which you've adapted for your latest
> round), avoids #2 by guarding the behavior behind the existing
> org-complete-tags-always-offer-all-agenda-tags option, and I think
> that's a good path forward.
>
>> 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.
>
> s/obey/&s/
Applied.
>
>> * doc/org-manual.org: Update the TAB key doc in tags selection UI.
>>
>> * etc/ORG-NEWS: Mention the change in org-set-tags-command.
>> ---
>> 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
>> --- a/doc/org-manual.org
>> +++ b/doc/org-manual.org
>> @@ -4860,9 +4860,9 @@ In this interface, you can also use the following special keys:
>>
>> #+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.
>> + predefined list. You can complete on all tags present in the buffer
>> + and globally pre-defined tags from ~org-tag{-persistent}-alist~.
>
> Please spell these two options out: ~org-tag-alist~ and
> ~org-tag-persistent-alist~.
Applied.
>
>> + You can also add several tags: just separate them with a comma.
>>
>> - {{{kbd(SPC)}}} ::
>>
>> diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
>> index 5e5f1954d..5e68d27c0 100644
>> --- a/etc/ORG-NEWS
>> +++ b/etc/ORG-NEWS
>> @@ -149,6 +149,11 @@ Example:
>> A new =u= mode flag for Calc formulas in Org tables has been added to
>> enable Calc units simplification mode.
>>
>> +*** =org-set-tags-command= select tags from ~org-global-tags-completion-table~
>> +
>> +Let =org-set-tags-command= complete tags from global tags list (both
>> +buffer-local tags and ~org-tag{-persistent}-alist~).
>
> Same note about avoiding shorthand for the option names.
Applied.
>
> Also, please rewrite this to make it clear that this is relevant for TAB
> in the fast completion interface. It's probably also worth mentioning
> that org-complete-tags-always-offer-all-agenda-tags is now honored.
>
> And, very minor, but any reason for the mix of =...= and ~...~ markup
> here?
Maybe our recognition is different I personally like to markup command as
verbatim, and option as code to display as two different face color. I forget to
drop my habit.... Now fixed to use "~code~".
>
>> diff --git a/lisp/org.el b/lisp/org.el
>> index 5b0ae389c..ba816dfa6 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,20 @@ (defun org-fast-tag-selection (current inherited table &optional todo-table)
>> (setq current nil)
>> (when exit-after-next (setq exit-after-next 'now)))
>> ((= c ?\t)
>> - (condition-case nil
>
> Unlike the patch I sent, you've dropped the condition-case here, which I
> don't think was intentional.
>
Added back now.
> Thanks.
--
[ 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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: latest patch --]
[-- Type: text/x-patch, Size: 4112 bytes --]
From 4bb6ca19ceb8dbd8f827e4df2d7cc4ec7c7a931b Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
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 obeys 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.
---
doc/org-manual.org | 7 ++++---
etc/ORG-NEWS | 7 +++++++
lisp/org.el | 25 +++++++++++++++----------
3 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/doc/org-manual.org b/doc/org-manual.org
index b015b502c..e717f9261 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -4860,9 +4860,10 @@ In this interface, you can also use the following special keys:
#+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.
+ predefined list. You can complete on all tags present in the buffer
+ and globally pre-defined tags from ~org-tag-alist~ and
+ ~org-tag-persistent-alist~. You can also add several tags: just
+ separate them with a comma.
- {{{kbd(SPC)}}} ::
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 5e5f1954d..0c9bb99d3 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -149,6 +149,13 @@ Example:
A new =u= mode flag for Calc formulas in Org tables has been added to
enable Calc units simplification mode.
+*** =org-set-tags-command= select tags from ~org-global-tags-completion-table~
+
+Let ~org-set-tags-command~ TAB fast tag completion interface complete
+tags including from both buffer local and user defined persistent
+global list (~org-tag-alist~ and ~org-tag-persistent-alist~). Now
+option ~org-complete-tags-always-offer-all-agenda-tags~ is horored.
+
** Miscellaneous
*** =org-goto-first-child= now works before first heading
diff --git a/lisp/org.el b/lisp/org.el
index 5b0ae389c..5b1443c4e 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,21 @@ (defun org-fast-tag-selection (current inherited table &optional todo-table)
(setq current nil)
(when exit-after-next (setq exit-after-next 'now)))
((= c ?\t)
- (condition-case nil
- (setq tg (completing-read
- "Tag: "
- (or buffer-tags
- (with-current-buffer buf
- (setq buffer-tags
- (org-get-buffer-tags))))))
- (quit (setq tg "")))
+ (condition-case nil
+ (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)
- (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)))
--
2.29.2
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] I updated patch by deleteing duplicate tags
2021-01-13 9:30 ` Christopher Miles
@ 2021-01-14 5:24 ` Kyle Meyer
2021-01-14 6:12 ` [APPLIED] " Christopher Miles
2021-04-25 3:25 ` Timothy
0 siblings, 2 replies; 10+ messages in thread
From: Kyle Meyer @ 2021-01-14 5:24 UTC (permalink / raw)
To: Christopher Miles; +Cc: Org-mode
Christopher Miles writes:
> Subject: [PATCH] org.el: Complete tags from both global and buffer local
Thanks. Applied (86ad8d279)...
> diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
> index 5e5f1954d..0c9bb99d3 100644
> --- a/etc/ORG-NEWS
> +++ b/etc/ORG-NEWS
> @@ -149,6 +149,13 @@ Example:
> A new =u= mode flag for Calc formulas in Org tables has been added to
> enable Calc units simplification mode.
>
> +*** =org-set-tags-command= select tags from ~org-global-tags-completion-table~
> +
> +Let ~org-set-tags-command~ TAB fast tag completion interface complete
> +tags including from both buffer local and user defined persistent
> +global list (~org-tag-alist~ and ~org-tag-persistent-alist~). Now
> +option ~org-complete-tags-always-offer-all-agenda-tags~ is horored.
... adding another space before "Now" and s/horored/honored/.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [APPLIED] Re: [PATCH] I updated patch by deleteing duplicate tags
2021-01-14 5:24 ` Kyle Meyer
@ 2021-01-14 6:12 ` Christopher Miles
2021-04-25 3:25 ` Timothy
1 sibling, 0 replies; 10+ messages in thread
From: Christopher Miles @ 2021-01-14 6:12 UTC (permalink / raw)
To: Kyle Meyer; +Cc: Org-mode
[-- Attachment #1: Type: text/plain, Size: 1352 bytes --]
Kyle Meyer <kyle@kyleam.com> writes:
> Christopher Miles writes:
>
>> Subject: [PATCH] org.el: Complete tags from both global and buffer local
>
> Thanks. Applied (86ad8d279)...
>
>> diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
>> index 5e5f1954d..0c9bb99d3 100644
>> --- a/etc/ORG-NEWS
>> +++ b/etc/ORG-NEWS
>> @@ -149,6 +149,13 @@ Example:
>> A new =u= mode flag for Calc formulas in Org tables has been added to
>> enable Calc units simplification mode.
>>
>> +*** =org-set-tags-command= select tags from ~org-global-tags-completion-table~
>> +
>> +Let ~org-set-tags-command~ TAB fast tag completion interface complete
>> +tags including from both buffer local and user defined persistent
>> +global list (~org-tag-alist~ and ~org-tag-persistent-alist~). Now
>> +option ~org-complete-tags-always-offer-all-agenda-tags~ is horored.
>
> ... adding another space before "Now"
Is there any good solution to auto suitable sentence end of one space or two
space configuration?
> and s/horored/honored/.
Sorry about the typo, being busy, so a little bit of rush.
--
[ 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] I updated patch by deleteing duplicate tags
2021-01-14 5:24 ` Kyle Meyer
2021-01-14 6:12 ` [APPLIED] " Christopher Miles
@ 2021-04-25 3:25 ` Timothy
1 sibling, 0 replies; 10+ messages in thread
From: Timothy @ 2021-04-25 3:25 UTC (permalink / raw)
To: emacs-orgmode
This was not marked as applied. Doing so with the X-Woof-Patch header.
Kyle Meyer <kyle@kyleam.com> writes:
> Christopher Miles writes:
>
>> Subject: [PATCH] org.el: Complete tags from both global and buffer local
>
> Thanks. Applied (86ad8d279)...
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-04-25 3:26 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-02 9:30 [PATCH] [C-c C-q] completing tags from both buffer-local and global alist of tags stardiviner
2020-12-03 2:40 ` [PATCH] I updated patch by deleteing duplicate tags stardiviner
2021-01-07 2:37 ` Christopher Miles
2021-01-10 22:10 ` Kyle Meyer
2021-01-11 2:24 ` Christopher Miles
2021-01-13 3:26 ` Kyle Meyer
2021-01-13 9:30 ` Christopher Miles
2021-01-14 5:24 ` Kyle Meyer
2021-01-14 6:12 ` [APPLIED] " Christopher Miles
2021-04-25 3:25 ` Timothy
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).