From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27045 invoked from network); 9 Aug 2000 21:14:13 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 9 Aug 2000 21:14:13 -0000 Received: (qmail 27834 invoked by alias); 9 Aug 2000 21:13:57 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12578 Received: (qmail 27793 invoked from network); 9 Aug 2000 21:12:53 -0000 Sender: opk Message-ID: <3991BACB.33692F9@u.genie.co.uk> Date: Wed, 09 Aug 2000 21:10:51 +0100 From: Oliver Kiddle X-Mailer: Mozilla 4.73 [en] (X11; I; Linux 2.2.16 i586) X-Accept-Language: en MIME-Version: 1.0 To: Zsh workers Subject: PATCH: New _read and selective parameter completion Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit This adds an _arguments based completion function for read. I don't think we have too many builtins left where conversion to use _arguments would still be useful. Any requests? I thought about modifying _vars to insert the '[' for arrays and associations but _parameters would first need to be given an option to make it only complete specific types of parameter. Would anyone object to my adding this? I was thinking of a -g option (analogous to the -g option of _files) where the pattern specified would be augmented with ~*local* and used to match the values in the $parameters association. I mentioned this vaguely before in 11284 and Sven had some good ideas in his reply (11293). The focus there is more towards having the patterns configurable via a style similar to the file-patterns tag but my suggested option would I think be a useful first step. Oliver Index: Completion/Builtins/_read =================================================================== RCS file: _read diff -N _read --- /dev/null Tue May 5 13:32:27 1998 +++ _read Wed Aug 9 14:09:15 2000 @@ -0,0 +1,18 @@ +#compdef read + +local pflag expl line curcontext="$curcontext" + +# -p flag only relevant if we have a coprocess +(:>&p) 2>/dev/null && + pflag='(-q -u -z)-p[input is read from the coprocess]' + +_arguments -C -s \ + '-r[raw mode]' \ + '(-p -k -u -z)-q[read y or n character from terminal]' \ + '(-q)-k[specify number of characters to read]:number of characters' \ + '(-q -u -p)-z[read entry from editor buffer stack]' \ + '(-E)-e[input read is echoed and not assigned]' \ + '(-e)-E[input read is echoed]' \ + '-A[first name is taken as an array]' \ + '(-q -z -p)-u+[specify file-descriptor to read from]:file-descriptor:_file_descriptors' \ + $pflag '1:varprompt:_vars -qS\?' '*:vars:_vars' Index: Completion/Builtins/_vars =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Builtins/_vars,v retrieving revision 1.3 diff -u -r1.3 _vars --- Completion/Builtins/_vars 2000/05/31 09:38:26 1.3 +++ Completion/Builtins/_vars 2000/08/09 21:09:15 @@ -1,4 +1,4 @@ -#compdef getopts read unset vared +#compdef getopts unset vared # This will handle completion of keys of associative arrays, e.g. at # `vared foo['. However, in this version the [ must be added @@ -20,5 +20,5 @@ compadd $addclose -k "$var" fi else - _parameters + _parameters "$@" fi