1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-17 10:20:55 +01:00

zsh-workers/8230

This commit is contained in:
Tanaka Akira 1999-10-13 13:47:21 +00:00
parent f67feb4054
commit ad92f96225
4 changed files with 148 additions and 26 deletions

75
Completion/User/_netscape Normal file
View file

@ -0,0 +1,75 @@
#compdef netscape
local state
_x_arguments \
'-xrm:resource:_x_resource' \
'-help[show usage message]' \
'-version[show the version number and build date]' \
'-visual[use a specific server visual]:id-or-number:' \
'-install[install a private colormap]' \
'-no-install[use the default colormap]' \
'-ncols[max no. of colors to allocate for images]:n:' \
'-mono[force 1-bit-deep image display]' \
'-iconic[start up iconified]' \
'-remote[execute a command in an existing Netscape]:remote command:->remote' \
'-id[id of X window to send remote commands to]:window-id:' \
'-raise[raise window following remote command]' \
"-noraise[don't raise window following remote command]" \
'-nethelp[show nethelp]' \
-{dont-force-window-stacking,no-about-splash} \
-{,no-}{,irix-}session-management \
-{done-save,ignore}-geometry-prefs \
-{component-bar,composer,edit,messenger,mail,discussions,news} \
'*:location:->urls'
[ "$state" = "urls" ] && _files "$@" && return
# 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 '*\('
case $IPREFIX in
openURL*|addBookmark* ) state=urls;;
openFile* ) _files -W ~;;
saveAs* )
if compset -P "*,"; then
compadd -s")" -M 'm:{a-zA-Z}={A-Za-z}' HTML Text PostScript
else
_path_files -W ~
fi
;;
mailto* )
compset -P "*,"
if compset -P '*@'; then
_description expl 'remote host name'
_hosts "$expl[@]" -q -S,
else
_description expl 'login name'
_users "$expl[@]" -q -S@
fi
;;
* )
if [ "$QIPREFIX" ]; then
compadd -q -S '(' -M 'm:{a-zA-Z}={A-Za-z}' $remote_commands
else
compadd -s'(' -S '' -M 'm:{a-zA-Z}={A-Za-z}' $remote_commands
fi
;;
esac
fi
if [ "$state" = "urls" ]; then
# Complete netscape urls
if [[ -prefix about: ]]; then
compset -P about:
compadd authors blank cache document fonts global hype image-cache \
license logo memory-cache mozilla plugins
else
compadd -S '' about: mocha: javascript:
_urls "$@"
fi
fi

View file

