From ad92f962259d359e561d1c0f657f6a731739b3e1 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Wed, 13 Oct 1999 13:47:21 +0000 Subject: zsh-workers/8230 --- Completion/User/_netscape | 75 ++++++++++++++++++++++++++++++++++++++ Completion/User/_urls | 88 ++++++++++++++++++++++++++++++++------------- Completion/User/_webbrowser | 2 +- Doc/Zsh/compsys.yo | 9 +++++ 4 files changed, 148 insertions(+), 26 deletions(-) create mode 100644 Completion/User/_netscape diff --git a/Completion/User/_netscape b/Completion/User/_netscape new file mode 100644 index 000000000..f176083d2 --- /dev/null +++ b/Completion/User/_netscape @@ -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 diff --git a/Completion/User/_urls b/Completion/User/_urls index 422c249d8..04fe934e7 100644 --- a/Completion/User/_urls +++ b/Completion/User/_urls @@ -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 diff --git a/Completion/User/_webbrowser b/Completion/User/_webbrowser index eb65aa2f2..e5b7e0ebd 100644 --- a/Completion/User/_webbrowser +++ b/Completion/User/_webbrowser @@ -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 diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index 82265ffd0..1cd61a22f 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -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 -- cgit 1.4.1