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

Re: [PATCH] Completion batch #4: New UNIX functions



dana wrote:
> new functions belonging to the 'Unix' group. None of them are particularly

Actually, I think sublimetext belongs under X. X is supposed to cover
anything that needs a GUI so stuff like acroread, netscape, matlab etc
are there. I've also called it _sublimetext rather than _subl which is
how things are normally named.

> As always, let me know if you see anything i've done weird.

I've tweaked the other functions to remove superfluous local statements
and correct the return status in one case. _arguments' local
requirements are unfortunately somewhat confusing:

If you don't use states (:-> syntax) no extra variables need to be
declared local.

If you do, you need to declare context, state and line local. state and
context are arrays and you should loop over them calling, _wanted -C
"$context[1]" as appropriate.

However, in the vast majority of cases, it is only ever possible for
state and context to have one element in them. You need something like
optional arguments for multiple simultaneous states to be an issue. In
this case, as a simplification, you can call _arguments -C and instead
of using context, $curcontext is modified directly with the context for
the one state. For this to work, you need to preserve the existing
value, hence this usage:
  local curcontext="$curcontext" state line

opt_args ought also to be declared local but we tend to be lax about
that.

state_descr is a relatively new addition and most functions predate it.
I tend not to bother.

With the return status, it is key to remember that if people unset the
prefix-needed style, _arguments is likely to add matches and return a
state so don't do: _arguments -options '*: :->state' && return
the common && ret=0 idiom works for this case along with an explicit
check that $state is set.

Oliver



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