@ -4,7 +4,7 @@
# Options:
# -f : complete files.
#
# Configuration key used:
# Configuration keys used:
#
# urls_path
# The path to a directory containing a URL database, such as:
@ -28,8 +28,16 @@
# http://sunsite.auc.dk/zsh/
# % cat bookmark/zsh/meta
# http://www.zsh.org/
#
# urls_localhttp
# Specify a local web server in the form:
# hostname:doc root:user area
# where hostname is the name of the web server, doc root is the path to
# the default web pages for the server and user area is the directory
# name used by a user placing web pages within their home area.
# e.g. compconf urls_localhttp=www:/usr/local/apache/htdocs:public_html
local ipre scheme dirs files
local ipre scheme host user dirs files ret=1
if [[ "$1" = -f ]]; then
shift
@ -46,37 +54,67 @@ if [[ -prefix [-+.a-z0-9]#: ]]; then
scheme="${PREFIX%%:*}"
compset -P "[-+.a-z0-9]#:"
else
compadd "$@" -S '' http:// ftp:// bookmark: file:
return
[ -d $compconfig[urls_path]/bookmark ] &&
compadd "$@" -S '' bookmark: && ret=0
compadd "$@" -S '' file: ftp:// gopher:// http:// && ret=0
return $ret
fi
case "$scheme" in
http|ftp) compset -P // || { compadd "$@" -S '' //; return };;
http|ftp|gopher) compset -P // || { compadd "$@" -S '' //; return };;
file)
if [[ -prefix // ]]; then
compset -P //
elif [ -prefix / ]; then
_files "$@"
return
elif [ ! "$PREFIX" ]; then
compadd -S '/' ~+
return
if ! compset -P //; then
if [ -prefix / ]; then
_files "$@"
return
elif [ ! "$PREFIX" ]; then
compadd -S '/' - "${PWD%/}"
return
fi
fi
;;
bookmark)
if [[ -f "$compconfig[urls_path]/$scheme/$PREFIX$SUFFIX" &&
-s "$compconfig[urls_path]/$scheme/$PREFIX$SUFFIX" ]]; then
compadd "$@" -QU -- \
"$ipre$(<"$compconfig[urls_path]/$scheme/$PREFIX$SUFFIX")"
else
compadd "$@" -Q -S '/' - \
$compconfig[urls_path]/$scheme/$PREFIX*$SUFFIX(/:t) && ret=0
compadd "$@" -QS '' - \
$compconfig[urls_path]/$scheme/$PREFIX*$SUFFIX(.:t) || return $ret
fi
return
;;
esac
if [[ "$scheme" = bookmark &&
-f "$compconfig[urls_path]/$scheme/$PREFIX$SUFFIX" &&
-s "$compconfig[urls_path]/$scheme/$PREFIX$SUFFIX" ]]; then
compadd "$@" -QU -- "$ipre$(<"$compconfig[urls_path]/$scheme/$PREFIX$SUFFIX")"
else
dirs=($compconfig[urls_path]/$scheme/$PREFIX*$SUFFIX(/:t))
files=($compconfig[urls_path]/$scheme/$PREFIX*$SUFFIX(.:t))
compset -P '*/'
compadd "$@" -Q -S '/' - $dirs
if [[ "$scheme" = bookmark ]]; then
compadd "$@" -QS '' - $files
if [[ -prefix */* ]]; then
# Complete part after hostname
host=${PREFIX%%/*}
compset -P "$host/"
if [[ "$compconfig[urls_localhttp]" = ${host}:* ]]; then
if [[ -prefix \~ ]]; then
compset -P \~
if [[ -prefix */* ]]; then
user=${PREFIX%%/*}
compset -P $user/
_path_files -W ~$user/${${(s.:.)compconfig[urls_localhttp]}[3]}/
else
_users -S/
fi
else
_path_files -W ${${(s.:.)compconfig[urls_localhttp]}[2]}
fi
else
compadd "$@" -Q - $files
_path_files -W $compconfig[urls_path]/$scheme/$host/
fi
else
# Complete hosts
dirs=($compconfig[urls_path]/$scheme/$PREFIX*$SUFFIX(/:t))
(( $#dirs )) || _hosts -S/ && ret=0
[ "$scheme" = "http" ] &&
dirs=($dirs ${${(s.:.)compconfig[urls_localhttp]}[1]})
compadd "$@" -Q -S '/' - $dirs || return $ret
fi

View file

@ -1,3 +1,3 @@
#compdef amaya arena chimera express grail gzilla hotjava mmm mozilla netscape w3m www xmosaic Mosaic
#compdef amaya arena chimera express grail gzilla hotjava mmm mozilla w3m www xmosaic Mosaic
_urls -f

View file

@ -1658,6 +1658,15 @@ generate process IDs as matches. These functions will display the
output of tt(ps) called with the value of this key as its argument
when showing completion lists.
)
item(tt(urls_localhttp))(
This key is used by completion functions which generate URLs as
possible matches to add suitable matches when a URL points to a
local web server. Its value should be of the form
`tt(hostname:doc root:user area)' where hostname is the name of the web
server, doc root is the path to the default web pages for the server
and user area is the directory name used by a user placing web pages
within their home area
)
item(tt(urls_path))(
This key is used by completion functions that generate URLs as
possible matches. It should be set to the path of a directory