emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BIKESHED: completion faces


From: Stefan Monnier
Subject: Re: BIKESHED: completion faces
Date: Tue, 29 Oct 2019 21:49:15 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> I wonder if it's *that* important, to be able to see the matching chars.

It has an explanatory value which makes the completion-style more
understandable (e.g. I'm pretty sure there are still users who don't
know about the `partial-completion` style that's enabled by default:
they just occasionally see completion lists which they don't understand
and shrug it off).

But no, I don't know how important it is (I do find it useful when
implementing/debugging the code to make sure it worked right ;-)

This said, it seems that highlighting the common part is the "standard"
behavior is all other completion systems whereas highlighting the "first
difference" seems to be specific to Emacs.

>> For this reason, it is common in other completion systems to
>> highlight the "common" part somehow (e.g. underline, bold, ...).
> Personally, I'm not a big fan of underline, italic and even bold (unless
> it's used sparingly, like it is now). With that said...

FWIW, I'm no big fan of underline (maybe it's the LaTeX influence speaking).
But I found it tolerable for first-difference after trying it out.


        Stefan


> The -first-difference face shows actionable info: the next character
> to type, to narrow down the completions list as much as possible while
> ensuring that a given completion is still in.
[...]
> Furthermore, the position of -first-difference also hints at what
> characters were matched (definitely ones before it).
[...]
> The "first difference" character is simply the one after the last
> segment of the common part, isn't it?

Agreed.

This is largely irrelevant for the choice of bikeshed color, but
I figure it's as a good a time as any to clarify that the above, while
largely true is not quite right either:

It's a bit more subtle than that (and the "first-difference" name is
a misnomer, due to history): when I revamped the default completion
system for Emacs-24, adding partial-completion (as well as `basic` which
is a bit more sophisticated than just "prefix completion", in reality),
I had to decide what to do with "first-difference" since it doesn't have
as clear a meaning as for the plain old prefix completion.  So the way
I adapted it to the new reality is that "first difference" now really
means "first char after point".  If you do

    M-x dovi C-b C-b ?

you'll see that `completions-first-difference` is applied to the "c"
of the "doc-view..." commands because that's the first character after
the position in the candidate that corresponds to the position of
point in the pattern.

So strictly speaking:
- No, there can also be common-part characters after first-difference
- Also, it's not always the case that the "first-difference" character
  is "the next character to type, to narrow down the completions list
  as much as possible while ensuring that a given completion is still
  in".  Two reasons for that:
  1- the "first-difference" character may already be part of the
     "common part".  E.g. `M-x revert C-b ?` will show the `t` with
     both `completions-first-difference` and `completion-common-part`
     and typing `t` will actually end up with a pattern that doesn't
     match anything.
  2- depending on the completion style, there might be further
     character that still keep the desired completion while
     eliminating more of the others.
     For example let's say you want to run
     `doc-view-fit-height-to-window`; after you do `M-x doc-view- ?`
     you'll see that the `f` is highlighted as first-difference
     but if hit `f` you still have 5 remaining choices, whereas if you
     hit `h` your choice is the only remaining one.

But by and large, these are exceptions.  Point (2) above is a bit more
true for `flex`, but I don't think it matters very much anyway.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]