From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7247 invoked from network); 14 Oct 1999 18:09:04 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 14 Oct 1999 18:09:04 -0000 Received: (qmail 24702 invoked by alias); 14 Oct 1999 18:08:54 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8263 Received: (qmail 24695 invoked from network); 14 Oct 1999 18:08:53 -0000 To: zsh-workers@sunsite.auc.dk Subject: Re: setopt localoptions noautoremoveslash References: MIME-Version: 1.0 (generated by AKEMI 1.13.2 - =?ISO-2022-JP?B?Ig==?= =?ISO-2022-JP?B?GyRCQTA0Y0s8GyhCIg==?=) Content-Type: text/plain; charset=US-ASCII From: Tanaka Akira Date: 15 Oct 1999 03:08:51 +0900 In-Reply-To: Zefram's message of "Thu, 14 Oct 1999 18:15:34 +0100 (BST)" Message-ID: User-Agent: Chao-gnus/6.12.5 AKEMI/1.13.2 (=?ISO-2022-JP?B?GyRCQTAbKEI=?= =?ISO-2022-JP?B?GyRCNGNLPBsoQg==?=) FLAM-DOODLE/1.12.6 (=?ISO-2022-JP?B?GyRCM3cbKEI=?= 10R4.0/5.0) Emacs/20.4 (sparc-sun-solaris2.6) MULE/4.0 (HANANOEN) In article , Zefram writes: > The removable suffix ought to be completely under user control, set on a > per-match basis. (Some of the built-in completions, such as completion > after $, already give different removable suffixes for different matches.) > AUTO_REMOVE_SLASH is only intended to apply to normal directory completion. I see. I modifed _urls to call _path_files twice: for directories and other files. Index: Completion/User/_urls =================================================================== RCS file: /projects/zsh/zsh/Completion/User/_urls,v retrieving revision 1.1.1.7 diff -u -F^( -r1.1.1.7 _urls --- Completion/User/_urls 1999/10/13 17:50:35 1.1.1.7 +++ Completion/User/_urls 1999/10/14 18:02:54 @@ -2,7 +2,7 @@ # Usage: _urls [-f] # Options: -# -f : complete files. +# -f : complete files first. # # Configuration keys used: # @@ -38,84 +38,89 @@ # e.g. compconf urls_localhttp=www:/usr/local/apache/htdocs:public_html local ipre scheme host user dirs files ret=1 expl +local urls_path="${compconfig[urls_path]:-${ZDOTDIR:-$HOME}/.zsh/urls}" +local localhttp_servername="${${(@s.:.)compconfig[urls_localhttp]}[1]}" +local localhttp_documentroot="${${(@s.:.)compconfig[urls_localhttp]}[2]}" +local localhttp_userdir="${${(@s.:.)compconfig[urls_localhttp]}[3]}" if [[ "$1" = -f ]]; then shift _files "$@" && return fi -if [[ -z "$compconfig[urls_path]" ]]; then - compconfig[urls_path]=${ZDOTDIR:-$HOME}/.zsh/urls -fi - ipre="$IPREFIX" -if [[ -prefix [-+.a-z0-9]#: ]]; then - scheme="${PREFIX%%:*}" - compset -P "[-+.a-z0-9]#:" -else +if ! [[ -prefix [-+.a-z0-9]#: ]]; then _description expl 'URL prefix' - [[ -d $compconfig[urls_path]/bookmark ]] && - compadd "$@" "$expl[@]" -S '' bookmark: && ret=0 + [[ -d $urls_path/bookmark ]] && + compadd "$@" "$expl[@]" -S '' bookmark: && ret=0 compadd "$@" "$expl[@]" -S '' file: ftp:// gopher:// http:// && ret=0 return $ret fi +scheme="${PREFIX%%:*}" +compset -P "[-+.a-z0-9]#:" + case "$scheme" in - http|ftp|gopher) compset -P // || { compadd "$@" -S '' //; return };; + http|ftp|gopher) + if ! compset -P //; then + compadd "$@" -S '' // + return + fi + ;; file) if ! compset -P //; then if [ -prefix / ]; then _files "$@" - return elif [ ! "$PREFIX" ]; then compadd -S '/' - "${PWD%/}" - return fi + return 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")" + if [[ -f "$urls_path/$scheme/$PREFIX$SUFFIX" && + -s "$urls_path/$scheme/$PREFIX$SUFFIX" ]]; then + compadd "$@" -QU -- "$ipre$(<"$urls_path/$scheme/$PREFIX$SUFFIX")" && ret=0 else - compadd "$@" -Q -S '/' - \ - $compconfig[urls_path]/$scheme/$PREFIX*$SUFFIX(/:t) && ret=0 - compadd "$@" -QS '' - \ - $compconfig[urls_path]/$scheme/$PREFIX*$SUFFIX(.:t) || return $ret + _description expl 'bookmark' + _path_files -W "$urls_path/$scheme" "$expl[@]" -S '' -g '*(^/)' && ret=0 + _path_files -W "$urls_path/$scheme" -S/ -r '' -/ && ret=0 fi - return + return $ret ;; esac -if [[ -prefix */* ]]; then +# Complete hosts +if ! [[ -prefix */* ]]; then + dirs=($urls_path/$scheme/$PREFIX*$SUFFIX(/:t)) + (( $#dirs )) || _hosts -S/ && ret=0 + [ "$scheme" = "http" ] && + dirs=($dirs $localhttp_servername) + compadd "$@" -QS/ - $dirs && ret=0 + return $ret +fi - # 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 +# 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/$localhttp_userdir -g '*(^/)' && ret=0 + _path_files -W ~$user/$localhttp_userdir -S/ -r '' -/ && ret=0 else - _path_files -W ${${(s.:.)compconfig[urls_localhttp]}[2]} + _users -S/ && ret=0 fi else - _path_files -W $compconfig[urls_path]/$scheme/$host/ + _path_files -W $localhttp_documentroot -g '*(^/)' && ret=0 + _path_files -W $localhttp_documentroot -S/ -r '' -/ && ret=0 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 + _path_files -W $urls_path/$scheme/$host/ -g '*(^/)' && ret=0 + _path_files -W $urls_path/$scheme/$host/ -S/ -r '' -/ && ret=0 fi +return $ret -- Tanaka Akira