Subject: bug#76461: 31.0.50; CRM tries to insert candidate in prompt read-only zone

From: Thierry Volpiatto <[email-masked]>
Date: Sat, 22 Feb 2025 05:36:02 +0000

Find the patch attached.

-- 
Thierry
From fd1606f8048200b954cf112e7da33a7db3d23d64 Mon Sep 17 00:00:00 2001
From: Thierry Volpiatto <[email-masked]>
Date: Sat, 22 Feb 2025 06:23:25 +0100
Subject: [PATCH] Fix insertion of completion candidate in minibuffer with CRM

Fix bug#76461.

When separator is ":" like in org tags, insertion fails because the
completion-list-insert-choice-function matches the end of prompt which
is ":" and set BEG at this place which is read-only.

Set BEG outside of the prompt field when it is the case.
---
 lisp/emacs-lisp/crm.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/crm.el b/lisp/emacs-lisp/crm.el
index 676252ae126..60334035a3d 100644
--- a/lisp/emacs-lisp/crm.el
+++ b/lisp/emacs-lisp/crm.el
@@ -270,7 +270,8 @@ with empty strings removed."
                       (lambda (_start _end choice)
                         (let* ((beg (save-excursion
                                       (if (search-backward-regexp crm-separator nil t)
-                                          (1+ (point))
+                                          (if (field-at-pos (point))
+                                              (field-end) (1+ (point)))
                                         (minibuffer-prompt-end))))
                                (end (save-excursion
                                       (if (search-forward-regexp crm-separator nil t)
-- 
2.34.1