From: Oliver Kiddle <opk@u.genie.co.uk>
To: Zsh workers <zsh-workers@sunsite.auc.dk>
Subject: PATCH: _urls and _rpm
Date: Mon, 05 Jun 2000 23:09:20 +0100 [thread overview]
Message-ID: <393C2510.5F7D3880@u.genie.co.uk> (raw)
I've changed _urls so that it now takes any -g option it is passed and
passes it on to _files.
It would be useful if zparseopts returned 0 only if it found the option
specified so I didn't need to use (( $#glob )) but we'd have to decide
how it would act with more than one option specified. I'm not convinced
by what Bart said earlier about _urls not handling IPREFIX properly
(isn't it supposed to be ignored) but I haven't got easy access to his
e-mail here to check what he said again.
I've also changed _rpm to now use _urls in that one place.
Why does [[ -prefix (f|ht)tp:// ]] give me an error message about the
first bracket? Is that a bug. I got around it by putting a 1 before the
pattern.
Oliver Kiddle
Index: Completion/Linux/_rpm
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Linux/_rpm,v
retrieving revision 1.13
diff -u -u -r1.13 _rpm
--- Completion/Linux/_rpm 2000/06/05 02:23:53 1.13
+++ Completion/Linux/_rpm 2000/06/05 23:08:24
@@ -211,12 +211,14 @@
_files -g \*.spec && ret=0
;;
package_file)
- if compset -P '(f|ht)tp://'; then
- _hosts -S/ && ret=0
+ _wanted files expl 'RPM package file' \
+ _files -g '*.(#i)rpm' && ret=0
+ if [[ -prefix 1 (f|ht)tp:// ]]; then
+ _wanted urls expl 'URL of RPM package file' \
+ _urls -f -g '*.(#i)rpm' "${expl[@]}" && ret=0
else
- _alternative \
- 'files:RPM package file:_files -g \*.\(\#i\)rpm' \
- 'prefixes:URL prefix:compadd ftp:// http://' && ret=0
+ _wanted urls expl 'URL of RPM package file' \
+ compadd -S '' "${expl[@]}" ftp:// http:// && ret=0
fi
;;
package_src)
Index: Completion/User/_urls
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_urls,v
retrieving revision 1.10
diff -u -u -r1.10 _urls
--- Completion/User/_urls 2000/05/31 09:38:26 1.10
+++ Completion/User/_urls 2000/06/05 23:08:24
@@ -38,7 +38,7 @@
# E.g.:
# zstyle ':completion:*:urls' local www /usr/local/apache/htdocs public_html
-local ipre scheme host user uhosts ret=1 expl match
+local ipre scheme host user uhosts ret=1 expl match glob
local urls_path localhttp
zstyle -s ":completion:${curcontext}:urls" path urls_path ||
urls_path="${ZDOTDIR:-$HOME}/.zsh/urls"
@@ -52,6 +52,9 @@
_wanted -C -f files expl file _files "$@" && return 0
fi
+zparseopts -D -E 'g:=glob'
+(( $#glob )) || glob=( -g '*(^/)' )
+
ipre="$IPREFIX"
if ! compset -P '(#b)([-+.a-z0-9]#):'; then
@@ -82,7 +85,7 @@
while _tags; do
while _next_label files expl 'local file'; do
if [[ -prefix / ]]; then
- _path_files "$expl[@]" -S '' -g '*(^/)' && ret=0
+ _path_files "$expl[@]" -S '' "${glob[@]}" && ret=0
_path_files "$expl[@]" -S/ -r '/' -/ && ret=0
elif [[ -z "$PREFIX" ]]; then
compadd -S '/' -r '/' "$expl[@]" "$@" - "${PWD%/}" && ret=0
@@ -103,7 +106,7 @@
_tags -C bookmark files
while _tags; do
while _next_label files expl 'bookmark'; do
- _path_files -W "$urls_path/$scheme" "$expl[@]" -S '' -g '*(^/)' &&
+ _path_files -W "$urls_path/$scheme" "$expl[@]" -S '' "${glob[@]}" &&
ret=0
_path_files -W "$urls_path/$scheme" -S/ -r '/' "$expl[@]" -/ && ret=0
done
@@ -145,7 +148,7 @@
user="$match[1]"
while _tags; do
while _next_label files expl 'local file'; do
- _path_files "$expl[@]" "$@" -W ~$user/$localhttp_userdir -g '*(^/)' && ret=0
+ _path_files "$expl[@]" "$@" -W ~$user/$localhttp_userdir "${glob[@]}" && ret=0
_path_files -S/ -r '/' "$expl[@]" -W ~$user/$localhttp_userdir-/ && ret=0
done
(( ret )) || return 0
@@ -153,7 +156,7 @@
else
while _tags; do
while _next_label files expl 'local file'; do
- _path_files "$expl[@]" "$@" -W $localhttp_documentroot -g '*(^/)' && ret=0
+ _path_files "$expl[@]" "$@" -W $localhttp_documentroot "${glob[@]}" && ret=0
_path_files -S/ -r '/' "$expl[@]" -W $localhttp_documentroot -/ && ret=0
done
(( ret )) || return 0
@@ -162,7 +165,7 @@
else
while _tags; do
while _next_label files expl 'local file'; do
- _path_files "$expl[@]" "$@" -W $urls_path/$scheme/$host -g '*(^/)' && ret=0
+ _path_files "$expl[@]" "$@" -W $urls_path/$scheme/$host "${glob[@]}" && ret=0
_path_files -S/ -r '/' "$expl[@]" -W $urls_path/$scheme/$host -/ && ret=0
done
(( ret )) || return 0
next reply other threads:[~2000-06-05 23:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-06-05 22:09 Oliver Kiddle [this message]
2000-06-06 3:48 ` Bart Schaefer
2000-06-06 4:08 ` zparseopts (Re: PATCH: _urls and _rpm) Bart Schaefer
2000-06-06 9:58 ` Oliver Kiddle
2000-06-07 5:55 ` Bart Schaefer
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=393C2510.5F7D3880@u.genie.co.uk \
--to=opk@u.genie.co.uk \
--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).