emacs-diffs
[Top][All Lists]
Advanced

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

emacs-29 37ed3d15f38: Avoid errors in completion due to 'completion-rege


From: Eli Zaretskii
Subject: emacs-29 37ed3d15f38: Avoid errors in completion due to 'completion-regexp-list'
Date: Sun, 2 Jul 2023 02:17:30 -0400 (EDT)

branch: emacs-29
commit 37ed3d15f38339400eba67647c87fad85de3a384
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Avoid errors in completion due to 'completion-regexp-list'
    
    * doc/lispref/minibuf.texi (Basic Completion):
    * src/minibuf.c (syms_of_minibuf) <completion-regexp-list>:
    Document that global non-nil settings of 'completion-regexp-list'
    are not safe.
    
    * lisp/minibuffer.el (completion-pcm--merge-completions): Avoid
    errors in 'try-completion' when PREFIX is nil.  (Bug#64351)
---
 doc/lispref/minibuf.texi | 6 ++++++
 lisp/minibuffer.el       | 3 ++-
 src/minibuf.c            | 7 ++++++-
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi
index 52eea3b9535..7fbdd9eb6e2 100644
--- a/doc/lispref/minibuf.texi
+++ b/doc/lispref/minibuf.texi
@@ -1052,6 +1052,12 @@ This is a list of regular expressions.  The completion 
functions only
 consider a completion acceptable if it matches all regular expressions
 in this list, with @code{case-fold-search} (@pxref{Searching and Case})
 bound to the value of @code{completion-ignore-case}.
+
+Do not set this variable to a non-@code{nil} value globally, as that
+is not safe and will probably cause errors in completion commands.
+This variable should be only let-bound to non-@code{nil} values around
+calls to basic completion functions: @code{try-completion},
+@code{test-completion}, and @code{all-completions}.
 @end defvar
 
 @defmac lazy-completion-table var fun
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 4aa1ab3e890..3e30b68d5e9 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -4027,7 +4027,8 @@ the same set of elements."
               (setq ccs (nreverse ccs))
               (let* ((prefix (try-completion fixed comps))
                      (unique (or (and (eq prefix t) (setq prefix fixed))
-                                 (eq t (try-completion prefix comps)))))
+                                 (and (stringp prefix)
+                                      (eq t (try-completion prefix comps))))))
                 (unless (or (eq elem 'prefix)
                             (equal prefix ""))
                   (push prefix res))
diff --git a/src/minibuf.c b/src/minibuf.c
index 6e54d8c3ba5..58adde1bf66 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -2471,7 +2471,12 @@ The basic completion functions only consider a 
completion acceptable
 if it matches all regular expressions in this list, with
 `case-fold-search' bound to the value of `completion-ignore-case'.
 See Info node `(elisp)Basic Completion', for a description of these
-functions.  */);
+functions.
+
+Do not set this variable to a non-nil value globally, as that is not
+safe and will probably cause errors in completion commands.  This
+variable should be only let-bound to non-nil values around calls to
+basic completion functions like `try-completion' and `all-completions'.  */);
   Vcompletion_regexp_list = Qnil;
 
   DEFVAR_BOOL ("minibuffer-allow-text-properties",



reply via email to

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