From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27082 invoked by alias); 4 Dec 2012 02:44:43 -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: 17452 Received: (qmail 7068 invoked from network); 4 Dec 2012 02:44:40 -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: none (ns1.primenet.com.au: domain at negyesi.net does not designate permitted sender hosts) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:x-gm-message-state; bh=kSs3K3Yh1mCYCAonAEWQH3+D7nmMUJbqacvVamCvjWA=; b=kvXk7xOM8/TrwiGG9ELWN/swfG0ZCZ3G4U9jS2vgYKDmjqS+cmL2gqqv0vZfaR+XcM RiaFoJhK2x0eYpEX82Eg/JJlM9/91sKONkdTjDlxaSyo8/tkwJ++sKNCDRoTl9XGpf+K +jzcDvare6dPlu+I8zCmAhpbnvv1h+J2eYHWU/PQHP+mcneiTU7i6zOqdD/TFDL7ToQ+ NaVDDzQ5ScTTdq+OvNHp0egC57ww4D4MMs5Ua0McTjCu+9gDo6ACN+7HLpOJFcGYMQBW PWZlMEWiM+ScaEwPuT5tRHSvHns5HsXN0NnY1vhV2j2puTElhX9tIoW/VpPwdaaXwA8f WTEg== MIME-Version: 1.0 In-Reply-To: <20120821192732.20f7e6b4@pws-pc.ntlworld.com> References: <120818171826.ZM18675@torch.brasslantern.com> <20120819204458.7718bde9@pws-pc.ntlworld.com> <20120820095751.4e84470a@pwslap01u.europe.root.pri> <120820083351.ZM12926@torch.brasslantern.com> <20120821192732.20f7e6b4@pws-pc.ntlworld.com> From: Karoly Negyesi Date: Mon, 3 Dec 2012 18:13:40 -0800 Message-ID: Subject: Re: Recursive Completition To: Peter Stephenson Cc: zsh-users@zsh.org Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQk7kyPNU6T51mSE7XSAw9n6hpU0oy2T3N9heBoEKgOhUEhQ/WvTDX4ZXI3sAyeXwM+FYQsk Sorry for not getting back to you sooner on this but I wanted to say a big thanks because it works! On Tue, Aug 21, 2012 at 11:27 AM, Peter Stephenson wrote: > Here's a second version with documentation. > > 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 21 Aug 2012 18:24:15 -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 rfiles rfile > > 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,21 @@ 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 -a ":completion:${curcontext}:$tag" recursive-files rfiles; then > + for rfile in $rfiles; do > + if [[ $PWD/ = ${~rfile} ]]; then > + for prepath in **/*(/); do > + oprefix=$PREFIX > + PREFIX=$prepath/$PREFIX > + _path_files -g "$pat" "$opts[@]" "$expl[@]" && ret=0 > + PREFIX=$oprefix > + done > + break > + fi > + done > + fi > else > _path_files "$expl[@]" -g "$pat" "$opts[@]" && ret=0 > fi > Index: Doc/Zsh/compsys.yo > =================================================================== > RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v > retrieving revision 1.247 > diff -p -u -r1.247 compsys.yo > --- Doc/Zsh/compsys.yo 14 Feb 2012 17:01:17 -0000 1.247 > +++ Doc/Zsh/compsys.yo 21 Aug 2012 18:24:15 -0000 > @@ -2355,6 +2355,28 @@ found, or var(max) words have been tried > > The default is to complete all words from the history at once. > ) > +kindex(recursive-files, completion style) > +item(tt(recursive-files))( > +If this style is set, its value is an array of patterns to be > +tested against `tt($PWD/)': note the trailing slash, which allows > +directories in the pattern to be delimited unambiguously by including > +slashes on both sides. If an ordinary file completion fails > +and the word on the command line does not yet have a directory part to its > +name, the style is retrieved using the same tag as for the completion > +just attempted, then the elements tested against tt($PWD/) in turn. > +If one matches, then the shell reattempts completion by prepending the word > +on the command line with each directory in the expansion of tt(**/*(/)) > +in turn. Typically the elements of the style will be set to restrict > +the number of directories beneath the current one to a manageable > +number, for example `tt(*/.git/*)'. > + > +For example, > + > +example(zstyle ':completion:*' recursive-files '*/zsh/*') > + > +If the current directory is tt(/home/pws/zsh/Src), then > +tt(zle_tr)em(TAB) can be completed to tt(Zle/zle_tricky.c). > +) > kindex(regular, completion style) > item(tt(regular))( > This style is used by the tt(_expand_alias) completer and bindable > > -- > Peter Stephenson > Web page now at http://homepage.ntlworld.com/p.w.stephenson/