emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 7e9d364b66: * lisp/emacs-lisp/crm.el: Set completion-list-insert-


From: Juri Linkov
Subject: master 7e9d364b66: * lisp/emacs-lisp/crm.el: Set completion-list-insert-choice-function.
Date: Thu, 5 May 2022 14:16:38 -0400 (EDT)

branch: master
commit 7e9d364b663613fd907f92de31e996463ef7d03c
Author: James N. V. Cash <james.nvc@gmail.com>
Commit: Juri Linkov <juri@linkov.net>

    * lisp/emacs-lisp/crm.el: Set completion-list-insert-choice-function.
    
    * 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 | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/lisp/emacs-lisp/crm.el b/lisp/emacs-lisp/crm.el
index f3e1981732..8a5c3d3730 100644
--- a/lisp/emacs-lisp/crm.el
+++ b/lisp/emacs-lisp/crm.el
@@ -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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]