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).
This commit is contained in:
Dmitry Gutov 2024-05-12 05:57:10 +03:00
parent 6e8bee27a5
commit 2c759b9ce6

View file

@ -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)