zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh-workers@zsh.org
Subject: Re: [PATCH] Completion batch #4: New UNIX functions
Date: Fri, 05 Jan 2018 15:54:12 +0100	[thread overview]
Message-ID: <24753.1515164052@thecus.kiddle.eu> (raw)
In-Reply-To: <0ED247D6-B6E3-40AB-A59D-DDEFC4083BEE@dana.is>

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


      reply	other threads:[~2018-01-05 14:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-04 17:48 dana
2018-01-05 14:54 ` Oliver Kiddle [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=24753.1515164052@thecus.kiddle.eu \
    --to=okiddle@yahoo.co.uk \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).