Subject: bug#16334: 24.3.50; company-capf eats the first char in IELM filename completions

From: Dmitry Gutov <[email-masked]>
Date: Mon, 06 Jan 2014 09:33:41 +0400

On 05.01.2014 08:53, Stefan Monnier wrote:
>> `completion-file-name-table' is more of an exception, I think.  But if
>> it was only passed the segment of STRING after the last path
>> separator, it could still look behind it in the buffer and see the
>> full path.
>
> But the completion may actually want to *change* the text before
> the boundary.  E.g. completion of /u/s/d to /usr/share/doc.

In that case, "/usr/share/doc" is the completion candidate, not "doc", 
right? Then, "/u/s/d" can be considered a "generalized" prefix, or the 
entity to complete, in c-a-p-f terms. And during completion we delete 
the latter and insert the former.

> The completion table itself does not know how to do that, but some
> completion styles do (e.g. partial-completion).
> So the completion-at-point-function needs to indicate the boundaries of
> "/u/s/d" which indicate which text can be affected by the completion,
> while `completion-boundaries' tells the lower-level completion code
> (e.g. the one in partial-completion) how to split the completion field
> into sub-fields.

To be clear, I'm not convinced that the notion of "sub-fields" is 
useful. Defining limits to the text that can be affected by completion 
only looks good to me from the presentation point of view: if the 
candidate strings can be shorter, we can show more of them in the 
*Candidates* buffer, whereas it's less useful for popup-style UIs where 
the candidates are displayed vertically anyway.

IOW, if I were to add a `boundaries' action to company-backends API, it 
would only be used for presentation: the popup will cut off that many 
characters from the candidate strings, and it will be rendered that many 
columns to the right.

And maybe do the same for suffix boundary, when/if we support that kind 
of completion.

Come to think of it, though, this new action may be incompatible with 
the notion of merged backends. If we have candidates that come from 
backends that return the same prefix but different boundaries, there's 
no way to reflect the boundaries in the popup.