From: Clemens <clemens.radermacher@posteo.de>
To: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Use completing-read-multiple for org-set-tags-command
Date: Sun, 19 Jul 2020 16:59:44 +0200 [thread overview]
Message-ID: <3b879821-8060-b8c0-c207-db32e7c8d777@posteo.de> (raw)
In-Reply-To: <c2c6644c-1b00-ed2f-d2d9-985a71179cd0@posteo.de>
[-- Attachment #1: Type: text/plain, Size: 50 bytes --]
Find the updated patch attached.
Clemens
[-- Attachment #2: 0001-org.el-Use-completing-read-multiple-for-org-set-tags.patch --]
[-- Type: text/x-patch, Size: 6198 bytes --]
From 1b50d7450fb23110603792e63c329d7db3115ae8 Mon Sep 17 00:00:00 2001
From: Clemens Radermacher <clemera@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
next prev parent reply other threads:[~2020-07-19 15:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-19 12:49 [PATCH] Use completing-read-multiple for org-set-tags-command Clemens
2020-07-19 14:26 ` Clemens
2020-07-19 14:58 ` Clemens
2020-07-19 14:59 ` Clemens [this message]
2020-07-20 3:23 ` Kyle Meyer
2020-07-20 6:03 ` Clemens
2020-07-22 4:26 ` Kyle Meyer
2020-07-22 7:04 ` Clemens
2020-07-22 7:16 ` Clemens
2020-07-22 12:37 ` Clemens
2020-07-23 4:37 ` Kyle Meyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3b879821-8060-b8c0-c207-db32e7c8d777@posteo.de \
--to=clemens.radermacher@posteo.de \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).