branch: elpa/helm commit 9f71fefd34402c0db27efba78c605194d9f65113 Author: Thierry Volpiatto <thie...@posteo.net> Commit: Thierry Volpiatto <thie...@posteo.net>
Fix crm insertion by advicing completion-list-insert-choice-function CRM tries to insert completion in the prompt field which is read-only when separator is ":". This fix Emacs bug~76461. --- helm-mode.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/helm-mode.el b/helm-mode.el index 7f4a83e848..7bd9be14e3 100644 --- a/helm-mode.el +++ b/helm-mode.el @@ -2901,10 +2901,25 @@ Be sure to know what you are doing when modifying this.") (when (looking-back crm-separator (1- (point))) (setq sep (match-string 0)))) (setq sep nil)) + (when (boundp 'crm-prompt) ; Emacs-30+. + (add-function :override (local 'completion-list-insert-choice-function) + #'helm--crm-insert-fn)) (funcall completion-list-insert-choice-function beg end (mapconcat 'identity (append result '("")) sep)))) (t nil))) +(defun helm--crm-insert-fn (_start _end choice) + ;; Fix Emacs bug~76461. + (let* ((beg (save-excursion + (if (re-search-backward crm-separator nil t) + (if (field-at-pos (point)) (field-end) (1+ (point))) + (minibuffer-prompt-end)))) + (end (save-excursion + (if (re-search-forward crm-separator nil t) + (1- (point)) + (point-max))))) + (completion--replace beg end choice))) + (defun helm-mode--disable-ido-maybe (&optional from-hook) (when (and (boundp 'ido-everywhere) ido-everywhere) (remove-function read-file-name-function #'ido-read-file-name)