From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20802 invoked from network); 13 Mar 2000 12:17:36 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 13 Mar 2000 12:17:36 -0000 Received: (qmail 23832 invoked by alias); 13 Mar 2000 12:17:29 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10112 Received: (qmail 23814 invoked from network); 13 Mar 2000 12:17:28 -0000 Date: Mon, 13 Mar 2000 13:17:08 +0100 (MET) Message-Id: <200003131217.NAA18673@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: "Bart Schaefer"'s message of Sun, 12 Mar 2000 21:36:29 +0000 Subject: Re: PATCH: _groups and _condition Bart Schaefer wrote: > On Mar 12, 3:22pm, Oliver Kiddle wrote: > } Subject: PATCH: _groups and _condition > } > } Also here, is a patch against _condition so that it completes only files > } after more of its options. > > This question isn't really directed at Oliver, but: > > Out of curiosity, why doesn't _condition complete any of the options > themselves? E.g. If I do > > zsh% [[ - > > it just inserts a space. I expected it to list -n, -z, -t, etc. Because it's really old and noone took the time to change it. The patch also fixes a problem when completing after `[[ ... && ' -- it thought it were in command position. Bye Sven diff -ru ../z.old/Completion/Base/_condition Completion/Base/_condition --- ../z.old/Completion/Base/_condition Mon Mar 13 11:14:30 2000 +++ Completion/Base/_condition Mon Mar 13 13:14:20 2000 @@ -1,11 +1,55 @@ #compdef -condition- -local prev="$words[CURRENT-1]" +local prev="$words[CURRENT-1]" ret=1 if [[ "$prev" = -o ]]; then _tags -C -o options && _options elif [[ "$prev" = -([a-hkprsuwxLOGSN]|[no]t|ef) ]]; then _tags -C "$prev" files && _files else - _alternative 'files:: _files' 'parameters:: _parameters' + if [[ "$PREFIX" = -* ]] || + ! zstyle -T ":completion:${curcontext}:options" prefix-needed; then + + if [[ "$prev" = (\[\[|\|\||\&\&|\!|\() ]]; then + _describe -o 'condition code' \ + '( -a:existing\ file + -b:block\ special\ file + -c:character\ special\ file + -d:directory + -e:existing\ file + -f:regular\ file + -g:setgid\ bit + -h:symbolic\ link + -k:sticky\ bit + -n:non-empty\ string + -o:option + -p:named\ pipe + -r:readable\ file + -s:non-empty\ file + -t:terminal\ file\ descriptor + -u:setuid\ bit + -w:writable\ file + -x:executable\ file + -z:empty\ string + -L:symbolic\ link + -O:own\ file + -G:group-owned\ file + -S:socket + -N:unread\ file)' && ret=0 + else + _describe -o 'condition code' \ + '( -nt:newer\ than + -ot:older\ than + -ef:same\ file + -eq:numerically\ equal + -ne:numerically\ not\ equal + -lt:numerically\ less\ than + -le:numerically\ less\ then\ or\ equal + -lt:numerically\ greater\ than + -le:numerically\ greater\ then\ or\ equal)' && ret=0 + fi + fi + _alternative 'files:: _files' 'parameters:: _parameters' && ret=0 + + return ret fi diff -ru ../z.old/Src/Zle/zle_tricky.c Src/Zle/zle_tricky.c --- ../z.old/Src/Zle/zle_tricky.c Mon Mar 13 11:14:14 2000 +++ Src/Zle/zle_tricky.c Mon Mar 13 13:11:36 2000 @@ -978,7 +978,7 @@ * this would be to pass the command line through the parser too, * * and get the arguments that way. Maybe in 3.1... */ do { - lincmd = ((incmdpos && !ins) || (oins == 2 && i == 2) || + lincmd = ((incmdpos && !ins && !incond) || (oins == 2 && i == 2) || (ins == 3 && i == 1)); linredir = (inredir && !ins); oins = ins; @@ -1023,7 +1023,7 @@ if (tok == ENDINPUT) break; if ((ins && (tok == DO || tok == SEPER)) || - (ins == 2 && i == 2) || (ins == 3 && i == 3) || + (ins == 2 && i == 2) || (ins == 3 && i == 3) || tok == BAR || tok == AMPER || tok == BARAMP || tok == AMPERBANG || ((tok == DBAR || tok == DAMPER) && !incond)) { @@ -1060,6 +1060,12 @@ inwhat = IN_COND; } else if (linredir) continue; + if (incond) { + if (tok == DBAR) + tokstr = "||"; + else if (tok == DAMPER) + tokstr = "&&"; + } if (!tokstr) continue; /* Hack to allow completion after `repeat n do'. */ -- Sven Wischnowsky wischnow@informatik.hu-berlin.de