No Wayman <iarchivedmywholel...@gmail.com> writes:

No Wayman <iarchivedmywholel...@gmail.com> writes:

See the attached patch for a first draft implementation.

Attached is a second draft which compiles cleanly and makes use of mapconcat
where appropriate.

[2. org-tags-crm-separators-2 --- text/x-patch; 0001-Add-org-tags-crm-separators.patch]...

See attached with amended commit message.

>From d059c4369ac17fcba885adf87c95c6797894d230 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer <iarchivedmywholel...@gmail.com>
Date: Fri, 3 Sep 2021 14:50:48 -0400
Subject: [PATCH] Add org-tags-crm-separators

* org.el (org-tags-crm-separators): Defcustom controlling which
characters are used to delimit tags in commands which utilize
`completing-read-multiple'.
(org-set-tags-command, org-capture-fill-template): Make use of org-tags-crm-separators; Show
delimiters in tag prompt.
---
 lisp/org-capture.el |  7 +++++--
 lisp/org.el         | 17 ++++++++++++++---
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index c51744680..e51d039d5 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1740,9 +1740,12 @@ The template may still contain \"%?\" for cursor positioning."
 			    (org-add-colon-after-tag-completion t)
 			    (ins (mapconcat
 				  #'identity
-				  (let ((crm-separator "[ \t]*:[ \t]*"))
+				  (let* ((separators (or org-tags-crm-separators '(?: ?,)))
+                                         (crm-separator (org-tags-crm-regexp separators)))
                                     (completing-read-multiple
-				     (if prompt (concat prompt ": ") "Tags: ")
+				     (if prompt (concat prompt ": ")
+                                       (format "Tags (%s to delimit): "
+                                               (mapconcat #'char-to-string separators " ")))
 				     org-last-tags-completion-table nil nil nil
 				     'org-tags-history))
 				  ":")))
diff --git a/lisp/org.el b/lisp/org.el
index ce68f4692..4cd173c99 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -2980,6 +2980,11 @@ is better to limit inheritance to certain tags using the variables
 	  (const :tag "Reverse alphabetical" org-string-collate-greaterp)
 	  (function :tag "Custom function" nil)))
 
+(defcustom org-tags-crm-separators '(?: ?,)
+  "List of tag delimiting characters used when reading multiple tags."
+  :type 'list
+  :group 'org-tags)
+
 (defvar org-tags-history nil
   "History of minibuffer reads for tags.")
 (defvar org-last-tags-completion-table nil
@@ -12007,6 +12012,10 @@ tags."
 	;; it now points to BLANK-START.  Use COLUMN instead.
 	(if in-blank? (org-move-to-column column) (goto-char origin))))))
 
+(defun org-tags-crm-regexp (chars)
+  "Return `crm-separator' regexp using CHARS as separators."
+  (format "[ \t]*%s[ \t]*" (regexp-opt (mapcar #'char-to-string chars))))
+
 (defun org-set-tags-command (&optional arg)
   "Set the tags for the current visible entry.
 
@@ -12065,11 +12074,13 @@ in Lisp code use `org-set-tags' instead."
 		      inherited-tags
 		      table
 		      (and org-fast-tag-selection-include-todo org-todo-key-alist))
-		   (let ((org-add-colon-after-tag-completion (< 1 (length table)))
-                         (crm-separator "[ \t]*:[ \t]*"))
+		   (let* ((org-add-colon-after-tag-completion (< 1 (length table)))
+                          (separators (or org-tags-crm-separators '(?: ?,)))
+                          (crm-separator (org-tags-crm-regexp separators)))
 		     (mapconcat #'identity
                                 (completing-read-multiple
-			         "Tags: "
+                                 (format "Tags (%s to delimit): "
+                                         (mapconcat #'char-to-string separators " "))
 			         org-last-tags-completion-table
 			         nil nil (org-make-tag-string current-tags)
 			         'org-tags-history)
-- 
2.33.0

Reply via email to