Zsh Mailing List Archive
Messages sorted by:
Re: User-defined completion listing
- X-seq: zsh-workers 3624
- From: Peter Stephenson <pws@xxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx (Zsh hackers list)
- Subject: Re: User-defined completion listing
- Date: Thu, 20 Nov 1997 10:22:29 +0100
- In-reply-to: ""Bart Schaefer""'s message of "Wed, 19 Nov 1997 11:41:50 MET." <971119114150.ZM1710@xxxxxxxxxxxxxxxxxxxxxxx>
"Bart Schaefer" wrote:
> } compctl ... -Y '$array'
> } or
> } compctl ... -Y 'func'
> I must confess confusion as to why you'd do it this way.
> If you're going to examine the first character and behave differently
> when it is '$', you could do that with -X and not need a new option.
-X doesn't do the right thing. It gets displayed with completions,
if there's no unique match, not just listings. Further, it gets displayed
in addition to a listing, just above. We want something to be displayed
instead of a listing. If you simply use -X, there's no way of adapting
the listing at all, and it would be wrong to misuse -X for that
purpose. Also, -Y *has* to be generated separately for each
completion, because it depends on the actual list; -X doesn't, so
there's no real rationale for making it support $var.
> If you're going to expand a variable, why does it have to be an array?
> The parameter to -X is just a string.
Because -Y replaces a list; it's natural to generate the replacement
list as an array. As with literal arrays (quoted below), I'd quite
like to alter get_user_var() to turn a scalar into a single element
array, which will solve this problem quite neatly, it just wasn't
a necessary part of yesterday's patch. I certainly agree it's
> If you're going to substitute a string, why pass it around with $reply?
I don't understand this. The $reply comes only from the function.
The exact $reply array is used for the listing. There is no more
substitution and $reply has always been for communication back from
functions. Do you mean `why not use $REPLY'? The answer is because
you can't replace a complete listing with that. It seems silly
to use both.
In more abstract terms, what gets displayed in a completion listing
is always an array of possibilities. The whole point of the -Y option
is to allow you to alter that. It is entirely natural that this altered
list would be an array. It just so happens you can get away with a one
element array with everything stuck together, if you want.
> } Another thing under the `could perhaps be better, but it's time I did
> } some work' heading: literal arrays are allowed as with -k, i.e. -Y
> } '(option1 option2 ...)', but there's no way of getting a literal
> } string there.
> Why do you need to pass a literal string to -Y when you can use -X ?
You can't, not for the same thing. See above. -X and -Y are
entirely different: -X gives a single, fixed banner heading for
the listing and for the completion; -Y gives a list of completions
to replace the ones shown when displaying completions.
Peter Stephenson <pws@xxxxxx> Tel: +49 33762 77366
WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77413
Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, Platanenallee 6, 15738 Zeuthen, Germany.
Messages sorted by: