unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 16334@debbugs.gnu.org
Subject: bug#16334: 24.3.50; company-capf eats the first char in IELM filename completions
Date: Tue, 07 Jan 2014 06:52:11 +0400	[thread overview]
Message-ID: <52CB6BDB.4020601@yandex.ru> (raw)
In-Reply-To: <jwv61pxrvrh.fsf-monnier+emacsbugs@gnu.org>

On 06.01.2014 19:23, 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.

Maybe I didn't ask the right question. If the completion may want to 
change the text outside of its defined boundaries, doesn't that subvert 
the meaning of the "boundaries"? Or do you mean that, depending on the 
completion style, `completion-file-name-table' may return different 
boundaries, with the same prefix and suffix? So that modifications will 
still remain within the boundaries?

>> In that case, "/usr/share/doc" is the completion candidate, not "doc",
>> right?
>
> Not sure what you mean by "completion candidate":

Elements returned by the completion table?
Strings of text, one of which is likely to replace the text between 
completion boundaries.

> try-completion and all-completions will both return nil because there's
> no "/u/s" directory.  Assuming we use partial-completion style,
> completion-try-completion should return "/usr/share/doc" and
> completion-all-completions should return ("usr/share/doc"), i.e. without
> the leading "/".  If we had started from "/usr/s/d" the results would
> have been the same except completion-all-completions would return
> ("share/doc").

Sounds quite convoluted.

>> 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.
>
> Then just have company-capf check completion-boundaries and concat the
> missing prefix to every element returned by all-completions.

Already done: 
https://github.com/company-mode/company-mode/compare/b70540b5fcd062c4670dea7004453de326ff4f70...8ecec3594931ae8e2329fec4b793ad4ba392e4ef

>> 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.
>
> If you want to let Company provide completion styles like
> partial-completion you'll need some additional info about "subfields".
> But as long as you limit yourself to prefix or substring completion you
> don't need that.

I wonder if this information has to be reflected in the backend API. For 
example, some external service might want to pick the completion styles 
itself, and we can just give the backend prefix, get back a list of 
completion candidates, and eventually replace the prefix with one of the 
candidates. Same with suffix whenever we get around to supporting that.

 From where I stand, knowing the completion style in advance only gives 
us benefits in visualization (know which characters in candidate strings 
match) and, in some cases, performance (no need to do concatenation even 
if the strings we receive from some subsystem have some offset in the 
prefix).

On the other hand, the backend is free to try all completion styles it 
knows/is allowed to use, sort and return together, like in this feature 
request: 
https://github.com/company-mode/company-mode/issues/45#issuecomment-31564029, 
saving several network road-trips and possibly further amount of CPU time.

And as far as highlighting the matching characters in candidates goes, 
we could just skip that for non-prefix matches (checking each on the 
fly), or do it sloppily, without regard for the backend logic.

>> 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.
>
> Yup.  Just like you have a problem when the start/end of the
> completion text is not identical.  E.g. you could have a "word" backend
> and a "varname" backend, and you type "my_fanc" and now the "word"
> backend wants to complete "fanc" whereas the varname backend wants to
> complete "my_fanc".

We currently deal with that by only using the backends that respond with 
the same prefix as the first one that returned non-nil. Guess we could 
add the boundaries to the comparison list, too...





  reply	other threads:[~2014-01-07  2:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-03 23:20 bug#16334: 24.3.50; company-capf eats the first char in IELM filename completions Dmitry Gutov
2014-01-04  5:00 ` Stefan Monnier
2014-01-05  2:20   ` Dmitry Gutov
2014-01-05  3:17     ` Dmitry Gutov
2014-01-05  4:53     ` Stefan Monnier
2014-01-06  5:33       ` Dmitry Gutov
2014-01-06 15:23         ` Stefan Monnier
2014-01-07  2:52           ` Dmitry Gutov [this message]
2014-01-08  3:33             ` Stefan Monnier
2014-01-09  6:21               ` Dmitry Gutov
2014-01-09 16:00                 ` Stefan Monnier
2014-01-10  6:23                   ` Dmitry Gutov
2014-01-10 14:58                     ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52CB6BDB.4020601@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=16334@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).