Subject: Re: bug#79265: [PATCH] Treat point more consistently in PCM completion, [PATCH] Treat point more consistently in PCM completion, [PATCH] Refactor completion-pcm--merge-completions

From: Stefan Monnier <[email-masked]>
Date: Mon, 01 Sep 2025 17:24:45 -0400

>> Also, can we just revert the last patch (and add the test(s) that we
>> found in the mean time) so as to make it easier to review patches?
>
> Certainly, the attached patch does that.
>
> (I would have just done the revert directly but I don't have the ability
> to push to the emacs repo)

Sorry, forgot about that.  Pushed, thanks.

>>> +(defun completion-pcm--group-pattern (pattern)
>>> +  "Group together adjacent wildcards in PATTERN."
>>> +  (let (ret)
>>> +    (dolist (elem pattern)
>>> +      (cond
>>> +       ((or (stringp elem) (eq elem 'any-delim))
>>> +        (push elem ret))
>>> +       ((consp (car-safe ret))
>>> +        (setf (car ret) (append (car ret) (list elem))))
>>> +       (t
>>> +        (push (list elem) ret))))
>>> +    (nreverse ret)))
>>
>> Why is `any-delim` not considered a "wildcard"?
>
> Because it's matched by a different regex which only matches
> delimiters.  The idea here is to have one regex subgroup for each
> stretch of wildcards; i.e., for the pattern '("foo" any star point) we
> have the regex "foo(.*)" instead of "foo(.*)(.*)(.*)".  But any-delim
> needs its own regex subgroup since its matched by a different regex.

Ah, I see, thanks.  I was thinking in terms of "needs a subgroup and
a `try-completion`", which `any-delim` does need.  But yeah, it's also
good to collapse any/star/point (also because it can avoid some
pathological regexp matching performance issues, tho I haven't bumped
into them).

> Yes, the return value of completion-pcm--merge-completions is no
> longer in reverse order.

Thanks, makes a lot more sense now.  🙂

        Stefan