From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20789 invoked from network); 20 Nov 1997 09:38:39 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 20 Nov 1997 09:38:39 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id EAA23115; Thu, 20 Nov 1997 04:23:33 -0500 (EST) Resent-Date: Thu, 20 Nov 1997 04:23:33 -0500 (EST) Message-Id: <199711200922.KAA06895@sgi.ifh.de> To: zsh-workers@math.gatech.edu (Zsh hackers list) Subject: Re: User-defined completion listing In-reply-to: ""Bart Schaefer""'s message of "Wed, 19 Nov 1997 11:41:50 MET." <971119114150.ZM1710@candle.brasslantern.com> Date: Thu, 20 Nov 1997 10:22:29 +0100 From: Peter Stephenson Resent-Message-ID: <"MFhI_.0.3f5.K60Tq"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/3624 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu "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 desirable. > 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 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.