]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/emacs-lisp/crm.el: Set completion-list-insert-choice-function.
authorJames N. V. Cash <james.nvc@gmail.com>
Thu, 5 May 2022 18:15:51 +0000 (21:15 +0300)
committerJuri Linkov <juri@linkov.net>
Thu, 5 May 2022 18:15:51 +0000 (21:15 +0300)
* lisp/emacs-lisp/crm.el (completing-read-multiple): Set buffer-local
completion-list-insert-choice-function that handles string values of args.
https://lists.gnu.org/archive/html/emacs-devel/2022-05/msg00017.html

lisp/emacs-lisp/crm.el

index f3e1981732c69484424ba34f7e6d9f100c3d874e..8a5c3d3730c2032e18069758813ef9247ac62816 100644 (file)
@@ -254,6 +254,23 @@ with empty strings removed."
                     'crm--choose-completion-string nil 'local)
           (setq-local minibuffer-completion-table #'crm--collection-fn)
           (setq-local minibuffer-completion-predicate predicate)
+          (setq-local completion-list-insert-choice-function
+                      (lambda (start end choice)
+                        (if (and (stringp start) (stringp end))
+                            (let* ((beg (save-excursion
+                                          (goto-char (minibuffer-prompt-end))
+                                          (or (search-forward start nil t)
+                                              (search-forward-regexp crm-separator nil t)
+                                              (minibuffer-prompt-end))))
+                                   (end (save-excursion
+                                          (goto-char (point-max))
+                                          (or (search-backward end nil t)
+                                              (progn
+                                                (goto-char beg)
+                                                (search-forward-regexp crm-separator nil t))
+                                              (point-max)))))
+                              (completion--replace beg end choice))
+                          (completion--replace start end choice))))
           ;; see completing_read in src/minibuf.c
           (setq-local minibuffer-completion-confirm
                       (unless (eq require-match t) require-match))