]> git.eshelyaron.com Git - emacs.git/commitdiff
; (completing-read-multiple): Add individual inputs to history.
authorEshel Yaron <me@eshelyaron.com>
Fri, 2 Feb 2024 19:09:15 +0000 (20:09 +0100)
committerEshel Yaron <me@eshelyaron.com>
Fri, 2 Feb 2024 19:09:15 +0000 (20:09 +0100)
lisp/emacs-lisp/crm.el

index 3580c9dfef976ec323acef35101dee5351c1cc46..87b6cffffcda18138bcea18dca5c4a9148d660cf 100644 (file)
@@ -414,17 +414,23 @@ contents of the minibuffer are \"alice,bob,eve\" and point is between
 
 This function returns a list of the strings that were read,
 with empty strings removed."
-  (let ((crm-current-separator
-         (if (consp crm-separator)
-             (car crm-separator)
-           crm-separator))
-        (crm-canonical-separator (cdr-safe crm-separator)))
-    (split-string
-     (minibuffer-with-setup-hook
-         #'completing-read-multiple-mode
-       (completing-read prompt (apply-partially #'crm--table table)
-        predicate require-match initial-input hist def inherit-input-method))
-     crm-current-separator t)))
+  (let* ((crm-current-separator
+          (if (consp crm-separator)
+              (car crm-separator)
+            crm-separator))
+         (crm-canonical-separator (cdr-safe crm-separator))
+         (string (minibuffer-with-setup-hook
+                     #'completing-read-multiple-mode
+                   (completing-read prompt (apply-partially #'crm--table table)
+                                    predicate require-match initial-input hist
+                                    def inherit-input-method)))
+         (results (split-string string crm-current-separator t)))
+    (when-let ((hist-var (and hist (not (eq hist t))
+                              (if (consp hist) (car hist) hist)))
+               (hist-list (symbol-value hist)))
+      (when (string= (car hist-list) string) (pop (symbol-value hist)))
+      (dolist (res results) (add-to-history hist-var res)))
+    results))
 
 (provide 'crm)