zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh-workers@sunsite.auc.dk (Zsh hackers list)
Subject: PATCH: _path_files -/
Date: Wed, 24 Feb 1999 18:03:36 +0100	[thread overview]
Message-ID: <9902241703.AA53847@ibmth.df.unipi.it> (raw)

Here's a small patch which stops _path_files -/ from returning matches for
non-directories when the path before the last component gets expanded.
Maybe Sven has a better way of doing this.  One thing I'm not sure about is
that (e.g.) ./F/C/<TAB> doesn't give ./Functions/Completion/ because it
wants another directory after the final /.  The question is whether we
should get any directory under that one, when there is one, or whether in
the first instance we should get ./Functions/Completion/, which is what you
would get if that last slash wasn't there, and only next start completing
in the directory.

--- Functions/Completion/_path_files.bk	Wed Feb 24 17:54:45 1999
+++ Functions/Completion/_path_files	Wed Feb 24 17:54:49 1999
@@ -26,7 +26,7 @@
 # Yes, so...
 
 local nm prepaths str linepath realpath donepath patstr prepath testpath rest
-local tmp1 collect tmp2 suffixes i ignore matchflags
+local tmp1 collect tmp2 suffixes i ignore matchflags comp_dirs
 
 setopt localoptions nullglob rcexpandparam globdots extendedglob
 unsetopt markdirs globsubst shwordsplit nounset
@@ -87,6 +87,7 @@
     complist "$tmp1[@]" -g "$argv[2,-1]"
     shift
   else
+    [[ $1 = -/ ]] && comp_dirs=1
     complist "$tmp1[@]" $1
     shift
   fi
@@ -206,6 +207,7 @@
       collect=()
       suffixes=( $rest$@ )
       suffixes=( "${(@)suffixes:gs.**.*.}" )
+      [[ -n $comp_dirs ]] && suffixes=( ${suffixes}"(-/)" )
 
       # In the loop the prefixes from the `tmp1' array produced above and
       # the suffixes we just built are used to produce possible matches
@@ -277,6 +279,7 @@
   tmp1="$prepath$realpath$testpath"
   suffixes=( $str$@ )
   suffixes=( "${(@)suffixes:gs.**.*.}" )
+  [[ -n $comp_dirs ]] && suffixes=( ${suffixes}"(-/)" )
   tmp2=( ${~tmp1}${~matchflags}${~suffixes} )
   compadd -p "$linepath$testpath" -W "$prepath$realpath$testpath" -f "$ignore[@]" - ${tmp2#$tmp1}
 done

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


             reply	other threads:[~1999-02-25  9:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-24 17:03 Peter Stephenson [this message]
1999-02-25 10:17 Sven Wischnowsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9902241703.AA53847@ibmth.df.unipi.it \
    --to=pws@ibmth.df.unipi.it \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).