Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: completion within a function
On Wed, Dec 30, 2020 at 9:22 AM Felipe Contreras
<felipe.contreras@xxxxxxxxx> wrote:
>
> After removing all the unnecessary stuff from the tests, I came up
> with this script that does list completions:
I think it might be possible to do something even less complicated.
The basic idea is to first borrow this from the manual:
zle -C all-matches complete-word _generic
bindkey '^Xa' all-matches
zstyle ':completion:all-matches::::' completer \
_all_matches _complete
zstyle ':completion:all-matches:*' insert true
And then:
do-complete() { zle -U $'\Cxa\n' }
zle -N do-complete
run-complete () {
vared -i do-complete argv
}
complete() {
local -i n=$argc
zpty complete-tty run-complete "$@"
zpty -r complete-tty
zpty -d complete-tty
}
There is likely some additional quoting needed on $@ to assure the
right arguments are passed to run-complete, and some more could be
done to separate the context from the results.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author