Subject: Re: [PATCH] _widgets: Complete zle-* widgets too.
From: Bart Schaefer <[email-masked]>
To: Daniel Shahaf <[email-masked]>
Cc: Zsh hackers list <[email-masked]>
Date: Sat, 30 Jul 2016 07:40:08 -0700
List-Id: Zsh Workers List <zsh-workers.zsh.org>

I don't think this is right.  Those names should be completed only if they
have already been created with "zle -N", and it is not appropriate to
autoload add-zle-hook-widget in the generic widgets completion function.

On Jul 30, 2016 8:13 AM, "Daniel Shahaf" <[email-masked]> wrote:

> ---
>  Completion/Zsh/Type/_widgets | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/Completion/Zsh/Type/_widgets b/Completion/Zsh/Type/_widgets
> index fdab281..0e7f491 100644
> --- a/Completion/Zsh/Type/_widgets
> +++ b/Completion/Zsh/Type/_widgets
> @@ -2,8 +2,14 @@
>
>  local expl pattern
>
> +local -a fake
> +autoload -U add-zle-hook-widget
> +add-zle-hook-widget -h >&/dev/null # sets the zstyle
> +zstyle -g fake zle-hook types
> +fake=( zle-${^fake} )
> +
>  pattern=( -g \* )
>  zparseopts -D -K -E g:=pattern
>
>  _description widgets expl widget
> -compadd "$@" "$expl[@]" -M 'r:|-=* r:|=*' -
> "${(@k)widgets[(R)${pattern[2]}]}"
> +compadd "$@" "$expl[@]" -M 'r:|-=* r:|=*' -
> "${(@k)widgets[(R)${pattern[2]}]}" "${(@M)fake:#${~pattern[2]}}"
>