From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4721 invoked by alias); 19 Aug 2012 19:53:37 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17205 Received: (qmail 10144 invoked from network); 19 Aug 2012 19:53:24 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 Received-SPF: neutral (ns1.primenet.com.au: 74.125.82.43 is neither permitted nor denied by SPF record at ntlworld.com) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-proxyuser-ip:date:from:to:subject:message-id:in-reply-to :references:x-mailer:mime-version:content-type :content-transfer-encoding:x-gm-message-state; bh=qoSdw4w3wGxo2EyMpzFtSwDNL2UaFssy5u1rhJfHEmM=; b=G/oJP0ocjbOBqryv67hdptpYbJg7Pp7P4/L2mrmXd5ozhWtC+HUIP6OSgQkoA/kIcW sf+4BmPv9d3i9IE3lnvKOiLUpOpgLQcAa+fwK3GCVwZcCggEd7waWp2SgmF15gQMbhp+ Hh2tMmeDdjLWwKxiyYSt/V9rEFdURkgo9tZPzhNpzJ8T8HfCh7rP/AaVhwXO9duR/2DK g6acHr7EhFUnKeefwEj5YZOkIZD9UlqJEvY7/rAVwCr1CEOnMXHzYhtMfJjxa3124cm4 x+QbXFQKoC+hsg2DsnGt6Olklc/uvVB4zC2pMVUu4nmsjkB8OzAg1BnlqbcoqowE1dzI nQwQ== X-ProxyUser-IP: 86.6.16.18 Date: Sun, 19 Aug 2012 20:44:58 +0100 From: Peter Stephenson To: zsh-users@zsh.org Subject: Re: Recursive Completition Message-ID: <20120819204458.7718bde9@pws-pc.ntlworld.com> In-Reply-To: <120818171826.ZM18675@torch.brasslantern.com> References: <120818171826.ZM18675@torch.brasslantern.com> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQli+cflQSMJO2qzNm/L/+4g/Wb+E60p1O5qndkXcytoKntjGVKTPXAqiOg5uf2VM/QcbluA On Sat, 18 Aug 2012 17:18:26 -0700 Bart Schaefer wrote: > } Perfect would be just > } > } ls Kern[tab] > } > } to do that. I am aware of the performance implications -- could this > } be restricted to the user's home dir only so it doesnt try to read the > } whole OS when in the root. > > This one would require that you create a new widget or a new completion > function to insert the implicit leading **/ in the right contexts. It's > certainly do-able, but I'm going to leave it as an exercise for someone > else, this time. Bizarrely, I think I've got this to work as part of normal file completion, ish. No, honestly. Set the recursive-files style to true and see if this does the right thing. No documentation yet. It only works if there's no "/" in the word on the command line at the point completion is tried. I can't be sure this is the best place to put it in the file completion calling sequence, but that statement is so obvious as hardly to be worth mentioning... I wonder if there's some limit we can apply to stop this going haywire? Index: Completion/Unix/Type/_files =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_files,v retrieving revision 1.13 diff -p -u -r1.13 _files --- Completion/Unix/Type/_files 19 Mar 2010 16:38:26 -0000 1.13 +++ Completion/Unix/Type/_files 19 Aug 2012 19:40:55 -0000 @@ -1,7 +1,7 @@ #compdef -redirect-,-default-,-default- local opts tmp glob pat pats expl tag i def descr end ign ret=1 match tried -local type sdef ignvars ignvar +local type sdef ignvars ignvar prepath oprefix zparseopts -a opts \ '/=tmp' 'f=tmp' 'g+:-=tmp' q n 1 2 P: S: r: R: W: X+: M+: F: J+: V+: @@ -118,7 +118,16 @@ for def in "$pats[@]"; do while _next_label "$tag" expl "$descr"; do _comp_ignore=( $_comp_ignore $ign ) if [[ -n "$end" ]]; then - _path_files -g "$pat" "$opts[@]" "$expl[@]" && ret=0 + if _path_files -g "$pat" "$opts[@]" "$expl[@]"; then + ret=0 + elif [[ $PREFIX$SUFFIX != */* ]] && zstyle -t ":completion:${curcontext}:" recursive-files; then + for prepath in **/*(/); do + oprefix=$PREFIX + PREFIX=$prepath/$PREFIX + _path_files -g "$pat" "$opts[@]" "$expl[@]" && ret=0 + PREFIX=$oprefix + done + fi else _path_files "$expl[@]" -g "$pat" "$opts[@]" && ret=0 fi -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/