From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: _zmodload
Date: Fri, 7 Jan 2000 11:28:30 +0100 (MET) [thread overview]
Message-ID: <200001071028.LAA21472@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Peter Stephenson's message of Thu, 06 Jan 2000 20:22:02 +0000
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@informatik.hu-berlin.de
next reply other threads:[~2000-01-07 11:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-01-07 10:28 Sven Wischnowsky [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-01-06 20:22 _zmodload Peter Stephenson
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=200001071028.LAA21472@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--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).