From: Dmitry Gutov Date: Sun, 12 May 2024 02:57:10 +0000 (+0300) Subject: completion--replace: Fix completion cycling X-Git-Tag: archive/raspbian/1%30.1+1-3+rpi1^2~2^2~20^2~1526 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=2c759b9ce620311df97f43b791ba27b1302171c4;p=emacs.git completion--replace: Fix completion cycling * lisp/minibuffer.el (completion--replace): Don't "insert before markers" after all because in some cases (https://lists.gnu.org/archive/html/emacs-devel/2024-05/msg00701.html) - like cycling - BEG can be denoted by a marker as well. (minibuffer-completion-help): Make FIELD-END simply a fixnum. And adjust its value manually inside the local completion-list-insert-choice-function (bug#48356). --- diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 61395577035..fbd49b569a8 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1363,7 +1363,7 @@ Moves point to the end of the new text." (setq newtext (substring newtext 0 (- suffix-len)))) (goto-char beg) (let ((length (- end beg))) ;Read `end' before we insert the text. - (insert-before-markers-and-inherit newtext) + (insert-and-inherit newtext) (delete-region (point) (+ (point) length))) (forward-char suffix-len))) @@ -2594,7 +2594,7 @@ The candidate will still be chosen by `choose-completion' unless ctable cpred (buffer-substring (point) end)))) - (point-marker))) + (point))) (field-char (and (< field-end end) (char-after field-end))) (all-md (completion--metadata (buffer-substring-no-properties start (point)) @@ -2702,6 +2702,7 @@ The candidate will still be chosen by `choose-completion' unless (= (aref choice (1- (length choice))) field-char)) (setq end (1+ end))) + (cl-decf field-end (- end start (length choice))) ;; FIXME: Use `md' to do quoting&terminator here. (completion--replace start end choice) (let* ((minibuffer-completion-table ctable)