Subject: Re: bug#70217: [PATCH] Add substring-partial-completion style

From: Spencer Baugh <[email-masked]>
Date: Thu, 18 Apr 2024 11:19:04 -0400

Stefan Monnier <[email-masked]> writes:
>> It's preferable for this to be a separate style from partial-completion
>> rather than a customization for partial-completion, because completing
>> with a leading glob is inefficient: it doesn't allow the completion
>> table to do any filtering at all.  So, for example, one might want the
>> regular partial-completion style to run first, and if it doesn't find
>> anything then the substring-partial-completion style can run.
>
> FWIW, I think the "language of completion styles" would benefit from
> being a bit richer.  I.e. instead of a completion style (i.e. an entry
> in `completion-styles`) being limited to a symbol, we could
> extend it so a style can take arguments.
>
> E.g. the `substring` style could take an argument which when set to the
> symbol `pcm` would cause it to behave like your "substring-partial-completion":
>
>     (setq completion-styles '(basic (substring pcm) emacs22))
>
> Alternatively, it could be an argument to `partial-completion`, e.g.:
>
>     (setq completion-styles '(basic (partial-completion notanchored) emacs22))

This is a good point, because I think there's a few things I want which
fit neatly with this:

- '(substring pcm) (i.e. the behavior added in this feature)

- '(emacs22 pcm)  (i.e. ignoring the suffix after point, but using pcm
  for what's before point)

- '(emacs22 pcm substring) (i.e. ignoring the suffix after point, but
  also globbing at the start of the completion like substring, and using
  pcm for it)

But, also, I realized that I basically always want PCM for both the
substring and emacs22 completion styles.  So what about having two
customizations, defaulting to nil?

completion-substring-use-pcm
completion-emacs22-use-pcm

These customization will affect all usage of those styles.  Without this
approach, I'd have to use completion-category-overrides to override the
completion styles for every single category, just to make the styles use
PCM.  (which IMO should be the default anyway)

This doesn't give me the substring-emacs22 style that I want, but maybe
that should actually be a separate style, since its behavior would be
fairly different from both emacs22 and substring, and so probably
doesn't make sense as an option.