Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: _path_files -/
- X-seq: zsh-workers 5516
- From: Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx (Zsh hackers list)
- Subject: PATCH: _path_files -/
- Date: Wed, 24 Feb 1999 18:03:36 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
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@xxxxxxxxxxxxxxxxx> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
Messages sorted by:
Reverse Date,
Date,
Thread,
Author