From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1546 invoked by alias); 7 Nov 2012 13:55:43 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17382 Received: (qmail 4504 invoked from network); 7 Nov 2012 13:55:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at yahoo.co.uk does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1352296168; bh=Ijup8H7YSXTljhJQaCnuO1gFXLyNvJMcKJXDaGt730Q=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Received:In-reply-to:From:References:To:Subject:Date:Message-ID; b=Da8gTEyC/HCWlfbD4a3giq1ZLR2J5Kd6wd3ESua+3xzQ+F3nXRkEA3tMP3jpW5NTJ7ptu0nuMU9y9fEZWgtlY8aXyEk4zAxHrPy2rPzHm227pmDN3zXg97hJ4P3094JLGA8awMSyKCiDbmHdLZ1cKHVIKh//Bl/K+tX/EPUniA4= X-Yahoo-Newman-Id: 413066.62444.bm@smtp141.mail.ukl.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: MtyNjkYVM1ki8_w8Rp0_CoaIyDQKLgrsXJ4NzOtx0H.ISBj DVKd_F4Jo_FTSKK5HYP6hx.PwXodBtzZDuDMNDcIGd6QDJ10eq8V1BhDHAZd JTXyK0SqmqBVGA2Hrk.ZeNYYl.KQ9Zp_eespySTii4prIHzBUpN5kKcGbNR0 asowglCJw2Br2GSxmPjNjqeF46IUfU8NEaFv380qTpfYZy70Q6dMKaqfdYsF K7F9V_RviGioJptCtIFhd4OOpfcOImZ8l013F9GKKDv4LHO2d8Om6VadRln6 vDKWa1PLHW4YclvRtf2HSkaeBS7wjaYhh9kA7XHdqfZf1s6m8biehGNYY6xp 27NASK7JmL48ObWpHdfJb5CLLtiNgB_uI9_HaKJ1V0UOFN6gaDKv7bYOZaE3 ItharWFBcH191.hQOGPjpTvnX9aDpdoF0Q1sy5w_V X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- In-reply-to: <12933.1352226046@thecus.kiddle.eu> From: Oliver Kiddle References: <12933.1352226046@thecus.kiddle.eu> To: shawn wilson , Zsh Users Subject: Re: vim scp autocomplete Date: Wed, 07 Nov 2012 14:49:27 +0100 Message-ID: <15999.1352296167@thecus.kiddle.eu> Actually, the main problem with _remote_files was that it was hard coded to use ${IPREFIX%:} for the remote host name. This adds a -h option for specifying the host. I've changed --no-files to -/ and added -g. There's no equivalent to the former --no-dirs option but if a function needs that, we should probably support something like the file-patterns style. I'll also move the function to Unix/Type from Base/Utilities. Oliver Index: Completion/Base/Utility/_remote_files =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_remote_files,v retrieving revision 1.1 diff -u -r1.1 _remote_files --- Completion/Base/Utility/_remote_files 9 Dec 2011 22:39:08 -0000 1.1 +++ Completion/Base/Utility/_remote_files 7 Nov 2012 13:30:37 -0000 @@ -4,11 +4,13 @@ # key-based authentication with no passwords or a running ssh-agent to work. # # Usage: -# _remote_files [--no-files] [--no-dirs] -- [] +# _remote_files [-/] [-g glob] [-h host] -- [] # # Options: -# - --no-files: don't complete remote files -# - --no-dirs: don't complete remote directories +# - -/: only complete directories +# - -g: specify a pattern to match against files +# p, = and * glob qualifiers supported +# - -h: specify the remote host, default is ${IPREFIX%:} # # Commands: # - ssh: Additional options for non-interactive use are automatically added @@ -27,12 +29,14 @@ # There should be coloring based on all the different ls -F classifiers. local expl rempat remfiles remdispf remdispd args cmd cmd_args suf ret=1 +local glob host if zstyle -T ":completion:${curcontext}:files" remote-access; then # Parse options to _remote_files. Stops at the first "--". - zparseopts -D -E -a args -no-files -no-dirs + zparseopts -D -E -a args / g:=glob h:=host shift + (( $#host)) && shift host || host="${IPREFIX%:}" # Command to run on the remote system. cmd="$1" @@ -51,23 +55,28 @@ else rempat="${(q)PREFIX%%[^./][^/]#}\*" fi - remfiles=(${(M)${(f)"$(_call_program files $cmd $cmd_args ${IPREFIX%:} ls -d1FL -- "$rempat" 2>/dev/null)"}%%[^/]#(|/)}) + remfiles=(${(M)${(f)"$(_call_program files $cmd $cmd_args $host ls -d1FL -- "$rempat" 2>/dev/null)"}%%[^/]#(|/)}) compset -P '*/' - compset -S '/*' || suf='remote file' + compset -S '/*' || (( ${args[(I)-/]} )) || suf='remote file' remdispf=(${remfiles:#*/}) remdispd=(${(M)remfiles:#*/}) + if (( $#glob )); then + match=( '(|[*=|])' ) + glob[2]="${glob[2]/(#b)\(((|^)[p=\*])\)(#e)/}" + glob[2]+="${${match[1]/p/\|}/\*/\*}" + remdispf=( ${(M)remdispf:#${~glob[2]}} ) + fi + _tags files while _tags; do while _next_label files expl ${suf:-remote directory}; do - [[ ${args[(I)--no-files]} -eq 0 ]] && \ - [[ -n $suf ]] && compadd "$@" "$expl[@]" -d remdispf \ - ${(q)remdispf%[*=@|]} && ret=0 - [[ ${args[(I)--no-dirs]} -eq 0 ]] && \ - compadd ${suf:+-S/} "$@" "$expl[@]" -d remdispd \ - ${(q)remdispd%/} && ret=0 + [[ -n $suf ]] && + compadd "$@" "$expl[@]" -d remdispf ${(q)remdispf%[*=|]} && ret=0 + compadd ${suf:+-S/} -r "/ \t\n\-" "$@" "$expl[@]" -d remdispd \ + ${(q)remdispd%/} && ret=0 done (( ret )) || return 0 done Index: Completion/Unix/Command/_git =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_git,v retrieving revision 1.167 diff -u -r1.167 _git --- Completion/Unix/Command/_git 6 Mar 2012 16:38:25 -0000 1.167 +++ Completion/Unix/Command/_git 7 Nov 2012 13:30:37 -0000 @@ -5451,7 +5451,7 @@ service= _ssh if compset -P '*:'; then - _remote_files --no-files -- ssh + _remote_files -/ -- ssh else _ssh_hosts -S: fi Index: Completion/Unix/Command/_vim =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_vim,v retrieving revision 1.11 diff -u -r1.11 _vim --- Completion/Unix/Command/_vim 10 Feb 2012 17:09:10 -0000 1.11 +++ Completion/Unix/Command/_vim 7 Nov 2012 13:30:37 -0000 @@ -4,6 +4,7 @@ _vim_files () { case $PREFIX in (+*) _files -P './' $* && return 0 ;; + (scp|http(|s)|(|s)ftp):*) _urls ;; (*) _files $* ;; esac case $PREFIX in @@ -21,14 +22,10 @@ '( -e -E -s -d -y)-v[vi mode]' '(-v -E -d -y)-e[ex mode]' '(-v -e -d -y)-E[improved ex mode]' - '(-v -e -E -s -y)-d[diff mode]' '(-v -e -E -s -d )-y[easy mode]' - '-R[readonly mode]' - '-Z[restricted mode]' '-m[modifications (writing files) not allowed]' '-M[modifications in text not allowed]' '-b[binary mode]' - '-g[start with GUI]' '-l[lisp mode]' '-C[start in compatible mode]' '-N[start in incompatible mode]' @@ -52,7 +49,6 @@ '(-A -H )-F[start in Farsi mode]' '-T[set terminal type]:::_terminals' '-u[use given vimrc file instead of default .vimrc]::rc file:_files' - '-U[use given gvimrc file instead of default .gvimrc]::rc file:_files' '--noplugin[do not load plugin scripts]' '-o-[number of windows to open (default: one for each file)]::window count: ' '-O-[number of windows to vertically split open (default is one for each file)]::window count: ' @@ -76,7 +72,6 @@ '--remote-tab-wait[as --remote-wait but open tab page for each file]:*:file:_vim_files' '--remote-tab-wait-silent[as --remote-wait-silent but open tab page for each file]:*:file:_vim_files' '--remote-expr[evaluate given expression in a vim server and print result]:expression: ' - '--echo-wid[echo window ID on STDOUT, GUI version only]' '--literal[do not expand wildcards in arguments (this is useless with ZSH)]' '(- *)--serverlist[list available vim servers and exit]' '--servername[name of vim server to send to or name of server to become]:server name:->server' @@ -88,6 +83,20 @@ '(* -q)-t[edit file where tag is defined]:tag:_complete_tag' '(-t -q)*:file:_vim_files' ) +[[ $service != *g* ]] && arguments+='-g[start with GUI]' +[[ $service != r* ]] && arguments+='-Z[restricted mode]' +[[ $service != *diff ]] && arguments+='(-v -e -E -s -y)-d[diff mode]' +[[ $service != *view ]] && arguments+='-R[readonly mode]' +[[ $service = *g* ]] || (( ${words[(I)-g]} )) && arguments+=( + '-font:font:_xft_fonts' + '-geometry:geometry:_x_geometry' + '(-rv -reverse)'{-rv,-reverse}'[use reverse video]' + '-display:display:_x_display' + '--role[set unique role to identify main window]:role' + '--socketid[open vim inside another GTK widget]:xid' + '--echo-wid[echo window ID on stdout]' + '-U[use given gvimrc file instead of default .gvimrc]::rc file:_files' +) _arguments -C -S $arguments && return Index: Completion/Unix/Type/_urls =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_urls,v retrieving revision 1.12 diff -u -r1.12 _urls --- Completion/Unix/Type/_urls 15 Nov 2009 17:52:02 -0000 1.12 +++ Completion/Unix/Type/_urls 7 Nov 2012 13:30:37 -0000 @@ -75,7 +75,7 @@ scheme="$match[1]" case "$scheme" in - http(|s)|ftp|gopher) + http(|s)|(|s)ftp|scp|gopher) if ! compset -P //; then _wanted -C "$scheme" prefixes expl 'end of prefix' compadd -S '' "$@" // return @@ -143,7 +143,7 @@ # Complete part after hostname -_tags -C local files || return 1 +_tags remote-files files || return 1 if [[ "$localhttp_servername" = "$host" ]]; then if compset -P \~; then @@ -170,10 +170,12 @@ fi else while _tags; do - while _next_label files expl 'local file'; do + (( $#urls )) && while _next_label files expl 'local file'; do _path_files "$expl[@]" "$@" -W $urls/$scheme/$host "${glob[@]}" && ret=0 _path_files -S/ -r '/' "$expl[@]" -W $urls/$scheme/$host -/ && ret=0 done + [[ $scheme = (scp|sftp) ]] && _requested remote-files && + _remote_files -h $host -- ssh && ret=0 (( ret )) || return 0 done fi