1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-26 13:51:05 +01:00

Do a better job of completing suffixes in netscape remote commands (11471)

This commit is contained in:
Oliver Kiddle 2000-05-19 18:44:21 +00:00
parent 2f6db0a72a
commit f97eaa4579
3 changed files with 28 additions and 17 deletions

View file

@ -1,3 +1,8 @@
2000-05-19 Oliver Kiddle <opk@zsh.org>
* 11471: Completion/User/_netscape, Completion/User/_urls: do
a better job of completing suffixes in netscape remote commands
2000-05-19 Peter Stephenson <pws@cambridgesiliconradio.com>
* zsh-users/3071: Completion/Core/compdump: avoid HOME=/

View file

@ -1,6 +1,6 @@
#compdef netscape
local curcontext="$curcontext" state line ret=1
local curcontext="$curcontext" state line ret=1 suf
typeset -A opt_args
_x_arguments -C \
@ -27,24 +27,27 @@ _x_arguments -C \
[[ "$state" = "urls" ]] &&
_files "$@" && return 0
# Handle netscape remote commands
if [[ "$state" = "remote" ]]; then
local -a remote_commands
remote_commands=(openURL openFile saveAs mailto addBookmark)
[[ $compstate[quoting] = (double|single) ]] && compset -q
compset -P '*\('
if compset -S '(|\\)\)*'; then
set - -S "" "$@"
else
set - -S"${${QIPREFIX:+)}:-\)}$compstate[quote] " "$@"
fi
case $IPREFIX in
openURL*|addBookmark*) state=urls;;
openFile*) _files -W ~;;
openFile*) _files "$@" -W ~;;
saveAs*)
if compset -P "*,"; then
_wanted types expl 'data type' \
compadd -s")" -M 'm:{a-zA-Z}={A-Za-z}' HTML Text PostScript &&
ret=0
compadd "$@" -M 'm:{a-zA-Z}={A-Za-z}' HTML Text PostScript && ret=0
else
_files -W ~ && ret=0
compset -S ",*" || suf=","
_files -qS "$suf" -W ~ && ret=0
fi
;;
mailto*)
@ -52,12 +55,14 @@ if [[ "$state" = "remote" ]]; then
if compset -P '*@'; then
_wanted hosts expl 'remote host name' _hosts -q -S, && ret=0
else
_wanted users expl 'login name' _users -q -S@ && ret=0
compset -S "@*" || suf="@"
_wanted users expl 'login name' _users -q -S "$suf" && ret=0
fi
;;
*)
compset -S '(|\\)\(*' || suf="${${QIPREFIX:+(}:-\(}"
_wanted commands expl 'remote commands' \
compadd -qS "${${QIPREFIX:+(}:-\(}" -M 'm:{a-zA-Z}={A-Za-z}' - \
compadd -qS "$suf" -M 'm:{a-zA-Z}={A-Za-z}' - \
$remote_commands && ret=0
;;
esac
@ -67,14 +72,15 @@ if [[ "$state" = "urls" ]]; then
# Complete netscape urls
if compset -P about: ; then
_wanted values expl 'about what' \
compadd authors blank cache document fonts global hype image-cache \
compadd "$@" authors blank cache document fonts global hype image-cache \
license logo memory-cache mozilla plugins && ret=0
else
_tags prefixes
while _tags; do
while _next_label prefixes expl 'URL prefix'; do
compadd "$expl[@]" -S '' about: mocha: javascript: && ret=0
_urls "$@" && ret=0
compset -S '[^:]*'
compadd "$expl[@]" -S '' about: mocha: javascript: && ret=0
done
(( ret )) || return 0
done

View file

@ -57,7 +57,7 @@ ipre="$IPREFIX"
if ! compset -P '(#b)([-+.a-z0-9]#):'; then
_tags -C argument prefixes
while _tags; do
while _next_label prefixes expl 'URL prefix' "$@"; 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
@ -79,7 +79,7 @@ case "$scheme" in
if ! compset -P //; then
_tags -C file files
while _tags; do
while _next_label files expl 'local file' "$@"; 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
@ -119,7 +119,7 @@ if ! compset -P '(#b)([^/]#)/'; then
_tags hosts
while _tags; do
while _next_label hosts expl host "$@"; 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
@ -143,7 +143,7 @@ if [[ "$localhttp_servername" = "$host" ]]; then
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 -g '*(^/)' && ret=0
_path_files "$expl[@]" -W ~$user/$localhttp_userdir -S/ -r '/' -/ && ret=0
done
(( ret )) || return 0
@ -151,7 +151,7 @@ if [[ "$localhttp_servername" = "$host" ]]; then
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 -g '*(^/)' && ret=0
_path_files "$expl[@]" -W $localhttp_documentroot -S/ -r '/' -/ && ret=0
done
(( ret )) || return 0
@ -160,7 +160,7 @@ 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 -g '*(^/)' && ret=0
_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