diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index f338b9bf453..43fe2dd196d 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -4188,8 +4188,8 @@ a submatch 1, then completion can add something at (match-end 1). This is used when the delimiter needs to be of size zero (e.g. the transition from lowercase to uppercase characters).") -(defun completion-pcm--prepare-delim-re (delims) - (setq completion-pcm--delim-wild-regex (concat "[" delims "*]"))) +(defun completion-pcm--delim-re (delims) + (concat "[" delims "*]")) (defcustom completion-pcm-word-delimiters "-_./:| " "A string of characters treated as word delimiters for completion. @@ -4202,7 +4202,8 @@ expression (not containing character ranges like `a-z')." :set (lambda (symbol value) (set-default symbol value) ;; Refresh other vars. - (completion-pcm--prepare-delim-re value)) + (setq completion-pcm--delim-wild-regex + (completion-pcm--delim-re value))) :initialize 'custom-initialize-reset :type 'string) @@ -4342,7 +4343,9 @@ one wildcard." (concat (when group "\\(") (if (all (lambda (x) (eq x 'any-delim)) (cdr segment)) - (concat completion-pcm--delim-wild-regex "*?") + (concat (completion-pcm--delim-re + completion-pcm-word-delimiters) + "*?") "[^z-a]*?") (when group "\\)"))))) segments diff --git a/test/lisp/minibuffer-tests.el b/test/lisp/minibuffer-tests.el index 8114899c0ff..78a5261a143 100644 --- a/test/lisp/minibuffer-tests.el +++ b/test/lisp/minibuffer-tests.el @@ -375,6 +375,15 @@ '(any "A" any-delim "B" any-delim "C" any)) "\\`[^z-a]*?A[-_./:| *]*?B[-_./:| *]*?C[^z-a]*?"))) +(ert-deftest completion-pcm--test-zerowidth-delim () + (let ((completion-pcm--delim-wild-regex ; Let "u8" complete to "utf-8". + (concat "\\(?:" completion-pcm--delim-wild-regex + "\\|\\([[:alpha:]]\\)[[:digit:]]\\)"))) + (should (equal (car (completion-try-completion + "u8-d" '("utf-8-dos" "utf-8-foo-dos" "utf-8-unix") + nil 4)) + "utf-8-dos")))) + (ert-deftest completion-pcm-bug4219 () ;; With `completion-ignore-case', try-completion should change the ;; case of existing text when the completions have different casing.