emacs-diffs
[Top][All Lists]
Advanced

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

master d8c1ac6c35f: Return t from completion-emacs22-try-completion only


From: Stefan Monnier
Subject: master d8c1ac6c35f: Return t from completion-emacs22-try-completion only for completions
Date: Fri, 17 Nov 2023 12:37:05 -0500 (EST)

branch: master
commit d8c1ac6c35f84000aedff67d60cd420360183019
Author: Spencer Baugh <sbaugh@janestreet.com>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    Return t from completion-emacs22-try-completion only for completions
    
    The emacs22 completion style ignores the text after point when
    computing completions.  However, it still needs to take into account
    the entire string it's given, to avoid returning incorrect values.
    
    Previously, completion-emacs22-try-completion would return t if the
    text before point was an exact completion.  But this is effectively
    saying that the entire input string was an exact completion, which may
    not be correct.  This would cause completing-read with REQUIRE-MATCH=t
    to return a non-completion.
    
    Now, completion-emacs22-try-completion only returns t if the entire
    input string is an exact completion.
    
    * lisp/minibuffer.el (completion-emacs22-try-completion): Return t
    only if the entire input string is an exact completion.  (Bug#67210)
---
 lisp/minibuffer.el | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 9ca3ecdf542..7af7a359674 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -3531,8 +3531,13 @@ Like `internal-complete-buffer', but removes BUFFER from 
the completion list."
 (defun completion-emacs22-try-completion (string table pred point)
   (let ((suffix (substring string point))
         (completion (try-completion (substring string 0 point) table pred)))
-    (if (not (stringp completion))
-        completion
+    (cond
+     ((eq completion t)
+      (if (equal "" suffix)
+          t
+        (cons string point)))
+     ((not (stringp completion)) completion)
+     (t
       ;; Merge a trailing / in completion with a / after point.
       ;; We used to only do it for word completion, but it seems to make
       ;; sense for all completions.
@@ -3546,7 +3551,7 @@ Like `internal-complete-buffer', but removes BUFFER from 
the completion list."
                (eq ?/ (aref suffix 0)))
           ;; This leaves point after the / .
           (setq suffix (substring suffix 1)))
-      (cons (concat completion suffix) (length completion)))))
+      (cons (concat completion suffix) (length completion))))))
 
 (defun completion-emacs22-all-completions (string table pred point)
   (let ((beforepoint (substring string 0 point)))



reply via email to

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