]> git.eshelyaron.com Git - emacs.git/commitdiff
; Improve 'minibuffer-force-complete-and-exit'
authorEshel Yaron <me@eshelyaron.com>
Tue, 13 Feb 2024 20:56:53 +0000 (21:56 +0100)
committerEshel Yaron <me@eshelyaron.com>
Tue, 13 Feb 2024 20:57:49 +0000 (21:57 +0100)
* lisp/minibuffer.el (minibuffer-force-complete-and-exit): Use
base size as determined by 'completion-all-sorted-completions',
instead of the beginning of current completion field (from
'completion-boundaries').  Those can differ when
'partial-completion' picks up part of the previous fields.  For
example, in file name completion with input "emacs/lisp/pr/xr",
we want to replace also the last field "pr" when completing to
"emacs/lisp/progmodes/xref.el".

lisp/minibuffer.el

index 84be37e27d5e7597096f316a2928b7692ee7a3b1..ca981a1e7d228943e734a11dc54e09185bdd6691 100644 (file)
@@ -1953,11 +1953,13 @@ instead of \\[minibuffer-cycle-completion] followed by \
 \\[exit-minibuffer] when you know you want the first
 completion even before cycling to it."
   (interactive "" minibuffer-mode)
-  (if-let ((beg-end (minibuffer--completion-boundaries))
-           (beg (car beg-end)) (end (cdr beg-end))
+  (if-let ((beg (minibuffer-prompt-end))
+           (end (cdr (minibuffer--completion-boundaries)))
            (all (completion-all-sorted-completions beg end)))
       (progn
-        (completion--replace beg end (car all))
+        (completion--replace (+ (minibuffer-prompt-end)
+                                (or (cdr (last all)) 0))
+                             end (car all))
         (completion--done (buffer-substring-no-properties beg (point))
                           'finished)
         (exit-minibuffer))