unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 16555@debbugs.gnu.org
Subject: bug#16555: 24.3.50; Company and CAPF: dealing with completion values containing extra text
Date: Sun, 26 Jan 2014 21:46:34 -0500	[thread overview]
Message-ID: <jwvy522go99.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <52E591BC.4090009@yandex.ru> (Dmitry Gutov's message of "Mon, 27 Jan 2014 00:52:44 +0200")

> * Without the additional text property, a1 and a2 are considered equal, and
> only one of them is listed in the completions buffer.

Hmm??  AFAIK even with the text property, they are considered equal, so
it's odd that it would influence whether only one or both are displayed.
AFAIK in *Completions* "duplicates" are only eliminated if their
"text+annotation" is identical.

> And it looks to me that this approach is incompatible with the `value'
> command, if we want company-capf to support it.  Using the annotation
> function, it would know how to get from value to value + annotation,
> but not the other way around.

Agreed.

ELISP> (js2-time (all-completions "" obarray 'fboundp))
> 0.0121
ELISP> (js2-time (mapcar
>            (lambda (s)
>              (if (> (length s) 2)
>                  (propertize s 's (substring s (/ (length s) 2)))
>                s))
>            (all-completions "" obarray 'fboundp)))
> 0.1318

> The second measurement fluctuates between 130ms and 80ms, probably due to
> GC.  Maybe this is negligible, considering that on my machine
> that's a collection with 19000 elements, and most completion lists will be
> considerably smaller.

While I don't want to minimize the performance problem, you also have to
take into account the fact that the whole completion operation will
actually do something with those strings, so 19K candidates will
typically suffer from performance problems elsewhere.

> On the other hand, using `annotate' cleanly separates the "meat" in
> completion candidates from the extra text, which can be used to
> e.g. visualize them differently, maybe with different faces and alignments
> in the popup. As long as we solve the issue of uniqueness.

Conceptually, it does seem cleaner to me, indeed.

>> - `exit-function' would be used to insert the arglist after selecting
>> a candidate.
> Yes, `exit-function' is the best match for `post-completion', but I don't
> see which value of STATUS should be considered as okay for
> insertion.  `finished' seems to be a good candidate, but it does not seem to
> really correspond to when happens after `company-complete-selection' (the
> completion is inserted and the popup is closed).

It does correspond exactly.

> `finished' can only be the status when the inserted completion doesn't
> have any possible continuations in the completions table,

That description was from the point of view of "TAB-style completion".
In the case of company-complete-selection', we know that even if there
could be further continuations, the user's action indicates he doesn't
want those, so it really should be `finished'.

IOW the problem is one of how to better document the meaning of `finished'.

> The reverse is also true: being able not to insert the arguments list
> for a sole candidate can also be useful, and in Company user can do that at
> least by repeatedly using TAB (company-complete-common) instead of
> company-complete-selection'.

Then I guess that company-complete-common wouldn't want to pass
`finished' to the exit-function.


        Stefan





  reply	other threads:[~2014-01-27  2:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-26  4:11 bug#16555: 24.3.50; Company and CAPF: dealing with completion values containing extra text Dmitry Gutov
2014-01-26  6:23 ` Stefan Monnier
2014-01-26 22:52   ` Dmitry Gutov
2014-01-27  2:46     ` Stefan Monnier [this message]
2014-01-28  5:37       ` Dmitry Gutov
2014-01-28 13:24         ` Stefan Monnier
2014-01-28 16:00           ` Dmitry Gutov
2014-01-28 22:04             ` Stefan Monnier
2014-01-28 22:51               ` Dmitry Gutov
2014-01-29  1:34                 ` 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=jwvy522go99.fsf-monnier+emacsbugs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=16555@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    /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).