zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: using the description from _arguments foo:description:->state
Date: Wed, 21 Sep 2011 08:50:12 -0700	[thread overview]
Message-ID: <110921085012.ZM16562@torch.brasslantern.com> (raw)
In-Reply-To: <17938.1316605147@thecus.kiddle.eu>

On Sep 21,  1:39pm, Oliver Kiddle wrote:
} Subject: Re: using the description from _arguments foo:description:->state
}
} Mikael Magnusson wrote:
} > Can we add a new option to _configure which enables this, so if you
} > say _arguments -d you also have to local state_descr. There's a couple
} > of other variables that work like this already, -n for NORMARG, -C for
} > curcontext.
} 
} While we could, there's always the possibility that some function
} somewhere has a -d that's intended to me an argument to be completed.

That condition is already handled by using e.g. "_arguments -n : -n".

More importantly, I don't think adding -d buys much.  -C changes the
meaning of ->state so that the caller doesn't need to copy from the
context array to curcontext, but there's no equivalent for states or
descriptions (unless we want to overload the name "descr" which is
already used in a bunch of places, but I don't like that idea).

} If you used a function instead of a state, it would be called with the
} relevant arguments for the description unless you prefix it with a space
} in which case, you'd have to dig around in $expl.

Before producing my patch I first thought about digging around in $expl,
but $expl is already marked up for use with _format, so that doesn't
really work.  Also $expl is only passed *down* from _arguments, not back
up to the caller.

} Unless you pass -C to _arguments there is the possibility of more than
} one state being possible so any state_descr would need to be an array.

Yes, that's what my patch does.  $state_descr is an array parallel to
the $state array.  (Except in _values when $state is never an array,
which I find a bit confusing but is probably too late to change.)

} And we can't do arrays of arrays so a state_expl wouldn't be possible
} (expl is already an array). That would put me off the whole idea
} somewhat.

Not an issue, _arguments declares "local expl" so it's never used with
this form of state handling.

} Personally, I'd be inclined to have a separate new-widget state in this
} particular function.

Yes, that would work in _zle, but other callers of _arguments are already
passing a description which _arguments parses out, only to then throw it
away.  Shouldn't we keep that parsing in one place and make it useful?


  reply	other threads:[~2011-09-21 15:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-11 15:04 Mikael Magnusson
2011-09-11 18:10 ` Bart Schaefer
2011-09-20 15:16   ` Mikael Magnusson
2011-09-21 11:39     ` Oliver Kiddle
2011-09-21 15:50       ` Bart Schaefer [this message]
2011-09-21 17:10         ` Oliver Kiddle
2011-09-22  4:04           ` Bart Schaefer

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=110921085012.ZM16562@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --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).