Find the updated patch attached. Clemens
>From 1b50d7450fb23110603792e63c329d7db3115ae8 Mon Sep 17 00:00:00 2001 From: Clemens Radermacher <clem...@posteo.net> Date: Sun, 19 Jul 2020 14:30:37 +0200 Subject: [PATCH] org.el: Use `completing-read-multiple' for `org-set-tags-command' * lisp/org.el (org-set-tags-command): Use `completing-read-multiple' when prompting for tags. * testing/lisp/test-org.el: Update tests to use `completing-read-multiple' too. --- lisp/org.el | 17 +++++++++++------ testing/lisp/test-org.el | 40 ++++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 12a853bd6..968883401 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -11819,6 +11819,7 @@ (defun org--align-tags-here (to-col) ;; it now points to BLANK-START. Use COLUMN instead. (if in-blank? (org-move-to-column column) (goto-char origin)))))) +(defvar crm-separator) (defun org-set-tags-command (&optional arg) "Set the tags for the current visible entry. @@ -11877,12 +11878,16 @@ (defun org-set-tags-command (&optional arg) inherited-tags table (and org-fast-tag-selection-include-todo org-todo-key-alist)) - (let ((org-add-colon-after-tag-completion (< 1 (length table)))) - (org-trim (completing-read - "Tags: " - #'org-tags-completion-function - nil nil (org-make-tag-string current-tags) - 'org-tags-history))))))) + (let ((org-add-colon-after-tag-completion (< 1 (length table))) + (crm-separator"[ ]*:[ ]*")) + (org-trim + (mapconcat #'identity + (completing-read-multiple + "Tags: " + #'org-tags-completion-function + nil nil (org-make-tag-string current-tags) + 'org-tags-history) + ":"))))))) (org-set-tags tags))))) ;; `save-excursion' may not replace the point at the right ;; position. diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 4f8c74539..32be5ad4a 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -6844,8 +6844,8 @@ (should (equal "* H1 :foo:" (org-test-with-temp-text "* H1" - (cl-letf (((symbol-function 'completing-read) - (lambda (&rest args) ":foo:"))) + (cl-letf (((symbol-function 'completing-read-multiple) + (lambda (&rest args) '(":foo:")))) (let ((org-use-fast-tag-selection nil) (org-tags-column 1)) (org-set-tags-command))) @@ -6854,8 +6854,8 @@ (should (equal "* H1 :foo:\nContents" (org-test-with-temp-text "* H1\n<point>Contents" - (cl-letf (((symbol-function 'completing-read) - (lambda (&rest args) ":foo:"))) + (cl-letf (((symbol-function 'completing-read-multiple) + (lambda (&rest args) '(":foo:")))) (let ((org-use-fast-tag-selection nil) (org-tags-column 1)) (org-set-tags-command))) @@ -6863,8 +6863,8 @@ (should-not (equal "* H1 :foo:\nContents2" (org-test-with-temp-text "* H1\n<point>Contents2" - (cl-letf (((symbol-function 'completing-read) - (lambda (&rest args) ":foo:"))) + (cl-letf (((symbol-function 'completing-read-multiple) + (lambda (&rest args) '(":foo:")))) (let ((org-use-fast-tag-selection nil) (org-tags-column 1)) (org-set-tags-command))) @@ -6873,8 +6873,8 @@ (should (equal "* H1 :foo:" (org-test-with-temp-text "* H1" - (cl-letf (((symbol-function 'completing-read) - (lambda (&rest args) ": foo *:"))) + (cl-letf (((symbol-function 'completing-read-multiple) + (lambda (&rest args) '(": foo *:")))) (let ((org-use-fast-tag-selection nil) (org-tags-column 1)) (org-set-tags-command))) @@ -6885,8 +6885,8 @@ (should (equal "* H1 :foo:\nContents\n* H2 :foo:" (org-test-with-temp-text "* H1\nContents\n* H2" - (cl-letf (((symbol-function 'completing-read) - (lambda (&rest args) ":foo:"))) + (cl-letf (((symbol-function 'completing-read-multiple) + (lambda (&rest args) '(":foo:")))) (let ((org-use-fast-tag-selection nil) (org-loop-over-headlines-in-active-region t) (org-tags-column 1)) @@ -6898,8 +6898,8 @@ (should (equal "* H1\nContents\n* H2 :foo:" (org-test-with-temp-text "* H1\nContents\n* H2" - (cl-letf (((symbol-function 'completing-read) - (lambda (&rest args) ":foo:"))) + (cl-letf (((symbol-function 'completing-read-multiple) + (lambda (&rest args) '(":foo:")))) (let ((org-use-fast-tag-selection nil) (org-loop-over-headlines-in-active-region nil) (org-tags-column 1)) @@ -6918,8 +6918,8 @@ (should (equal ":foo:" (org-test-with-temp-text "* <point>" - (cl-letf (((symbol-function 'completing-read) - (lambda (&rest args) ":foo:"))) + (cl-letf (((symbol-function 'completing-read-multiple) + (lambda (&rest args) '(":foo:")))) (let ((org-use-fast-tag-selection nil) (org-tags-column 1)) (org-set-tags-command))) @@ -6928,8 +6928,8 @@ (should (equal "* H1 :foo:" (org-test-with-temp-text "* H1" - (cl-letf (((symbol-function 'completing-read) - (lambda (&rest args) ":foo:"))) + (cl-letf (((symbol-function 'completing-read-multiple) + (lambda (&rest args) '(":foo:")))) (let ((org-use-fast-tag-selection nil) (org-tags-column 1)) (org-set-tags-command))) @@ -6938,8 +6938,8 @@ (should (equal "* H1 :foo:" (org-test-with-temp-text "*<point>* H1" - (cl-letf (((symbol-function 'completing-read) - (lambda (&rest args) ":foo:"))) + (cl-letf (((symbol-function 'completing-read-multiple) + (lambda (&rest args) '(":foo:")))) (let ((org-use-fast-tag-selection nil) (org-tags-column 1)) (org-set-tags-command))) @@ -6948,8 +6948,8 @@ (should (equal " b :foo:" (org-test-with-temp-text "* a<point> b" - (cl-letf (((symbol-function 'completing-read) - (lambda (&rest args) ":foo:"))) + (cl-letf (((symbol-function 'completing-read-multiple) + (lambda (&rest args) '(":foo:")))) (let ((org-use-fast-tag-selection nil) (org-tags-column 1)) (org-set-tags-command))) -- 2.17.1