From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18831 invoked from network); 6 May 2001 19:43:49 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 6 May 2001 19:43:49 -0000 Received: (qmail 29506 invoked by alias); 6 May 2001 19:43:44 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 14235 Received: (qmail 29493 invoked from network); 6 May 2001 19:43:43 -0000 From: "Bart Schaefer" Message-Id: <1010506194240.ZM21879@candle.brasslantern.com> Date: Sun, 6 May 2001 19:42:40 +0000 X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.dk Subject: PATCH: Improve handling of b/n/s subscript flags MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii The delimiters following the b/n/s flags are allowed to be matched pairs of parens, brackets, or braces, so the `compset -P' had to change so as not to treat the close-paren of such a pair as the close-paren of the flags. These can't nest, so it's possible to match them with a pattern. (I note in passing that it's impossible to use a close-paren in the string argument of the `s' flag; that is, you can't split into words on parens, so it's not important that you can't complete that.) I've included code to handle e.g. (s[string]), but with `$scalar[(s[' on the line we arrive in _subscript with the `(s[' already moved into $IPREFIX and so `compset -P \(' fails and we branch into `_contexts -math-'. I'm not sure what code has to change to fix this; I suspect it's in C somewhere. The next change to make to this is to discover that i/I/r/R are in the flags and NOT complete in math context (for arrays) or association keys (assoc's). --- zsh-forge/current/Completion/Zsh/Context/_subscript Sat May 5 13:09:50 2001 +++ zsh-4.0/Completion/Zsh/Context/_subscript Sun May 6 12:15:53 2001 @@ -8,15 +8,39 @@ shift fi -compset -P '\([^\)]##\)' # remove subscript flags +compset -P '\(([^\(\)]|*\(*\)*)##\)' # remove subscript flags if [[ "$PREFIX" = :* ]]; then _wanted characters expl 'character class' \ compadd -p: -S ':]' alnum alpha blank cntrl digit graph \ lower print punct space upper xdigit elif compset -P '\('; then + local match compset -S '\)*' + if [[ $PREFIX = (#b)*([bns])(?|)(*) ]]; then + local f=$match[1] d=$match[2] e=$match[2] v=$match[3] + [[ $f = s && ${(Pt)${compstate[parameter]}} != scalar ]] && return 1 + if [[ -z $d ]]; then + _message 'delimiter' + return + else + case $d in + (\() e=\);; + (\[) e=\];; + (\{) e=\};; + esac + if [[ $v != *$e* ]]; then + case $f in + (s) _message 'separator string';; + (b|n) [[ $v = <-># ]] && _message 'number' || return 1;; + esac + [[ -n $v && $SUFFIX$ISUFFIX != *$e* ]] && _message 'delimiter' + return 0 + fi + fi + fi + case ${(Pt)${compstate[parameter]}} in assoc*) flags=( '(R k K i I)r[any one value matched by subscript as pattern]' -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net