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.
This commit is contained in:
stardiviner 2020-12-02 17:24:29 +08:00 committed by Kyle Meyer
parent 9ea7ff5e2f
commit 86ad8d2791
3 changed files with 26 additions and 13 deletions

View File

@ -4860,9 +4860,10 @@ In this interface, you can also use the following special keys:
#+kindex: TAB #+kindex: TAB
Enter a tag in the minibuffer, even if the tag is not in the 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 predefined list. You can complete on all tags present in the buffer
buffer. You can also add several tags: just separate them with and globally pre-defined tags from ~org-tag-alist~ and
a comma. ~org-tag-persistent-alist~. You can also add several tags: just
separate them with a comma.
- {{{kbd(SPC)}}} :: - {{{kbd(SPC)}}} ::

View File

@ -149,6 +149,13 @@ Example:
A new =u= mode flag for Calc formulas in Org tables has been added to A new =u= mode flag for Calc formulas in Org tables has been added to
enable Calc units simplification mode. 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 honored.
** Miscellaneous ** Miscellaneous
*** =org-goto-first-child= now works before first heading *** =org-goto-first-child= now works before first heading

View File

@ -12139,7 +12139,7 @@ Returns the new tags string, or nil to not change the current settings."
fulltable)))) fulltable))))
(buf (current-buffer)) (buf (current-buffer))
(expert (eq org-fast-tag-selection-single-key 'expert)) (expert (eq org-fast-tag-selection-single-key 'expert))
(buffer-tags nil) (tab-tags nil)
(fwidth (+ maxlen 3 1 3)) (fwidth (+ maxlen 3 1 3))
(ncol (/ (- (window-width) 4) fwidth)) (ncol (/ (- (window-width) 4) fwidth))
(i-face 'org-done) (i-face 'org-done)
@ -12275,15 +12275,20 @@ Returns the new tags string, or nil to not change the current settings."
(when exit-after-next (setq exit-after-next 'now))) (when exit-after-next (setq exit-after-next 'now)))
((= c ?\t) ((= c ?\t)
(condition-case nil (condition-case nil
(setq tg (completing-read (unless tab-tags
"Tag: " (setq tab-tags
(or buffer-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 (with-current-buffer buf
(setq buffer-tags (org-get-buffer-tags))
(org-get-buffer-tags)))))) table))))))
(quit (setq tg ""))) (setq tg (completing-read "Tag: " tab-tags))
(when (string-match "\\S-" 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) (if (member tg current)
(setq current (delete tg current)) (setq current (delete tg current))
(push tg current))) (push tg current)))