Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: _zmodload
- X-seq: zsh-workers 9263
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: _zmodload
- Date: Fri, 7 Jan 2000 11:28:30 +0100 (MET)
- In-reply-to: Peter Stephenson's message of Thu, 06 Jan 2000 20:22:02 +0000
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Peter Stephenson wrote:
> Completion for zmodload hasn't caught up with module hierarchies yet. The
> nicest way of doing this would be to use `_files -W module_path -g
> "*.so"' to match the modules and subdirectories (tags permitting) --- but
> then you need to strip the .so from the matches, and that appears to be
> hard. Any thoughts before I try and do it some less nice way? Option to
> transform the matches by a given parameter substitution in _path_files?
This makes patterns of the form '*(:r)' work with _path_files. Then it
makes _files handle -/g... correctly and it makes the sorting
qualifiers for the sort style be inserted at the beginning of the
qualifier list if there is any in the supplied pattern.
Then it changes _zmodload to use the thing you suggest.
Bye
Sven
diff -ru ../z.old/Completion/Builtins/_zmodload Completion/Builtins/_zmodload
--- ../z.old/Completion/Builtins/_zmodload Thu Jan 6 16:04:06 2000
+++ Completion/Builtins/_zmodload Fri Jan 7 11:27:12 2000
@@ -9,5 +9,5 @@
_wanted modules expl module && compadd "$expl[@]" - "${(@k)modules}"
else
_wanted files expl 'module file' &&
- compadd "$expl[@]" - ${^module_path}/*.s[ol](N:t:r)
+ _files "$expl[@]" -W module_path -/g '*.s[ol](:r)'
fi
diff -ru ../z.old/Completion/Core/_files Completion/Core/_files
--- ../z.old/Completion/Core/_files Thu Jan 6 16:04:09 2000
+++ Completion/Core/_files Fri Jan 7 10:47:08 2000
@@ -1,16 +1,16 @@
#autoload
-local opts opt type=file group
+local opts opt type=file glob group
opts=()
group=()
while getopts "P:S:qr:R:W:F:J:V:X:f/g:M:12n" opt; do
case "$opt" in
- /) [[ "$type" = file ]] && type=dir ;;
- g) [[ "$type" = (file|dir) ]] && type="$OPTARG" ;;
- [qn12]) opts=("$opts[@]" "-$opt" ) ;;
- [JV]) group=( "-$opt" "$OPTARG") ;;
- [^f]) opts=("$opts[@]" "-$opt" "$OPTARG") ;;
+ /) type="${type}dir" ;;
+ g) type="${type}glob"; glob="$OPTARG" ;;
+ [qn12]) opts=("$opts[@]" "-$opt" ) ;;
+ [JV]) group=( "-$opt" "$OPTARG") ;;
+ [^f]) opts=("$opts[@]" "-$opt" "$OPTARG") ;;
esac
done
@@ -20,9 +20,10 @@
fi
case "$type" in
-file) _tags all-files ;;
-dir) _tags directories all-files ;;
-*) _tags globbed-files directories all-files ;;
+*dir*glob*|*glob*dir) _tags globbed-files all-files ;;
+*glob*) _tags globbed-files directories all-files ;;
+*dir*) _tags directories all-files ;;
+*) _tags all-files ;;
esac
while _tags; do
@@ -39,7 +40,7 @@
group[2]=globbed-files
_setup globbed-files
fi
- _path_files "$opts[@]" -/g "$type" && return 0
+ _path_files "$opts[@]" -/g "$glob" && return 0
else
if (( $#group )); then
group[2]=directories
@@ -52,7 +53,11 @@
group[2]=globbed-files
_setup globbed-files
fi
- _path_files "$opts[@]" -g "$type" && return 0
+ if [[ "$type" = (*dir*glob*|*glob*dir*) ]]; then
+ _path_files "$opts[@]" -/g "$glob" && return 0
+ else
+ _path_files "$opts[@]" -g "$glob" && return 0
+ fi
fi
done
diff -ru ../z.old/Completion/Core/_path_files Completion/Core/_path_files
--- ../z.old/Completion/Core/_path_files Thu Jan 6 16:04:10 2000
+++ Completion/Core/_path_files Fri Jan 7 11:27:14 2000
@@ -6,7 +6,7 @@
local linepath realpath donepath prepath testpath exppath
local tmp1 tmp2 tmp3 tmp4 i orig eorig pre suf tpre tsuf opre osuf cpre
local pats haspats=no ignore group expl addpfx addsfx remsfx
-local nm=$compstate[nmatches] menu match matcher mopts atmp sort
+local nm=$compstate[nmatches] menu mspec matcher mopts atmp sort match
typeset -U prepaths exppaths
@@ -76,21 +76,21 @@
pats=("$pats[@]" ${=OPTARG})
haspats=yes
;;
- M) match="$OPTARG"
+ M) mspec="$OPTARG"
matcher=(-M "$OPTARG")
;;
esac
done
if (( ! ( $#group + $#expl ) )); then
- if [[ "$sopt" = -/ ]]; then
+ if [[ -z "$gopt" && "$sopt" = -/ ]]; then
_description directories expl directory
else
_description files expl file
fi
tmp1=$expl[(I)-M]
if (( tmp1 )); then
- match="$match $expl[1+tmp1]"
+ mspec="$mspec $expl[1+tmp1]"
if (( $#matcher )); then
matcher[2]="$matcher[2] $expl[1+tmp1]"
else
@@ -132,10 +132,10 @@
tmp2=()
for tmp1 in "$pats[@]"; do
- if [[ "$tmp1" = ?*\(\([^\|~]##\)\) ]]; then
- tmp2=( "$tmp2[@]" "${tmp1[1,-3]}${sort}))" )
- elif [[ "$tmp1" = ?*\([^\|~]##\) ]]; then
- tmp2=( "$tmp2[@]" "${tmp1[1,-2]}${sort})" )
+ if [[ "$tmp1" = (#b)(?*)(\(\([^\|~]##\)\)) ]]; then
+ tmp2=( "$tmp2[@]" "${match[1]}((${sort}${match[2][3,-1]}" )
+ elif [[ "$tmp1" = (#b)(?*)(\([^\|~]##\)) ]]; then
+ tmp2=( "$tmp2[@]" "${match[1]}(${sort}${match[2][2,-1]}" )
else
tmp2=( "$tmp2[@]" "${tmp1}(${sort})" )
fi
@@ -425,13 +425,13 @@
compadd -Qf "$mopts[@]" -p "$linepath$tmp4" -s "/${tmp3#*/}" \
-W "$prepath$realpath$testpath" "$ignore[@]" \
"$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \
- -M "r:|/=* r:|=* $match" "$group[@]" "$expl[@]" \
+ -M "r:|/=* r:|=* $mspec" "$group[@]" "$expl[@]" \
- "${(@)tmp1%%/*}"
else
compadd -Qf "$mopts[@]" -p "$linepath$tmp4" \
-W "$prepath$realpath$testpath" "$ignore[@]" \
"$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \
- -M "r:|/=* r:|=* $match" "$group[@]" "$expl[@]" \
+ -M "r:|/=* r:|=* $mspec" "$group[@]" "$expl[@]" \
- "$tmp1[@]"
fi
else
@@ -439,7 +439,7 @@
atmp=( -Qf "$mopts[@]" -p "$linepath$tmp4"
-W "$prepath$realpath$testpath" "$ignore[@]"
"$addpfx[@]" "$addsfx[@]" "$remsfx[@]"
- -M "r:|/=* r:|=* $match" "$group[@]" "$expl[@]" )
+ -M "r:|/=* r:|=* $mspec" "$group[@]" "$expl[@]" )
for i in "$tmp1[@]"; do
compadd "$atmp[@]" -s "/${i#*/}" - "${i%%/*}"
done
@@ -447,7 +447,7 @@
compadd -Qf "$mopts[@]" -p "$linepath$tmp4" \
-W "$prepath$realpath$testpath" "$ignore[@]" \
"$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \
- -M "r:|/=* r:|=* $match" "$group[@]" "$expl[@]" \
+ -M "r:|/=* r:|=* $mspec" "$group[@]" "$expl[@]" \
- "$tmp1[@]"
fi
fi
@@ -497,7 +497,7 @@
compadd -Qf "$mopts[@]" -p "$linepath$tmp4" \
-W "$prepath$realpath$testpath" "$ignore[@]" \
"$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \
- -M "r:|/=* r:|=* $match" "$group[@]" "$expl[@]" \
+ -M "r:|/=* r:|=* $mspec" "$group[@]" "$expl[@]" \
- "$tmp1[@]"
fi
done
@@ -513,7 +513,7 @@
PREFIX="${opre}"
SUFFIX="${osuf}"
compadd -Q "$mopts[@]" -S '' "$group[@]" "$expl[@]" \
- -M "r:|/=* r:|=* $match" -p "$linepath" - "$exppaths[@]"
+ -M "r:|/=* r:|=* $mspec" -p "$linepath" - "$exppaths[@]"
fi
[[ nm -ne compstate[nmatches] ]]
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author