From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22164 invoked by alias); 14 May 2011 05:58:27 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 29278 Received: (qmail 5094 invoked from network); 14 May 2011 05:58:24 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <110513225805.ZM13712@torch.brasslantern.com> Date: Fri, 13 May 2011 22:58:03 -0700 In-reply-to: Comments: In reply to Mikael Magnusson "Re: squeeze-slashes false not working?" (May 13, 10:07pm) References: <20110513191710.657d2f61@pws-pc.ntlworld.com> <20110513195324.6ab90eb2@pws-pc.ntlworld.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh workers Subject: PATCH Re: squeeze-slashes false not working? MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On May 13, 10:07pm, Mikael Magnusson wrote: } } Okay, I'll try to sum up :). Starting from zsh -f + compinit, with } path-files on and squeeze-slashes off (the default), I get this } behaviour: ls //// jumps back to the first slash and allows me to } complete components in /. Yep, I get that too. But once something is completed (e.g. /home///), subsequent completions treat the trailing "///" as if it were a single slash. This certainly contradicts the assertion in the doc for squeeze-slashes that by default it behaves as if /*/*/. } With the same and path-files off, it simply behaves as if I had ls } /, ie it completes components in / after the four slashes. You mean path-completion off, but yes. In this case it *should* be happening this way because } squeeze-slashes on and path-completion on behaves as the second case. } squeeze-slashes on and path-completion off behaves the same way. These are as expected. Once it has skipped the slashes there's nothing for path-completion to act upon. } When I type ls /*/*/, all paths matching that glob are inserted } on the command line, this does not equal any of the above results. Red herring. Tab is expand-or-complete and as soon as you explicitly put in glob characters you're invoking the "expand" instead of the "complete". } In almost none of the above have I seen any evidence that with } squeeze-slashes on, is any repeated slashes treated as an asterisk } appearing between them though. :) When the doc for squeeze-slashes says "as if there were a star between" it is referring to the internal behavior of the match generation, not to what would have happened if the command line contained "/*/" before you started completing. It's a shorter way of saying "as if there were some part of a path component name between every pair of adjacent slashes on the command line, so that the match function had something to work with, except in this case the path component is empty so the function falls back on grabbing everything it possibly can." Anyway, almost the entire implementation of squeeze-slashes is: # Check if we have to skip over sequences of slashes. The value of $skips # is used below to match the pathname components we always have to accept # immediately. if zstyle -t ":completion:${curcontext}:paths" squeeze-slashes; then skips='((.|..|)/)##' else skips='((.|..)/)##' fi This is followed by using skips here: tmp2="${(M)tpre##${~skips}}" tpre="${tpre#$tmp2}" And indeed for "ls ////" with squeeze-slashes off that is +_path_files:410> tmp2='' +_path_files:411> tpre=/// +_path_files:413> tmp1=( / ) Whereas with squeeze-slashes on it is +_path_files:410> tmp2=/// +_path_files:411> tpre='' +_path_files:413> tmp1=( //// ) However, as soon as there's anything after the first slash, THAT CODE IS NEVER REACHED for the consecutive slashes. We get down to here: # There are more components, so skip over the next components and make a # slash be added. tmp1=( ${tmp1//(#b)([][()|*?^#~<>\\=])/\\${match[1]}} ) tmp2="${(M)tpre##((.|..|)/)##}" if [[ -n "$tmp2" ]]; then skipped="/$tmp2" tpre="${tpre#$tmp2}" else skipped=/ fi Looks like we need a reference to $skips at that assignment to tmp2 on line 577. +_path_files:576> tmp1=( /home ) +_path_files:577> tmp2=// +_path_files:578> [[ -n // ]] +_path_files:579> skipped=/// +_path_files:580> tpre='' So try this; but there may be other places where similar things have been missed as this function evolved ... Index: Completion/Unix/Type/_path_files =================================================================== RCS file: /extra/cvsroot/zsh/zsh-4.0/Completion/Unix/Type/_path_files,v retrieving revision 1.23 diff -u -r1.23 _path_files --- Completion/Unix/Type/_path_files 6 May 2011 15:29:05 -0000 1.23 +++ Completion/Unix/Type/_path_files 14 May 2011 05:53:20 -0000 @@ -574,7 +574,7 @@ # slash be added. tmp1=( ${tmp1//(#b)([][()|*?^#~<>\\=])/\\${match[1]}} ) - tmp2="${(M)tpre##((.|..|)/)##}" + tmp2="${(M)tpre##${~skips}}" if [[ -n "$tmp2" ]]; then skipped="/$tmp2" tpre="${tpre#$tmp2}" --