summaryrefslogtreecommitdiff
path: root/Completion/User/_urls
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/User/_urls')
-rw-r--r--Completion/User/_urls91
1 files changed, 56 insertions, 35 deletions
diff --git a/Completion/User/_urls b/Completion/User/_urls
index 3989f2219..4234aa274 100644
--- a/Completion/User/_urls
+++ b/Completion/User/_urls
@@ -49,18 +49,22 @@ local localhttp_userdir="$localhttp[3]"
if [[ "$1" = -f ]]; then
shift
- _wanted -C -f files && _files "$@" && return
+ _wanted -C -f files _files "$@" && return 0
fi
ipre="$IPREFIX"
-if ! compset -P '(#b)([-+.a-z0-9]#):' && _wanted -C argument prefixes; then
- while _next_label prefixes expl 'URL prefix' "$@"; do
- [[ -d $urls_path/bookmark ]] &&
- compadd "$expl[@]" -S '' bookmark: && ret=0
- compadd "$expl[@]" -S '' file: ftp:// gopher:// http:// && ret=0
+if ! compset -P '(#b)([-+.a-z0-9]#):'; then
+ _tags -C argument prefixes
+ while _tags; do
+ while _next_label prefixes expl 'URL prefix' "$@"; do
+ [[ -d $urls_path/bookmark ]] &&
+ compadd "$expl[@]" -S '' bookmark: && ret=0
+ compadd "$expl[@]" -S '' file: ftp:// gopher:// http:// && ret=0
+ done
+ (( ret )) || return 0
done
- return ret
+ return 1
fi
scheme="$match[1]"
@@ -73,17 +77,19 @@ case "$scheme" in
;;
file)
if ! compset -P //; then
- _wanted -C file files || return 1
-
- while _next_label files expl 'local file' "$@"; do
- if [[ -prefix / ]]; then
- _path_files "$expl[@]" -S '' -g '*(^/)' && ret=0
- _path_files "$expl[@]" -S/ -r '/' -/ && ret=0
- elif [[ -z "$PREFIX" ]]; then
- compadd "$expl[@]" -S '/' -r '/' - "${PWD%/}" && ret=0
- fi
+ _tags -C file files
+ 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/ -r '/' -/ && ret=0
+ elif [[ -z "$PREFIX" ]]; then
+ compadd "$expl[@]" -S '/' -r '/' - "${PWD%/}" && ret=0
+ fi
+ done
+ (( ret )) || return 0
done
- return ret
+ return 1
fi
;;
bookmark)
@@ -93,34 +99,40 @@ case "$scheme" in
compadd "$@" -U - \
"$ipre$(<"$urls_path/$scheme/${(Q)PREFIX}${(Q)SUFFIX}")" && ret=0
else
- if _wanted -C bookmark files; then
+ _tags -C bookmark files
+ while _tags; do
while _next_label files expl 'bookmark'; do
_path_files -W "$urls_path/$scheme" "$expl[@]" -S '' -g '*(^/)' &&
ret=0
_path_files -W "$urls_path/$scheme" -S/ -r '/' -/ && ret=0
done
- fi
+ (( ret )) || return 0
+ done
fi
return ret
;;
esac
# Complete hosts
-if ! compset -P '(#b)([^/]#)/' && _wanted hosts; then
+if ! compset -P '(#b)([^/]#)/'; then
uhosts=($urls_path/$scheme/$PREFIX*$SUFFIX(/:t))
- while _next_label hosts expl host "$@"; do
- (( $#uhosts )) || _hosts -S/ && ret=0
- [[ "$scheme" = http ]] && uhosts=($uhosts $localhttp_servername)
- compadd "$expl[@]" -S/ - $uhosts && ret=0
+ _tags hosts
+ while _tags; do
+ while _next_label hosts expl host "$@"; do
+ (( $#uhosts )) || _hosts -S/ && ret=0
+ [[ "$scheme" = http ]] && uhosts=($uhosts $localhttp_servername)
+ compadd "$expl[@]" -S/ - $uhosts && ret=0
+ done
+ (( ret )) || return 0
done
- return ret
+ return 1
fi
host="$match[1]"
# Complete part after hostname
-_wanted -C local files || return 1
+_tags -C local files || return 1
if [[ "$localhttp_servername" = "$host" ]]; then
if compset -P \~; then
@@ -129,20 +141,29 @@ if [[ "$localhttp_servername" = "$host" ]]; then
return
fi
user="$match[1]"
- 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 -S/ -r '/' -/ && ret=0
+ 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 -S/ -r '/' -/ && ret=0
+ done
+ (( ret )) || return 0
done
else
- while _next_label files expl 'local file'; do
- _path_files "$expl[@]" -W $localhttp_documentroot -g '*(^/)' && ret=0
- _path_files "$expl[@]" -W $localhttp_documentroot -S/ -r '/' -/ && ret=0
+ 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 -S/ -r '/' -/ && ret=0
+ done
+ (( ret )) || return 0
done
fi
else
- 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 -S/ -r '/' -/ && ret=0
+ 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 -S/ -r '/' -/ && ret=0
+ done
+ (( ret )) || return 0
done
fi
return $ret