emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 2a84ab905c8: Handle point in last file-name component in minibu


From: Eli Zaretskii
Subject: emacs-29 2a84ab905c8: Handle point in last file-name component in minibuffer completion
Date: Sun, 4 Jun 2023 03:06:13 -0400 (EDT)

branch: emacs-29
commit 2a84ab905c8009db4d7df7b8f7cfb34c403081c8
Author: Spencer Baugh <sbaugh@janestreet.com>
Commit: Eli Zaretskii <eliz@gnu.org>

    Handle point in last file-name component in minibuffer completion
    
    This is a followup to commit e338a8ac41d4a9fd798dda90275abe75ac071335
    (Handle point not at EOB in minibuffer-choose-completion).
    That commit added a heuristic, but the heuristic was insufficient:
    It still had the original wrong behavior when completing the last
    file-name component (i.e., the completion category is 'file' and
    there's no slash after point).  This patch makes the heuristic
    cover that case as well.
    * lisp/minibuffer.el (minibuffer-next-completion)
    (minibuffer-choose-completion): If in file completion and there's no
    slash after point, clear what's after point when we complete.
    (Bug#62700)
---
 lisp/minibuffer.el | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 298f3f8728d..a873e5f9747 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -4498,8 +4498,9 @@ insert the selected completion to the minibuffer."
                (base-suffix
                 (if (eq (alist-get 'category (cdr md)) 'file)
                     (with-current-buffer buf
-                      (buffer-substring (save-excursion (search-forward "/" 
nil t) (point))
-                                        (point-max)))
+                      (buffer-substring
+                       (save-excursion (or (search-forward "/" nil t) 
(point-max)))
+                       (point-max)))
                   ""))
               (completion-base-affixes (list (car completion-base-affixes) 
base-suffix)))
           (choose-completion nil t t))))))
@@ -4524,8 +4525,9 @@ minibuffer, but don't quit the completions window."
   (let* ((md (completion--field-metadata (minibuffer--completion-prompt-end)))
          (base-suffix
           (if (eq (alist-get 'category (cdr md)) 'file)
-              (buffer-substring (save-excursion (search-forward "/" nil t) 
(point))
-                                (point-max))
+              (buffer-substring
+               (save-excursion (or (search-forward "/" nil t) (point-max)))
+               (point-max))
             "")))
     (with-minibuffer-completions-window
       (let ((completion-use-base-affixes t)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]