emacs-31 287187f202e: pcm-try-completion: collapse ** into *
Sean Whitton <[email protected]> Tue, 4 Aug 2026 08:55:43 -0400 (EDT)
| Newsgroups | gmane.emacs.diffs |
|---|---|
| Message-ID | <[email protected]> |
branch: emacs-31 commit 287187f202eec01b43672b1811fbc4306cf132f7 Author: Spencer Baugh <[email protected]> Commit: Sean Whitton <[email protected]> pcm-try-completion: collapse ** into * * lisp/minibuffer.el (completion-pcm--merge-completions): Only include one star in the return value (bug#81394). * test/lisp/minibuffer-tests.el (completion-pcm-test-7): Update for new behavior. --- lisp/minibuffer.el | 16 +++++++++++++--- test/lisp/minibuffer-tests.el | 5 +++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 277840ae7b2..2019fe5299d 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -4773,9 +4773,19 @@ the same set of elements." (setq prefix (substring prefix 0 (length fixed)))) (push prefix res) ;; Push all the wildcards in this stretch, to preserve `point' and - ;; `star' wildcards before ELEM. - (dolist (wildcard wildcards) - (push wildcard res)) + ;; `star' wildcards before ELEM. Collapse multiple `star's down to one + ;; on each side of point. (bug#81394) + (let ((star-seen nil)) + (dolist (wildcard wildcards) + (cond + ((eq wildcard 'star) + (unless star-seen + (push 'star res)) + (setq star-seen t)) + (t + (when (eq wildcard 'point) + (setq star-seen nil)) + (push wildcard res))))) ;; Extract common suffix additionally to common prefix. ;; Don't do it for `any' since it could lead to a merged ;; completion that doesn't itself match the candidates. diff --git a/test/lisp/minibuffer-tests.el b/test/lisp/minibuffer-tests.el index d7f0ae73d2b..2f70d248711 100644 --- a/test/lisp/minibuffer-tests.el +++ b/test/lisp/minibuffer-tests.el @@ -312,11 +312,12 @@ '("lisp/minibuffer.el" "src/minibuf.c") nil 9) '("*/minibuf" . 9))) - ;; A series of wildcards is preserved (for now), along with point's position. + ;; A series of `star's is collapsed into a single one, but point's + ;; position is preserved in the middle. (bug#81394) (should (equal (completion-pcm--merge-try '(star star point star "foo") '("xxfoo" "xyfoo") "" "") - '("x***foo" . 3))) + '("x**foo" . 2))) ;; The series of wildcards is considered together; if any of them wants the common suffix, it's generated. (should (equal (completion-pcm--merge-try