]> git.eshelyaron.com Git - emacs.git/commitdiff
completion--replace: Fix completion cycling
authorDmitry Gutov <dmitry@gutov.dev>
Sun, 12 May 2024 02:57:10 +0000 (05:57 +0300)
committerEshel Yaron <me@eshelyaron.com>
Sun, 12 May 2024 16:33:45 +0000 (18:33 +0200)
* 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).

(cherry picked from commit 2c759b9ce620311df97f43b791ba27b1302171c4)

lisp/minibuffer.el

index f7b802a7d53f2b24089158c0d6275c254dbe50a6..716875ae826bd225ac53fb4e3adfdbe91f2b8644 100644 (file)
@@ -1458,7 +1458,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)))
 
@@ -3002,7 +3002,7 @@ completions list."
                                              minibuffer-completion-table
                                              minibuffer-completion-predicate
                                              (buffer-substring (point) end))))
-                (point-marker)))
+                (point)))
              (field-char (and (< field-end end) (char-after field-end)))
              (style completion--matching-style)
              (exceptional-candidates
@@ -3150,6 +3150,7 @@ completions list."
                                 (= (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)