emacs-devel
[Top][All Lists]
Advanced

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

Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package


From: Tassilo Horn
Subject: Re: Stepping Back: A Wealth Of Completion systems Re: [ELPA] New package: vertico
Date: Fri, 09 Apr 2021 20:51:13 +0200
User-agent: mu4e 1.5.11; emacs 28.0.50

Daniel Mendler <mail@daniel-mendler.de> writes:

Hi Daniel,

>> I'm not sure that's what your are asking but one thing that comes to
>> mind is that when I want to find the file
>>    ~/Repos/el/emacs/lisp/doc-view.el
>> I can just do
>>    C-x C-f reeld<TAB>
>> and that will already expand to ~/Repos/el/emacs/l/d if
>> `completion-styles' contains `initials' (and
>> `read-file-name-completion-ignore-case' set to t).  Now depending on
>> what I type further, it'll also switch between lisp/ or lib/ directory.
>> AFAIK, that's not really supported with (most) alternative completion
>> UIs where the possible completions are always the files of the currently
>> selected directory.
>
> The completion you describe works with Vertico.  The candidate set is
> updated accordingly in the UI.
>
>    (setq completion-category-overrides nil)
>    (setq completion-category-defaults nil)
>    (setq completion-styles '(initials))
>    (vertico-mode)

Indeed, I've just tried it out.

> However what does not work is the further narrowing in an Orderless
> fashion (your lisp/lib selection). This is what I assume you want to
> do?

Well, I've guessed that already the `initials' completion wouldn't work
at all.  So with my recipe above I've got

  ~/Repos/el/emacs/lib/deps/

as the first completion candidate.  When I TAB there, it'll expand to
just that.  In order to find ~/Repos/el/emacs/lisp/doc-view.el, it seems
I need to scroll the list of possible completions which is very long.

> One could use both initials+orderless completion styles, but then one
> would also need a feature in the completion system which locks the
> current candidate set. There is the Restricto package by Omar, who is
> also the author of Orderless. Restricto essentially replaces the
> minibuffer-completion table with the current candidate subset - a bit
> of a hack if you ask me.

Yes, probably, but it helps in the situation I sketched.

Well, but I guess the better way to find doc-view.el with vertico is to
just do

  C-x C-f reel
  Hit TAB on the ~/Repos/el/emacs/lisp/ candidate being pretty much on
      top of the list.
  do<TAB>

BTW, more a question to the list (and Stefan in particular): I actually
have several emacs worktrees

  ~/Repos/el/emacs/
  ~/Repos/el/emacs-27/
  ~/Repos/el/emacs-native-comp/

With the `completion-category-overrides'

     (file
      (styles basic partial-completion initials))

(actually, just `initials' suffices) and the input ~/Reeld<TAB> the
expansion is ~/Repos/el/emacs/l/d, and the completion help just shows
lib/d*, lisp/d*, and lwlib/d* files.  Shouldn't it also consider
{lib,lisp,lwlib}/d* in emacs-27/ and emacs-native-comp/?

When I rename the emacs-27 directory to e27, it'll include the files in
there.  So the reason seems to be that my emacs-*/ worktrees start with
emacs and TAB expands to the shortest possibility neglecting longer
ones.  It seems like the files below ~/Repos/el/emacs-27/ is completely
inaccessible in the presence of ~/Repos/el/emacs/ using the initials
style.  Of course, when I move point to ~/Repos/el/emacs|/l/d (| being
point) and hit TAB, I can complete any emacs-* worktree.

> The idea is basically to lock the candidate set and switch between
> completion styles.  This feature does not seem to be available in the
> Emacs completion mechanism directly.

I understand the idea but I'm not sure how convenient it would be to
enable/disable styles using key bindings during completion.  In general,
I prefer if it just does what I want. ;-)

Bye,
Tassilo



reply via email to

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