diff options
author | Bram Moolenaar <Bram@vim.org> | 2005-11-25 19:54:28 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2005-11-25 19:54:28 +0000 |
commit | 1afcace307a11080c4876e6bbaf0fb8073c61bad (patch) | |
tree | eb2b1940394596027d45e8e730ab4747dc306aaa /runtime/autoload | |
parent | c20658076d1f1a92beff718ded3fe71f486ef6e8 (diff) |
updated for version 7.0159
Diffstat (limited to 'runtime/autoload')
-rw-r--r-- | runtime/autoload/netrw.vim | 834 |
1 files changed, 497 insertions, 337 deletions
diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 5a06bb0a27..4f74fbb8ad 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -1,36 +1,96 @@ " netrw.vim: Handles file transfer and remote directory listing across a network " AUTOLOAD PORTION -" Last Change: Aug 31, 2005 +" Date: Nov 18, 2005 +" Version: 75 " Maintainer: Charles E Campbell, Jr <drchipNOSPAM at campbellfamily dot biz> " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " Copyright: Copyright (C) 1999-2005 Charles E. Campbell, Jr. {{{1 " Permission is hereby granted to use and distribute this code, " with or without modifications, provided that this copyright " notice is copied with it. Like anything else that's free, -" netrw.vim is provided *as is* and comes with no warranty -" of any kind, either expressed or implied. By using this -" plugin, you agree that in no event will the copyright -" holder be liable for any damages resulting from the use +" netrw.vim, netrwPlugin.vim, and netrwSettings.vim are provided +" *as is* and comes with no warranty of any kind, either +" expressed or implied. By using this plugin, you agree that +" in no event will the copyright holder be liable for any damages +" resulting from the use of this software. " of this software. " " But be doers of the Word, and not only hearers, deluding your own selves {{{1 " (James 1:22 RSV) " =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -let s:keepcpo= &cpo -set cpo&vim -" call Decho("doing autoload/netrw.vim") + +" Exception for &cp: {{{1 +if &cp || exists("g:loaded_netrw") + finish +endif +let g:loaded_netrw = "v75" if v:version < 700 echohl WarningMsg | echo "***netrw*** you need vim version 7.0 or later for version ".g:loaded_netrw." of netrw" | echohl None finish endif +let s:keepcpo= &cpo +set cpo&vim +" call Decho("doing autoload/netrw.vim") " --------------------------------------------------------------------- -" Default values for global netrw variables {{{1 -if !exists("g:netrw_ftpmode") - let g:netrw_ftpmode= "binary" +" Default values for netrw's global protocol variables {{{1 +if !exists("g:netrw_dav_cmd") + let g:netrw_dav_cmd = "cadaver" endif -if !exists("g:netrw_win95ftp") - let g:netrw_win95ftp= 1 +if !exists("g:netrw_fetch_cmd") + if executable("fetch") + let g:netrw_fetch_cmd = "fetch -o" + else + let g:netrw_fetch_cmd = "" + endif +endif +if !exists("g:netrw_ftp_cmd") + let g:netrw_ftp_cmd = "ftp" +endif +if !exists("g:netrw_http_cmd") + if executable("wget") + let g:netrw_http_cmd = "wget -q -O" + elseif executable("fetch") + let g:netrw_http_cmd = "fetch -o" + else + let g:netrw_http_cmd = "" + endif +endif +if !exists("g:netrw_rcp_cmd") + let g:netrw_rcp_cmd = "rcp" +endif +if !exists("g:netrw_rsync_cmd") + let g:netrw_rsync_cmd = "rsync" +endif +if !exists("g:netrw_scp_cmd") + let g:netrw_scp_cmd = "scp -q" +endif +if !exists("g:netrw_sftp_cmd") + let g:netrw_sftp_cmd = "sftp" +endif +if !exists("g:netrw_ssh_cmd") + let g:netrw_ssh_cmd= "ssh" +endif + +if has("win32") || has("win95") || has("win64") || has("win16") + \ && exists("g:netrw_use_nt_rcp") + \ && g:netrw_use_nt_rcp + \ && executable( $SystemRoot .'/system32/rcp.exe') + let s:netrw_has_nt_rcp = 1 + let s:netrw_rcpmode = '-b' + else + let s:netrw_has_nt_rcp = 0 + let s:netrw_rcpmode = '' +endif + +" --------------------------------------------------------------------- +" Default values for netrw's global variables {{{1 +" Default values - a-c ---------- {{{2 +if !exists("g:netrw_alto") + let g:netrw_alto= 0 +endif +if !exists("g:netrw_altv") + let g:netrw_altv= 0 endif if !exists("g:netrw_cygwin") if has("win32") || has("win95") || has("win64") || has("win16") @@ -43,14 +103,15 @@ if !exists("g:netrw_cygwin") let g:netrw_cygwin= 0 endif endif -if !exists("g:netrw_list_cmd") - if executable("ssh") - " provide a default listing command - let g:netrw_list_cmd= "ssh HOSTNAME ls -FLa" - else -" call Decho("ssh is not executable, can't do remote directory exploring with ssh") - let g:netrw_list_cmd= "" - endif +" Default values - d-f ---------- {{{2 +if !exists("g:NETRW_DIRHIST_CNT") + let g:NETRW_DIRHIST_CNT= 0 +endif +if !exists("g:netrw_dirhistmax") + let g:netrw_dirhistmax= 10 +endif +if !exists("g:netrw_ftp_browse_reject") + let g:netrw_ftp_browse_reject='^total\s\+\d\+$\|^Trying\s\+\d\+.*$\|^KERBEROS_V\d rejected\|^Security extensions not\|No such file\|: connect to address [0-9a-fA-F:]*: No route to host$' endif if !exists("g:netrw_ftp_list_cmd") if has("unix") || exists("g:netrw_cygwin") @@ -59,75 +120,96 @@ if !exists("g:netrw_ftp_list_cmd") let g:netrw_ftp_list_cmd= "dir" endif endif -if !exists("g:netrw_rm_cmd") - let g:netrw_rm_cmd = "ssh HOSTNAME rm" +if !exists("g:netrw_ftpmode") + let g:netrw_ftpmode= "binary" endif -if !exists("g:netrw_rmf_cmd") - let g:netrw_rmf_cmd = "ssh HOSTNAME rm -f" +" Default values - h-lh ---------- {{{2 +if !exists("g:netrw_hide") + let g:netrw_hide= 1 endif -if !exists("g:netrw_rmdir_cmd") - let g:netrw_rmdir_cmd = "ssh HOSTNAME rmdir" +if !exists("g:netrw_keepdir") + let g:netrw_keepdir= 1 +endif +if !exists("g:netrw_list_cmd") + if executable(g:netrw_ssh_cmd) + " provide a default listing command + let g:netrw_list_cmd= g:netrw_ssh_cmd." HOSTNAME ls -FLa" + else +" call Decho(g:netrw_ssh_cmd." is not executable, can't do remote directory exploring) + let g:netrw_list_cmd= "" + endif +endif +if !exists("g:netrw_list_hide") + let g:netrw_list_hide= "" +endif +" Default values - lh-lz ---------- {{{2 +if !exists("g:netrw_local_mkdir") + let g:netrw_local_mkdir= "mkdir" +endif +if !exists("g:netrw_local_rmdir") + let g:netrw_local_rmdir= "rmdir" +endif +if !exists("g:netrw_longlist") + let g:netrw_longlist= 0 +endif +if g:netrw_longlist < 0 || g:netrw_longlist > 2 + " sanity check + let g:netrw_longlist= 0 +endif +if g:netrw_longlist == 1 + let g:netrw_list_cmd= g:netrw_list_cmd." -l" +endif +" Default values - m-r ---------- {{{2 +if !exists("g:netrw_maxfilenamelen") + let g:netrw_maxfilenamelen= 32 +endif +if !exists("g:netrw_mkdir_cmd") + let g:netrw_mkdir_cmd= g:netrw_ssh_cmd." HOSTNAME mkdir" endif if !exists("g:netrw_rename_cmd") - let g:netrw_rename_cmd= "ssh HOSTNAME mv" + let g:netrw_rename_cmd= g:netrw_ssh_cmd." HOSTNAME mv" +endif +if !exists("g:netrw_rm_cmd") + let g:netrw_rm_cmd = g:netrw_ssh_cmd." HOSTNAME rm" +endif +if !exists("g:netrw_rmdir_cmd") + let g:netrw_rmdir_cmd = g:netrw_ssh_cmd." HOSTNAME rmdir" +endif +if !exists("g:netrw_rmf_cmd") + let g:netrw_rmf_cmd = g:netrw_ssh_cmd." HOSTNAME rm -f" endif +" Default values - s ---------- {{{2 if exists("g:netrw_silent") && g:netrw_silent != 0 let g:netrw_silentxfer= "silent " else let g:netrw_silentxfer= "" endif -if !exists("g:netrw_winsize") - let g:netrw_winsize= "" -endif -if !exists("g:netrw_list_hide") - let g:netrw_list_hide= "" -endif if !exists("g:netrw_sort_by") " alternatives: date size let g:netrw_sort_by= "name" endif -if !exists("g:netrw_sort_sequence") - let g:netrw_sort_sequence= '[\/]$,*,\.bak$,\.o$,\.h$,\.info$,\.swp$,\.obj$' -endif if !exists("g:netrw_sort_direction") " alternative: reverse (z y x ...) let g:netrw_sort_direction= "normal" endif -if !exists("g:netrw_longlist") - let g:netrw_longlist= 0 -endif -if g:netrw_longlist == 0 || g:netrw_longlist == 2 - let g:netrw_list_cmd= "ssh HOSTNAME ls -FLa" -else - let g:netrw_longlist= 1 - let g:netrw_list_cmd= "ssh HOSTNAME ls -FLa -l" +if !exists("g:netrw_sort_sequence") + let g:netrw_sort_sequence= '[\/]$,*,\.bak$,\.o$,\.h$,\.info$,\.swp$,\.obj$' endif -if !exists("g:netrw_list_cmd") +if !exists("g:netrw_ssh_browse_reject") + let g:netrw_ssh_browse_reject='^total\s\+\d\+$' endif +" Default values - t-w ---------- {{{2 if !exists("g:netrw_timefmt") let g:netrw_timefmt= "%c" endif -if !exists("g:netrw_local_rmdir") - let g:netrw_local_rmdir= "rmdir" -endif -if !exists("g:netrw_local_mkdir") - let g:netrw_local_mkdir= "mkdir" -endif -if !exists("g:netrw_mkdir_cmd") - let g:netrw_mkdir_cmd= "ssh HOSTNAME mkdir" -endif -if !exists("g:netrw_hide") - let g:netrw_hide= 1 -endif -if !exists("g:netrw_ftp_browse_reject") - let g:netrw_ftp_browse_reject='^total\s\+\d\+$\|^Trying\s\+\d\+.*$\|^KERBEROS_V\d rejected\|^Security extensions not\|No such file\|: connect to address [0-9a-fA-F:]*: No route to host$' -endif -if !exists("g:netrw_ssh_browse_reject") - let g:netrw_ssh_browse_reject='^total\s\+\d\+$' +if !exists("g:netrw_win95ftp") + let g:netrw_win95ftp= 1 endif -if !exists("g:netrw_keepdir") - let g:netrw_keepdir= 1 +if !exists("g:netrw_winsize") + let g:netrw_winsize= "" endif +" --------------------------------------------------------------------- +" Default values for netrw's script variables: {{{1 if !exists("s:netrw_cd_escape") if has("win32") || has("win95") || has("win64") || has("win16") let s:netrw_cd_escape="#% " @@ -142,75 +224,12 @@ if !exists("s:netrw_glob_escape") let s:netrw_glob_escape= '[]*?`{~$' endif endif -if !exists("g:netrw_alto") - let g:netrw_alto= 0 -endif -if !exists("g:netrw_altv") - let g:netrw_altv= 0 -endif -if !exists("g:netrw_maxfilenamelen") - let g:netrw_maxfilenamelen= 32 -endif -if !exists("g:netrw_dirhistmax") - let g:netrw_dirhistmax= 10 -endif -if !exists("g:NETRW_DIRHIST_CNT") - let g:NETRW_DIRHIST_CNT= 0 -endif " BufEnter event ignored by decho when following variable is true " Has a side effect that doau BufReadPost doesn't work, so " files read by network transfer aren't appropriately highlighted. "let g:decho_bufenter = 1 "Decho -" --------------------------------------------------------------------- -" Default values for global protocol variables {{{1 -if !exists("g:netrw_rcp_cmd") - let g:netrw_rcp_cmd = "rcp" -endif -if !exists("g:netrw_ftp_cmd") - let g:netrw_ftp_cmd = "ftp" -endif -if !exists("g:netrw_scp_cmd") - let g:netrw_scp_cmd = "scp -q" -endif -if !exists("g:netrw_sftp_cmd") - let g:netrw_sftp_cmd = "sftp" -endif -if !exists("g:netrw_http_cmd") - if executable("wget") - let g:netrw_http_cmd = "wget -q -O" - elseif executable("fetch") - let g:netrw_http_cmd = "fetch -o" - else - let g:netrw_http_cmd = "" - endif -endif -if !exists("g:netrw_dav_cmd") - let g:netrw_dav_cmd = "cadaver" -endif -if !exists("g:netrw_rsync_cmd") - let g:netrw_rsync_cmd = "rsync" -endif -if !exists("g:netrw_fetch_cmd") - if executable("fetch") - let g:netrw_fetch_cmd = "fetch -o" - else - let g:netrw_fetch_cmd = "" - endif -endif - -if has("win32") || has("win95") || has("win64") || has("win16") - \ && exists("g:netrw_use_nt_rcp") - \ && g:netrw_use_nt_rcp - \ && executable( $SystemRoot .'/system32/rcp.exe') - let s:netrw_has_nt_rcp = 1 - let s:netrw_rcpmode = '-b' - else - let s:netrw_has_nt_rcp = 0 - let s:netrw_rcpmode = '' -endif - " ------------------------------------------------------------------------ " NetSavePosn: saves position of cursor on screen {{{1 fun! netrw#NetSavePosn() @@ -368,10 +387,20 @@ fun! netrw#NetRead(...) " call Dret("NetRead") return endif + + " use filename's suffix for the temporary file + if b:netrw_fname =~ '\.[^./]\+' + let suffix = substitute(b:netrw_fname,'^.*\(\.[^./]\+\)','\1','e') + let tmpfile= substitute(tmpfile,"$",suffix,'e') +" call Decho("chgd tmpfile<".tmpfile."> (added ".suffix." suffix)") + endif " ============ " Perform Read " ============ + if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1 + echo "(netrw) Processing your read request..." + endif "......................................... " rcp: NetRead Method #1 @@ -403,12 +432,14 @@ fun! netrw#NetRead(...) "......................................... " ftp + <.netrc>: NetRead Method #2 elseif b:netrw_method == 2 " read with ftp + <.netrc> -" call Decho("read via ftp+.netrc (method #2)") +" call Decho("read via ftp+.netrc (method #2)") let netrw_fname= b:netrw_fname new setlocal ff=unix exe "put ='".g:netrw_ftpmode."'" - exe "put ='"."get ".netrw_fname." ".tmpfile."'" +" call Decho("filter input: ".getline(".")) + exe "put ='".'get \"'.netrw_fname.'\" '.tmpfile."'" +" call Decho("filter input: ".getline(".")) if exists("g:netrw_port") && g:netrw_port != "" " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port) exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port @@ -425,7 +456,7 @@ fun! netrw#NetRead(...) let &debug= debugkeep endif bd! - let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) + let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) let b:netrw_lastfile = choice "......................................... @@ -438,27 +469,33 @@ fun! netrw#NetRead(...) setlocal ff=unix if exists("g:netrw_port") && g:netrw_port != "" put ='open '.g:netrw_machine.' '.g:netrw_port +" call Decho("filter input: ".getline(".")) else put ='open '.g:netrw_machine +" call Decho("filter input: ".getline(".")) endif if exists("g:netrw_ftp") && g:netrw_ftp == 1 put =g:netrw_uid - put =g:netrw_passwd +" call Decho("filter input: ".getline(".")) + put ='\"'.g:netrw_passwd.'\"' +" call Decho("filter input: ".getline(".")) else - put ='user '.g:netrw_uid.' '.g:netrw_passwd + put ='user \"'.g:netrw_uid.'\" \"'.g:netrw_passwd.'\"' +" call Decho("filter input: ".getline(".")) endif if exists("g:netrw_ftpmode") && g:netrw_ftpmode != "" put =g:netrw_ftpmode +" call Decho("filter input: ".getline(".")) endif - put ='get '.netrw_fname.' '.tmpfile + put ='get \"'.netrw_fname.'\" '.tmpfile +" call Decho("filter input: ".getline(".")) " perform ftp: " -i : turns off interactive prompting from ftp " -n unix : DON'T use <.netrc>, even though it exists " -n win32: quit being obnoxious about password -" call Decho('performing ftp -i -n') norm! 1Gdd " call Decho("executing: %!".g:netrw_ftp_cmd." -i -n") exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n" @@ -491,7 +528,7 @@ fun! netrw#NetRead(...) " call Decho("executing: !".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile) exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile endif - let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) + let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) let b:netrw_lastfile = choice "......................................... @@ -502,7 +539,8 @@ fun! netrw#NetRead(...) echohl Error | echo "***netrw*** neither wget nor fetch command is available" | echohl None call inputsave()|call input("Press <cr> to continue")|call inputrestore() endif - exit +" call Dret("NetRead") + return endif if match(b:netrw_fname,"#") == -1 @@ -581,7 +619,7 @@ fun! netrw#NetRead(...) echohl Error | echo "***netrw*** fetch command not available" | echohl None call inputsave()|call input("Press <cr> to continue")|call inputrestore() endif - exit +" call Dret("NetRead") endif if exists("g:netrw_option") && g:netrw_option == ":http" let netrw_option= "http" @@ -635,9 +673,13 @@ fun! netrw#NetRead(...) endfun " ------------------------------------------------------------------------ -" NetGetFile: Function to read file "fname" with command "readcmd". {{{1 -fun! s:NetGetFile(readcmd, fname, method) -" call Dfunc("NetGetFile(readcmd<".a:readcmd.">,fname<".a:fname."> method<".a:method.">)") +" NetGetFile: Function to read temporary file "tfile" with command "readcmd". {{{1 +fun! s:NetGetFile(readcmd, tfile, method) +" call Dfunc("NetGetFile(readcmd<".a:readcmd.">,tfile<".a:tfile."> method<".a:method.">)") + + " get name of remote filename (ie. url and all) + let rfile= bufname("%") +" call Decho("rfile<".rfile.">") if exists("*NetReadFixup") " for the use of NetReadFixup (not otherwise used internally) @@ -647,50 +689,57 @@ fun! s:NetGetFile(readcmd, fname, method) " transform paths from / to \ for Windows (except for cygwin) if &term == "win32" if g:netrw_cygwin - let fname= a:fname -" call Decho("(win32 && cygwin) fname<".fname.">") + let tfile= a:tfile +" call Decho("(win32 && cygwin) tfile<".tfile.">") else - let fname= substitute(a:fname,'/','\\\\','ge') -" call Decho("(win32 && !cygwin) fname<".fname.">") + let tfile= substitute(a:tfile,'/','\\\\','ge') +" call Decho("(win32 && !cygwin) tfile<".tfile.">") endif else - let fname= a:fname -" call Decho("(copied) fname<".fname.">") + let tfile= a:tfile +" call Decho("tfile=a:tfile<".tfile.">") endif if a:readcmd[0] == '0' " get file into buffer - " record remote filename - let rfile= bufname(".") -" call Decho("remotefile<".rfile.">") " call Dredir("ls!","starting buffer list") - " rename the current buffer to the temp file (ie. fname) - keepalt exe "file ".fname -" call Dredir("ls!","after renaming current buffer to <".fname.">") + " rename the current buffer to the temp file (ie. tfile) + keepalt exe "file ".tfile +" call Dredir("ls!","after renaming current buffer to <".tfile.">") - " edit temporary file - e -" call Dredir("ls!","after editing temporary file") + " edit temporary file (ie. read the temporary file in) + if rfile =~ '\.zip$' + call zip#Browse(tfile) + elseif rfile =~ '\.tar$' + call tar#Browse(tfile) + else + e + endif " rename buffer back to remote filename keepalt exe "file ".rfile -" call Dredir("ls!","renaming buffer back to remote filename<".rfile.">") + filetype detect +" call Dredir("ls!","renamed buffer back to remote filename<".rfile.">") let line1 = 1 let line2 = line("$") - elseif filereadable(fname) + elseif filereadable(tfile) " read file after current line let curline = line(".") let lastline= line("$") -" call Decho("exe<".a:readcmd." ".v:cmdarg." ".fname."> line#".curline) - exe a:readcmd." ".v:cmdarg." ".fname +" call Decho("exe<".a:readcmd." ".v:cmdarg." ".tfile."> line#".curline) + exe a:readcmd." ".v:cmdarg." ".tfile let line1 = curline + 1 let line2 = line("$") - lastline + 1 + else " not readable -" call Dret("NetGetFile : fname<".fname."> not readable") +" call Dfunc("NetGetFile(readcmd<".a:readcmd.">,tfile<".a:tfile."> method<".a:method.">)") + echohl WarningMsg | echo "***netrw*** file <".tfile."> not readable"| echohl None + call inputsave()|call input("Press <cr> to continue")|call inputrestore() +" call Dret("NetGetFile : tfile<".tfile."> not readable") return endif @@ -707,10 +756,9 @@ fun! s:NetGetFile(readcmd, fname, method) silent! emenu Buffers.Refresh\ menu endif -" call Decho("readcmd<".a:readcmd."> cmdarg<".v:cmdarg."> fname<".a:fname."> readable=".filereadable(a:fname)) +" call Decho("readcmd<".a:readcmd."> cmdarg<".v:cmdarg."> tfile<".a:tfile."> readable=".filereadable(a:tfile)) - " insure that we have the right filetype and that its being displayed - filetype detect + " make sure file is being displayed redraw! " call Dret("NetGetFile") endfun @@ -729,7 +777,7 @@ fun! netrw#NetWrite(...) range if !isdirectory(substitute(tmpfile,'[^/]\+$','','e')) echohl Error | echo "***netrw*** your ".substitute(tmpfile,'[^/]\+$','','e')." directory is missing!" call inputsave()|call input("Press <cr> to continue")|call inputrestore() -" call Dret("NetRead") +" call Dret("NetWrite") return endif @@ -739,8 +787,16 @@ fun! netrw#NetWrite(...) range let ichoice = 1 endif - " write (selected portion of) file to temporary - silent exe a:firstline."," . a:lastline . "w! ".v:cmdarg." ".tmpfile + if &binary + " for binary writes, write entire file. Line numbers don't really make sense. + " Supports the writing of tar and zip files. +" call Decho("silent exe w! ".v:cmdarg." ".tmpfile) + silent exe "w! ".v:cmdarg." ".tmpfile + else + " write (selected portion of) file to temporary +" call Decho("silent exe ".a:firstline."," . a:lastline . "w! ".v:cmdarg." ".tmpfile) + silent exe a:firstline."," . a:lastline . "w! ".v:cmdarg." ".tmpfile + endif while ichoice <= a:0 @@ -810,11 +866,14 @@ fun! netrw#NetWrite(...) range " ============= " Perform Write " ============= + if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1 + echo "(netrw) Processing your write request..." + endif "......................................... " rcp: NetWrite Method #1 if b:netrw_method == 1 " write with rcp -" Decho "write via rcp (method #1)" +" call Decho("write via rcp (method #1)") if s:netrw_has_nt_rcp == 1 if exists("g:netrw_uid") && ( g:netrw_uid != "" ) let uid_machine = g:netrw_machine .'.'. g:netrw_uid @@ -839,9 +898,9 @@ fun! netrw#NetWrite(...) range new setlocal ff=unix exe "put ='".g:netrw_ftpmode."'" -" call Decho(" NetWrite: put ='".g:netrw_ftpmode."'") - exe "put ='"."put ".tmpfile." ".netrw_fname."'" -" call Decho("put ='"."put ".tmpfile." ".netrw_fname."'") +" call Decho(" filter input: ".getline(".")) + exe "put ='"."put ".tmpfile.' \"'.netrw_fname.'\"'."'" +" call Decho(" filter input: ".getline(".")) if exists("g:netrw_port") && g:netrw_port != "" " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port) exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port @@ -868,16 +927,22 @@ fun! netrw#NetWrite(...) range setlocal ff=unix if exists("g:netrw_port") && g:netrw_port != "" put ='open '.g:netrw_machine.' '.g:netrw_port +" call Decho("filter input: ".getline(".")) else put ='open '.g:netrw_machine +" call Decho("filter input: ".getline(".")) endif if exists("g:netrw_ftp") && g:netrw_ftp == 1 put =g:netrw_uid - put =g:netrw_passwd +" call Decho("filter input: ".getline(".")) + put ='\"'.g:netrw_passwd.'\"' +" call Decho("filter input: ".getline(".")) else - put ='user '.g:netrw_uid.' '.g:netrw_passwd + put ='user \"'.g:netrw_uid.'\" \"'.g:netrw_passwd.'\"' +" call Decho("filter input: ".getline(".")) endif - put ='put '.tmpfile.' '.netrw_fname + put ='put '.tmpfile.' \"'.netrw_fname.'\"' +" call Decho("filter input: ".getline(".")) " save choice/id/password for future use let b:netrw_lastfile = choice @@ -885,7 +950,6 @@ fun! netrw#NetWrite(...) range " -i : turns off interactive prompting from ftp " -n unix : DON'T use <.netrc>, even though it exists " -n win32: quit being obnoxious about password -" call Decho('performing ftp -i -n') norm! 1Gdd " call Decho("executing: %!".g:netrw_ftp_cmd." -i -n") exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n" @@ -1038,7 +1102,7 @@ fun! s:NetBrowse(dirname) endif elseif !exists("g:netrw_list_cmd") || g:netrw_list_cmd == '' if !exists("g:netrw_quiet") - echohl Error | echo "***netrw*** this system doesn't support remote directory listing via ssh" | echohl None + echohl Error | echo "***netrw*** this system doesn't support remote directory listing via ".g:netrw_list_cmd | echohl None call inputsave()|call input("Press <cr> to continue")|call inputrestore() endif @@ -1056,7 +1120,7 @@ fun! s:NetBrowse(dirname) " analyze a:dirname and g:netrw_list_cmd let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/]\+\)/\(.*\)$' let dirname = substitute(a:dirname,'\\','/','ge') -" call Decho("dirpat<".dirpat.">") +" call Decho("dirname<".dirname.">") if dirname !~ dirpat if !exists("g:netrw_quiet") echohl Error | echo "***netrw*** netrw doesn't understand your dirname<".dirname.">" | echohl None @@ -1126,9 +1190,9 @@ fun! s:NetBrowse(dirname) " call Decho("new path<".path.">") " remote-read the requested file into current buffer - enew! + keepjumps keepalt enew! set ma -" call Decho("exe file .method."://".user.machine."/".escape(path,s:netrw_cd_escape)) +" call Decho("exe file ".method."://".user.machine."/".escape(path,s:netrw_cd_escape)) exe "file ".method."://".user.machine."/".escape(path,s:netrw_cd_escape) exe "silent doau BufReadPre ".fname silent call netrw#NetRead(method."://".user.machine."/".path) @@ -1136,7 +1200,7 @@ fun! s:NetBrowse(dirname) keepjumps 1d " save certain window-oriented variables into buffer-oriented variables - call s:BufWinVars() + call s:SetBufWinVars() call s:NetOptionRestore() setlocal nomod @@ -1162,7 +1226,7 @@ fun! s:NetBrowse(dirname) endif else " call Decho("generate a new buffer") - enew! + keepjumps keepalt enew! endif " rename file to reflect where its from @@ -1179,7 +1243,7 @@ fun! s:NetBrowse(dirname) " set up buffer-local mappings " call Decho("set up buffer-local mappings") nnoremap <buffer> <silent> <cr> :call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),<SID>NetGetWord()))<cr> - nnoremap <buffer> <silent> <c-l> :call <SID>NetRefresh(<SID>NetBrowseChgDir(expand("%"),'./'))<cr> + nnoremap <buffer> <silent> <c-l> :call <SID>NetRefresh(<SID>NetBrowseChgDir(expand("%"),'./'),0)<cr> nnoremap <buffer> <silent> - :exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'../'))<cr> nnoremap <buffer> <silent> a :let g:netrw_hide=(g:netrw_hide+1)%3<bar>exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'./'))<cr> if w:netrw_longlist != 2 @@ -1200,7 +1264,7 @@ fun! s:NetBrowse(dirname) nnoremap <buffer> <silent> U :<c-u>call <SID>NetBookmarkDir(5,expand("%"))<cr> nnoremap <buffer> <silent> v :call <SID>NetSplit(1)<cr> nnoremap <buffer> <silent> x :call <SID>NetBrowseX(<SID>NetBrowseChgDir(expand("%"),<SID>NetGetWord()),1)<cr> - nnoremap <buffer> <silent> <2-leftmouse> :call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),<SID>NetGetWord()))<cr> + nnoremap <buffer> <silent> <2-leftmouse> :call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),<SID>NetGetWord()))<cr> exe 'nnoremap <buffer> <silent> <del> :call <SID>NetBrowseRm("'.user.machine.'","'.path.'")<cr>' exe 'vnoremap <buffer> <silent> <del> :call <SID>NetBrowseRm("'.user.machine.'","'.path.'")<cr>' exe 'nnoremap <buffer> <silent> d :call <SID>NetMakeDir("'.user.machine.'")<cr>' @@ -1232,6 +1296,7 @@ fun! s:NetBrowse(dirname) keepjumps put ='\" Sorted by '.sortby endif if g:netrw_list_hide != "" && g:netrw_hide +" call Decho("g:netrw_hide=".g:netrw_hide) if g:netrw_hide == 1 keepjumps put ='\" Hiding: '.g:netrw_list_hide else @@ -1260,6 +1325,7 @@ fun! s:NetBrowse(dirname) if g:netrw_ftp_browse_reject != "" exe "silent! g/".g:netrw_ftp_browse_reject."/keepjumps d" endif + silent! keepjumps %s/\r$//e " if there's no ../ listed, then put ./ and ../ in let line1= line(".") @@ -1274,9 +1340,9 @@ fun! s:NetBrowse(dirname) keepjumps norm! 0 " more cleanup - exe 'keepjumps silent! '.w:netrw_bannercnt.',$s/^\(\%(\S\+\s\+\)\{7}\S\+\)\s\+\(\S.*\)$/\2/e' - exe "keepjumps silent! ".w:netrw_bannercnt.',$g/ -> /s# -> .*/$#/#e' - exe "keepjumps silent! ".w:netrw_bannercnt.',$g/ -> /s# -> .*$#/#e' + exe 'silent! keepjumps '.w:netrw_bannercnt.',$s/^\(\%(\S\+\s\+\)\{7}\S\+\)\s\+\(\S.*\)$/\2/e' + exe "silent! keepjumps ".w:netrw_bannercnt.',$g/ -> /s# -> .*/$#/#e' + exe "silent! keepjumps ".w:netrw_bannercnt.',$g/ -> /s# -> .*$#/#e' endif else @@ -1333,33 +1399,33 @@ fun! s:NetBrowse(dirname) keepjumps norm! 0 endif - exe 'keepjumps silent '.w:netrw_bannercnt.',$s/ -> .*$//e' - exe 'keepjumps silent '.w:netrw_bannercnt.',$s/^\(\%(\S\+\s\+\)\{7}\S\+\)\s\+\(\S.*\)$/\2\t\1/e' - exe w:netrw_bannercnt + exe 'silent keepjumps '.w:netrw_bannercnt.',$s/ -> .*$//e' + exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\(\%(\S\+\s\+\)\{7}\S\+\)\s\+\(\S.*\)$/\2\t\1/e' + exe 'silent keepjumps '.w:netrw_bannercnt endif if line("$") >= w:netrw_bannercnt if g:netrw_sort_by =~ "^n" call s:SetSort() if g:netrw_sort_direction =~ 'n' - exe 'keepjumps silent '.w:netrw_bannercnt.',$sort' + exe 'silent keepjumps '.w:netrw_bannercnt.',$sort' else - exe 'keepjumps silent '.w:netrw_bannercnt.',$sort!' + exe 'silent keepjumps '.w:netrw_bannercnt.',$sort!' endif - exe 'keepjumps silent '.w:netrw_bannercnt.',$s/^\d\{3}\///e' + exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\d\{3}\///e' endif if w:netrw_longlist == 1 " shorten the list to keep its width <= winwidth characters - exe "keepjumps silent ".w:netrw_bannercnt.',$s/\t[-dstrwx]\+/\t/e' + exe "silent keepjumps ".w:netrw_bannercnt.',$s/\t[-dstrwx]\+/\t/e' endif endif endif - " cleanup any windows mess at end-of-line - keepjumps silent! %s/\r$//e call s:NetrwWideListing() if line("$") >= w:netrw_bannercnt + " place cursor on the top-left corner of the file listing exe "keepjumps ".w:netrw_bannercnt + norm! 0 endif call s:NetOptionRestore() @@ -1449,7 +1515,7 @@ fun! s:NetGetWord() let s:netrw_skipbrowse= 1 echo 'Pressing "a" also works' elseif line("$") > w:netrw_bannercnt - exe w:netrw_bannercnt + exe 'silent keepjumps '.w:netrw_bannercnt endif elseif w:netrw_longlist == 0 @@ -1513,6 +1579,9 @@ fun! s:NetBrowseRm(usrhost,path) range let ok= input("Confirm deletion of file<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ") call inputrestore() echohl NONE + if ok == "" + let ok="no" + endif let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e') if ok =~ 'a\%[ll]' let all= 1 @@ -1539,6 +1608,9 @@ fun! s:NetBrowseRm(usrhost,path) range call inputsave() let ok= input("Confirm deletion of directory<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ") call inputrestore() + if ok == "" + let ok="no" + endif let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e') if ok =~ 'a\%[ll]' let all= 1 @@ -1627,11 +1699,17 @@ endfun " --------------------------------------------------------------------- " NetRefresh: {{{2 -fun! s:NetRefresh(dirname) -" call Dfunc("NetRefresh(dirname<".a:dirname.">)") +fun! s:NetRefresh(dirname,islocal) +" call Dfunc("NetRefresh(dirname<".a:dirname.">,islocal=".a:islocal.")") + call netrw#NetSavePosn() set ma %d - call <SID>NetBrowse(dirname) + if a:islocal + call s:LocalBrowse(a:dirname) + else + call s:NetBrowse(a:dirname) + endif + call netrw#NetRestorePosn() redraw! " call Dret("NetRefresh") endfun @@ -1690,12 +1768,12 @@ fun! s:NetBrowseX(fname,remote) " create a local copy let fname= tempname().".".exten " call Decho("create a local copy of <".a:fname."> as <".fname.">") - exe "keepjumps silent bot 1new ".a:fname + exe "silent keepjumps bot 1new ".a:fname set bh=delete exe "w! ".fname q endif -" call Decho("exten<".exten."> "."NetrwFileHandler_".exten."():exists=".exists("*NetrwFileHandler_".exten)) +" call Decho("exten<".exten."> "."netrwFileHandlers#NFH_".exten."():exists=".exists("*netrwFileHandlers#NFH_".exten)) " set up redirection if &srr =~ "%s" @@ -1711,19 +1789,22 @@ fun! s:NetBrowseX(fname,remote) exe 'silent !start rundll32 url.dll,FileProtocolHandler "'.escape(fname, '%#').'"' let ret= v:shell_error - elseif has("unix") && executable("kfmclient") -" call Decho("exe silent !kfmclient exec '".escape(fname,'%#')."' ".redir) - exe "silent !kfmclient exec '".escape(fname,'%#')."' ".redir - let ret= v:shell_error - elseif has("unix") && executable("gnome-open") " call Decho("exe silent !gnome-open '".escape(fname,'%#')."' ".redir) exe "silent !gnome-open '".escape(fname,'%#')."'".redir let ret= v:shell_error - elseif exten != "" && exists("*NetrwFileHandler_".exten) -" call Decho("let ret= NetrwFileHandler_".exten.'("'.fname.'")') - exe "let ret= NetrwFileHandler_".exten.'("'.fname.'")' + elseif has("unix") && executable("kfmclient") +" call Decho("exe silent !kfmclient exec '".escape(fname,'%#')."' ".redir) + exe "silent !kfmclient exec '".escape(fname,'%#')."' ".redir + let ret= v:shell_error + + else + call netrwFileHandlers#Init() + if exten != "" && exists("*netrwFileHandlers#NFH_".exten) +" call Decho("let ret= netrwFileHandlers#NFH_".exten.'("'.fname.'")') + exe "let ret= netrwFileHandlers#NFH_".exten.'("'.fname.'")' + endif endif redraw! @@ -1765,11 +1846,11 @@ fun! s:NetBrowseFtpCmd(path,cmd) if w:netrw_method == 2 || w:netrw_method == 5 " ftp + <.netrc>: Method #2 if a:path != "" - put ='cd '.a:path -" call Decho("ftp: cd ".a:path) + put ='cd \"'.a:path.'\"' +" call Decho('ftp: '.getline(".")) endif exe "put ='".a:cmd."'" -" call Decho("ftp: ".a:cmd) +" call Decho("ftp: ".getline(".")) " redraw!|call inputsave()|call input("Pausing...")|call inputrestore() if exists("g:netrw_port") && g:netrw_port != "" " call Decho("exe ".g:netrw_silentxfer.curline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port) @@ -1791,13 +1872,13 @@ fun! s:NetBrowseFtpCmd(path,cmd) if exists("g:netrw_ftp") && g:netrw_ftp == 1 put =g:netrw_uid - put =g:netrw_passwd + put ='\"'.g:netrw_passwd.'\"' else - put ='user '.g:netrw_uid.' '.g:netrw_passwd + put ='user \"'.g:netrw_uid.'\" \"'.g:netrw_passwd.'\"' endif if a:path != "" - put ='cd '.a:path + put ='cd \"'.a:path.'\"' endif exe "put ='".a:cmd."'" @@ -1815,14 +1896,14 @@ fun! s:NetBrowseFtpCmd(path,cmd) " cleanup for Windows if has("win32") || has("win95") || has("win64") || has("win16") - keepjumps silent!! %s/\r$//e + silent! keepjumps! %s/\r$//e endif if a:cmd == "dir" " infer directory/link based on the file permission string - keepjumps silent! g/d\%([-r][-w][-x]\)\{3}/s@$@/@ - keepjumps silent! g/l\%([-r][-w][-x]\)\{3}/s/$/@/ + silent! keepjumps g/d\%([-r][-w][-x]\)\{3}/s@$@/@ + silent! keepjumps g/l\%([-r][-w][-x]\)\{3}/s/$/@/ if w:netrw_longlist == 0 || w:netrw_longlist == 2 - exe "keepjumps silent! ".curline.',$s/^\%(\S\+\s\+\)\{8}//e' + exe "silent! keepjumps ".curline.',$s/^\%(\S\+\s\+\)\{8}//e' endif endif @@ -1845,7 +1926,7 @@ endfun " NetrwListHide: uses [range]g~...~d to delete files that match comma {{{2 " separated patterns given in g:netrw_list_hide fun! s:NetrwListHide() -" call Dfunc("NetrwListHide() listhide<".g:netrw_list_hide.">") +" call Dfunc("NetrwListHide() hide=".g:netrw_hide." listhide<".g:netrw_list_hide.">") let listhide= g:netrw_list_hide while listhide != "" @@ -1858,11 +1939,14 @@ fun! s:NetrwListHide() endif " Prune the list by hiding any files which match -" call Decho("pruning <".hide."> listhide<".listhide.">") if g:netrw_hide == 1 - exe 'keepjumps silent '.w:netrw_bannercnt.',$g~'.hide.'~d' +" call Decho("hiding<".hide."> listhide<".listhide.">") +" call Decho('exe silent keepjumps '.w:netrw_bannercnt.',$g~'.hide.'~d') + exe 'silent keepjumps '.w:netrw_bannercnt.',$g~'.hide.'~d' elseif g:netrw_hide == 2 - exe 'keepjumps silent '.w:netrw_bannercnt.',$v~'.hide.'~d' +" call Decho("showing<".hide."> listhide<".listhide.">") +" call Decho('exe silent keepjumps '.w:netrw_bannercnt.',$v~'.hide.'~d') + exe 'silent keepjumps '.w:netrw_bannercnt.',$v~'.hide.'~d' endif endwhile @@ -1871,19 +1955,21 @@ endfun " ------------------------------------------------------ |