diff options
| author | Spencer Baugh | 2024-12-10 12:41:49 -0500 |
|---|---|---|
| committer | Eli Zaretskii | 2024-12-26 10:42:58 +0200 |
| commit | 6412a5503c404bbe177879d113c2299288c76ccd (patch) | |
| tree | 8ac9898dde6b18c3517d3db98e6f7a63a2dc0e87 | |
| parent | aaacd5806c75019b052a69764ef4d193d243573c (diff) | |
| download | emacs-6412a5503c404bbe177879d113c2299288c76ccd.tar.gz emacs-6412a5503c404bbe177879d113c2299288c76ccd.zip | |
Consistently add wildcards for completion-pcm-leading-wildcard
completion-pcm--find-all-completions has two different phases:
First we turn the minibuffer text into a regex and matches
completion alternatives against it. If that finds no matches,
then we strip some text off the completions and minibuffer text
and call ourselves recursively to find completions, then filter
the results with the removed text (converted into a regex).
Because of this, completion-pcm-leading-wildcard had
inconsistent behavior: in the second phase, the filter created
from the removed text would have a leading wildcard. That
effectively adds wildcards in the middle of the minibuffer text
at the start of each "word". But the first phrase created a
regex which had no such wildcards. Thus, the two phases could
get substantially different results.
We fix this by changing completion-pcm-leading-wildcard to
consistently add a leading wildcard for each word. This was
always my intention.
* lisp/minibuffer.el (completion-pcm--string->pattern): Include
a wildcard after each delimter with
completion-pcm-leading-wildcard. (bug#74772)
* lisp/minibuffer.el (completion-pcm-leading-wildcard): Update
docs.
* doc/emacs/mini.texi (Completion Styles): Update docs.
| -rw-r--r-- | doc/emacs/mini.texi | 6 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 17 |
2 files changed, 12 insertions, 11 deletions
diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi index 0fcd24ed79d..8e0d58d0f7c 100644 --- a/doc/emacs/mini.texi +++ b/doc/emacs/mini.texi | |||
| @@ -577,9 +577,9 @@ corresponding position in the completion alternative. | |||
| 577 | 577 | ||
| 578 | @vindex completion-pcm-leading-wildcard | 578 | @vindex completion-pcm-leading-wildcard |
| 579 | If @code{completion-pcm-leading-wildcard} is set to @code{t}, this style | 579 | If @code{completion-pcm-leading-wildcard} is set to @code{t}, this style |
| 580 | always acts as if a @dfn{wildcard} is present at the start of the | 580 | always acts as if a @dfn{wildcard} is present at the start of each word |
| 581 | minibuffer text, similar to the @code{substring} style. For example, | 581 | in the minibuffer text, similar to the @code{substring} style. For |
| 582 | @samp{l-m} will complete to @samp{emacs-lisp-mode}. | 582 | example, @samp{l-ode} will complete to @samp{emacs-lisp-mode}. |
| 583 | 583 | ||
| 584 | @item emacs22 | 584 | @item emacs22 |
| 585 | @cindex @code{emacs22}, completion style | 585 | @cindex @code{emacs22}, completion style |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 253c26a84ea..39e7a399404 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -3951,17 +3951,18 @@ the commands start with a \"-\" or a SPC." | |||
| 3951 | trivial))) | 3951 | trivial))) |
| 3952 | 3952 | ||
| 3953 | (defcustom completion-pcm-leading-wildcard nil | 3953 | (defcustom completion-pcm-leading-wildcard nil |
| 3954 | "If non-nil, partial-completion completes as if there's a leading wildcard. | 3954 | "If non-nil, partial-completion behaves as if each word is preceded by wildcard. |
| 3955 | 3955 | ||
| 3956 | If nil (the default), partial-completion requires a matching completion | 3956 | If nil (the default), partial-completion requires each word in a |
| 3957 | alternative to have the same beginning as the first \"word\" in the | 3957 | matching completion alternative to have the same beginning as each |
| 3958 | minibuffer text, where \"word\" is determined by | 3958 | \"word\" in the minibuffer text, where \"word\" is determined by |
| 3959 | `completion-pcm-word-delimiters'. | 3959 | `completion-pcm-word-delimiters'. |
| 3960 | 3960 | ||
| 3961 | If non-nil, partial-completion allows any string of characters to occur | 3961 | If non-nil, partial-completion allows any string of characters to occur |
| 3962 | at the beginning of a completion alternative, as if a wildcard such as | 3962 | at the beginning of each word in a completion alternative, as if a |
| 3963 | \"*\" was present at the beginning of the minibuffer text. This makes | 3963 | wildcard such as \"*\" was present at the beginning of each word. This |
| 3964 | partial-completion behave more like the substring completion style." | 3964 | makes partial-completion behave more like the substring completion |
| 3965 | style." | ||
| 3965 | :version "31.1" | 3966 | :version "31.1" |
| 3966 | :type 'boolean) | 3967 | :type 'boolean) |
| 3967 | 3968 | ||
| @@ -4008,7 +4009,7 @@ or a symbol, see `completion-pcm--merge-completions'." | |||
| 4008 | (setq p0 p) | 4009 | (setq p0 p) |
| 4009 | (push (substring string p (match-end 0)) pattern) | 4010 | (push (substring string p (match-end 0)) pattern) |
| 4010 | ;; `any-delim' is used so that "a-b" also finds "array->beginning". | 4011 | ;; `any-delim' is used so that "a-b" also finds "array->beginning". |
| 4011 | (setq pending 'any-delim) | 4012 | (setq pending (if completion-pcm-leading-wildcard 'prefix 'any-delim)) |
| 4012 | (setq p0 (match-end 0)))) | 4013 | (setq p0 (match-end 0)))) |
| 4013 | (setq p p0)) | 4014 | (setq p p0)) |
| 4014 | 4015 | ||