Subject: Re: bug#73234: 30.0.91; completion-preview-mode doesn't trigger for case-insensitive capf

From: Morgan Willcock <[email-masked]>
Date: Thu, 19 Sep 2024 15:59:17 +0100

Eshel Yaron <[email-masked]> writes:

>> e.g. If a valid completion was "FooBar", and I typed "foo", having the
>> final result as "fooBar" wouldn't be ideal.
>
> Fair enough, although earlier you mentioned that your use case was
> completing symbols in a case-insensitive language, so I wonder what's
> wrong with "fooBar", or "foobar" for that matter.  They are all the same
> as the completion candidate, "FooBar", ignoring case differences, no?

The symbols would technically be valid in the language, but the
completion candidates will be using a particular style of naming.

Fundamentally, if I am meant to be writing using PascalCase then I don't
want the result to be accidentally transformed into camelCase.

>> I've been trying to think of a way to get it to work without disturbing
>> the user interface that already exists.  Maybe it would be possible
>> fixup the result in a post-insertion hook if one existed - such a hook
>> might be generally useful anyway.
>
> We have the :exit-function (which your capf can provide as an extra
> property alongside the completion table it returns), and indeed you
> could use that to "fix" the case of your prefix after completing it.

I don't think it is the responsibility of the completion function
because it is not the completion function that is modifying the buffer.

> That's an interesting solution, I think.  Or do you have some other kind
> of hook in mind?

Just a hook that runs after it was completion-preview-mode that inserted
a completion.

I thought that completion-preview-active-mode-hook might have been
suitable, but it looks like that is being called on every key-press when
typing in the buffer (without the completion preview).

Thanks,
Morgan

-- 
Morgan Willcock