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

Re: compadd -Q -U completes $(( without inserting upon it



On 16 January 2016 at 23:55, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> B) Don't invoke completion directly; instead, invoke a normal editing
> widget to modify the buffer so the tokens do not begin a context, then
> call the completion widget, and finally clean up the buffer again when
> the completion widget returns.

I went this path and it was quite easy. I have zew-complete-shell-word
widget (attached) that does a simple grep:
        __zew_csw_found=(
"${(@M)historywords:#(#i)$__zew_csw_left*$__zew_csw_right}" )

then zle -M displays the results and Alt-h/H navigates among them. One
minute video:

https://asciinema.org/a/9smut3m7l6njvwfhrkfb6emdp

> The unfortunate bit of (B)
> is that it can't work at all as a completer function (zstyle element).

So no automatic multi-column zle -M, no actual highlighting (tried to
pass ANSI codes to zle -M but it doesn't process them), no zstyles
that configure pagination etc. These are the drawbacks? All this is in
the queue to implement, e.g. I currently display LINES / 3 matches and
there is no access to matches beyond that.

Code is at:

https://github.com/psprint/zsh-editing-workbench/blob/master/zew-complete-shell-word

only 74 lines for a robust _history_complete_older

Thanks,
Sebastian Gniazdowski

Attachment: zew-complete-shell-word
Description: Binary data

Attachment: zew-process-buffer
Description: Binary data



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