unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eshel Yaron <me@eshelyaron.com>
To: Ergus <spacibba@aol.com>
Cc: emacs-devel@gnu.org
Subject: Re: [PATCH] Completion preview common
Date: Fri, 12 Apr 2024 08:18:57 +0200	[thread overview]
Message-ID: <m1cyqv3xym.fsf@dazzs-mbp.kpn> (raw)
In-Reply-To: <uiynuk54vfaxdwwmtxf7ekibu2pf3u7dx5yolmwjzt4snv2o73@ct76cworb4u2> (Ergus's message of "Wed, 10 Apr 2024 17:54:15 +0200")

Ergus <spacibba@aol.com> writes:

> On Wed, Apr 10, 2024 at 01:55:36PM +0200, Eshel Yaron wrote:
>>
>>I understand the value of inserting the common prefix as you describe
>>it.  This is what the command completion-preview-insert-common-prefix
>>that I proposed up-thread does.  It lets you insert (complete up to) the
>>longest common prefix even if the preview shows (also) the first suffix.
>>
> Indeed. The problem is that in my patch the user knows what's gonna be
> inserted. While otherwise we need to as some highlight to the candidate
> to let the user more or less know.
>
> To allow this second part the change implies modifications in all the
> functions chain to somehow export the prefix when shown + 1 extra
> command to insert only the common prefix + a user side rebind of
> tab. That change seems much more complicated (compared to my patch)

Right.  I think we're on the same page.  There's a tradeoff between
keeping the library as simple as possible on the one hand, and providing
the best UX on the other.

I've implemented my suggested approach, including highlighting the
longest common prefix.  This indeed required more changes than the patch
you proposed, but nothing too complicated so far.  I plan to experiment
with this some more and settle on an implementation (perhaps closer to
your patch, if I run into unexpected issues with this approach) in a
couple of weeks.

>>> If you allow me a couple of code comments:
>>>
>>> 1. Considering how the package works maybe it is useful to let-set:
>>>
>>> (completion-styles '(basic)) before calling completion-all-completions.
>>>
>>> Because you only care and handle the candidates where the matches are in
>>> the beginning, but with substring, partial-completion, etc the matches
>>> could be anywhere, giving a longer list (with many useless)
>>> candidates.
>>
>>I'll try it out and see if it makes for a significant performance
>>improvement.  Otherwise, I think it's better not to override
>>completion-styles in case someone has some exotic completion style with
>>specific behavior that they rely on.  IOW, I'd rather avoid making any
>>assumptions about completion-styles.
>>
> The assumption is actually good considering that your package handles
> candidates like (prefix)suffix inserting suffix; but it shouldn't handle
> correctly pre(prefix)suffix where `pre` is not inserted (or even
> previewed)

Yes, in most cases the basic style is exactly what we need here.  In my
testing, let-binding completion-styles as you suggested indeed led to a
significant performance (speed) improvement in comparison with using
e.g. the 'substring' completion style.  I'll push such a change soon.

> If the user has some `flex` like style set by default it will just add
> even more noise; when what you care is just the prefix right?

Specifically the flex style also influences sorting, so it's overriding
it is not totally innocent.  But in practice I think it should be fine.


Thanks,

Eshel



  reply	other threads:[~2024-04-12  6:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <njlevizac6zitj5fulduqcgtfwhac5vmcsz2we562fym7z5u6i.ref@su5oafrms4r7>
2024-04-07 18:38 ` [PATCH] Completion preview common Ergus
2024-04-07 21:12   ` Eshel Yaron
2024-04-07 23:39     ` Ergus
2024-04-09 18:30       ` Eshel Yaron
2024-04-09 23:05         ` Ergus
2024-04-10 11:55           ` Eshel Yaron
2024-04-10 15:54             ` Ergus
2024-04-12  6:18               ` Eshel Yaron [this message]
2024-04-07 21:15   ` [External] : " Drew Adams

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=m1cyqv3xym.fsf@dazzs-mbp.kpn \
    --to=me@eshelyaron.com \
    --cc=emacs-devel@gnu.org \
    --cc=spacibba@aol.com \
    /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).