From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id aJt2F1tgFF8DGAAA0tVLHw (envelope-from ) for ; Sun, 19 Jul 2020 15:01:47 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id eKdUE1tgFF+XFwAA1q6Kng (envelope-from ) for ; Sun, 19 Jul 2020 15:01:47 +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 6EF6E94071A for ; Sun, 19 Jul 2020 15:01:46 +0000 (UTC) Received: from localhost ([::1]:59072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jxAox-0008Fq-MU for larch@yhetil.org; Sun, 19 Jul 2020 11:01:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jxAn7-0007SK-9R for emacs-orgmode@gnu.org; Sun, 19 Jul 2020 10:59:49 -0400 Received: from mout02.posteo.de ([185.67.36.66]:43707) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jxAn5-0007QG-BM for emacs-orgmode@gnu.org; Sun, 19 Jul 2020 10:59:49 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 9963A2400FE for ; Sun, 19 Jul 2020 16:59:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1595170785; bh=s3nmesgVGEC6PwCV9/Vo1TgVJ4X0iHpGXDf09Oeh4YE=; h=Subject:From:To:Date:From; b=Uc2NIhcLfuJbqddSwvnYR1iBW8oR1DZuAGi4lWmQH/z4IMIurJiahm5Af4G5/ydVq il7jlp66MCFHBI7MNvhiA0ljzOvaSrPbS58hIW2ugU09Jlsjg16xPt3GblUdvERKLh YowmkLt6vvcRDiH46C6skKymZa1ZfNUH/qUSTQlyd90OHLd1FhadHnkORj8ywV18tf z5o8UrQEAerXfj0cy/Im7PT33YmyLyH3tiCQERqdLYyrxcacdDoDJX/3AlhgmW9oyC CRCkxPfX6W6ozIs9WL80pdZUp4rSijo74UH2qjIW/FmDevTUtSe8eL/yDOyH2yjVYN 2to4ZUfRw8+Cw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4B8p1F1VGkz9rxB for ; Sun, 19 Jul 2020 16:59:45 +0200 (CEST) Subject: Re: [PATCH] Use completing-read-multiple for org-set-tags-command From: Clemens To: emacs-orgmode@gnu.org References: <6afc1c4b-9846-6081-aa3e-0496226e135a@posteo.de> Message-ID: <3b879821-8060-b8c0-c207-db32e7c8d777@posteo.de> Date: Sun, 19 Jul 2020 16:59:44 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------A093B3AFDE878FC0F0B785EE" Content-Language: de-DE Received-SPF: pass client-ip=185.67.36.66; envelope-from=clemens.radermacher@posteo.de; helo=mout02.posteo.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/19 07:26:00 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.de header.s=2017 header.b=Uc2NIhcL; dmarc=pass (policy=none) header.from=posteo.de; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -1.71 X-TUID: XZLpsR1q8/mW This is a multi-part message in MIME format. --------------A093B3AFDE878FC0F0B785EE Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Find the updated patch attached. Clemens --------------A093B3AFDE878FC0F0B785EE Content-Type: text/x-patch; charset=UTF-8; name="0001-org.el-Use-completing-read-multiple-for-org-set-tags.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-org.el-Use-completing-read-multiple-for-org-set-tags.pa"; filename*1="tch" >From 1b50d7450fb23110603792e63c329d7db3115ae8 Mon Sep 17 00:00:00 2001 From: Clemens Radermacher 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\nContents" - (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\nContents2" - (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 "* " - (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 "** 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 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 --------------A093B3AFDE878FC0F0B785EE--