summaryrefslogtreecommitdiffstats
path: root/runtime/autoload/netrw.vim
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/autoload/netrw.vim')
-rw-r--r--runtime/autoload/netrw.vim3355
1 files changed, 3355 insertions, 0 deletions
diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim
new file mode 100644
index 0000000000..e077e25e74
--- /dev/null
+++ b/runtime/autoload/netrw.vim
@@ -0,0 +1,3355 @@
+" netrw.vim: Handles file transfer and remote directory listing across a network
+" AUTOLOAD PORTION
+" Last Change: Aug 16, 2005
+" Maintainer: Charles E Campbell, Jr <drchipNOSPAM at campbellfamily dot biz>
+" Version: 63
+" 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
+" 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")
+
+" ---------------------------------------------------------------------
+" Default values for global netrw variables {{{1
+if !exists("g:netrw_ftpmode")
+ let g:netrw_ftpmode= "binary"
+endif
+if !exists("g:netrw_win95ftp")
+ let g:netrw_win95ftp= 1
+endif
+if !exists("g:netrw_cygwin")
+ if has("win32") || has("win95") || has("win64") || has("win16")
+ if &shell == "bash"
+ let g:netrw_cygwin= 1
+ else
+ let g:netrw_cygwin= 0
+ endif
+ else
+ 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
+endif
+if !exists("g:netrw_ftp_list_cmd")
+ if has("unix") || exists("g:netrw_cygwin")
+ let g:netrw_ftp_list_cmd= "ls -lF"
+ else
+ let g:netrw_ftp_list_cmd= "dir"
+ endif
+endif
+if !exists("g:netrw_rm_cmd")
+ let g:netrw_rm_cmd = "ssh HOSTNAME rm"
+endif
+if !exists("g:netrw_rmf_cmd")
+ let g:netrw_rmf_cmd = "ssh HOSTNAME rm -f"
+endif
+if !exists("g:netrw_rmdir_cmd")
+ let g:netrw_rmdir_cmd = "ssh HOSTNAME rmdir"
+endif
+if !exists("g:netrw_rename_cmd")
+ let g:netrw_rename_cmd= "ssh HOSTNAME mv"
+endif
+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") || g:netrw_longlist == 0
+ let g:netrw_longlist= 0
+ 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"
+endif
+if !exists("g:netrw_list_cmd")
+endif
+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\+$'
+endif
+if !exists("g:netrw_keepdir")
+ let g:netrw_keepdir= 1
+endif
+if !exists("s:netrw_cd_escape")
+ if has("win32") || has("win95") || has("win64") || has("win16")
+ let s:netrw_cd_escape="#% "
+ else
+ let s:netrw_cd_escape="[]#*$%'\" ?`!&();<>\\"
+ endif
+endif
+if !exists("s:netrw_glob_escape")
+ if has("win32") || has("win95") || has("win64") || has("win16")
+ let s:netrw_glob_escape= ""
+ else
+ 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()
+" call Dfunc("NetSavePosn()")
+ " Save current line and column
+ let w:netrw_winnr= winnr()
+ let w:netrw_line = line(".")
+ let w:netrw_col = virtcol(".")
+
+ " Save top-of-screen line
+ norm! H0
+ let w:netrw_hline= line(".")
+
+ call netrw#NetRestorePosn()
+" call Dret("NetSavePosn : winnr=".w:netrw_winnr." line=".w:netrw_line." col=".w:netrw_col." hline=".w:netrw_hline)
+endfun
+
+" ------------------------------------------------------------------------
+" NetRestorePosn: restores the cursor and file position as saved by NetSavePosn() {{{1
+fun! netrw#NetRestorePosn()
+" call Dfunc("NetRestorePosn() winnr=".w:netrw_winnr." line=".w:netrw_line." col=".w:netrw_col." hline=".w:netrw_hline)
+ let eikeep= &ei
+ set ei=all
+
+ " restore window
+" call Decho("restore window: exe silent! ".w:netrw_winnr."wincmd w")
+ exe "silent! ".w:netrw_winnr."wincmd w"
+" if v:shell_error == 0
+" " as suggested by Bram M: redraw on no error
+" " allows protocol error messages to remain visible
+" redraw!
+" endif
+
+ " restore top-of-screen line
+" call Decho("restore topofscreen: exe norm! ".w:netrw_hline."G0z")
+ exe "norm! ".w:netrw_hline."G0z\<CR>"
+
+ " restore position
+" call Decho("restore posn: exe norm! ".w:netrw_line."G0".w:netrw_col."|")
+ exe "norm! ".w:netrw_line."G0".w:netrw_col."\<bar>"
+
+ let &ei= eikeep
+" call Dret("NetRestorePosn")
+endfun
+
+" ------------------------------------------------------------------------
+" NetRead: responsible for reading a file over the net {{{1
+fun! netrw#NetRead(...)
+" call Dfunc("NetRead(a:1<".a:1.">)")
+
+ " save options
+ call s:NetOptionSave()
+
+ " Special Exception: if a file is named "0r", then
+ " "0r" will be used to read the
+ " following files instead of "r"
+ if a:0 == 0
+ let readcmd= "r"
+ let ichoice= 0
+ elseif a:1 == "0r"
+ let readcmd = "0r"
+ let ichoice = 2
+ else
+ let readcmd = "r"
+ let ichoice = 1
+ endif
+
+ " get name of a temporary file and set up shell-quoting character
+ let tmpfile= tempname()
+ 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")
+ return
+ endif
+
+" call Decho("ichoice=".ichoice." readcmd<".readcmd.">")
+ while ichoice <= a:0
+
+ " attempt to repeat with previous host-file-etc
+ if exists("b:netrw_lastfile") && a:0 == 0
+" call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">")
+ let choice = b:netrw_lastfile
+ let ichoice= ichoice + 1
+
+ else
+ exe "let choice= a:" . ichoice
+" call Decho("no lastfile: choice<" . choice . ">")
+
+ if match(choice,"?") == 0
+ " give help
+ echomsg 'NetRead Usage:'
+ echomsg ':Nread machine:path uses rcp'
+ echomsg ':Nread "machine path" uses ftp with <.netrc>'
+ echomsg ':Nread "machine id password path" uses ftp'
+ echomsg ':Nread dav://machine[:port]/path uses cadaver'
+ echomsg ':Nread fetch://machine/path uses fetch'
+ echomsg ':Nread ftp://[user@]machine[:port]/path uses ftp autodetects <.netrc>'
+ echomsg ':Nread http://[user@]machine/path uses http wget'
+ echomsg ':Nread rcp://[user@]machine/path uses rcp'
+ echomsg ':Nread rsync://machine[:port]/path uses rsync'
+ echomsg ':Nread scp://[user@]machine[[:#]port]/path uses scp'
+ echomsg ':Nread sftp://[user@]machine[[:#]port]/path uses sftp'
+ break
+
+ elseif match(choice,"^\"") != -1
+ " Reconstruct Choice if choice starts with '"'
+" call Decho("reconstructing choice")
+ if match(choice,"\"$") != -1
+ " case "..."
+ let choice=strpart(choice,1,strlen(choice)-2)
+ else
+ " case "... ... ..."
+ let choice = strpart(choice,1,strlen(choice)-1)
+ let wholechoice = ""
+
+ while match(choice,"\"$") == -1
+ let wholechoice = wholechoice . " " . choice
+ let ichoice = ichoice + 1
+ if ichoice > a:0
+ if !exists("g:netrw_quiet")
+ echohl Error | echo "***netrw*** Unbalanced string in filename '". wholechoice ."'" | echohl None
+ call inputsave()|call input("Press <cr> to continue")|call inputrestore()
+ endif
+" call Dret("NetRead")
+ return
+ endif
+ let choice= a:{ichoice}
+ endwhile
+ let choice= strpart(wholechoice,1,strlen(wholechoice)-1) . " " . strpart(choice,0,strlen(choice)-1)
+ endif
+ endif
+ endif
+
+" call Decho("choice<" . choice . ">")
+ let ichoice= ichoice + 1
+
+ " fix up windows urls
+ if has("win32") || has("win95") || has("win64") || has("win16")
+ let choice = substitute(choice,'\\','/','ge')
+" call Decho("fixing up windows url to <".choice."> tmpfile<".tmpfile)
+
+ exe 'lcd ' . fnamemodify(tmpfile,':h')
+ let tmpfile = fnamemodify(tmpfile,':t')
+ endif
+
+ " Determine method of read (ftp, rcp, etc)
+ call s:NetMethod(choice)
+
+ " Check if NetBrowse() should be handling this request
+" call Decho("checking if netlist: choice<".choice."> netrw_list_cmd<".g:netrw_list_cmd.">")
+ if choice =~ "^.*[\/]$"
+ keepjumps call s:NetBrowse(choice)
+" call Dret("NetRead")
+ return
+ endif
+
+ " ============
+ " Perform Read
+ " ============
+
+ ".........................................
+ " rcp: NetRead Method #1
+ if b:netrw_method == 1 " read with rcp
+" call Decho("read via rcp (method #1)")
+ " ER: noting done with g:netrw_uid yet?
+ " ER: on Win2K" rcp machine[.user]:file tmpfile
+ " ER: if machine contains '.' adding .user is required (use $USERNAME)
+ " ER: the tmpfile is full path: rcp sees C:\... as host C
+ if s:netrw_has_nt_rcp == 1
+ if exists("g:netrw_uid") && ( g:netrw_uid != "" )
+ let uid_machine = g:netrw_machine .'.'. g:netrw_uid
+ else
+ " Any way needed it machine contains a '.'
+ let uid_machine = g:netrw_machine .'.'. $USERNAME
+ endif
+ else
+ if exists("g:netrw_uid") && ( g:netrw_uid != "" )
+ let uid_machine = g:netrw_uid .'@'. g:netrw_machine
+ else
+ let uid_machine = g:netrw_machine
+ endif
+ endif
+" call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".uid_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile)
+ exe g:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".uid_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile
+ let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
+ let b:netrw_lastfile = choice
+
+ ".........................................
+ " ftp + <.netrc>: NetRead Method #2
+ elseif b:netrw_method == 2 " read with ftp + <.netrc>
+" 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."'"
+ 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
+ else
+" call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine)
+ exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine
+ endif
+ " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
+ if getline(1) !~ "^$" && !exists("g:netrw_quiet") && getline(1) !~ '^Trying '
+ let debugkeep= &debug
+ set debug=msg
+ echohl Error | echo "***netrw*** ".getline(1) | echohl None
+ call inputsave()|call input("Press <cr> to continue")|call inputrestore()
+ let &debug= debugkeep
+ endif
+ bd!
+ let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
+ let b:netrw_lastfile = choice
+
+ ".........................................
+ " ftp + machine,id,passwd,filename: NetRead Method #3
+ elseif b:netrw_method == 3 " read with ftp + machine, id, passwd, and fname
+ " Construct execution string (four lines) which will be passed through filter
+" call Decho("read via ftp+mipf (method #3)")
+ let netrw_fname= b:netrw_fname
+ new
+ setlocal ff=unix
+ if exists("g:netrw_port") && g:netrw_port != ""
+ put ='open '.g:netrw_machine.' '.g:netrw_port
+ else
+ put ='open '.g:netrw_machine
+ endif
+
+ if exists("g:netrw_ftp") && g:netrw_ftp == 1
+ put =g:netrw_uid
+ put =g:netrw_passwd
+ else
+ put ='user '.g:netrw_uid.' '.g:netrw_passwd
+ endif
+
+ if exists("g:netrw_ftpmode") && g:netrw_ftpmode != ""
+ put =g:netrw_ftpmode
+ endif
+ put ='get '.netrw_fname.' '.tmpfile
+
+ " 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"
+ " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
+ if getline(1) !~ "^$"
+" call Decho("error<".getline(1).">")
+ if !exists("g:netrw_quiet")
+ echohl Error | echo "***netrw*** ".getline(1) | echohl None
+ call inputsave()|call input("Press <cr> to continue")|call inputrestore()
+ endif
+ endif
+ bd!
+ let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
+ let b:netrw_lastfile = choice
+
+ ".........................................
+ " scp: NetRead Method #4
+ elseif b:netrw_method == 4 " read with scp
+" call Decho("read via scp (method #4)")
+ if exists("g:netrw_port") && g:netrw_port != ""
+ let useport= " -P ".g:netrw_port
+ else
+ let useport= ""
+ endif
+ if g:netrw_cygwin == 1
+ let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
+" call Decho("executing: !".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile)
+ exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile
+ else
+" 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 b:netrw_lastfile = choice
+
+ ".........................................
+ elseif b:netrw_method == 5 " read with http (wget)
+" call Decho("read via http (method #5)")
+ if g:netrw_http_cmd == ""
+ if !exists("g:netrw_quiet")
+ 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
+ endif
+
+ if match(b:netrw_fname,"#") == -1
+ " simple wget
+" call Decho("executing: !".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.escape(b:netrw_fname,' ?&'))
+ exe g:netrw_silentxfer."!".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.escape(b:netrw_fname,' ?&')
+ let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
+
+ else
+ " wget plus a jump to an in-page marker (ie. http://abc/def.html#aMarker)
+ let netrw_html= substitute(b:netrw_fname,"#.*$","","")
+ let netrw_tag = substitute(b:netrw_fname,"^.*#","","")
+" call Decho("netrw_html<".netrw_html.">")
+" call Decho("netrw_tag <".netrw_tag.">")
+" call Decho("executing: !".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_html)
+ exe g:netrw_silentxfer."!".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_html
+ let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
+" call Decho('<\s*a\s*name=\s*"'.netrw_tag.'"/')
+ exe 'norm! 1G/<\s*a\s*name=\s*"'.netrw_tag.'"/'."\<CR>"
+ endif
+ let b:netrw_lastfile = choice
+
+ ".........................................
+ " cadaver: NetRead Method #6
+ elseif b:netrw_method == 6 " read with cadaver
+" call Decho("read via cadaver (method #6)")
+
+ " Construct execution string (four lines) which will be passed through filter
+ let netrw_fname= b:netrw_fname
+ new
+ setlocal ff=unix
+ if exists("g:netrw_port") && g:netrw_port != ""
+ put ='open '.g:netrw_machine.' '.g:netrw_port
+ else
+ put ='open '.g:netrw_machine
+ endif
+ put ='user '.g:netrw_uid.' '.g:netrw_passwd
+
+ if g:netrw_cygwin == 1
+ let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
+ put ='get '.netrw_fname.' '.cygtmpfile
+ else
+ put ='get '.netrw_fname.' '.tmpfile
+ endif
+ put ='quit'
+
+ " perform cadaver operation:
+ norm! 1Gdd
+" call Decho("executing: %!".g:netrw_dav_cmd)
+ exe g:netrw_silentxfer."%!".g:netrw_dav_cmd
+ bd!
+ let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
+ let b:netrw_lastfile = choice
+
+ ".........................................
+ " rsync: NetRead Method #7
+ elseif b:netrw_method == 7 " read with rsync
+" call Decho("read via rsync (method #7)")
+ if g:netrw_cygwin == 1
+ let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
+" call Decho("executing: !".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile)
+ exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile
+ else
+" call Decho("executing: !".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile)
+ exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile
+ endif
+ let result = s:NetGetFile(readcmd,tmpfile, b:netrw_method)
+ let b:netrw_lastfile = choice
+
+ ".........................................
+ " fetch: NetRead Method #8
+ " fetch://[user@]host[:http]/path
+ elseif b:netrw_method == 8 " read with fetch
+ if g:netrw_fetch_cmd == ""
+ if !exists("g:netrw_quiet")
+ echohl Error | echo "***netrw*** fetch command not available" | echohl None
+ call inputsave()|call input("Press <cr> to continue")|call inputrestore()
+ endif
+ exit
+ endif
+ if exists("g:netrw_option") && g:netrw_option == ":http"
+ let netrw_option= "http"
+ else
+ let netrw_option= "ftp"
+ endif
+" call Decho("read via fetch for ".netrw_option)
+
+ if exists("g:netrw_uid") && g:netrw_uid != "" && exists("g:netrw_passwd") && g:netrw_passwd != ""
+" call Decho("executing: !".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_uid.':'.g:netrw_passwd.'@'.g:netrw_machine."/".escape(b:netrw_fname,' ?&'))
+ exe g:netrw_silentxfer."!".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_uid.':'.g:netrw_passwd.'@'.g:netrw_machine."/".escape(b:netrw_fname,' ?&')
+ else
+" call Decho("executing: !".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_machine."/".escape(b:netrw_fname,' ?&'))
+ exe g:netrw_silentxfer."!".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_machine."/".escape(b:netrw_fname,' ?&')
+ endif
+
+ let result = s:NetGetFile(readcmd,tmpfile, b:netrw_method)
+ let b:netrw_lastfile = choice
+
+ ".........................................
+ " sftp: NetRead Method #9
+ elseif b:netrw_method == 9 " read with sftp
+" call Decho("read via sftp (method #4)")
+ if g:netrw_cygwin == 1
+ let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
+" call Decho("!".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile)
+" call Decho("executing: !".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile)
+ exe "!".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile
+ else
+" call Decho("executing: !".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile)
+ exe g:netrw_silentxfer."!".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile
+ endif
+ let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
+ let b:netrw_lastfile = choice
+
+ ".........................................
+ else " Complain
+ echo "***warning*** unable to comply with your request<" . choice . ">"
+ endif
+ endwhile
+
+ " cleanup
+" call Decho("cleanup")
+ if exists("b:netrw_method")
+ unlet b:netrw_method
+ unlet b:netrw_fname
+ endif
+ call s:NetOptionRestore()
+
+" call Dret("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.">)")
+
+ if exists("*NetReadFixup")
+ " for the use of NetReadFixup (not otherwise used internally)
+ let line2= line("$")
+ endif
+
+ " 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.">")
+ else
+ let fname= substitute(a:fname,'/','\\\\','ge')
+" call Decho("(win32 && !cygwin) fname<".fname.">")
+ endif
+ else
+ let fname= a:fname
+" call Decho("(copied) fname<".fname.">")
+ 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)
+ if v:version < 700
+ exe "file ".fname
+ else
+ keepalt exe "file ".fname
+ endif
+" call Dredir("ls!","after renaming current buffer to <".fname.">")
+
+ " edit temporary file
+ e
+" call Dredir("ls!","after editing temporary file")
+
+ " rename buffer back to remote filename
+ if v:version < 700
+ exe "file ".rfile
+ else
+ keepalt exe "file ".rfile
+ endif
+" call Dredir("ls!","renaming buffer back to remote filename<".rfile.">")
+ let line1 = 1
+ let line2 = line("$")
+
+ elseif filereadable(fname)
+ " 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
+ let line1 = curline + 1
+ let line2 = line("$") - lastline + 1
+ let s:netrw_line = s:netrw_line + 1
+ let s:netrw_col = 1
+ else
+ " not readable
+" call Dret("NetGetFile : fname<".fname."> not readable")
+ return
+ endif
+
+ " User-provided (ie. optional) fix-it-up command
+ if exists("*NetReadFixup")
+" call Decho("calling NetReadFixup(method<".a:method."> line1=".line1." line2=".line2.")")
+ call NetReadFixup(a:method, line1, line2)
+" else " Decho
+" call Decho("NetReadFixup() not called, doesn't exist")
+ endif
+
+ " update the Buffers menu
+ if has("gui") && has("gui_running")
+ silent! emenu Buffers.Refresh\ menu
+ endif
+
+" call Decho("readcmd<".a:readcmd."> cmdarg<".v:cmdarg."> fname<".a:fname."> readable=".filereadable(a:fname))
+
+ " insure that we have the right filetype and that its being displayed
+ filetype detect
+ redraw!
+" call Dret("NetGetFile")
+endfun
+
+" ------------------------------------------------------------------------
+" NetWrite: responsible for writing a file over the net {{{1
+fun! netrw#NetWrite(...) range
+" call Dfunc("NetWrite(a:0=".a:0.")")
+
+ " option handling
+ let mod= 0
+ call s:NetOptionSave()
+
+ " Get Temporary Filename
+ let tmpfile= tempname()
+ 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")
+ return
+ endif
+
+ if a:0 == 0
+ let ichoice = 0
+ else
+ let ichoice = 1
+ endif
+
+ " write (selected portion of) file to temporary
+ silent exe a:firstline."," . a:lastline . "w! ".v:cmdarg." ".tmpfile
+
+ while ichoice <= a:0
+
+ " attempt to repeat with previous host-file-etc
+ if exists("b:netrw_lastfile") && a:0 == 0
+" call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">")
+ let choice = b:netrw_lastfile
+ let ichoice= ichoice + 1
+ else
+ exe "let choice= a:" . ichoice
+
+ " Reconstruct Choice if choice starts with '"'
+ if match(choice,"?") == 0
+ echomsg 'NetWrite Usage:"'
+ echomsg ':Nwrite machine:path uses rcp'
+ echomsg ':Nwrite "machine path" uses ftp with <.netrc>'
+ echomsg ':Nwrite "machine id password path" uses ftp'
+ echomsg ':Nwrite dav://[user@]machine/path uses cadaver'
+ echomsg ':Nwrite fetch://[user@]machine/path uses fetch'
+ echomsg ':Nwrite ftp://machine[#port]/path uses ftp (autodetects <.netrc>)'
+ echomsg ':Nwrite rcp://machine/path uses rcp'
+ echomsg ':Nwrite rsync://[user@]machine/path uses rsync'
+ echomsg ':Nwrite scp://[user@]machine[[:#]port]/path uses scp'
+ echomsg ':Nwrite sftp://[user@]machine/path uses sftp'
+ break
+
+ elseif match(choice,"^\"") != -1
+ if match(choice,"\"$") != -1
+ " case "..."
+ let choice=strpart(choice,1,strlen(choice)-2)
+ else
+ " case "... ... ..."
+ let choice = strpart(choice,1,strlen(choice)-1)
+ let wholechoice = ""
+
+ while match(choice,"\"$") == -1
+ let wholechoice= wholechoice . " " . choice
+ let ichoice = ichoice + 1
+ if choice > a:0
+ if !exists("g:netrw_quiet")
+ echohl Error | echo "***netrw*** Unbalanced string in filename '". wholechoice ."'" | echohl None
+ call inputsave()|call input("Press <cr> to continue")|call inputrestore()
+ endif
+" call Dret("NetWrite")
+ return
+ endif
+ let choice= a:{ichoice}
+ endwhile
+ let choice= strpart(wholechoice,1,strlen(wholechoice)-1) . " " . strpart(choice,0,strlen(choice)-1)
+ endif
+ endif
+ endif
+" call Decho("choice<" . choice . ">")
+ let ichoice= ichoice + 1
+
+ " fix up windows urls
+ if has("win32") || has("win95") || has("win64") || has("win16")
+ let choice= substitute(choice,'\\','/','ge')
+ "ER: see NetRead()
+ exe 'lcd ' . fnamemodify(tmpfile,':h')
+ let tmpfile = fnamemodify(tmpfile,':t')
+ endif
+
+ " Determine method of read (ftp, rcp, etc)
+ call s:NetMethod(choice)
+
+ " =============
+ " Perform Write
+ " =============
+
+ ".........................................
+ " rcp: NetWrite Method #1
+ if b:netrw_method == 1 " write with rcp
+" 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
+ else
+ let uid_machine = g:netrw_machine .'.'. $USERNAME
+ endif
+ else
+ if exists("g:netrw_uid") && ( g:netrw_uid != "" )
+ let uid_machine = g:netrw_uid .'@'. g:netrw_machine
+ else
+ let uid_machine = g:netrw_machine
+ endif
+ endif
+" call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".tmpfile." ".uid_machine.":".escape(b:netrw_fname,' ?&'))
+ exe g:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".tmpfile." ".uid_machine.":".escape(b:netrw_fname,' ?&')
+ let b:netrw_lastfile = choice
+
+ ".........................................
+ " ftp + <.netrc>: NetWrite Method #2
+ elseif b:netrw_method == 2 " write with ftp + <.netrc>
+ let netrw_fname = b:netrw_fname
+ 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."'")
+ 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
+ else
+" call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine)
+ exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine
+ endif
+ " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
+ if getline(1) !~ "^$"
+ if !exists("g:netrw_quiet")
+ echohl Error | echo "***netrw*** ".getline(1) | echohl None
+ call inputsave()|call input("Press <cr> to continue")|call inputrestore()
+ endif
+ let mod=1
+ endif
+ bd!
+ let b:netrw_lastfile = choice
+
+ ".........................................
+ " ftp + machine, id, passwd, filename: NetWrite Method #3
+ elseif b:netrw_method == 3 " write with ftp + machine, id, passwd, and fname
+ let netrw_fname= b:netrw_fname
+ new
+ setlocal ff=unix
+ if exists("g:netrw_port") && g:netrw_port != ""
+ put ='open '.g:netrw_machine.' '.g:netrw_port
+ else
+ put ='open '.g:netrw_machine
+ endif
+ if exists("g:netrw_ftp") && g:netrw_ftp == 1
+ put =g:netrw_uid
+ put =g:netrw_passwd
+ else
+ put ='user '.g:netrw_uid.' '.g:netrw_passwd
+ endif
+ put ='put '.tmpfile.' '.netrw_fname
+ " save choice/id/password for future use
+ let b:netrw_lastfile = choice
+
+ " 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"
+ " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
+ if getline(1) !~ "^$"
+ if !exists("g:netrw_quiet")
+ echohl Error | echo "***netrw*** ".getline(1) | echohl None
+ call inputsave()|call input("Press <cr> to continue")|call inputrestore()
+ endif
+ let mod=1
+ endif
+ bd!
+
+ ".........................................
+ " scp: NetWrite Method #4
+ elseif b:netrw_method == 4 " write with scp
+ if exists("g:netrw_port") && g:netrw_port != ""
+ let useport= " -P ".g:netrw_port
+ else
+ let useport= ""
+ endif
+ if g:netrw_cygwin == 1
+ let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
+" call Decho("executing: !".g:netrw_scp_cmd.useport." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&'))
+ exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')
+ else
+" call Decho("executing: !".g:netrw_scp_cmd.useport." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&'))
+ exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')
+ endif
+ let b:netrw_lastfile = choice
+
+ ".........................................
+ " http: NetWrite Method #5
+ elseif b:netrw_method == 5
+ if !exists("g:netrw_quiet")
+ echohl Error | echo "***netrw*** currently <netrw.vim> does not support writing using http:" | echohl None
+ call inputsave()|call input("Press <cr> to continue")|call inputrestore()
+ endif
+
+ ".........................................
+ " dav: NetWrite Method #6
+ elseif b:netrw_method == 6 " write with cadaver
+" call Decho("write via cadaver (method #6)")
+
+ " Construct execution string (four lines) which will be passed through filter
+ let netrw_fname= b:netrw_fname
+ new
+ setlocal ff=unix
+ if exists("g:netrw_port") && g:netrw_port != ""
+ put ='open '.g:netrw_machine.' '.g:netrw_port
+ else
+ put ='open '.g:netrw_machine
+ endif
+ put ='user '.g:netrw_uid.' '.g:netrw_passwd
+
+ if g:netrw_cygwin == 1
+ let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
+ put ='put '.cygtmpfile.' '.netrw_fname
+ else
+ put ='put '.tmpfile.' '.netrw_fname
+ endif
+
+ " perform cadaver operation:
+ norm! 1Gdd
+" call Decho("executing: %!".g:netrw_dav_cmd)
+ exe g:netrw_silentxfer."%!".g:netrw_dav_cmd
+ bd!
+ let b:netrw_lastfile = choice
+
+ ".........................................
+ " rsync: NetWrite Method #7
+ elseif b:netrw_method == 7 " write with rsync
+ if g:netrw_cygwin == 1
+ let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
+" call Decho("executing: !".g:netrw_rsync_cmd." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&'))
+ exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')
+ else
+" call Decho("executing: !".g:netrw_rsync_cmd." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&'))
+ exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')
+ endif
+ let b:netrw_lastfile = choice
+
+ ".........................................
+ " scp: NetWrite Method #9
+ elseif b:netrw_method == 9 " write with sftp
+ let netrw_fname= b:netrw_fname
+ if exists("g:netrw_uid") && ( g:netrw_uid != "" )
+ let uid_machine = g:netrw_uid .'@'. g:netrw_machine
+ else
+ let uid_machine = g:netrw_machine
+ endif
+ new
+ setlocal ff=unix
+ put ='put '.tmpfile.' '.netrw_fname
+ norm! 1Gdd
+" call Decho("executing: %!".g:netrw_sftp_cmd.' '.uid_machine)
+ exe g:netrw_silentxfer."%!".g:netrw_sftp_cmd.' '.uid_machine
+ bd!
+ let b:netrw_lastfile= choice
+
+ ".........................................
+ else " Complain
+ echo "***warning*** unable to comply with your request<" . choice . ">"
+ endif
+ endwhile
+
+ " cleanup
+" call Decho("cleanup")
+ let result=delete(tmpfile)
+ call s:NetOptionRestore()
+
+ if a:firstline == 1 && a:lastline == line("$")