From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21378 invoked from network); 21 Jan 2002 16:11:05 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 21 Jan 2002 16:11:05 -0000 Received: (qmail 8954 invoked by alias); 21 Jan 2002 16:10:59 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 16472 Received: (qmail 8940 invoked from network); 21 Jan 2002 16:10:57 -0000 From: Sven Wischnowsky MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15436.15674.724403.240491@wischnow.berkom.de> Date: Mon, 21 Jan 2002 17:09:30 +0100 To: zsh-workers@sunsite.dk Subject: Re: PATCH: _file_systems & Re: zstyle for _arguments feature request In-Reply-To: <20020107160652.11027.qmail@web9303.mail.yahoo.com> References: <15417.46354.791905.730459@wischnow.berkom.de> <20020107160652.11027.qmail@web9303.mail.yahoo.com> X-Mailer: VM 6.95 under 21.5 (patch 3) "asparagus" XEmacs Lucid Oliver Kiddle wrote: > --- Sven Wischnowsky wrote: > > > > And here is a patch for this. Not very nice, because we use $_comps > > in several places and I've just added `eval's there. Probably should > > be put into a separate function, but somehow it looks to small and > > simple for that. > > It could be useful as a utility function anyway though. That it would > be used in _su convinces me. Including the $service setting stuff would > make it slightly less small. Perhaps it could be merged with _contexts > which is similar anyway. > > > This, too, I'm not going to commit until I get replies. > > It looks good to me and seems to work well. Using eval instead of $=tmp > is not something I'd thought about. I suppose it might be useful to get > at one of the special variables like $words or $QIPREFIX. Here is a better patch and I'm going to commit it this time. I've left the calls to `eval' in _complete and _normal, these functions are just too specialised to put that code into a separate function (and they are part of the core system anyway). For _su I've given _contexts an option (-o) that makes the contexts be or'ed, i.e. _contexts returns as soon as completions could be generated for one of the contexts. Bye Sven Index: Completion/Base/Completer/_complete =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Base/Completer/_complete,v retrieving revision 1.1 diff -u -r1.1 _complete --- Completion/Base/Completer/_complete 2001/04/02 11:06:01 1.1 +++ Completion/Base/Completer/_complete 2002/01/21 16:03:55 @@ -85,7 +85,7 @@ ccarray[3]="$compcontext" comp="$_comps[$compcontext]" - [[ -z "$comp" ]] || "$comp" + [[ -n "$comp" ]] && eval "$comp" fi return @@ -94,10 +94,10 @@ # An entry for `-first-' is the replacement for `compctl -T' comp="$_comps[-first-]" -if [[ ! -z "$comp" ]]; then +if [[ -n "$comp" ]]; then service="${_services[-first-]:--first-}" ccarray[3]=-first- - "$comp" && ret=0 + eval "$comp" && ret=0 if [[ "$_compskip" = all ]]; then _compskip= return ret @@ -135,8 +135,8 @@ fi comp="$_comps[-default-]" fi - [[ -z "$comp" ]] || - service="${_services[-default-]:--default-}" && "$comp" && ret=0 + [[ -n "$comp" ]] && + service="${_services[-default-]:--default-}" && eval "$comp" && ret=0 fi _compskip= Index: Completion/Base/Core/_normal =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Base/Core/_normal,v retrieving revision 1.1 diff -u -r1.1 _normal --- Completion/Base/Core/_normal 2001/04/02 11:04:04 1.1 +++ Completion/Base/Core/_normal 2002/01/21 16:03:55 @@ -19,7 +19,7 @@ curcontext="${curcontext%:*:*}:-command-:" comp="$_comps[-command-]" - [[ -z "$comp" ]] || "$comp" && ret=0 + [[ -n "$comp" ]] && eval "$comp" && ret=0 return ret else @@ -86,7 +86,7 @@ if [[ -n "$comp" ]]; then _compskip=patterns - "$comp" && ret=0 + eval "$comp" && ret=0 [[ "$_compskip" = (all|*patterns*) ]] && return ret elif [[ "$_compskip" != *default* ]]; then name=-default- @@ -121,7 +121,7 @@ fi [[ "$name" = -default- && -n "$comp" && "$_compskip" != (all|*default*) ]] && - service="${_services[-default-]:--default-}" && "$comp" && ret=0 + service="${_services[-default-]:--default-}" && eval "$comp" && ret=0 _compskip='' Index: Completion/Base/Utility/_contexts =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_contexts,v retrieving revision 1.1 diff -u -r1.1 _contexts --- Completion/Base/Utility/_contexts 2001/04/02 11:10:27 1.1 +++ Completion/Base/Utility/_contexts 2002/01/21 16:03:55 @@ -7,11 +7,17 @@ # `_contexts -math-' to get the completions that would be generated for a # mathematical context. -local i tmp ret=1 service +local i tmp ret=1 service or +if [[ $1 = -o ]]; then + or=yes + shift +fi + for i; do tmp="$_comps[$i]" - [[ -z "$tmp" ]] || service="${_services[$i]:-$i}" && "$tmp" && ret=0 + [[ -n "$tmp" ]] && service="${_services[$i]:-$i}" && eval "$tmp" && ret=0 + [[ -n "$or" && ret -eq 0 ]] && return 0 done return ret Index: Completion/Unix/Command/_su =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_su,v retrieving revision 1.1 diff -u -r1.1 _su --- Completion/Unix/Command/_su 2001/04/02 12:03:16 1.1 +++ Completion/Unix/Command/_su 2002/01/21 16:03:55 @@ -16,7 +16,5 @@ shell="${${(M@)${(@f)$(