summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Completion/User/_urls37
-rw-r--r--Doc/Zsh/compsys.yo36
3 files changed, 50 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index c877f137a..ecf63fd92 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2001-03-28  Sven Wischnowsky  <wischnow@zsh.org>
 
+	* 13814: Completion/User/_urls, Doc/Zsh/compsys.yo: replace
+	`path' with more general `urls' style
+
 	* 13813: Completion/Core/_multi_parts: make sure _multi_parts
 	doesn't add the empty string as a possible completion
 
diff --git a/Completion/User/_urls b/Completion/User/_urls
index 78a72f890..7567f362c 100644
--- a/Completion/User/_urls
+++ b/Completion/User/_urls
@@ -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 @@ if [[ "$1" = -f ]]; then
   _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 @@ if ! compset -P '(#b)([-+.a-z0-9]#):'; then
   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 @@ case "$scheme" in
     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 @@ esac
 
 # 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 @@ if [[ "$localhttp_servername" = "$host" ]]; then
 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
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 0456ba8c3..227b90fdb 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -810,7 +810,7 @@ for types of whatever (e.g. address types for the tt(xhost) command)
 )
 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 @@ to be completed for `dpkg --status'.
 )
 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.
@@ -2118,6 +2108,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))(
 If this is set, the completion caching layer is activated for any completions