Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: urls (was: Re: new completion modifications)
- X-seq: zsh-workers 13814
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: PATCH: urls (was: Re: new completion modifications)
- Date: Wed, 28 Mar 2001 13:21:36 +0200 (MET DST)
- In-reply-to: "Bart Schaefer"'s message of Tue, 27 Mar 2001 17:57:43 +0000
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
Bart Schaefer wrote:
> On Mar 27, 1:06pm, Sven Wischnowsky wrote:
> }
> } path -- removed
> } urls -- if it has only one value
> } if that is the name of a directory: like path now
> } elif it is the name of a normal file: list of urls from the file
> } otherwise the values are the urls
> }
> } In any case local is unchanged.
>
> This would be fine with me.
Yes, I preferred that one, too.
Bye
Sven
Index: Completion/User/_urls
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_urls,v
retrieving revision 1.16
diff -u -r1.16 _urls
--- Completion/User/_urls 2001/03/11 22:53:41 1.16
+++ Completion/User/_urls 2001/03/28 11:19:43
@@ -6,7 +6,7 @@
#
# Configuration styles used:
#
-# path
+# urls
# The path to a directory containing a URL database, such as:
#
# % cd ~/.zsh/urls
@@ -29,6 +29,9 @@
# % cat bookmark/zsh/meta
# http://www.zsh.org/
#
+# Alternatively it may contain the path to a normal file and the URLs will
+# be taken from that. Or the style may contain the URLs as its values.
+#
# local
# Specify a local web server as an array with three elements:
# <hostname> <doc root> <user area>
@@ -39,9 +42,7 @@
# zstyle ':completion:*:urls' local www /usr/local/apache/htdocs public_html
local ipre scheme host user uhosts ret=1 expl match glob suf
-local urls_path localhttp
-zstyle -s ":completion:${curcontext}:urls" path urls_path ||
- urls_path="${ZDOTDIR:-$HOME}/.zsh/urls"
+local localhttp
zstyle -a ":completion:${curcontext}:urls" local localhttp
local localhttp_servername="$localhttp[1]"
local localhttp_documentroot="$localhttp[2]"
@@ -52,6 +53,16 @@
_wanted -C -f files expl file _files "$@" && return 0
fi
+zstyle -a ":completion:${curcontext}:urls" urls urls
+
+if [[ $#urls -gt 1 || ( $#urls -eq 1 && ! -d $urls[1] ) ]]; then
+ [[ $#urls -eq 1 && -f $urls[1] ]] && urls=( $(< $urls[1]) )
+ _wanted urls expl 'urls' compadd -a urls && return 0
+ urls=()
+fi
+
+urls="$urls[1]"
+
glob=(-g '*(^/)')
zparseopts -D -K -E 'g:=glob'
@@ -62,7 +73,7 @@
while _tags; do
while _next_label prefixes expl 'URL prefix' -S '' "$@"; do
compset -S '[^:/]*' && compstate[to_end]=''
- [[ -d $urls_path/bookmark ]] &&
+ [[ -d $urls/bookmark ]] &&
compadd "$expl[@]" bookmark: && ret=0
compadd "$expl[@]" file: ftp:// gopher:// http:// && ret=0
done
@@ -97,18 +108,18 @@
fi
;;
bookmark)
- if [[ -f "$urls_path/$scheme/${(Q)PREFIX}${(Q)SUFFIX}" &&
- -s "$urls_path/$scheme/${(Q)PREFIX}${(Q)SUFFIX}" ]]; then
+ if [[ -f "$urls/$scheme/${(Q)PREFIX}${(Q)SUFFIX}" &&
+ -s "$urls/$scheme/${(Q)PREFIX}${(Q)SUFFIX}" ]]; then
_wanted -C bookmark bookmarks expl bookmarks \
compadd "$@" -U - \
- "$ipre$(<"$urls_path/$scheme/${(Q)PREFIX}${(Q)SUFFIX}")" && ret=0
+ "$ipre$(<"$urls/$scheme/${(Q)PREFIX}${(Q)SUFFIX}")" && ret=0
else
_tags -C bookmark files
while _tags; do
while _next_label files expl 'bookmark'; do
- _path_files -W "$urls_path/$scheme" "$expl[@]" -S '' "${glob[@]}" &&
+ _path_files -W "$urls/$scheme" "$expl[@]" -S '' "${glob[@]}" &&
ret=0
- _path_files -W "$urls_path/$scheme" -S/ -r '/' "$expl[@]" -/ && ret=0
+ _path_files -W "$urls/$scheme" -S/ -r '/' "$expl[@]" -/ && ret=0
done
(( ret )) || return 0
done
@@ -119,7 +130,7 @@
# Complete hosts
if ! compset -P '(#b)([^:/]#)([:/])'; then
- uhosts=($urls_path/$scheme/$PREFIX*$SUFFIX(/:t))
+ uhosts=($urls/$scheme/$PREFIX*$SUFFIX(/:t))
_tags hosts
while _tags; do
@@ -167,8 +178,8 @@
else
while _tags; do
while _next_label files expl 'local file'; do
- _path_files "$expl[@]" "$@" -W $urls_path/$scheme/$host "${glob[@]}" && ret=0
- _path_files -S/ -r '/' "$expl[@]" -W $urls_path/$scheme/$host -/ && ret=0
+ _path_files "$expl[@]" "$@" -W $urls/$scheme/$host "${glob[@]}" && ret=0
+ _path_files -S/ -r '/' "$expl[@]" -W $urls/$scheme/$host -/ && ret=0
done
(( ret )) || return 0
done
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.112
diff -u -r1.112 compsys.yo
--- Doc/Zsh/compsys.yo 2001/03/27 13:03:51 1.112
+++ Doc/Zsh/compsys.yo 2001/03/28 11:19:46
@@ -810,7 +810,7 @@
)
kindex(urls, completion tag)
item(tt(urls))(
-used to look up the tt(path) and tt(local) styles when completing URLs
+used to look up the tt(urls) and tt(local) styles when completing URLs
)
kindex(users, completion tag)
item(tt(users))(
@@ -1808,18 +1808,8 @@
)
kindex(path, completion style)
item(tt(path))(
-This is used together with the the tt(urls) tag by completion
-functions that generate URLs as possible matches. It should be set to
-the path of a directory containing sub-directories named after the
-retrieval methods which occur as the first part of a URL, i.e.
-`tt(http)', `tt(ftp)', `tt(bookmark)', and so on. These
-sub-directories should contain files and other sub-directories whose
-pathnames are possible completions after the initial `tt(http://)',
-`tt(ftp://)', etc. See the description in the file tt(_urls) in the
-tt(User) sub-directory of the completion system for more information.
-
-The function that completes color names also uses this style with the
-tt(colors) tag. Here, the value should be the pathname of a file
+The function that completes color names uses this style with the
+tt(colors) tag. The value should be the pathname of a file
containing color names in the format of an X11 tt(rgb.txt) file. If
the style is not set but this file is found in one of various standard
locations it will be used as the default.
@@ -2117,6 +2107,26 @@
sensible default behavior that causes arguments (whether normal command
arguments or arguments of options) to be completed before option names for
most commands.
+)
+kindex(urls, completion style)
+item(tt(urls))(
+This is used together with the the tt(urls) tag by completion
+functions that generate URLs as possible matches. If the value
+consists of more than one string or if the only string does not name a
+file or directory, the strings are used as the URLs to complete.
+
+If the value contains only one string and that is the name of a normal
+file, the URLs are taken from that file (where the URLs may be
+separated by white space or newlines).
+
+Finally, if the only string in the value names a directory, that
+should contain sub-directories named after the
+retrieval methods which occur as the first part of a URL, i.e.
+`tt(http)', `tt(ftp)', `tt(bookmark)', and so on. These
+sub-directories should contain files and other sub-directories whose
+pathnames are possible completions after the initial `tt(http://)',
+`tt(ftp://)', etc. See the description in the file tt(_urls) in the
+tt(User) sub-directory of the completion system for more information.
)
kindex(use-cache, completion style)
item(tt(use-cache))(
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author