* PATCH: -qrR for _path_files
@ 1999-03-11 13:58 Sven Wischnowsky
0 siblings, 0 replies; only message in thread
From: Sven Wischnowsky @ 1999-03-11 13:58 UTC (permalink / raw)
To: zsh-workers
This makes `_path_files' accept the `-q', `-r chars', and `-R func'
options (since it already supported `-S' we should allow them). It
also makes the support for `-P' and `-S' be documented and fixes a
little bug in `_long_options' which I didn't bother to send an extra
patch for.
Bye
Sven
diff -u -r oc/Core/_path_files Completion/Core/_path_files
--- oc/Core/_path_files Thu Mar 11 14:31:28 1999
+++ Completion/Core/_path_files Thu Mar 11 14:54:58 1999
@@ -2,13 +2,15 @@
# Utility function for in-path completion.
# Supported arguments are: `-f', `-/', `-g <patterns>', `-J <group>',
-# `-V <group>', `-W paths', `-X explanation', and `-F <ignore>'. All but
-# the last have the same syntax and meaning as for `compgen'. The
-# `-F <ignore>' option may be used to give a list of suffixes either by
-# giving the name of an array or literally by giving them in a string
-# surrounded by parentheses. Files with one of the suffixes thus given
-# are treated like files with one of the suffixes in the `fignore' array
-# in normal completion.
+# `-V <group>', `-W paths', `-X explanation', `-P prefix', `-S suffix',
+# `-q', `-r remove-chars', `-R remove-func', and `-F <ignore>'. All but
+# the last have the same syntax and meaning as for `compgen' or
+# `compadd', respectively. The `-F <ignore>' option may be used to give
+# a list of suffixes either by giving the name of an array or
+# literally by giving them in a string surrounded by
+# parentheses. Files with one of the suffixes thus given are treated
+# like files with one of the suffixes in the `fignore' array in normal
+# completion.
#
# This function uses the helper functions `_match_test' and `_match_pattern'.
@@ -20,7 +22,7 @@
local nm prepaths str linepath realpath donepath patstr prepath testpath rest
local tmp1 collect tmp2 suffixes i ignore matchflags opt group sopt pats gopt
-local addpfx addsfx expl orig ostr nm=$compstate[nmatches] menu
+local addpfx addsfx expl orig ostr nm=$compstate[nmatches] menu remsfx
setopt localoptions nullglob rcexpandparam extendedglob
unsetopt markdirs globsubst shwordsplit nounset
@@ -33,16 +35,21 @@
pats=()
addpfx=()
addsfx=()
+remsfx=()
expl=()
# Get the options.
-while getopts "P:S:W:F:J:V:X:f/g:" opt; do
+while getopts "P:S:qr:R:W:F:J:V:X:f/g:" opt; do
case "$opt" in
P) addpfx=(-P "$OPTARG")
;;
S) addsfx=(-S "$OPTARG")
;;
+ q) tmp1=yes
+ ;;
+ [rR]) remsfx=("-$opt" "$OPTARG")
+ ;;
W) tmp1="$OPTARG"
if [[ "$tmp1[1]" = '(' ]]; then
prepaths=( ${^=tmp1[2,-2]}/ )
@@ -76,6 +83,8 @@
esac
done
+[[ -n "$tmp1" && $#addsfx -ne 0 ]] && addsfx[1]=-qS
+
# If we were given no file selection option, we behave as if we were given
# a `-f'.
@@ -105,9 +114,9 @@
# We will first try normal completion called with `compgen', but only if we
-# weren't given a `-F' option.
+# weren't given a `-F', `-r', or `-R' option.
-if (( ! $#ignore )); then
+if (( ! ( $#ignore + $#remsfx ) )); then
# First build an array containing the `-W' option, if there is any and we
# want to use it. We don't want to use it if the string from the command line
# is a absolute path or relative to the current directory.
@@ -340,7 +349,7 @@
compadd -QU -S '' "$group[@]" "$expl[@]" \
-i "$IPREFIX" -f - "${linepath:q}${testpath:q}$ostr"
else
- compadd -U "$addpfx[@]" "$addsfx[@]" "$group[@]" "$expl[@]" \
+ compadd -U "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" "$group[@]" "$expl[@]" \
-i "$IPREFIX" -p "$linepath$testpath" -f "$ignore[@]" \
-W "$prepath$realpath$testpath" - "${(@)tmp2#$tmp1}"
fi
diff -u -r oc/User/_long_options Completion/User/_long_options
--- oc/User/_long_options Wed Mar 10 17:03:28 1999
+++ Completion/User/_long_options Thu Mar 11 14:38:33 1999
@@ -88,7 +88,7 @@
# that contain uppercase letters are removed.
opts=("--${(@)^${(@)${(@)${(@M)${(@ps:\n:j:\n:)${(@)${(@M)${(@f)$("$words[1]" --help)}:#[ ]#-*}//,/
-}}:#*--*}#*--}%%[, ]*}:#(*-[A-Z]*|)}")
+}}:#[ ]#--*}#*--}%%[, ]*}:#(*-[A-Z]*|)}")
# The interpretation of the options is completely table driven. We
# use the positional parameters we were given and a few standard
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1999-03-11 14:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-11 13:58 PATCH: -qrR for _path_files Sven Wischnowsky
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).