From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4752 invoked from network); 18 Feb 1999 15:24:05 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 18 Feb 1999 15:24:05 -0000 Received: (qmail 27999 invoked by alias); 18 Feb 1999 15:22:56 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5419 Received: (qmail 27992 invoked from network); 18 Feb 1999 15:22:54 -0000 Date: Thu, 18 Feb 1999 16:22:11 +0100 (MET) Message-Id: <199902181522.QAA08463@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: "Bart Schaefer"'s message of Sat, 13 Feb 1999 11:19:37 -0800 Subject: Re: PATCH: compadd (+ questions) Bart Schaefer wrote: > [ completion tests and resetting the completion parameters... ] > > That's just a matter of more shell functions: > > listsignals() { complist -k "($signals[1,-3])" } > tryprefix - listsignals > > but you're right that a real syntactic construct would be much cleaner. > > Maybe we can figure out a way to make "local" work inside { ... } ? I've > seen some postings on zsh-users that lead me to believe some people think > it does already. We could use aliases in the meantime: alias compsave='local _oprefix$_level _oiprefix$_level _oargv$_level _ocurrent$_level; \ eval "_oprefix${_level}=\"\$PREFIX\"; \ _oiprefix${_level}=\"\$IPREFIX\"; \ _oargv${_level}=( \"\$@\" ); \ _ocurrent${_level}=\"\$CURRENT\""' alias compreset='eval "PREFIX=\"\$_oprefix${_level}\"; \ IPREFIX=\"\$_oiprefix${_level}\"; \ argv=( \"\$_oargv${_level}[@]\" ); \ CURRENT=\"\$_ocur${_level}\""' alias __if='(( $+_level )) || local _level=0; (( _level++ )); compsave; if' alias __elif='compreset; elif' alias __else='compreset; else' alias __fi='compreset; fi; unset _oprefix$_level _oiprefix$_level _oargv$_level _ocurrent$_level; (( _level-- ))' With this one can use `__if ... __elif ... __else ... __fi' for tests in completion functions (even nested) without having to worry about calling comp{save,reset}. But of course that's quite expensive... Bye Sven -- Sven Wischnowsky wischnow@informatik.hu-berlin.de