Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Make _expand_alias more usable as a completer

On Thu, Jun 3, 2021 at 2:24 AM Oliver Kiddle <opk@xxxxxxx> wrote:
> In practical tests, I'm not finding that this works too well, it ends up
> removing the characters typed.

I cannot reproduce that. Here's what I tried:

% cd $(mktemp -d)
% print "PS1='%# ' PS2='' RPS2='< %^'\nsetopt transientrprompt" > .zshrc
% exec env -i HOME=$PWD TERM=$TERM zsh -d
% autoload -Uz compinit
% compinit
% _foo() {
compadd -QU 'ls -al'
compadd -Q lsusb lsvfs
% compdef _foo foo
% foo <tab>
% foo ls<tab>
ls -al  lsusb   lsvfs

It inserts the unambiguous prefix and cycles through the three
choices, without removing any characters I've typed. Am I missing

> I also wonder if this would be better done from within _command_names
> directly but I'm not sure.

Actually, I feel like it could instead be added to the _expand
completer. Would that be a better idea than what I presented in this
patch? I could, for example, move the actual business logic for
expanding aliases from _expand_alias to _expand, and then have
_expand_alias call _expand to do the work.

Messages sorted by: Reverse Date, Date, Thread, Author