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

Re: [PATCH] _add-zle-hook-widget: New completion.



Daniel Shahaf wrote:
> +local context state state_descr line
> +typeset -A opt_args

Those are only needed if you're using _values or _arguments with states.
This function doesn't so that isn't needed.

> +    _wanted widgets expl "installed hooks" compadd -- ${tmp#<->:} && return 0

The description should be singular - "installed hook". Even if you can
specify a list, they are only completed one at a time.

> +  else
> +    _wanted widgets expl widget compadd -M 'r:|-=* r:|=*' -k widgets && ret=0 && return 0
> +  fi
> +  return 1

ret was not declared local so ret=0 should not be there.
Actually, all this messing with return codes is superfluous. Given an
if..then..else block, the last command in either branch determines the
final return status. If you have '&& return 0', the 0 is always
redundant. But in this case, no return statement at all should be needed.

Also, Bart suggested:
>  compadd "$@" -M 'L:|zle-=' -a hooktypes

That L: form makes the zle- a sort of optional prefix. Is that what
you intended? Unfortunately it doesn't work together with -M 'r:|-=*
r:|=*' and zl<tab> won't complete. 'B:zle-=' is a shorter version
of the same thing. It might be better to do:
  compadd "$@" -a hooktypes || compadd "$@" -pzle- -a hooktypes

Oliver



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