Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

9140 lines (8291 sloc) 373.848 kb
" netrw.vim: Handles file transfer and remote directory listing across
" AUTOLOAD SECTION
" Date: Apr 05, 2012
" Version: 145
" Maintainer: Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
" Copyright: Copyright (C) 1999-2010 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, netrwPlugin.vim, and netrwSettings.vim are provided
" *as is* and come 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.
"redraw!|call DechoSep()|call inputsave()|call input("Press <cr> to continue")|call inputrestore()
"
" But be doers of the Word, and not only hearers, deluding your own selves {{{1
" (James 1:22 RSV)
" =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
" Load Once: {{{1
if &cp || exists("g:loaded_netrw")
finish
endif
let g:loaded_netrw = "v145"
if v:version < 702
echohl WarningMsg
echo "***warning*** this version of netrw needs vim 7.2"
echohl Normal
finish
endif
if !exists("s:NOTE")
let s:NOTE = 0
let s:WARNING = 1
let s:ERROR = 2
endif
" sanity checks
if v:version < 700
call netrw#ErrorMsg(s:WARNING,"you need vim version 7.0 or later for version ".g:loaded_netrw." of netrw",1)
finish
endif
let s:keepcpo= &cpo
set cpo&vim
"DechoTabOn
"call Decho("doing autoload/netrw.vim version ".g:loaded_netrw)
" ======================
" Netrw Variables: {{{1
" ======================
" ---------------------------------------------------------------------
" netrw#ErrorMsg: {{{2
" 0=note = s:NOTE
" 1=warning = s:WARNING
" 2=error = s:ERROR
" Apr 05, 2012 : max errnum currently is 88
fun! netrw#ErrorMsg(level,msg,errnum)
" call Dfunc("netrw#ErrorMsg(level=".a:level." msg<".a:msg."> errnum=".a:errnum.") g:netrw_use_errorwindow=".g:netrw_use_errorwindow)
if a:level < g:netrw_errorlvl
call Dret("netrw#ErrorMsg : suppressing level=".a:level." since g;netrw_errorlvl=".g:netrw_errorlvl)
return
endif
if a:level == 1
let level= "**warning** (netrw) "
elseif a:level == 2
let level= "**error** (netrw) "
else
let level= "**note** (netrw) "
endif
" call Decho("level=".level)
if g:netrw_use_errorwindow
" (default) netrw creates a one-line window to show error/warning
" messages (reliably displayed)
" record current window number for NetrwRestorePosn()'s benefit
let s:winBeforeErr= winnr()
" call Decho("s:winBeforeErr=".s:winBeforeErr)
" getting messages out reliably is just plain difficult!
" This attempt splits the current window, creating a one line window.
if bufexists("NetrwMessage") && bufwinnr("NetrwMessage") > 0
" call Decho("write to NetrwMessage buffer")
exe bufwinnr("NetrwMessage")."wincmd w"
" call Decho("setl ma noro")
setl ma noro
keepj call setline(line("$")+1,level.a:msg)
keepj $
else
" call Decho("create a NetrwMessage buffer window")
bo 1split
sil! call s:NetrwEnew()
sil! keepj call s:NetrwSafeOptions()
setl bt=nofile
keepj file NetrwMessage
" call Decho("setlocal ma noro")
setl ma noro
call setline(line("$"),level.a:msg)
endif
" call Decho("wrote msg<".level.a:msg."> to NetrwMessage win#".winnr())
if &fo !~ '[ta]'
syn clear
syn match netrwMesgNote "^\*\*note\*\*"
syn match netrwMesgWarning "^\*\*warning\*\*"
syn match netrwMesgError "^\*\*error\*\*"
hi link netrwMesgWarning WarningMsg
hi link netrwMesgError Error
endif
" call Decho("(ErrorMsg) setl noma ro bh=wipe")
setl noma ro bh=wipe
else
" (optional) netrw will show messages using echomsg. Even if the
" message doesn't appear, at least it'll be recallable via :messages
" redraw!
if a:level == s:WARNING
echohl WarningMsg
elseif a:level == s:ERROR
echohl Error
endif
echomsg level.a:msg
" call Decho("echomsg ***netrw*** ".a:msg)
echohl None
endif
" call Dret("netrw#ErrorMsg")
endfun
" ---------------------------------------------------------------------
" NetrwInit: initializes variables if they haven't been defined {{{2
" Loosely, varname = value.
fun s:NetrwInit(varname,value)
if !exists(a:varname)
if type(a:value) == 0
exe "let ".a:varname."=".a:value
elseif type(a:value) == 1
exe "let ".a:varname."="."'".a:value."'"
else
exe "let ".a:varname."=".a:value
endif
endif
endfun
" ---------------------------------------------------------------------
" Netrw Constants: {{{2
call s:NetrwInit("g:netrw_dirhist_cnt",0)
if !exists("s:LONGLIST")
call s:NetrwInit("s:THINLIST",0)
call s:NetrwInit("s:LONGLIST",1)
call s:NetrwInit("s:WIDELIST",2)
call s:NetrwInit("s:TREELIST",3)
call s:NetrwInit("s:MAXLIST" ,4)
endif
" ---------------------------------------------------------------------
" Default values for netrw's global protocol variables {{{2
call s:NetrwInit("g:netrw_use_errorwindow",1)
if !exists("g:netrw_dav_cmd")
if executable("cadaver")
let g:netrw_dav_cmd = "cadaver"
elseif executable("curl")
let g:netrw_dav_cmd = "curl"
else
let g:netrw_dav_cmd = ""
endif
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 !exists("g:netrw_ftp_cmd")
let g:netrw_ftp_cmd = "ftp"
endif
let s:netrw_ftp_cmd= g:netrw_ftp_cmd
if !exists("g:netrw_ftp_options")
let g:netrw_ftp_options= "-i -n"
endif
if !exists("g:netrw_http_cmd")
if executable("elinks")
let g:netrw_http_cmd = "elinks"
call s:NetrwInit("g:netrw_http_xcmd","-source >")
elseif executable("links")
let g:netrw_http_cmd = "links"
call s:NetrwInit("g:netrw_http_xcmd","-source >")
elseif executable("curl")
let g:netrw_http_cmd = "curl"
call s:NetrwInit("g:netrw_http_xcmd","-o")
elseif executable("wget")
let g:netrw_http_cmd = "wget"
call s:NetrwInit("g:netrw_http_xcmd","-q -O")
elseif executable("fetch")
let g:netrw_http_cmd = "fetch"
call s:NetrwInit("g:netrw_http_xcmd","-o")
else
let g:netrw_http_cmd = ""
endif
endif
call s:NetrwInit("g:netrw_rcp_cmd" , "rcp")
call s:NetrwInit("g:netrw_rsync_cmd", "rsync")
call s:NetrwInit("g:netrw_scp_cmd" , "scp -q")
call s:NetrwInit("g:netrw_sftp_cmd" , "sftp")
call s:NetrwInit("g:netrw_ssh_cmd" , "ssh")
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 {{{2
" Cygwin Detection ------- {{{3
if !exists("g:netrw_cygwin")
if has("win32") || has("win95") || has("win64") || has("win16")
if &shell =~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$'
let g:netrw_cygwin= 1
else
let g:netrw_cygwin= 0
endif
else
let g:netrw_cygwin= 0
endif
endif
" Default values - a-c ---------- {{{3
call s:NetrwInit("g:netrw_alto" , &sb)
call s:NetrwInit("g:netrw_altv" , &spr)
call s:NetrwInit("g:netrw_banner" , 1)
call s:NetrwInit("g:netrw_browse_split", 0)
call s:NetrwInit("g:netrw_bufsettings" , "noma nomod nonu nobl nowrap ro")
call s:NetrwInit("g:netrw_chgwin" , -1)
call s:NetrwInit("g:netrw_compress" , "gzip")
call s:NetrwInit("g:netrw_ctags" , "ctags")
if exists("g:netrw_cursorline") && !exists("g:netrw_cursor")
call netrw#ErrorMsg(s:NOTE,'g:netrw_cursorline is deprecated; use g:netrw_cursor instead',77)
let g:netrw_cursor= g:netrw_cursorline
endif
call s:NetrwInit("g:netrw_cursor" , 2)
let s:netrw_usercul = &cursorline
let s:netrw_usercuc = &cursorcolumn
" Default values - d-g ---------- {{{3
call s:NetrwInit("g:netrw_dirhist_cnt" , 0)
call s:NetrwInit("g:netrw_decompress" , '{ ".gz" : "gunzip", ".bz2" : "bunzip2", ".zip" : "unzip", ".tar" : "tar -xf", ".xz" : "unxz" }')
call s:NetrwInit("g:netrw_dirhistmax" , 10)
call s:NetrwInit("g:netrw_errorlvl" , s:NOTE)
call s:NetrwInit("g:netrw_fastbrowse" , 1)
call s:NetrwInit("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$')
if !exists("g:netrw_ftp_list_cmd")
if has("unix") || (exists("g:netrw_cygwin") && g:netrw_cygwin)
let g:netrw_ftp_list_cmd = "ls -lF"
let g:netrw_ftp_timelist_cmd = "ls -tlF"
let g:netrw_ftp_sizelist_cmd = "ls -slF"
else
let g:netrw_ftp_list_cmd = "dir"
let g:netrw_ftp_timelist_cmd = "dir"
let g:netrw_ftp_sizelist_cmd = "dir"
endif
endif
call s:NetrwInit("g:netrw_ftpmode",'binary')
" Default values - h-lh ---------- {{{3
call s:NetrwInit("g:netrw_hide",1)
if !exists("g:netrw_ignorenetrc")
if &shell =~ '\c\<\%(cmd\|4nt\)\.exe$'
let g:netrw_ignorenetrc= 1
else
let g:netrw_ignorenetrc= 0
endif
endif
call s:NetrwInit("g:netrw_keepdir",1)
if !exists("g:netrw_list_cmd")
if g:netrw_scp_cmd =~ '^pscp' && executable("pscp")
" provide a 'pscp' listing command
if (has("win32") || has("win95") || has("win64") || has("win16")) && filereadable("c:\\private.ppk")
let g:netrw_scp_cmd ="pscp -i C:\\private.ppk"
endif
let g:netrw_list_cmd= g:netrw_scp_cmd." -ls USEPORT HOSTNAME:"
elseif executable(g:netrw_ssh_cmd)
" provide a default listing command
let g:netrw_list_cmd= g:netrw_ssh_cmd." USEPORT HOSTNAME ls -FLa"
else
" call Decho(g:netrw_ssh_cmd." is not executable")
let g:netrw_list_cmd= ""
endif
endif
call s:NetrwInit("g:netrw_list_hide","")
" Default values - lh-lz ---------- {{{3
if exists("g:netrw_local_copycmd")
let g:netrw_localcopycmd= g:netrw_local_copycmd"
call netrw#ErrorMsg(s:NOTE,"g:netrw_local_copycmd is deprecated in favor of g:netrw_localcopycmd",84)
endif
if !exists("g:netrw_localcopycmd")
if has("win32") || has("win95") || has("win64") || has("win16")
if g:netrw_cygwin
let g:netrw_localcopycmd= "cp"
else
let g:netrw_localcopycmd= "copy"
endif
elseif has("unix") || has("macunix")
let g:netrw_localcopycmd= "cp"
else
let g:netrw_localcopycmd= ""
endif
if !executable(g:netrw_localcopycmd)
call netrw#ErrorMsg(s:NOTE,"consider setting g:netrw_localcopycmd<".g:netrw_localcopycmd."> to something that works",80)
endif
endif
if exists("g:netrw_local_mkdir")
let g:netrw_localmkdir= g:netrw_local_mkdir"
call netrw#ErrorMsg(s:NOTE,"g:netrw_local_mkdir is deprecated in favor of g:netrw_localmkdir",87)
endif
call s:NetrwInit("g:netrw_localmkdir","mkdir")
if !executable(g:netrw_localmkdir)
call netrw#ErrorMsg(s:NOTE,"consider setting g:netrw_localmkdir<".g:netrw_localmkdir."> to something that works",80)
endif
call s:NetrwInit("g:netrw_remote_mkdir","mkdir")
if exists("g:netrw_local_movecmd")
let g:netrw_localmovecmd= g:netrw_local_movecmd"
call netrw#ErrorMsg(s:NOTE,"g:netrw_local_movecmd is deprecated in favor of g:netrw_localmovecmd",88)
endif
if !exists("g:netrw_localmovecmd")
if has("win32") || has("win95") || has("win64") || has("win16")
if g:netrw_cygwin
let g:netrw_localmovecmd= "mv"
else
let g:netrw_localmovecmd= "move"
endif
elseif has("unix") || has("macunix")
let g:netrw_localmovecmd= "mv"
else
let g:netrw_localmovecmd= ""
endif
if !executable(g:netrw_localmkdir)
call netrw#ErrorMsg(s:NOTE,"consider setting g:netrw_localmkdir<".g:netrw_localmkdir."> to something that works",81)
endif
endif
call s:NetrwInit("g:netrw_localrmdir", "rmdir")
if exists("g:netrw_local_rmdir")
let g:netrw_localrmdir= g:netrw_local_rmdir"
call netrw#ErrorMsg(s:NOTE,"g:netrw_local_rmdir is deprecated in favor of g:netrw_localrmdir",86)
endif
if !executable(g:netrw_localrmdir)
call netrw#ErrorMsg(s:NOTE,"consider setting g:netrw_localrmdir<".g:netrw_localrmdir."> to something that works",82)
endif
call s:NetrwInit("g:netrw_liststyle" , s:THINLIST)
" sanity checks
if g:netrw_liststyle < 0 || g:netrw_liststyle >= s:MAXLIST
let g:netrw_liststyle= s:THINLIST
endif
if g:netrw_liststyle == s:LONGLIST && g:netrw_scp_cmd !~ '^pscp'
let g:netrw_list_cmd= g:netrw_list_cmd." -l"
endif
" Default values - m-r ---------- {{{3
call s:NetrwInit("g:netrw_markfileesc" , '*./[\~')
call s:NetrwInit("g:netrw_maxfilenamelen", 32)
call s:NetrwInit("g:netrw_menu" , 1)
call s:NetrwInit("g:netrw_mkdir_cmd" , g:netrw_ssh_cmd." USEPORT HOSTNAME mkdir")
call s:NetrwInit("g:netrw_mousemaps" , (exists("&mouse") && &mouse =~ '[anh]'))
call s:NetrwInit("g:netrw_retmap" , 0)
if has("unix") || (exists("g:netrw_cygwin") && g:netrw_cygwin)
call s:NetrwInit("g:netrw_chgperm" , "chmod PERM FILENAME")
elseif has("win32") || has("win95") || has("win64") || has("win16")
call s:NetrwInit("g:netrw_chgperm" , "cacls FILENAME /e /p PERM")
else
call s:NetrwInit("g:netrw_chgperm" , "chmod PERM FILENAME")
endif
call s:NetrwInit("g:netrw_preview" , 0)
call s:NetrwInit("g:netrw_scpport" , "-P")
call s:NetrwInit("g:netrw_sshport" , "-p")
call s:NetrwInit("g:netrw_rename_cmd" , g:netrw_ssh_cmd." USEPORT HOSTNAME mv")
call s:NetrwInit("g:netrw_rm_cmd" , g:netrw_ssh_cmd." USEPORT HOSTNAME rm")
call s:NetrwInit("g:netrw_rmdir_cmd" , g:netrw_ssh_cmd." USEPORT HOSTNAME rmdir")
call s:NetrwInit("g:netrw_rmf_cmd" , g:netrw_ssh_cmd." USEPORT HOSTNAME rm -f")
" Default values - s ---------- {{{3
" g:netrw_sepchr: picking a character that doesn't appear in filenames that can be used to separate priority from filename
call s:NetrwInit("g:netrw_sepchr" , (&enc == "euc-jp")? "\<Char-0x01>" : "\<Char-0xff>")
call s:NetrwInit("s:netrw_silentxfer" , (exists("g:netrw_silent") && g:netrw_silent != 0)? "sil keepj " : "keepj ")
call s:NetrwInit("g:netrw_sort_by" , "name") " alternatives: date , size
call s:NetrwInit("g:netrw_sort_options" , "")
call s:NetrwInit("g:netrw_sort_direction", "normal") " alternative: reverse (z y x ...)
if !exists("g:netrw_sort_sequence")
if has("unix")
let g:netrw_sort_sequence= '[\/]$,\<core\%(\.\d\+\)\=\>,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$'
else
let g:netrw_sort_sequence= '[\/]$,\.h$,\.c$,\.cpp$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$'
endif
endif
call s:NetrwInit("g:netrw_special_syntax" , 0)
call s:NetrwInit("g:netrw_ssh_browse_reject", '^total\s\+\d\+$')
call s:NetrwInit("g:netrw_use_noswf" , 0)
" Default values - t-w ---------- {{{3
call s:NetrwInit("g:netrw_timefmt","%c")
call s:NetrwInit("g:netrw_xstrlen",0)
call s:NetrwInit("g:NetrwTopLvlMenu","Netrw.")
call s:NetrwInit("g:netrw_win95ftp",1)
call s:NetrwInit("g:netrw_winsize",50)
if g:netrw_winsize == 0|let g:netrw_winsize= -1|endif
if g:netrw_winsize > 100|let g:netrw_winsize= 100|endif
" ---------------------------------------------------------------------
" Default values for netrw's script variables: {{{2
call s:NetrwInit("g:netrw_fname_escape",' ?&;%')
if has("win32") || has("win95") || has("win64") || has("win16")
call s:NetrwInit("g:netrw_glob_escape",'[]*?`{$')
else
call s:NetrwInit("g:netrw_glob_escape",'[]*?`{~$\')
endif
call s:NetrwInit("g:netrw_menu_escape",'./&? \')
call s:NetrwInit("g:netrw_tmpfile_escape",' &;')
call s:NetrwInit("s:netrw_map_escape","<|\n\r\\\<C-V>\"")
" 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
" ======================
" Netrw Initialization: {{{1
" ======================
if v:version >= 700 && has("balloon_eval") && !exists("s:initbeval") && !exists("g:netrw_nobeval") && has("syntax") && exists("g:syntax_on")
let s:initbeval = &beval
" let s:initbexpr = &l:bexpr
let &l:bexpr = "netrw#NetrwBalloonHelp()"
set beval
au BufWinEnter,WinEnter * if &ft == "netrw"|set beval|else|let &beval= s:initbeval|endif
endif
au WinEnter * if &ft == "netrw"|call s:NetrwInsureWinVars()|endif
" ==============================
" Netrw Utility Functions: {{{1
" ==============================
" ---------------------------------------------------------------------
" netrw#NetrwBalloonHelp: {{{2
if v:version >= 700 && has("balloon_eval") && &beval == 1 && has("syntax") && exists("g:syntax_on")
fun! netrw#NetrwBalloonHelp()
if !exists("w:netrw_bannercnt") || v:beval_lnum >= w:netrw_bannercnt || (exists("g:netrw_nobeval") && g:netrw_nobeval)
let mesg= ""
elseif v:beval_text == "Netrw" || v:beval_text == "Directory" || v:beval_text == "Listing"
let mesg = "i: thin-long-wide-tree gh: quick hide/unhide of dot-files qf: quick file info %:open new file"
elseif getline(v:beval_lnum) =~ '^"\s*/'
let mesg = "<cr>: edit/enter o: edit/enter in horiz window t: edit/enter in new tab v:edit/enter in vert window"
elseif v:beval_text == "Sorted" || v:beval_text == "by"
let mesg = 's: sort by name, time, or file size r: reverse sorting order mt: mark target'
elseif v:beval_text == "Sort" || v:beval_text == "sequence"
let mesg = "S: edit sorting sequence"
elseif v:beval_text == "Hiding" || v:beval_text == "Showing"
let mesg = "a: hiding-showing-all ctrl-h: editing hiding list mh: hide/show by suffix"
elseif v:beval_text == "Quick" || v:beval_text == "Help"
let mesg = "Help: press <F1>"
elseif v:beval_text == "Copy/Move" || v:beval_text == "Tgt"
let mesg = "mt: mark target mc: copy marked file to target mm: move marked file to target"
else
let mesg= ""
endif
return mesg
endfun
endif
" ------------------------------------------------------------------------
" s:NetrwOptionSave: save options and set to "standard" form {{{2
" 06/08/07 : removed call to NetrwSafeOptions(), either placed
" immediately after NetrwOptionSave() calls in NetRead
" and NetWrite, or after the s:NetrwEnew() call in
" NetrwBrowse.
" vt: normally its "w:" or "s:" (a variable type)
fun! s:NetrwOptionSave(vt)
" call Dfunc("s:NetrwOptionSave(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")."<".bufname(bufnr("%")).">"." winnr($)=".winnr("$"))
" call Decho(a:vt."netrw_optionsave".(exists("{a:vt}netrw_optionsave")? ("=".{a:vt}netrw_optionsave) : " doesn't exist"))
if !exists("{a:vt}netrw_optionsave")
let {a:vt}netrw_optionsave= 1
else
" call Dret("s:NetrwOptionSave : options already saved")
return
endif
" call Decho("fo=".&fo.(exists("&acd")? " acd=".&acd : " acd doesn't exist")." diff=".&l:diff)
" Save current settings and current directory
" call Decho("saving current settings and current directory")
let s:yykeep = @@
if exists("&l:acd")|let {a:vt}netrw_acdkeep = &l:acd|endif
let {a:vt}netrw_aikeep = &l:ai
let {a:vt}netrw_awkeep = &l:aw
let {a:vt}netrw_bhkeep = &l:bh
let {a:vt}netrw_blkeep = &l:bl
let {a:vt}netrw_btkeep = &l:bt
let {a:vt}netrw_bombkeep = &l:bomb
let {a:vt}netrw_cikeep = &l:ci
let {a:vt}netrw_cinkeep = &l:cin
let {a:vt}netrw_cinokeep = &l:cino
let {a:vt}netrw_comkeep = &l:com
let {a:vt}netrw_cpokeep = &l:cpo
let {a:vt}netrw_diffkeep = &l:diff
let {a:vt}netrw_fenkeep = &l:fen
let {a:vt}netrw_ffkeep = &l:ff
let {a:vt}netrw_fokeep = &l:fo " formatoptions
let {a:vt}netrw_gdkeep = &l:gd " gdefault
let {a:vt}netrw_hidkeep = &l:hidden
let {a:vt}netrw_imkeep = &l:im
let {a:vt}netrw_iskkeep = &l:isk
let {a:vt}netrw_lskeep = &l:ls
let {a:vt}netrw_makeep = &l:ma
let {a:vt}netrw_magickeep = &l:magic
let {a:vt}netrw_modkeep = &l:mod
let {a:vt}netrw_nukeep = &l:nu
let {a:vt}netrw_repkeep = &l:report
let {a:vt}netrw_rokeep = &l:ro
let {a:vt}netrw_selkeep = &l:sel
let {a:vt}netrw_spellkeep = &l:spell
let {a:vt}netrw_tskeep = &l:ts
let {a:vt}netrw_twkeep = &l:tw " textwidth
let {a:vt}netrw_wigkeep = &l:wig " wildignore
let {a:vt}netrw_wrapkeep = &l:wrap
let {a:vt}netrw_writekeep = &l:write
if g:netrw_use_noswf && has("win32") && !has("win95")
let {a:vt}netrw_swfkeep = &l:swf
endif
" save a few selected netrw-related variables
" call Decho("saving a few selected netrw-related variables")
if g:netrw_keepdir
let {a:vt}netrw_dirkeep = getcwd()
endif
if has("win32") && !has("win95")
let {a:vt}netrw_swfkeep = &l:swf " swapfile
endif
if &go =~# 'a' | sil! let {a:vt}netrw_regstar = @* | endif
sil! let {a:vt}netrw_regslash= @/
" call Dret("s:NetrwOptionSave : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")." modified=".&modified." modifiable=".&modifiable." readonly=".&readonly)
endfun
" ------------------------------------------------------------------------
" s:NetrwOptionRestore: restore options {{{2
fun! s:NetrwOptionRestore(vt)
" call Dfunc("s:NetrwOptionRestore(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> winnr($)=".winnr("$"))
if !exists("{a:vt}netrw_optionsave")
if exists("s:nbcd_curpos_{bufnr('%')}")
" call Decho("(NetrwOptionRestore) restoring previous position (s:nbcd_curpos_".bufnr('%')." exists)")
keepj call netrw#NetrwRestorePosn(s:nbcd_curpos_{bufnr('%')})
" call Decho("(NetrwOptionRestore) win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> winnr($)=".winnr("$"))
" call Decho("(NetrwOptionRestore) unlet s:nbcd_curpos_".bufnr('%'))
unlet s:nbcd_curpos_{bufnr('%')}
else
" call Decho("(NetrwOptionRestore) no previous position")
endif
" call Decho("(NetrwOptionRestore) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")
" call Dret("s:NetrwOptionRestore : ".a:vt."netrw_optionsave doesn't exist")
return
endif
unlet {a:vt}netrw_optionsave
if exists("&acd")
if exists("{a:vt}netrw_acdkeep")
" call Decho("(NetrwOptionRestore) g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd)
let curdir = getcwd()
let &l:acd = {a:vt}netrw_acdkeep
unlet {a:vt}netrw_acdkeep
if &l:acd
" call Decho("exe keepj lcd ".fnameescape(curdir)) " NOTE: was g:netrw_fname_escape for some reason
try
if !exists("&l:acd") && !&l:acd
exe 'keepj lcd '.fnameescape(curdir)
endif
catch /^Vim\%((\a\+)\)\=:E472/
call netrw#ErrorMsg(s:ERROR,"unable to change directory to <".curdir."> (permissions?)",61)
endtry
endif
endif
endif
if exists("{a:vt}netrw_aikeep") |let &l:ai = {a:vt}netrw_aikeep |unlet {a:vt}netrw_aikeep |endif
if exists("{a:vt}netrw_awkeep") |let &l:aw = {a:vt}netrw_awkeep |unlet {a:vt}netrw_awkeep |endif
if exists("{a:vt}netrw_bhkeep") |let &l:bh = {a:vt}netrw_bhkeep |unlet {a:vt}netrw_bhkeep |endif
if exists("{a:vt}netrw_blkeep") |let &l:bl = {a:vt}netrw_blkeep |unlet {a:vt}netrw_blkeep |endif
if exists("{a:vt}netrw_btkeep") |let &l:bt = {a:vt}netrw_btkeep |unlet {a:vt}netrw_btkeep |endif
if exists("{a:vt}netrw_bombkeep") |let &l:bomb = {a:vt}netrw_bombkeep |unlet {a:vt}netrw_bombkeep |endif
if exists("{a:vt}netrw_cikeep") |let &l:ci = {a:vt}netrw_cikeep |unlet {a:vt}netrw_cikeep |endif
if exists("{a:vt}netrw_cinkeep") |let &l:cin = {a:vt}netrw_cinkeep |unlet {a:vt}netrw_cinkeep |endif
if exists("{a:vt}netrw_cinokeep") |let &l:cino = {a:vt}netrw_cinokeep |unlet {a:vt}netrw_cinokeep |endif
if exists("{a:vt}netrw_comkeep") |let &l:com = {a:vt}netrw_comkeep |unlet {a:vt}netrw_comkeep |endif
if exists("{a:vt}netrw_cpokeep") |let &l:cpo = {a:vt}netrw_cpokeep |unlet {a:vt}netrw_cpokeep |endif
if exists("{a:vt}netrw_diffkeep") |let &l:diff = {a:vt}netrw_diffkeep |unlet {a:vt}netrw_diffkeep |endif
if exists("{a:vt}netrw_fenkeep") |let &l:fen = {a:vt}netrw_fenkeep |unlet {a:vt}netrw_fenkeep |endif
if exists("{a:vt}netrw_ffkeep") |let &l:ff = {a:vt}netrw_ffkeep |unlet {a:vt}netrw_ffkeep |endif
if exists("{a:vt}netrw_fokeep") |let &l:fo = {a:vt}netrw_fokeep |unlet {a:vt}netrw_fokeep |endif
if exists("{a:vt}netrw_gdkeep") |let &l:gd = {a:vt}netrw_gdkeep |unlet {a:vt}netrw_gdkeep |endif
if exists("{a:vt}netrw_hidkeep") |let &l:hidden = {a:vt}netrw_hidkeep |unlet {a:vt}netrw_hidkeep |endif
if exists("{a:vt}netrw_imkeep") |let &l:im = {a:vt}netrw_imkeep |unlet {a:vt}netrw_imkeep |endif
if exists("{a:vt}netrw_iskkeep") |let &l:isk = {a:vt}netrw_iskkeep |unlet {a:vt}netrw_iskkeep |endif
if exists("{a:vt}netrw_lskeep") |let &l:ls = {a:vt}netrw_lskeep |unlet {a:vt}netrw_lskeep |endif
if exists("{a:vt}netrw_makeep") |let &l:ma = {a:vt}netrw_makeep |unlet {a:vt}netrw_makeep |endif
if exists("{a:vt}netrw_magickeep")|let &l:magic = {a:vt}netrw_magickeep |unlet {a:vt}netrw_magickeep|endif
if exists("{a:vt}netrw_modkeep") |let &l:mod = {a:vt}netrw_modkeep |unlet {a:vt}netrw_modkeep |endif
if exists("{a:vt}netrw_nukeep") |let &l:nu = {a:vt}netrw_nukeep |unlet {a:vt}netrw_nukeep |endif
if exists("{a:vt}netrw_repkeep") |let &l:report = {a:vt}netrw_repkeep |unlet {a:vt}netrw_repkeep |endif
if exists("{a:vt}netrw_rokeep") |let &l:ro = {a:vt}netrw_rokeep |unlet {a:vt}netrw_rokeep |endif
if exists("{a:vt}netrw_selkeep") |let &l:sel = {a:vt}netrw_selkeep |unlet {a:vt}netrw_selkeep |endif
if exists("{a:vt}netrw_spellkeep")|let &l:spell = {a:vt}netrw_spellkeep |unlet {a:vt}netrw_spellkeep|endif
if exists("{a:vt}netrw_tskeep") |let &l:ts = {a:vt}netrw_tskeep |unlet {a:vt}netrw_tskeep |endif
if exists("{a:vt}netrw_twkeep") |let &l:tw = {a:vt}netrw_twkeep |unlet {a:vt}netrw_twkeep |endif
if exists("{a:vt}netrw_wigkeep") |let &l:wig = {a:vt}netrw_wigkeep |unlet {a:vt}netrw_wigkeep |endif
if exists("{a:vt}netrw_wrapkeep") |let &l:wrap = {a:vt}netrw_wrapkeep |unlet {a:vt}netrw_wrapkeep |endif
if exists("{a:vt}netrw_writekeep")|let &l:write = {a:vt}netrw_writekeep |unlet {a:vt}netrw_writekeep|endif
if exists("s:yykeep") |let @@ = s:yykeep |unlet s:yykeep |endif
if exists("{a:vt}netrw_swfkeep")
if &directory == ""
" user hasn't specified a swapfile directory;
" netrw will temporarily set the swapfile directory
" to the current directory as returned by getcwd().
let &l:directory = getcwd()
sil! let &l:swf = {a:vt}netrw_swfkeep
setlocal directory=
unlet {a:vt}netrw_swfkeep
elseif &l:swf != {a:vt}netrw_swfkeep
" following line causes a Press ENTER in windows -- can't seem to work around it!!!
sil! let &l:swf= {a:vt}netrw_swfkeep
unlet {a:vt}netrw_swfkeep
endif
endif
if exists("{a:vt}netrw_dirkeep") && isdirectory({a:vt}netrw_dirkeep) && g:netrw_keepdir
let dirkeep = substitute({a:vt}netrw_dirkeep,'\\','/','g')
if exists("{a:vt}netrw_dirkeep") |exe "keepj lcd ".fnameescape(dirkeep)|unlet {a:vt}netrw_dirkeep |endif
endif
if exists("{a:vt}netrw_regstar") |sil! let @*= {a:vt}netrw_regstar |unlet {a:vt}netrw_regstar |endif
if exists("{a:vt}netrw_regslash")|sil! let @/= {a:vt}netrw_regslash|unlet {a:vt}netrw_regslash|endif
if exists("s:nbcd_curpos_{bufnr('%')}")
" call Decho("(NetrwOptionRestore) restoring previous position (s:nbcd_curpos_".bufnr('%')." exists)")
keepj call netrw#NetrwRestorePosn(s:nbcd_curpos_{bufnr('%')})
" call Decho("(NetrwOptionRestore) unlet s:nbcd_curpos_".bufnr('%'))
unlet s:nbcd_curpos_{bufnr('%')}
else
" call Decho("no previous position")
endif
" call Decho("(NetrwOptionRestore) g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd)
" call Decho("(NetrwOptionRestore) fo=".&fo.(exists("&acd")? " acd=".&acd : " acd doesn't exist"))
" call Decho("(NetrwOptionRestore) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")
" call Decho("(NetrwOptionRestore) diff=".&l:diff." win#".winnr()." w:netrw_diffkeep=".(exists("w:netrw_diffkeep")? w:netrw_diffkeep : "doesn't exist"))
" call Dret("s:NetrwOptionRestore : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> modified=".&modified." modifiable=".&modifiable." readonly=".&readonly)
endfun
" ---------------------------------------------------------------------
" s:NetrwSafeOptions: sets options to help netrw do its job {{{2
fun! s:NetrwSafeOptions()
" call Dfunc("s:NetrwSafeOptions() win#".winnr()." buf#".bufnr("%")."<".bufname(bufnr("%"))."> winnr($)=".winnr("$"))
" call Decho("win#".winnr()."'s ft=".&ft)
if exists("&acd") | setlocal noacd | endif
setlocal noai
setlocal noaw
setlocal nobomb
setlocal noci
setlocal nocin
setlocal cino=
setlocal com=
setlocal cpo-=a
setlocal cpo-=A
setlocal fo=nroql2
setlocal nohid
setlocal noim
setlocal isk+=@ isk+=* isk+=/
setlocal magic
setlocal report=10000
setlocal sel=inclusive
setlocal nospell
setlocal tw=0
setlocal wig=
if g:netrw_use_noswf && has("win32") && !has("win95")
setlocal noswf
endif
call s:NetrwCursor()
" allow the user to override safe options
" call Decho("ft<".&ft."> ei=".&ei)
if &ft == "netrw"
" call Decho("do any netrw FileType autocmds")
sil! keepalt keepj doau FileType netrw
endif
" call Decho("fo=".&fo.(exists("&acd")? " acd=".&acd : " acd doesn't exist"))
" call Dret("s:NetrwSafeOptions")
endfun
" ---------------------------------------------------------------------
" netrw#NetrwClean: remove netrw {{{2
" supports :NetrwClean -- remove netrw from first directory on runtimepath
" :NetrwClean! -- remove netrw from all directories on runtimepath
fun! netrw#NetrwClean(sys)
" call Dfunc("netrw#NetrwClean(sys=".a:sys.")")
if a:sys
let choice= confirm("Remove personal and system copies of netrw?","&Yes\n&No")
else
let choice= confirm("Remove personal copy of netrw?","&Yes\n&No")
endif
" call Decho("choice=".choice)
let diddel= 0
let diddir= ""
if choice == 1
for dir in split(&rtp,',')
if filereadable(dir."/plugin/netrwPlugin.vim")
" call Decho("removing netrw-related files from ".dir)
if s:NetrwDelete(dir."/plugin/netrwPlugin.vim") |call netrw#ErrorMsg(1,"unable to remove ".dir."/plugin/netrwPlugin.vim",55) |endif
if s:NetrwDelete(dir."/autoload/netrwFileHandlers.vim")|call netrw#ErrorMsg(1,"unable to remove ".dir."/autoload/netrwFileHandlers.vim",55)|endif
if s:NetrwDelete(dir."/autoload/netrwSettings.vim") |call netrw#ErrorMsg(1,"unable to remove ".dir."/autoload/netrwSettings.vim",55) |endif
if s:NetrwDelete(dir."/autoload/netrw.vim") |call netrw#ErrorMsg(1,"unable to remove ".dir."/autoload/netrw.vim",55) |endif
if s:NetrwDelete(dir."/syntax/netrw.vim") |call netrw#ErrorMsg(1,"unable to remove ".dir."/syntax/netrw.vim",55) |endif
if s:NetrwDelete(dir."/syntax/netrwlist.vim") |call netrw#ErrorMsg(1,"unable to remove ".dir."/syntax/netrwlist.vim",55) |endif
let diddir= dir
let diddel= diddel + 1
if !a:sys|break|endif
endif
endfor
endif
echohl WarningMsg
if diddel == 0
echomsg "netrw is either not installed or not removable"
elseif diddel == 1
echomsg "removed one copy of netrw from <".diddir.">"
else
echomsg "removed ".diddel." copies of netrw"
endif
echohl None
" call Dret("netrw#NetrwClean")
endfun
" ---------------------------------------------------------------------
" netrw#Nread: {{{2
fun! netrw#Nread(mode,fname)
" call Dfunc("netrw#Nread(mode=".a:mode." fname<".a:fname.">)")
call netrw#NetrwSavePosn()
call netrw#NetRead(a:mode,a:fname)
call netrw#NetrwRestorePosn()
" call Dret("netrw#Nread")
endfun
" ------------------------------------------------------------------------
" Netrw Transfer Functions: {{{1
" ===============================
" ------------------------------------------------------------------------
" netrw#NetRead: responsible for reading a file over the net {{{2
" mode: =0 read remote file and insert before current line
" =1 read remote file and insert after current line
" =2 replace with remote file
" =3 obtain file, but leave in temporary format
fun! netrw#NetRead(mode,...)
" call Dfunc("netrw#NetRead(mode=".a:mode.",...) a:0=".a:0." ".g:loaded_netrw)
" NetRead: save options {{{3
call s:NetrwOptionSave("w:")
call s:NetrwSafeOptions()
call s:RestoreCursorline()
" NetRead: interpret mode into a readcmd {{{3
if a:mode == 0 " read remote file before current line
let readcmd = "0r"
elseif a:mode == 1 " read file after current line
let readcmd = "r"
elseif a:mode == 2 " replace with remote file
let readcmd = "%r"
elseif a:mode == 3 " skip read of file (leave as temporary)
let readcmd = "t"
else
exe a:mode
let readcmd = "r"
endif
let ichoice = (a:0 == 0)? 0 : 1
" call Decho("readcmd<".readcmd."> ichoice=".ichoice)
" NetRead: get temporary filename {{{3
let tmpfile= s:GetTempfile("")
if tmpfile == ""
" call Dret("netrw#NetRead : unable to get a tempfile!")
return
endif
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'
sleep 4
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")
call netrw#ErrorMsg(s:ERROR,"Unbalanced string in filename '". wholechoice ."'",3)
endif
" call Dret("netrw#NetRead :2 getcwd<".getcwd().">")
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
" NetRead: Determine method of read (ftp, rcp, etc) {{{3
call s:NetrwMethod(choice)
if !exists("b:netrw_method") || b:netrw_method < 0
" call Dfunc("netrw#NetRead : unsupported method")
return
endif
let tmpfile= s:GetTempfile(b:netrw_fname) " apply correct suffix
" Check if NetrwBrowse() should be handling this request
" call Decho("checking if NetrwBrowse() should handle choice<".choice."> with netrw_list_cmd<".g:netrw_list_cmd.">")
if choice =~ "^.*[\/]$" && b:netrw_method != 5 && choice !~ '^https\=://'
" call Decho("yes, choice matches '^.*[\/]$'")
keepj call s:NetrwBrowse(0,choice)
" call Dret("netrw#NetRead :3 getcwd<".getcwd().">")
return
endif
" ============
" NetRead: Perform Protocol-Based Read {{{3
" ===========================
if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1
echo "(netrw) Processing your read request..."
endif
".........................................
" NetRead: (rcp) NetRead Method #1 {{{3
if b:netrw_method == 1 " read with rcp
" call Decho("read via rcp (method #1)")
" ER: nothing 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." ".shellescape(uid_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1))
exe s:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".shellescape(uid_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1)
let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)
let b:netrw_lastfile = choice
".........................................
" NetRead: (ftp + <.netrc>) NetRead Method #2 {{{3
elseif b:netrw_method == 2 " read with ftp + <.netrc>
" call Decho("read via ftp+.netrc (method #2)")
let netrw_fname= b:netrw_fname
keepj call s:SaveBufVars()|new|keepj call s:RestoreBufVars()
let filtbuf= bufnr("%")
setlocal ff=unix
keepj put =g:netrw_ftpmode
" call Decho("filter input: ".getline(line("$")))
if exists("g:netrw_ftpextracmd")
keepj put =g:netrw_ftpextracmd
" call Decho("filter input: ".getline(line("$")))
endif
call setline(line("$")+1,'get "'.netrw_fname.'" '.tmpfile)
" call Decho("filter input: ".getline(line("$")))
if exists("g:netrw_port") && g:netrw_port != ""
" call Decho("executing: %!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1))
exe s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1)
else
" call Decho("executing: %!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1))
exe s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)
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
setlocal debug=msg
keepj call netrw#ErrorMsg(s:ERROR,getline(1),4)
let &debug = debugkeep
endif
call s:SaveBufVars()
bd!
if bufname("%") == "" && getline("$") == "" && line('$') == 1
" needed when one sources a file in a nolbl setting window via ftp
q!
endif
call s:RestoreBufVars()
let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)
let b:netrw_lastfile = choice
".........................................
" NetRead: (ftp + machine,id,passwd,filename) NetRead Method #3 {{{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= escape(b:netrw_fname,g:netrw_fname_escape)
keepj call s:SaveBufVars()|new|keepj call s:RestoreBufVars()
let filtbuf= bufnr("%")
setlocal ff=unix
if exists("g:netrw_port") && g:netrw_port != ""
keepj put ='open '.g:netrw_machine.' '.g:netrw_port
" call Decho("filter input: ".getline('.'))
else
keepj put ='open '.g:netrw_machine
" call Decho("filter input: ".getline('.'))
endif
if exists("g:netrw_uid" && g:netrw_uid != ""
if exists("g:netrw_ftp") && g:netrw_ftp == 1
keepj put =g:netrw_uid
" call Decho("filter input: ".getline('.'))
if exists("s:netrw_passwd")
keepj put ='\"'.s:netrw_passwd.'\"'
endif
" call Decho("filter input: ".getline('.'))
elseif exists("s:netrw_passwd")
keepj put ='user \"'.g:netrw_uid.'\" \"'.s:netrw_passwd.'\"'
" call Decho("filter input: ".getline('.'))
endif
endif
if exists("g:netrw_ftpmode") && g:netrw_ftpmode != ""
keepj put =g:netrw_ftpmode
" call Decho("filter input: ".getline('.'))
endif
if exists("g:netrw_ftpextracmd")
keepj put =g:netrw_ftpextracmd
" call Decho("filter input: ".getline('.'))
endif
keepj 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
keepj norm! 1Gdd
" call Decho("executing: %!".s:netrw_ftp_cmd." ".g:netrw_ftp_options)
exe s:netrw_silentxfer."%!".s:netrw_ftp_cmd." ".g:netrw_ftp_options
" 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")
call netrw#ErrorMsg(s:ERROR,getline(1),5)
endif
endif
call s:SaveBufVars()|bd!|call s:RestoreBufVars()
let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)
let b:netrw_lastfile = choice
".........................................
" NetRead: (scp) NetRead Method #4 {{{3
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= " ".g:netrw_scpport." ".g:netrw_port
else
let useport= ""
endif
" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1))
exe s:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1)
let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)
let b:netrw_lastfile = choice
".........................................
" NetRead: (http) NetRead Method #5 (wget) {{{3
elseif b:netrw_method == 5
" call Decho("read via http (method #5)")
if g:netrw_http_cmd == ""
if !exists("g:netrw_quiet")
call netrw#ErrorMsg(s:ERROR,"neither the wget nor the fetch command is available",6)
endif
" call Dret("netrw#NetRead :4 getcwd<".getcwd().">")
return
endif
if match(b:netrw_fname,"#") == -1 || exists("g:netrw_http_xcmd")
" using g:netrw_http_cmd (usually elinks, links, curl, wget, or fetch)
" call Decho('using '.g:netrw_http_cmd.' (# not in b:netrw_fname<'.b:netrw_fname.">)")
if exists("g:netrw_http_xcmd")
" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape("http://".g:netrw_machine.b:netrw_fname,1)." ".g:netrw_http_xcmd." ".shellescape(tmpfile,1))
exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape("http://".g:netrw_machine.b:netrw_fname,1)." ".g:netrw_http_xcmd." ".shellescape(tmpfile,1)
else
" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("http://".g:netrw_machine.b:netrw_fname,1))
exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("http://".g:netrw_machine.b:netrw_fname,1)
endif
let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)
else
" wget/curl/fetch plus a jump to an in-page marker (ie. http://abc/def.html#aMarker)
" call Decho("wget/curl plus jump (# in b:netrw_fname<".b:netrw_fname.">)")
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("exe ".s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("http://".g:netrw_machine.netrw_html,1))
exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("http://".g:netrw_machine.netrw_html,1)
let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)
" call Decho('<\s*a\s*name=\s*"'.netrw_tag.'"/')
exe 'keepj norm! 1G/<\s*a\s*name=\s*"'.netrw_tag.'"/'."\<CR>"
endif
let b:netrw_lastfile = choice
" call Decho("(NetRead) setl ro")
setl ro
".........................................
" NetRead: (dav) NetRead Method #6 {{{3
elseif b:netrw_method == 6
" call Decho("read via cadaver (method #6)")
if !executable(g:netrw_dav_cmd)
call netrw#ErrorMsg(s:ERROR,g:netrw_dav_cmd." is not executable",73)
" call Dret("netrw#NetRead : ".g:netrw_dav_cmd." not executable")
return
endif
if g:netrw_dav_cmd =~ "curl"
" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_dav_cmd." ".shellescape("dav://".g:netrw_machine.b:netrw_fname,1)." ".shellescape(tmpfile,1))
exe s:netrw_silentxfer."!".g:netrw_dav_cmd." ".shellescape("dav://".g:netrw_machine.b:netrw_fname,1)." ".shellescape(tmpfile,1)
else
" Construct execution string (four lines) which will be passed through filter
let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
new
setlocal ff=unix
if exists("g:netrw_port") && g:netrw_port != ""
keepj put ='open '.g:netrw_machine.' '.g:netrw_port
else
keepj put ='open '.g:netrw_machine
endif
if exists("g:netrw_uid") && exists("s:netrw_passwd") && g:netrw_uid != ""
keepj put ='user '.g:netrw_uid.' '.s:netrw_passwd
endif
keepj put ='get '.netrw_fname.' '.tmpfile
keepj put ='quit'
" perform cadaver operation:
keepj norm! 1Gdd
" call Decho("executing: %!".g:netrw_dav_cmd)
exe s:netrw_silentxfer."%!".g:netrw_dav_cmd
bd!
endif
let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)
let b:netrw_lastfile = choice
".........................................
" NetRead: (rsync) NetRead Method #7 {{{3
elseif b:netrw_method == 7
" call Decho("read via rsync (method #7)")
" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_rsync_cmd." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1))
exe s:netrw_silentxfer."!".g:netrw_rsync_cmd." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1)
let result = s:NetrwGetFile(readcmd,tmpfile, b:netrw_method)
let b:netrw_lastfile = choice
".........................................
" NetRead: (fetch) NetRead Method #8 {{{3
" fetch://[user@]host[:http]/path
elseif b:netrw_method == 8
" call Decho("read via fetch (method #8)")
if g:netrw_fetch_cmd == ""
if !exists("g:netrw_quiet")
keepj call netrw#ErrorMsg(s:ERROR,"fetch command not available",7)
endif
" call Dret("NetRead")
return
endif
if exists("g:netrw_option") && g:netrw_option == ":https\="
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("s:netrw_passwd") && s:netrw_passwd != ""
" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_fetch_cmd." ".shellescape(tmpfile,1)." ".shellescape(netrw_option."://".g:netrw_uid.':'.s:netrw_passwd.'@'.g:netrw_machine."/".b:netrw_fname,1))
exe s:netrw_silentxfer."!".g:netrw_fetch_cmd." ".shellescape(tmpfile,1)." ".shellescape(netrw_option."://".g:netrw_uid.':'.s:netrw_passwd.'@'.g:netrw_machine."/".b:netrw_fname,1)
else
" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_fetch_cmd." ".shellescape(tmpfile,1)." ".shellescape(netrw_option."://".g:netrw_machine."/".b:netrw_fname,1))
exe s:netrw_silentxfer."!".g:netrw_fetch_cmd." ".shellescape(tmpfile,1)." ".shellescape(netrw_option."://".g:netrw_machine."/".b:netrw_fname,1)
endif
let result = s:NetrwGetFile(readcmd,tmpfile, b:netrw_method)
let b:netrw_lastfile = choice
" call Decho("(NetRead) setl ro")
setl ro
".........................................
" NetRead: (sftp) NetRead Method #9 {{{3
elseif b:netrw_method == 9
" call Decho("read via sftp (method #9)")
" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_sftp_cmd." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".tmpfile)
exe s:netrw_silentxfer."!".g:netrw_sftp_cmd." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".tmpfile
let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)
let b:netrw_lastfile = choice
".........................................
" NetRead: Complain {{{3
else
call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . choice . ">",8)
endif
endwhile
" NetRead: cleanup {{{3
if exists("b:netrw_method")
" call Decho("cleanup b:netrw_method and b:netrw_fname")
unlet b:netrw_method
unlet b:netrw_fname
endif
if s:FileReadable(tmpfile) && tmpfile !~ '.tar.bz2$' && tmpfile !~ '.tar.gz$' && tmpfile !~ '.zip' && tmpfile !~ '.tar' && readcmd != 't' && tmpfile !~ '.tar.xz$' && tmpfile !~ '.txz'
" call Decho("cleanup by deleting tmpfile<".tmpfile.">")
keepj call s:NetrwDelete(tmpfile)
endif
keepj call s:NetrwOptionRestore("w:")
" call Dret("netrw#NetRead :5 getcwd<".getcwd().">")
endfun
" ------------------------------------------------------------------------
" netrw#NetWrite: responsible for writing a file over the net {{{2
fun! netrw#NetWrite(...) range
" call Dfunc("netrw#NetWrite(a:0=".a:0.") ".g:loaded_netrw)
" NetWrite: option handling {{{3
let mod= 0
call s:NetrwOptionSave("w:")
call s:NetrwSafeOptions()
" NetWrite: Get Temporary Filename {{{3
let tmpfile= s:GetTempfile("")
if tmpfile == ""
" call Dret("netrw#NetWrite : unable to get a tempfile!")
return
endif
if a:0 == 0
let ichoice = 0
else
let ichoice = 1
endif
let curbufname= expand("%")
" call Decho("curbufname<".curbufname.">")
if &binary
" For binary writes, always write entire file.
" (line numbers don't really make sense for that).
" Also supports the writing of tar and zip files.
" call Decho("(write entire file) sil exe w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile))
exe "sil keepj w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile)
elseif g:netrw_cygwin
" write (selected portion of) file to temporary
let cygtmpfile= substitute(tmpfile,'/cygdrive/\(.\)','\1:','')
" call Decho("(write selected portion) sil exe ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(cygtmpfile))
exe "sil keepj ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(cygtmpfile)
else
" write (selected portion of) file to temporary
" call Decho("(write selected portion) sil exe ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile))
exe "sil keepj ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile)
endif
if curbufname == ""
" if the file is [No Name], and one attempts to Nwrite it, the buffer takes
" on the temporary file's name. Deletion of the temporary file during
" cleanup then causes an error message.
0file!
endif
" NetWrite: while choice loop: {{{3
while ichoice <= a:0
" Process arguments: {{{4
" 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'
sleep 4
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")
call netrw#ErrorMsg(s:ERROR,"Unbalanced string in filename '". wholechoice ."'",13)
endif
" call Dret("netrw#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
let ichoice= ichoice + 1
" call Decho("choice<" . choice . "> ichoice=".ichoice)
" Determine method of write (ftp, rcp, etc) {{{4
keepj call s:NetrwMethod(choice)
if !exists("b:netrw_method") || b:netrw_method < 0
" call Dfunc("netrw#NetWrite : unsupported method")
return
endif
" =============
" NetWrite: Perform Protocol-Based Write {{{3
" ============================
if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1
echo "(netrw) Processing your write request..."
" call Decho("(netrw) Processing your write request...")
endif
".........................................
" NetWrite: (rcp) NetWrite Method #1 {{{3
if b:netrw_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
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." ".shellescape(tmpfile,1)." ".shellescape(uid_machine.":".b:netrw_fname,1))
exe s:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".shellescape(tmpfile,1)." ".shellescape(uid_machine.":".b:netrw_fname,1)
let b:netrw_lastfile = choice
".........................................
" NetWrite: (ftp + <.netrc>) NetWrite Method #2 {{{3
elseif b:netrw_method == 2
" call Decho("write via ftp+.netrc (method #2)")
let netrw_fname = b:netrw_fname
" formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead
let bhkeep = &l:bh
let curbuf = bufnr("%")
setlocal bh=hide
enew
" call Decho("filter input window#".winnr())
setlocal ff=unix
keepj put =g:netrw_ftpmode
" call Decho("filter input: ".getline('$'))
if exists("g:netrw_ftpextracmd")
keepj put =g:netrw_ftpextracmd
" call Decho("filter input: ".getline("$"))
endif
keepj call setline(line("$")+1,'put "'.tmpfile.'" "'.netrw_fname.'"')
" call Decho("filter input: ".getline("$"))
if exists("g:netrw_port") && g:netrw_port != ""
" call Decho("executing: %!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1))
exe s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1)
else
" call Decho("filter input window#".winnr())
" call Decho("executing: %!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1))
exe s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)
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")
keepj call netrw#ErrorMsg(s:ERROR,getline(1),14)
endif
let mod=1
endif
" remove enew buffer (quietly)
let filtbuf= bufnr("%")
exe curbuf."b!"
let &l:bh = bhkeep
exe filtbuf."bw!"
let b:netrw_lastfile = choice
".........................................
" NetWrite: (ftp + machine, id, passwd, filename) NetWrite Method #3 {{{3
elseif b:netrw_method == 3
" Construct execution string (three or more lines) which will be passed through filter
" call Decho("read via ftp+mipf (method #3)")
let netrw_fname = b:netrw_fname
let bhkeep = &l:bh
" formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead
let curbuf = bufnr("%")
setlocal bh=hide
enew
setlocal ff=unix
if exists("g:netrw_port") && g:netrw_port != ""
keepj put ='open '.g:netrw_machine.' '.g:netrw_port
" call Decho("filter input: ".getline('.'))
else
keepj put ='open '.g:netrw_machine
" call Decho("filter input: ".getline('.'))
endif
if exists("g:netrw_uid") && g:netrw_uid != ""
if exists("g:netrw_ftp") && g:netrw_ftp == 1
keepj put =g:netrw_uid
" call Decho("filter input: ".getline('.'))
if exists("s:netrw_passwd") && s:netrw_passwd != ""
keepj put ='\"'.s:netrw_passwd.'\"'
endif
" call Decho("filter input: ".getline('.'))
elseif exists("s:netrw_passwd") && s:netrw_passwd != ""
keepj put ='user \"'.g:netrw_uid.'\" \"'.s:netrw_passwd.'\"'
" call Decho("filter input: ".getline('.'))
endif
endif
keepj put =g:netrw_ftpmode
" call Decho("filter input: ".getline('$'))
if exists("g:netrw_ftpextracmd")
keepj put =g:netrw_ftpextracmd
" call Decho("filter input: ".getline("$"))
endif
keepj put ='put \"'.tmpfile.'\" \"'.netrw_fname.'\"'
" call Decho("filter input: ".getline('.'))
" 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
keepj norm! 1Gdd
" call Decho("executing: %!".s:netrw_ftp_cmd." ".g:netrw_ftp_options)
exe s:netrw_silentxfer."%!".s:netrw_ftp_cmd." ".g:netrw_ftp_options
" 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")
call netrw#ErrorMsg(s:ERROR,getline(1),15)
endif
let mod=1
endif
" remove enew buffer (quietly)
let filtbuf= bufnr("%")
exe curbuf."b!"
let &l:bh= bhkeep
exe filtbuf."bw!"
".........................................
" NetWrite: (scp) NetWrite Method #4 {{{3
elseif b:netrw_method == 4
" call Decho("write via scp (method #4)")
if exists("g:netrw_port") && g:netrw_port != ""
let useport= " ".g:netrw_scpport." ".fnameescape(g:netrw_port)
else
let useport= ""
endif
" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".shellescape(tmpfile,1)." ".shellescape(g:netrw_machine.":".b:netrw_fname,1))
exe s:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".shellescape(tmpfile,1)." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)
let b:netrw_lastfile = choice
".........................................
" NetWrite: (http) NetWrite Method #5 {{{3
elseif b:netrw_method == 5
" call Decho("write via http (method #5)")
if !exists("g:netrw_quiet")
call netrw#ErrorMsg(s:ERROR,"currently <netrw.vim> does not support writing using http:",16)
endif
".........................................
" NetWrite: (dav) NetWrite Method #6 (cadaver) {{{3
elseif b:netrw_method == 6
" call Decho("write via cadaver (method #6)")
" Construct execution string (four lines) which will be passed through filter
let netrw_fname = escape(b:netrw_fname,g:netrw_fname_escape)
let bhkeep = &l:bh
" formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead
let curbuf = bufnr("%")
setlocal bh=hide
enew
setlocal ff=unix
if exists("g:netrw_port") && g:netrw_port != ""
keepj put ='open '.g:netrw_machine.' '.g:netrw_port
else
keepj put ='open '.g:netrw_machine
endif
if exists("g:netrw_uid") && exists("s:netrw_passwd") && g:netrw_uid != ""
keepj put ='user '.g:netrw_uid.' '.s:netrw_passwd
endif
keepj put ='put '.tmpfile.' '.netrw_fname
" perform cadaver operation:
keepj norm! 1Gdd
" call Decho("executing: %!".g:netrw_dav_cmd)
exe s:netrw_silentxfer."%!".g:netrw_dav_cmd
" remove enew buffer (quietly)
let filtbuf= bufnr("%")
exe curbuf."b!"
let &l:bh = bhkeep
exe filtbuf."bw!"
let b:netrw_lastfile = choice
".........................................
" NetWrite: (rsync) NetWrite Method #7 {{{3
elseif b:netrw_method == 7
" call Decho("write via rsync (method #7)")
" call Decho("executing: !".g:netrw_rsync_cmd." ".shellescape(tmpfile,1)." ".shellescape(g:netrw_machine.":".b:netrw_fname,1))
exe s:netrw_silentxfer."!".g:netrw_rsync_cmd." ".shellescape(tmpfile,1)." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)
let b:netrw_lastfile = choice
".........................................
" NetWrite: (sftp) NetWrite Method #9 {{{3
elseif b:netrw_method == 9
" call Decho("read via sftp (method #9)")
let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
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
" formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead
let bhkeep = &l:bh
let curbuf = bufnr("%")
setlocal bh=hide
enew
setlocal ff=unix
call setline(1,'put "'.escape(tmpfile,'\').'" '.netrw_fname)
" call Decho("filter input: ".getline('.'))
" call Decho("executing: %!".g:netrw_sftp_cmd.' '.shellescape(uid_machine,1))
exe s:netrw_silentxfer."%!".g:netrw_sftp_cmd.' '.shellescape(uid_machine,1)
let filtbuf= bufnr("%")
exe curbuf."b!"
let &l:bh = bhkeep
exe filtbuf."bw!"
let b:netrw_lastfile = choice
".........................................
" NetWrite: Complain {{{3
else
call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . choice . ">",17)
let leavemod= 1
endif
endwhile
" NetWrite: Cleanup: {{{3
" call Decho("cleanup")
if s:FileReadable(tmpfile)
" call Decho("tmpfile<".tmpfile."> readable, will now delete it")
call s:NetrwDelete(tmpfile)
endif
call s:NetrwOptionRestore("w:")
if a:firstline == 1 && a:lastline == line("$")
" restore modifiability; usually equivalent to set nomod
let &mod= mod
" call Decho("(NetWrite) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")
elseif !exists("leavemod")
" indicate that the buffer has not been modified since last written
" call Decho("(NetWrite) set nomod")
set nomod
" call Decho("(NetWrite) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")
endif
" call Dret("netrw#NetWrite")
endfun
" ---------------------------------------------------------------------
" netrw#NetSource: source a remotely hosted vim script {{{2
" uses NetRead to get a copy of the file into a temporarily file,
" then sources that file,
" then removes that file.
fun! netrw#NetSource(...)
" call Dfunc("netrw#NetSource() a:0=".a:0)
if a:0 > 0 && a:1 == '?'
" give help
echomsg 'NetSource Usage:'
echomsg ':Nsource dav://machine[:port]/path uses cadaver'
echomsg ':Nsource fetch://machine/path uses fetch'
echomsg ':Nsource ftp://[user@]machine[:port]/path uses ftp autodetects <.netrc>'
echomsg ':Nsource http[s]://[user@]machine/path uses http wget'
echomsg ':Nsource rcp://[user@]machine/path uses rcp'
echomsg ':Nsource rsync://machine[:port]/path uses rsync'
echomsg ':Nsource scp://[user@]machine[[:#]port]/path uses scp'
echomsg ':Nsource sftp://[user@]machine[[:#]port]/path uses sftp'
sleep 4
else
let i= 1
while i <= a:0
call netrw#NetRead(3,a:{i})
" call Decho("(netrw#NetSource) s:netread_tmpfile<".s:netrw_tmpfile.">")
if s:FileReadable(s:netrw_tmpfile)
" call Decho("(netrw#NetSource) exe so ".fnameescape(s:netrw_tmpfile))
exe "so ".fnameescape(s:netrw_tmpfile)
" call Decho("(netrw#NetSource) delete(".s:netrw_tmpfile.")")
call delete(s:netrw_tmpfile)
unlet s:netrw_tmpfile
else
call netrw#ErrorMsg(s:ERROR,"unable to source <".a:{i}.">!",48)
endif
let i= i + 1
endwhile
endif
" call Dret("netrw#NetSource")
endfun
" ===========================================
" s:NetrwGetFile: Function to read temporary file "tfile" with command "readcmd". {{{2
" readcmd == %r : replace buffer with newly read file
" == 0r : read file at top of buffer
" == r : read file after current line
" == t : leave file in temporary form (ie. don't read into buffer)
fun! s:NetrwGetFile(readcmd, tfile, method)
" call Dfunc("NetrwGetFile(readcmd<".a:readcmd.">,tfile<".a:tfile."> method<".a:method.">)")
" readcmd=='t': simply do nothing
if a:readcmd == 't'
" call Decho("(NetrwGetFile) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")
" call Dret("NetrwGetFile : skip read of <".a:tfile.">")
return
endif
" 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)
let line2= line("$")
endif
if a:readcmd[0] == '%'
" get file into buffer
" call Decho("get file into buffer")
" rename the current buffer to the temp file (ie. tfile)
if g:netrw_cygwin
let tfile= substitute(a:tfile,'/cygdrive/\(.\)','\1:','')
else
let tfile= a:tfile
endif
" call Decho("exe sil! keepalt file ".fnameescape(tfile))
exe "sil! keepalt file ".fnameescape(tfile)
" edit temporary file (ie. read the temporary file in)
if rfile =~ '\.zip$'
" call Decho("handling remote zip file with zip#Browse(tfile<".tfile.">)")
call zip#Browse(tfile)
elseif rfile =~ '\.tar$'
" call Decho("handling remote tar file with tar#Browse(tfile<".tfile.">)")
call tar#Browse(tfile)
elseif rfile =~ '\.tar\.gz$'
" call Decho("handling remote gzip-compressed tar file")
call tar#Browse(tfile)
elseif rfile =~ '\.tar\.bz2$'
" call Decho("handling remote bz2-compressed tar file")
call tar#Browse(tfile)
elseif rfile =~ '\.tar\.xz$'
" call Decho("handling remote xz-compressed tar file")
call tar#Browse(tfile)
elseif rfile =~ '\.txz$'
" call Decho("handling remote xz-compressed tar file (.txz)")
call tar#Browse(tfile)
else
" call Decho("edit temporary file")
e!
endif
" rename buffer back to remote filename
" call Decho("exe sil! keepalt file ".fnameescape(rfile))
exe "sil! keepj keepalt file ".fnameescape(rfile)
" detect filetype of local version of remote file
" Note that isk must not include a "/" for scripts.vim
" to process this detection correctly.
" call Decho("detect filetype of local version of remote file")
let iskkeep= &isk
set isk-=/
filetype detect
let &isk= iskkeep
" call Dredir("renamed buffer back to remote filename<".rfile."> : expand(%)<".expand("%").">","ls!")
let line1 = 1
let line2 = line("$")
elseif s:FileReadable(a:tfile)
" read file after current line
" call Decho("read file<".a:tfile."> after current line")
let curline = line(".")
let lastline= line("$")
" call Decho("exe<".a:readcmd." ".fnameescape(v:cmdarg)." ".fnameescape(a:tfile)."> line#".curline)
exe "keepj ".a:readcmd." ".fnameescape(v:cmdarg)." ".fnameescape(a:tfile)
let line1= curline + 1
let line2= line("$") - lastline + 1
else
" not readable
" call Decho("(NetrwGetFile) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")
" call Decho("tfile<".a:tfile."> not readable")
keepj call netrw#ErrorMsg(s:WARNING,"file <".a:tfile."> not readable",9)
" call Dret("NetrwGetFile : tfile<".a:tfile."> 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.")")
keepj call NetReadFixup(a:method, line1, line2)
" else " Decho
" call Decho("NetReadFixup() not called, doesn't exist (line1=".line1." line2=".line2.")")
endif
if has("gui") && has("menu") && has("gui_running") && &go =~# 'm' && g:netrw_menu
" update the Buffers menu
keepj call s:UpdateBuffersMenu()
endif
" call Decho("readcmd<".a:readcmd."> cmdarg<".v:cmdarg."> tfile<".a:tfile."> readable=".s:FileReadable(a:tfile))
" make sure file is being displayed
" redraw!
" call Decho("(NetrwGetFile) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")
" call Dret("NetrwGetFile")
endfun
" ------------------------------------------------------------------------
" s:NetrwMethod: determine method of transfer {{{2
" Input:
" choice = url [protocol:]//[userid@]hostname[:port]/[path-to-file]
" Output:
" b:netrw_method= 1: rcp
" 2: ftp + <.netrc>
" 3: ftp + machine, id, password, and [path]filename
" 4: scp
" 5: http[s] (wget)
" 6: dav
" 7: rsync
" 8: fetch
" 9: sftp
" g:netrw_machine= hostname
" b:netrw_fname = filename
" g:netrw_port = optional port number (for ftp)
" g:netrw_choice = copy of input url (choice)
fun! s:NetrwMethod(choice)
" call Dfunc("NetrwMethod(a:choice<".a:choice.">)")
" sanity check: choice should have at least three slashes in it
if strlen(substitute(a:choice,'[^/]','','g')) < 3
call netrw#ErrorMsg(s:ERROR,"not a netrw-style url; netrw uses protocol://[user@]hostname[:port]/[path])",78)
let b:netrw_method = -1
" call Dret("NetrwMethod : incorrect url format<".a:choice.">")
return
endif
" record current g:netrw_machine, if any
" curmachine used if protocol == ftp and no .netrc
if exists("g:netrw_machine")
let curmachine= g:netrw_machine
" call Decho("curmachine<".curmachine.">")
else
let curmachine= "N O T A HOST"
endif
if exists("g:netrw_port")
let netrw_port= g:netrw_port
endif
" insure that netrw_ftp_cmd starts off every method determination
" with the current g:netrw_ftp_cmd
let s:netrw_ftp_cmd= g:netrw_ftp_cmd
" initialization
let b:netrw_method = 0
let g:netrw_machine = ""
let b:netrw_fname = ""
let g:netrw_port = ""
let g:netrw_choice = a:choice
" Patterns:
" mipf : a:machine a:id password filename Use ftp
" mf : a:machine filename Use ftp + <.netrc> or g:netrw_uid s:netrw_passwd
" ftpurm : ftp://[user@]host[[#:]port]/filename Use ftp + <.netrc> or g:netrw_uid s:netrw_passwd
" rcpurm : rcp://[user@]host/filename Use rcp
" rcphf : [user@]host:filename Use rcp
" scpurm : scp://[user@]host[[#:]port]/filename Use scp
" httpurm : http[s]://[user@]host/filename Use wget
" davurm : dav[s]://host[:port]/path Use cadaver/curl
" rsyncurm : rsync://host[:port]/path Use rsync
" fetchurm : fetch://[user@]host[:http]/filename Use fetch (defaults to ftp, override for http)
" sftpurm : sftp://[user@]host/filename Use scp
let mipf = '^\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)$'
let mf = '^\(\S\+\)\s\+\(\S\+\)$'
" let ftpurm = '^ftp://\(\([^/@]\{-}\)@\)\=\([^/#:]\{-}\)\([#:]\d\+\)\=/\(.*\)$'
" let rcpurm = '^rcp://\%(\([^/@]\{-}\)@\)\=\([^/]\{-}\)/\(.*\)$'
" let fetchurm = '^fetch://\(\([^/@]\{-}\)@\)\=\([^/#:]\{-}\)\(:http\)\=/\(.*\)$'
let ftpurm = '^ftp://\(\([^/]*\)@\)\=\([^/#:]\{-}\)\([#:]\d\+\)\=/\(.*\)$'
let rcpurm = '^rcp://\%(\([^/]*\)@\)\=\([^/]\{-}\)/\(.*\)$'
let rcphf = '^\(\(\h\w*\)@\)\=\(\h\w*\):\([^@]\+\)$'
let scpurm = '^scp://\([^/#:]\+\)\%([#:]\(\d\+\)\)\=/\(.*\)$'
let httpurm = '^https\=://\([^/]\{-}\)\(/.*\)\=$'
let davurm = '^davs\=://\([^/]\+\)/\(.*/\)\([-_.~[:alnum:]]\+\)$'
let rsyncurm = '^rsync://\([^/]\{-}\)/\(.*\)\=$'
let fetchurm = '^fetch://\(\([^/]*\)@\)\=\([^/#:]\{-}\)\(:http\)\=/\(.*\)$'
let sftpurm = '^sftp://\([^/]\{-}\)/\(.*\)\=$'
" call Decho("determine method:")
" Determine Method
" Method#1: rcp://user@hostname/...path-to-file {{{3
if match(a:choice,rcpurm) == 0
" call Decho("rcp://...")
let b:netrw_method = 1
let userid = substitute(a:choice,rcpurm,'\1',"")
let g:netrw_machine = substitute(a:choice,rcpurm,'\2',"")
let b:netrw_fname = substitute(a:choice,rcpurm,'\3',"")
if userid != ""
let g:netrw_uid= userid
endif
" Method#4: scp://user@hostname/...path-to-file {{{3
elseif match(a:choice,scpurm) == 0
" call Decho("scp://...")
let b:netrw_method = 4
let g:netrw_machine = substitute(a:choice,scpurm,'\1',"")
let g:netrw_port = substitute(a:choice,scpurm,'\2',"")
let b:netrw_fname = substitute(a:choice,scpurm,'\3',"")
" Method#5: http[s]://user@hostname/...path-to-file {{{3
elseif match(a:choice,httpurm) == 0
" call Decho("http://...")
let b:netrw_method = 5
let g:netrw_machine= substitute(a:choice,httpurm,'\1',"")
let b:netrw_fname = substitute(a:choice,httpurm,'\2',"")
" Method#6: dav://hostname[:port]/..path-to-file.. {{{3
elseif match(a:choice,davurm) == 0
" call Decho("dav://...")
let b:netrw_method= 6
if a:choice =~ 'davs:'
let g:netrw_machine= 'https://'.substitute(a:choice,davurm,'\1/\2',"")
else
let g:netrw_machine= 'http://'.substitute(a:choice,davurm,'\1/\2',"")
endif
let b:netrw_fname = substitute(a:choice,davurm,'\3',"")
" Method#7: rsync://user@hostname/...path-to-file {{{3
elseif match(a:choice,rsyncurm) == 0
" call Decho("rsync://...")
let b:netrw_method = 7
let g:netrw_machine= substitute(a:choice,rsyncurm,'\1',"")
let b:netrw_fname = substitute(a:choice,rsyncurm,'\2',"")
" Methods 2,3: ftp://[user@]hostname[[:#]port]/...path-to-file {{{3
elseif match(a:choice,ftpurm) == 0
" call Decho("ftp://...")
let userid = substitute(a:choice,ftpurm,'\2',"")
let g:netrw_machine= substitute(a:choice,ftpurm,'\3',"")
let g:netrw_port = substitute(a:choice,ftpurm,'\4',"")
let b:netrw_fname = substitute(a:choice,ftpurm,'\5',"")
" call Decho("g:netrw_machine<".g:netrw_machine.">")
if userid != ""
let g:netrw_uid= userid
endif
if curmachine != g:netrw_machine
if exists("s:netwr_hup[".g:netrw_machine."]")
call NetUserPass("ftp:".g:netrw_machine)
elseif exists("s:netrw_passwd")
" if there's a change in hostname, require password re-entry
unlet s:netrw_passwd
endif
if exists("netrw_port")
unlet netrw_port
endif
endif
if exists("g:netrw_uid") && exists("s:netrw_passwd")
let b:netrw_method = 3
else
let host= substitute(g:netrw_machine,'\..*$','','')
if exists("s:netrw_hup[host]")
call NetUserPass("ftp:".host)
elseif (has("win32") || has("win95") || has("win64") || has("win16")) && s:netrw_ftp_cmd =~ '-[sS]:'
" call Decho("has -s: : s:netrw_ftp_cmd<".s:netrw_ftp_cmd.">")
" call Decho(" g:netrw_ftp_cmd<".g:netrw_ftp_cmd.">")
if g:netrw_ftp_cmd =~ '-[sS]:\S*MACHINE\>'
let machine = substitute(g:netrw_machine,'\([^.]\+\)\.\S*','\1','')
let s:netrw_ftp_cmd= substitute(g:netrw_ftp_cmd,'\<MACHINE\>',machine.".ftp",'')
" call Decho("s:netrw_ftp_cmd<".s:netrw_ftp_cmd.">")
endif
let b:netrw_method= 2
elseif s:FileReadable(expand("$HOME/.netrc")) && !g:netrw_ignorenetrc
" call Decho("using <".expand("$HOME/.netrc")."> (readable)")
let b:netrw_method= 2
else
if !exists("g:netrw_uid") || g:netrw_uid == ""
call NetUserPass()
elseif !exists("s:netrw_passwd") || s:netrw_passwd == ""
call NetUserPass(g:netrw_uid)
" else just use current g:netrw_uid and s:netrw_passwd
endif
let b:netrw_method= 3
endif
endif
" Method#8: fetch {{{3
elseif match(a:choice,fetchurm) == 0
" call Decho("fetch://...")
let b:netrw_method = 8
let g:netrw_userid = substitute(a:choice,fetchurm,'\2',"")
let g:netrw_machine= substitute(a:choice,fetchurm,'\3',"")
let b:netrw_option = substitute(a:choice,fetchurm,'\4',"")
let b:netrw_fname = substitute(a:choice,fetchurm,'\5',"")
" Method#3: Issue an ftp : "machine id password [path/]filename" {{{3
elseif match(a:choice,mipf) == 0
" call Decho("(ftp) host id pass file")
let b:netrw_method = 3
let g:netrw_machine = substitute(a:choice,mipf,'\1',"")
let g:netrw_uid = substitute(a:choice,mipf,'\2',"")
let s:netrw_passwd = substitute(a:choice,mipf,'\3',"")
let b:netrw_fname = substitute(a:choice,mipf,'\4',"")
call NetUserPass(g:netrw_machine,g:netrw_uid,s:netrw_passwd)
" Method#3: Issue an ftp: "hostname [path/]filename" {{{3
elseif match(a:choice,mf) == 0
" call Decho("(ftp) host file")
if exists("g:netrw_uid") && exists("s:netrw_passwd")
let b:netrw_method = 3
let g:netrw_machine = substitute(a:choice,mf,'\1',"")
let b:netrw_fname = substitute(a:choice,mf,'\2',"")
elseif s:FileReadable(expand("$HOME/.netrc"))
let b:netrw_method = 2
let g:netrw_machine = substitute(a:choice,mf,'\1',"")
let b:netrw_fname = substitute(a:choice,mf,'\2',"")
endif
" Method#9: sftp://user@hostname/...path-to-file {{{3
elseif match(a:choice,sftpurm) == 0
" call Decho("sftp://...")
let b:netrw_method = 9
let g:netrw_machine= substitute(a:choice,sftpurm,'\1',"")
let b:netrw_fname = substitute(a:choice,sftpurm,'\2',"")
" Method#1: Issue an rcp: hostname:filename" (this one should be last) {{{3
elseif match(a:choice,rcphf) == 0
" call Decho("(rcp) [user@]host:file) rcphf<".rcphf.">")
let b:netrw_method = 1
let userid = substitute(a:choice,rcphf,'\2',"")
let g:netrw_machine = substitute(a:choice,rcphf,'\3',"")
let b:netrw_fname = substitute(a:choice,rcphf,'\4',"")
" call Decho('\1<'.substitute(a:choice,rcphf,'\1',"").">")
" call Decho('\2<'.substitute(a:choice,rcphf,'\2',"").">")
" call Decho('\3<'.substitute(a:choice,rcphf,'\3',"").">")
" call Decho('\4<'.substitute(a:choice,rcphf,'\4',"").">")
if userid != ""
let g:netrw_uid= userid
endif
" Cannot Determine Method {{{3
else
if !exists("g:netrw_quiet")
call netrw#ErrorMsg(s:WARNING,"cannot determine method (format: protocol://[user@]hostname[:port]/[path])",45)
endif
let b:netrw_method = -1
endif
"}}}3
if g:netrw_port != ""
" remove any leading [:#] from port number
let g:netrw_port = substitute(g:netrw_port,'[#:]\+','','')
elseif exists("netrw_port")
" retain port number as implicit for subsequent ftp operations
let g:netrw_port= netrw_port
endif
" call Decho("a:choice <".a:choice.">")
" call Decho("b:netrw_method <".b:netrw_method.">")
" call Decho("g:netrw_machine<".g:netrw_machine.">")
" call Decho("g:netrw_port <".g:netrw_port.">")
" if exists("g:netrw_uid") "Decho
" call Decho("g:netrw_uid <".g:netrw_uid.">")
" endif "Decho
" if exists("s:netrw_passwd") "Decho
" call Decho("s:netrw_passwd <".s:netrw_passwd.">")
" endif "Decho
" call Decho("b:netrw_fname <".b:netrw_fname.">")
" call Dret("NetrwMethod : b:netrw_method=".b:netrw_method." g:netrw_port=".g:netrw_port)
endfun
" ------------------------------------------------------------------------
" NetReadFixup: this sort of function is typically written by the user {{{2
" to handle extra junk that their system's ftp dumps
" into the transfer. This function is provided as an
" example and as a fix for a Windows 95 problem: in my
" experience, win95's ftp always dumped four blank lines
" at the end of the transfer.
if has("win95") && exists("g:netrw_win95ftp") && g:netrw_win95ftp
fun! NetReadFixup(method, line1, line2)
" call Dfunc("NetReadFixup(method<".a:method."> line1=".a:line1." line2=".a:line2.")")
" sanity checks -- attempt to convert inputs to integers
let method = a:method + 0
let line1 = a:line1 + 0
let line2 = a:line2 + 0
if type(method) != 0 || type(line1) != 0 || type(line2) != 0 || method < 0 || line1 <= 0 || line2 <= 0
" call Dret("NetReadFixup")
return
endif
if method == 3 " ftp (no <.netrc>)
let fourblanklines= line2 - 3
if fourblanklines >= line1
exe "sil keepj ".fourblanklines.",".line2."g/^\s*$/d"
call histdel("/",-1)
endif
endif
" call Dret("NetReadFixup")
endfun
endif
" ---------------------------------------------------------------------
" NetUserPass: set username and password for subsequent ftp transfer {{{2
" Usage: :call NetUserPass() -- will prompt for userid and password
" :call NetUserPass("uid") -- will prompt for password
" :call NetUserPass("uid","password") -- sets global userid and password
" :call NetUserPass("ftp:host") -- looks up userid and password using hup dictionary
" :call NetUserPass("host","uid","password") -- sets hup dictionary with host, userid, password
fun! NetUserPass(...)
" call Dfunc("NetUserPass() a:0=".a:0)
if !exists('s:netrw_hup')
let s:netrw_hup= {}
endif
if a:0 == 0
if !exists("g:netrw_uid") || g:netrw_uid == ""
" get uid via prompt
let g:netrw_uid= input('Enter username: ')
endif
" get password via prompt
let s:netrw_passwd= inputsecret("Enter Password: ")
" set up hup database
let host = substitute(g:netrw_machine,'\..*$','','')
if !exists('s:netrw_hup[host]')
let s:netrw_hup[host]= {}
endif
let s:netrw_hup[host].uid = g:netrw_uid
let s:netrw_hup[host].passwd = s:netrw_passwd
elseif a:0 == 1
if a:1 =~ '^ftp:'
" access userid and password from hup (host-user-passwd) dictionary
let host = substitute(a:1,'^ftp:','','')
let host = substitute(host,'\..*','','')
if exists("s:netrw_hup[host]")
let g:netrw_uid = s:netrw_hup[host].uid
let s:netrw_passwd = s:netrw_hup[host].passwd
" call Decho("get s:netrw_hup[".host."].uid <".s:netrw_hup[host].uid.">")
" call Decho("get s:netrw_hup[".host."].passwd<".s:netrw_hup[host].passwd.">")
else
let g:netrw_uid = input("Enter UserId: ")
let s:netrw_passwd = inputsecret("Enter Password: ")
endif
else
" set userid, prompt for password
" call Decho("set g:netrw_uid= <".a:1.">")
if exists("g:netrw_machine")
let host= substitute(g:netrw_machine,'\..*$','','')
endif
let g:netrw_uid = a:1
let s:netrw_passwd = inputsecret("Enter Password: ")
endif
" call Decho("host<".host.">")
if exists("host")
if !exists('s:netrw_hup[host]')
let s:netrw_hup[host]= {}
endif
let s:netrw_hup[host].uid = g:netrw_uid
let s:netrw_hup[host].passwd = s:netrw_passwd
endif
elseif a:0 == 2
let g:netrw_uid = a:1
let s:netrw_passwd = a:2
elseif a:0 == 3
" enter hostname, user-id, and password into the hup dictionary
let host = substitute(a:1,'^\a\+:','','')
let host = substitute(host,'\..*$','','')
if !exists('s:netrw_hup[host]')
let s:netrw_hup[host]= {}
endif
let s:netrw_hup[host].uid = a:2
let s:netrw_hup[host].passwd = a:3
let g:netrw_uid = s:netrw_hup[host].uid
let s:netrw_passwd = s:netrw_hup[host].passwd
" call Decho("set s:netrw_hup[".host."].uid <".s:netrw_hup[host].uid.">")
" call Decho("set s:netrw_hup[".host."].passwd<".s:netrw_hup[host].passwd.">")
endif
" call Dret("NetUserPass : uid<".g:netrw_uid."> passwd<".s:netrw_passwd.">")
endfun
" ===========================================
" Shared Browsing Support: {{{1
" ===========================================
" ---------------------------------------------------------------------
" s:NetrwMaps: {{{2
fun! s:NetrwMaps(islocal)
" call Dfunc("s:NetrwMaps(islocal=".a:islocal.") b:netrw_curdir<".b:netrw_curdir.">")
" set up Rexplore and [ 2-leftmouse-click -or- c-leftmouse ]
" call Decho("set up Rexplore command")
com! Rexplore if exists("w:netrw_rexlocal")|call s:NetrwRexplore(w:netrw_rexlocal,exists("w:netrw_rexdir")? w:netrw_rexdir : ".")|else|call netrw#ErrorMsg(s:WARNING,"not a former netrw window",79)|endif
if g:netrw_mousemaps && g:netrw_retmap
" call Decho("set up Rexplore 2-leftmouse")
if !hasmapto("<Plug>NetrwReturn")
if maparg("<2-leftmouse>","n") == "" || maparg("<2-leftmouse>","n") =~ '^-$'
" call Decho("making map for 2-leftmouse")
nmap <unique> <silent> <2-leftmouse> <Plug>NetrwReturn
elseif maparg("<c-leftmouse>","n") == ""
" call Decho("making map for c-leftmouse")
nmap <unique> <silent> <c-leftmouse> <Plug>NetrwReturn
endif
endif
nno <silent> <Plug>NetrwReturn :Rexplore<cr>
" call Decho("made <Plug>NetrwReturn map")
endif
if a:islocal
" call Decho("make local maps")
" local normal-mode maps
nnoremap <buffer> <silent> a :call <SID>NetrwHide(1)<cr>
nnoremap <buffer> <silent> % :call <SID>NetrwOpenFile(1)<cr>
nnoremap <buffer> <silent> c :exe "keepjumps lcd ".fnameescape(b:netrw_curdir)<cr>
nnoremap <buffer> <silent> C :let g:netrw_chgwin= winnr()<cr>
nnoremap <buffer> <silent> <cr> :call netrw#LocalBrowseCheck(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord()))<cr>
nnoremap <buffer> <silent> d :call <SID>NetrwMakeDir("")<cr>
nnoremap <buffer> <silent> - :exe "norm! 0"<bar>call netrw#LocalBrowseCheck(<SID>NetrwBrowseChgDir(1,'../'))<cr>
nnoremap <buffer> <silent> gb :<c-u>call <SID>NetrwBookHistHandler(1,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> gd :<c-u>call <SID>NetrwForceChgDir(1,<SID>NetrwGetWord())<cr>
nnoremap <buffer> <silent> gf :<c-u>call <SID>NetrwForceFile(1,<SID>NetrwGetWord())<cr>
nnoremap <buffer> <silent> gh :<c-u>call <SID>NetrwHidden(1)<cr>
nnoremap <buffer> <silent> gp :<c-u>call <SID>NetrwChgPerm(1,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> I :call <SID>NetrwBannerCtrl(1)<cr>
nnoremap <buffer> <silent> i :call <SID>NetrwListStyle(1)<cr>
nnoremap <buffer> <silent> mb :<c-u>call <SID>NetrwBookHistHandler(0,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> mB :<c-u>call <SID>NetrwBookHistHandler(6,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> mc :<c-u>call <SID>NetrwMarkFileCopy(1)<cr>
nnoremap <buffer> <silent> md :<c-u>call <SID>NetrwMarkFileDiff(1)<cr>
nnoremap <buffer> <silent> me :<c-u>call <SID>NetrwMarkFileEdit(1)<cr>
nnoremap <buffer> <silent> mf :<c-u>call <SID>NetrwMarkFile(1,<SID>NetrwGetWord())<cr>
nnoremap <buffer> <silent> mg :<c-u>call <SID>NetrwMarkFileGrep(1)<cr>
nnoremap <buffer> <silent> mh :<c-u>call <SID>NetrwMarkHideSfx(1)<cr>
nnoremap <buffer> <silent> mm :<c-u>call <SID>NetrwMarkFileMove(1)<cr>
nnoremap <buffer> <silent> mp :<c-u>call <SID>NetrwMarkFilePrint(1)<cr>
nnoremap <buffer> <silent> mr :<c-u>call <SID>NetrwMarkFileRegexp(1)<cr>
nnoremap <buffer> <silent> ms :<c-u>call <SID>NetrwMarkFileSource(1)<cr>
nnoremap <buffer> <silent> mt :<c-u>call <SID>NetrwMarkFileTgt(1)<cr>
nnoremap <buffer> <silent> mT :<c-u>call <SID>NetrwMarkFileTag(1)<cr>
nnoremap <buffer> <silent> mu :<c-u>call <SID>NetrwUnMarkFile(1)<cr>
nnoremap <buffer> <silent> mx :<c-u>call <SID>NetrwMarkFileExe(1)<cr>
nnoremap <buffer> <silent> mX :<c-u>call <SID>NetrwMarkFileVimCmd(1)<cr>
nnoremap <buffer> <silent> mz :<c-u>call <SID>NetrwMarkFileCompress(1)<cr>
nnoremap <buffer> <silent> O :call <SID>NetrwObtain(1)<cr>
nnoremap <buffer> <silent> o :call <SID>NetrwSplit(3)<cr>
nnoremap <buffer> <silent> p :call <SID>NetrwPreview(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord(),1))<cr>
nnoremap <buffer> <silent> P :call <SID>NetrwPrevWinOpen(1)<cr>
nnoremap <buffer> <silent> qb :<c-u>call <SID>NetrwBookHistHandler(2,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> qf :<c-u>call <SID>NetrwFileInfo(1,<SID>NetrwGetWord())<cr>
nnoremap <buffer> <silent> r :let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetrwRefresh(1,<SID>NetrwBrowseChgDir(1,'./'))<cr>
nnoremap <buffer> <silent> s :call <SID>NetrwSortStyle(1)<cr>
nnoremap <buffer> <silent> S :call <SID>NetSortSequence(1)<cr>
nnoremap <buffer> <silent> T :call <SID>NetrwSplit(4)<bar>norm! gT<cr>
nnoremap <buffer> <silent> t :call <SID>NetrwSplit(4)<cr>
nnoremap <buffer> <silent> u :<c-u>call <SID>NetrwBookHistHandler(4,expand("%"))<cr>
nnoremap <buffer> <silent> U :<c-u>call <SID>NetrwBookHistHandler(5,expand("%"))<cr>
nnoremap <buffer> <silent> v :call <SID>NetrwSplit(5)<cr>
nnoremap <buffer> <silent> x :call netrw#NetrwBrowseX(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord(),0),0)"<cr>
" local insert-mode maps
inoremap <buffer> <silent> a <c-o>:call <SID>NetrwHide(1)<cr>
inoremap <buffer> <silent> c <c-o>:exe "keepjumps lcd ".fnameescape(b:netrw_curdir)<cr>
inoremap <buffer> <silent> C <c-o>:let g:netrw_chgwin= winnr()<cr>
inoremap <buffer> <silent> % <c-o>:call <SID>NetrwOpenFile(1)<cr>
inoremap <buffer> <silent> - <c-o>:exe "norm! 0"<bar>call netrw#LocalBrowseCheck(<SID>NetrwBrowseChgDir(1,'../'))<cr>
inoremap <buffer> <silent> <cr> <c-o>:call netrw#LocalBrowseCheck(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord()))<cr>
inoremap <buffer> <silent> d <c-o>:call <SID>NetrwMakeDir("")<cr>
inoremap <buffer> <silent> gb <c-o>:<c-u>call <SID>NetrwBookHistHandler(1,b:netrw_curdir)<cr>
inoremap <buffer> <silent> gh <c-o>:<c-u>call <SID>NetrwHidden(1)<cr>
inoremap <buffer> <silent> gp <c-o>:<c-u>call <SID>NetrwChgPerm(1,b:netrw_curdir)<cr>
inoremap <buffer> <silent> I <c-o>:call <SID>NetrwBannerCtrl(1)<cr>
inoremap <buffer> <silent> i <c-o>:call <SID>NetrwListStyle(1)<cr>
inoremap <buffer> <silent> mb <c-o>:<c-u>call <SID>NetrwBookHistHandler(0,b:netrw_curdir)<cr>
inoremap <buffer> <silent> mB <c-o>:<c-u>call <SID>NetrwBookHistHandler(6,b:netrw_curdir)<cr>
inoremap <buffer> <silent> mc <c-o>:<c-u>call <SID>NetrwMarkFileCopy(1)<cr>
inoremap <buffer> <silent> md <c-o>:<c-u>call <SID>NetrwMarkFileDiff(1)<cr>
inoremap <buffer> <silent> me <c-o>:<c-u>call <SID>NetrwMarkFileEdit(1)<cr>
inoremap <buffer> <silent> mf <c-o>:<c-u>call <SID>NetrwMarkFile(1,<SID>NetrwGetWord())<cr>
inoremap <buffer> <silent> mg <c-o>:<c-u>call <SID>NetrwMarkFileGrep(1)<cr>
inoremap <buffer> <silent> mh <c-o>:<c-u>call <SID>NetrwMarkHideSfx(1)<cr>
inoremap <buffer> <silent> mm <c-o>:<c-u>call <SID>NetrwMarkFileMove(1)<cr>
inoremap <buffer> <silent> mp <c-o>:<c-u>call <SID>NetrwMarkFilePrint(1)<cr>
inoremap <buffer> <silent> mr <c-o>:<c-u>call <SID>NetrwMarkFileRegexp(1)<cr>
inoremap <buffer> <silent> ms <c-o>:<c-u>call <SID>NetrwMarkFileSource(1)<cr>
inoremap <buffer> <silent> mT <c-o>:<c-u>call <SID>NetrwMarkFileTag(1)<cr>
inoremap <buffer> <silent> mt <c-o>:<c-u>call <SID>NetrwMarkFileTgt(1)<cr>
inoremap <buffer> <silent> mu <c-o>:<c-u>call <SID>NetrwUnMarkFile(1)<cr>
inoremap <buffer> <silent> mx <c-o>:<c-u>call <SID>NetrwMarkFileExe(1)<cr>
inoremap <buffer> <silent> mX <c-o>:<c-u>call <SID>NetrwMarkFileVimCmd(1)<cr>
inoremap <buffer> <silent> mz <c-o>:<c-u>call <SID>NetrwMarkFileCompress(1)<cr>
inoremap <buffer> <silent> O <c-o>:call <SID>NetrwObtain(1)<cr>
inoremap <buffer> <silent> o <c-o>:call <SID>NetrwSplit(3)<cr>
inoremap <buffer> <silent> p <c-o>:call <SID>NetrwPreview(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord(),1))<cr>
inoremap <buffer> <silent> P <c-o>:call <SID>NetrwPrevWinOpen(1)<cr>
inoremap <buffer> <silent> qb <c-o>:<c-u>call <SID>NetrwBookHistHandler(2,b:netrw_curdir)<cr>
inoremap <buffer> <silent> qf <c-o>:<c-u>call <SID>NetrwFileInfo(1,<SID>NetrwGetWord())<cr>
inoremap <buffer> <silent> r <c-o>:let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetrwRefresh(1,<SID>NetrwBrowseChgDir(1,'./'))<cr>
inoremap <buffer> <silent> s <c-o>:call <SID>NetrwSortStyle(1)<cr>
inoremap <buffer> <silent> S <c-o>:call <SID>NetSortSequence(1)<cr>
inoremap <buffer> <silent> T <c-o>:call <SID>NetrwSplit(4)<bar>norm! gT<cr>
inoremap <buffer> <silent> t <c-o>:call <SID>NetrwSplit(4)<cr>
inoremap <buffer> <silent> u <c-o>:<c-u>call <SID>NetrwBookHistHandler(4,expand("%"))<cr>
inoremap <buffer> <silent> U <c-o>:<c-u>call <SID>NetrwBookHistHandler(5,expand("%"))<cr>
inoremap <buffer> <silent> v <c-o>:call <SID>NetrwSplit(5)<cr>
inoremap <buffer> <silent> x <c-o>:call netrw#NetrwBrowseX(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord(),0),0)"<cr>
if !hasmapto('<Plug>NetrwHideEdit')
nmap <buffer> <unique> <c-h> <Plug>NetrwHideEdit
imap <buffer> <unique> <c-h> <Plug>NetrwHideEdit
endif
nnoremap <buffer> <silent> <Plug>NetrwHideEdit :call <SID>NetrwHideEdit(1)<cr>
if !hasmapto('<Plug>NetrwRefresh')
nmap <buffer> <unique> <c-l> <Plug>NetrwRefresh
imap <buffer> <unique> <c-l> <Plug>NetrwRefresh
endif
nnoremap <buffer> <silent> <Plug>NetrwRefresh :call <SID>NetrwRefresh(1,<SID>NetrwBrowseChgDir(1,'./'))<cr>
if s:didstarstar || !mapcheck("<s-down>","n")
nnoremap <buffer> <silent> <s-down> :Nexplore<cr>
inoremap <buffer> <silent> <s-down> :Nexplore<cr>
endif
if s:didstarstar || !mapcheck("<s-up>","n")
nnoremap <buffer> <silent> <s-up> :Pexplore<cr>
inoremap <buffer> <silent> <s-up> :Pexplore<cr>
endif
let mapsafecurdir = escape(b:netrw_curdir, s:netrw_map_escape)
if g:netrw_mousemaps == 1
nmap <buffer> <leftmouse> <Plug>NetrwLeftmouse
nno <buffer> <silent> <Plug>NetrwLeftmouse <leftmouse>:call <SID>NetrwLeftmouse(1)<cr>
nmap <buffer> <middlemouse> <Plug>NetrwMiddlemouse
nno <buffer> <silent> <Plug>NetrwMiddlemouse <leftmouse>:call <SID>NetrwPrevWinOpen(1)<cr>
nmap <buffer> <s-leftmouse> <Plug>NetrwSLeftmouse
nno <buffer> <silent> <Plug>NetrwSLeftmouse <leftmouse>:call <SID>NetrwMarkFile(1,<SID>NetrwGetWord())<cr>
nmap <buffer> <2-leftmouse> <Plug>Netrw2Leftmouse
nmap <buffer> <silent> <Plug>Netrw2Leftmouse -
imap <buffer> <leftmouse> <Plug>ILeftmouse
ino <buffer> <silent> <Plug>ILeftmouse <c-o><leftmouse><c-o>:call <SID>NetrwLeftmouse(1)<cr>
imap <buffer> <middlemouse> <Plug>IMiddlemouse
ino <buffer> <silent> <Plug>IMiddlemouse <c-o><leftmouse><c-o>:call <SID>NetrwPrevWinOpen(1)<cr>
imap <buffer> <s-leftmouse> <Plug>ISLeftmouse
ino <buffer> <silent> <Plug>ISLeftmouse <c-o><leftmouse><c-o>:call <SID>NetrwMarkFile(1,<SID>NetrwGetWord())<cr>
exe 'nnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
exe 'vnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
exe 'inoremap <buffer> <silent> <rightmouse> <c-o><leftmouse><c-o>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
endif
exe 'nnoremap <buffer> <silent> <del> :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
exe 'nnoremap <buffer> <silent> D :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
exe 'nnoremap <buffer> <silent> R :call <SID>NetrwLocalRename("'.mapsafecurdir.'")<cr>'
exe 'nnoremap <buffer> <silent> <Leader>m :call <SID>NetrwMakeDir("")<cr>'
exe 'vnoremap <buffer> <silent> <del> :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
exe 'vnoremap <buffer> <silent> D :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
exe 'vnoremap <buffer> <silent> R :call <SID>NetrwLocalRename("'.mapsafecurdir.'")<cr>'
exe 'inoremap <buffer> <silent> <del> <c-o>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
exe 'inoremap <buffer> <silent> D <c-o>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
exe 'inoremap <buffer> <silent> R <c-o>:call <SID>NetrwLocalRename("'.mapsafecurdir.'")<cr>'
exe 'inoremap <buffer> <silent> <Leader>m <c-o>:call <SID>NetrwMakeDir("")<cr>'
nnoremap <buffer> <F1> :he netrw-quickhelp<cr>
else " remote
" call Decho("make remote maps")
call s:RemotePathAnalysis(b:netrw_curdir)
" remote normal-mode maps
nnoremap <buffer> <silent> <cr> :call <SID>NetrwBrowse(0,<SID>NetrwBrowseChgDir(0,<SID>NetrwGetWord()))<cr>
nnoremap <buffer> <silent> <c-l> :call <SID>NetrwRefresh(0,<SID>NetrwBrowseChgDir(0,'./'))<cr>
nnoremap <buffer> <silent> - :exe "norm! 0"<bar>call <SID>NetrwBrowse(0,<SID>NetrwBrowseChgDir(0,'../'))<cr>
nnoremap <buffer> <silent> a :call <SID>NetrwHide(0)<cr>
nnoremap <buffer> <silent> mb :<c-u>call <SID>NetrwBookHistHandler(0,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> mc :<c-u>call <SID>NetrwMarkFileCopy(0)<cr>
nnoremap <buffer> <silent> md :<c-u>call <SID>NetrwMarkFileDiff(0)<cr>
nnoremap <buffer> <silent> me :<c-u>call <SID>NetrwMarkFileEdit(0)<cr>
nnoremap <buffer> <silent> mf :<c-u>call <SID>NetrwMarkFile(0,<SID>NetrwGetWord())<cr>
nnoremap <buffer> <silent> mg :<c-u>call <SID>NetrwMarkFileGrep(0)<cr>
nnoremap <buffer> <silent> mh :<c-u>call <SID>NetrwMarkHideSfx(0)<cr>
nnoremap <buffer> <silent> mm :<c-u>call <SID>NetrwMarkFileMove(0)<cr>
nnoremap <buffer> <silent> mp :<c-u>call <SID>NetrwMarkFilePrint(0)<cr>
nnoremap <buffer> <silent> mr :<c-u>call <SID>NetrwMarkFileRegexp(0)<cr>
nnoremap <buffer> <silent> ms :<c-u>call <SID>NetrwMarkFileSource(0)<cr>
nnoremap <buffer> <silent> mt :<c-u>call <SID>NetrwMarkFileTgt(0)<cr>
nnoremap <buffer> <silent> mT :<c-u>call <SID>NetrwMarkFileTag(0)<cr>
nnoremap <buffer> <silent> mu :<c-u>call <SID>NetrwUnMarkFile(0)<cr>
nnoremap <buffer> <silent> mx :<c-u>call <SID>NetrwMarkFileExe(0)<cr>
nnoremap <buffer> <silent> mX :<c-u>call <SID>NetrwMarkFileVimCmd(0)<cr>
nnoremap <buffer> <silent> mz :<c-u>call <SID>NetrwMarkFileCompress(0)<cr>
nnoremap <buffer> <silent> gb :<c-u>call <SID>NetrwBookHistHandler(1,b:netrw_cur)<cr>
nnoremap <buffer> <silent> gd :<c-u>call <SID>NetrwForceChgDir(0,<SID>NetrwGetWord())<cr>
nnoremap <buffer> <silent> gf :<c-u>call <SID>NetrwForceFile(0,<SID>NetrwGetWord())<cr>
nnoremap <buffer> <silent> gh :<c-u>call <SID>NetrwHidden(0)<cr>
nnoremap <buffer> <silent> gp :<c-u>call <SID>NetrwChgPerm(0,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> C :let g:netrw_chgwin= winnr()<cr>
nnoremap <buffer> <silent> i :call <SID>NetrwListStyle(0)<cr>
nnoremap <buffer> <silent> I :call <SID>NetrwBannerCtrl(1)<cr>
nnoremap <buffer> <silent> o :call <SID>NetrwSplit(0)<cr>
nnoremap <buffer> <silent> O :call <SID>NetrwObtain(0)<cr>
nnoremap <buffer> <silent> p :call <SID>NetrwPreview(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord(),1))<cr>
nnoremap <buffer> <silent> P :call <SID>NetrwPrevWinOpen(0)<cr>
nnoremap <buffer> <silent> qb :<c-u>call <SID>NetrwBookHistHandler(2,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> mB :<c-u>call <SID>NetrwBookHistHandler(6,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> qf :<c-u>call <SID>NetrwFileInfo(0,<SID>NetrwGetWord())<cr>
nnoremap <buffer> <silent> r :let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetrwBrowse(0,<SID>NetrwBrowseChgDir(0,'./'))<cr>
nnoremap <buffer> <silent> s :call <SID>NetrwSortStyle(0)<cr>
nnoremap <buffer> <silent> S :call <SID>NetSortSequence(0)<cr>
nnoremap <buffer> <silent> t :call <SID>NetrwSplit(1)<cr>
nnoremap <buffer> <silent> T :call <SID>NetrwSplit(1)<bar>norm! gT<cr>
nnoremap <buffer> <silent> u :<c-u>call <SID>NetrwBookHistHandler(4,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> U :<c-u>call <SID>NetrwBookHistHandler(5,b:netrw_curdir)<cr>
nnoremap <buffer> <silent> v :call <SID>NetrwSplit(2)<cr>
nnoremap <buffer> <silent> x :call netrw#NetrwBrowseX(<SID>NetrwBrowseChgDir(0,<SID>NetrwGetWord()),1)<cr>
nnoremap <buffer> <silent> % :call <SID>NetrwOpenFile(0)<cr>
" remote insert-mode maps
inoremap <buffer> <silent> <cr> <c-o>:call <SID>NetrwBrowse(0,<SID>NetrwBrowseChgDir(0,<SID>NetrwGetWord()))<cr>
inoremap <buffer> <silent> <c-l> <c-o>:call <SID>NetrwRefresh(0,<SID>NetrwBrowseChgDir(0,'./'))<cr>
inoremap <buffer> <silent> - <c-o>:exe "norm! 0"<bar>call <SID>NetrwBrowse(0,<SID>NetrwBrowseChgDir(0,'../'))<cr>
inoremap <buffer> <silent> a <c-o>:call <SID>NetrwHide(0)<cr>
inoremap <buffer> <silent> mb <c-o>:<c-u>call <SID>NetrwBookHistHandler(0,b:netrw_curdir)<cr>
inoremap <buffer> <silent> mc <c-o>:<c-u>call <SID>NetrwMarkFileCopy(0)<cr>
inoremap <buffer> <silent> md <c-o>:<c-u>call <SID>NetrwMarkFileDiff(0)<cr>
inoremap <buffer> <silent> me <c-o>:<c-u>call <SID>NetrwMarkFileEdit(0)<cr>
inoremap <buffer> <silent> mf <c-o>:<c-u>call <SID>NetrwMarkFile(0,<SID>NetrwGetWord())<cr>
inoremap <buffer> <silent> mg <c-o>:<c-u>call <SID>NetrwMarkFileGrep(0)<cr>
inoremap <buffer> <silent> mh <c-o>:<c-u>call <SID>NetrwMarkHideSfx(0)<cr>
inoremap <buffer> <silent> mm <c-o>:<c-u>call <SID>NetrwMarkFileMove(0)<cr>
inoremap <buffer> <silent> mp <c-o>:<c-u>call <SID>NetrwMarkFilePrint(0)<cr>
inoremap <buffer> <silent> mr <c-o>:<c-u>call <SID>NetrwMarkFileRegexp(0)<cr>
inoremap <buffer> <silent> ms <c-o>:<c-u>call <SID>NetrwMarkFileSource(0)<cr>
inoremap <buffer> <silent> mt <c-o>:<c-u>call <SID>NetrwMarkFileTgt(0)<cr>
inoremap <buffer> <silent> mT <c-o>:<c-u>call <SID>NetrwMarkFileTag(0)<cr>
inoremap <buffer> <silent> mu <c-o>:<c-u>call <SID>NetrwUnMarkFile(0)<cr>
inoremap <buffer> <silent> mx <c-o>:<c-u>call <SID>NetrwMarkFileExe(0)<cr>
inoremap <buffer> <silent> mX <c-o>:<c-u>call <SID>NetrwMarkFileVimCmd(0)<cr>
inoremap <buffer> <silent> mz <c-o>:<c-u>call <SID>NetrwMarkFileCompress(0)<cr>
inoremap <buffer> <silent> gb <c-o>:<c-u>call <SID>NetrwBookHistHandler(1,b:netrw_cur)<cr>
inoremap <buffer> <silent> gh <c-o>:<c-u>call <SID>NetrwHidden(0)<cr>
inoremap <buffer> <silent> gp <c-o>:<c-u>call <SID>NetrwChgPerm(0,b:netrw_curdir)<cr>
inoremap <buffer> <silent> C <c-o>:let g:netrw_chgwin= winnr()<cr>
inoremap <buffer> <silent> i <c-o>:call <SID>NetrwListStyle(0)<cr>
inoremap <buffer> <silent> I <c-o>:call <SID>NetrwBannerCtrl(1)<cr>
inoremap <buffer> <silent> o <c-o>:call <SID>NetrwSplit(0)<cr>
inoremap <buffer> <silent> O <c-o>:call <SID>NetrwObtain(0)<cr>
inoremap <buffer> <silent> p <c-o>:call <SID>NetrwPreview(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord(),1))<cr>
inoremap <buffer> <silent> P <c-o>:call <SID>NetrwPrevWinOpen(0)<cr>
inoremap <buffer> <silent> qb <c-o>:<c-u>call <SID>NetrwBookHistHandler(2,b:netrw_curdir)<cr>
inoremap <buffer> <silent> mB <c-o>:<c-u>call <SID>NetrwBookHistHandler(6,b:netrw_curdir)<cr>
inoremap <buffer> <silent> qf <c-o>:<c-u>call <SID>NetrwFileInfo(0,<SID>NetrwGetWord())<cr>
inoremap <buffer> <silent> r <c-o>:let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetrwBrowse(0,<SID>NetrwBrowseChgDir(0,'./'))<cr>
inoremap <buffer> <silent> s <c-o>:call <SID>NetrwSortStyle(0)<cr>
inoremap <buffer> <silent> S <c-o>:call <SID>NetSortSequence(0)<cr>
inoremap <buffer> <silent> t <c-o>:call <SID>NetrwSplit(1)<cr>
inoremap <buffer> <silent> T <c-o>:call <SID>NetrwSplit(1)<bar>norm! gT<cr>
inoremap <buffer> <silent> u <c-o>:<c-u>call <SID>NetrwBookHistHandler(4,b:netrw_curdir)<cr>
inoremap <buffer> <silent> U <c-o>:<c-u>call <SID>NetrwBookHistHandler(5,b:netrw_curdir)<cr>
inoremap <buffer> <silent> v <c-o>:call <SID>NetrwSplit(2)<cr>
inoremap <buffer> <silent> x <c-o>:call netrw#NetrwBrowseX(<SID>NetrwBrowseChgDir(0,<SID>NetrwGetWord()),1)<cr>
inoremap <buffer> <silent> % <c-o>:call <SID>NetrwOpenFile(0)<cr>
if !hasmapto('<Plug>NetrwHideEdit')
nmap <buffer> <c-h> <Plug>NetrwHideEdit
imap <buffer> <c-h> <Plug>NetrwHideEdit
endif
nnoremap <buffer> <silent> <Plug>NetrwHideEdit :call <SID>NetrwHideEdit(0)<cr>
if !hasmapto('<Plug>NetrwRefresh')
nmap <buffer> <c-l> <Plug>NetrwRefresh
imap <buffer> <c-l> <Plug>NetrwRefresh
endif
let mapsafepath = escape(s:path, s:netrw_map_escape)
let mapsafeusermach = escape(s:user.s:machine, s:netrw_map_escape)
nnoremap <buffer> <silent> <Plug>NetrwRefresh :call <SID>NetrwRefresh(0,<SID>NetrwBrowseChgDir(0,'./'))<cr>
if g:netrw_mousemaps == 1
nmap <leftmouse> <Plug>NetrwLeftmouse
nno <buffer> <silent> <Plug>NetrwLeftmouse <leftmouse>:call <SID>NetrwLeftmouse(0)<cr>
nmap <middlemouse> <Plug>NetrwMiddlemouse
nno <buffer> <silent> <middlemouse> <Plug>NetrwMiddlemouse <leftmouse>:call <SID>NetrwPrevWinOpen(0)<cr>
nmap <buffer> <s-leftmouse> <Plug>NetrwSLeftmouse
nno <buffer> <silent> <Plug>NetrwSLeftmouse <leftmouse>:call <SID>NetrwMarkFile(0,<SID>NetrwGetWord())<cr>
nmap <buffer> <2-leftmouse> <Plug>Netrw2Leftmouse
nmap <buffer> <silent> <Plug>Netrw2Leftmouse -
imap <buffer> <leftmouse> <Plug>ILeftmouse
ino <buffer> <silent> <Plug>ILeftmouse <c-o><leftmouse><c-o>:call <SID>NetrwLeftmouse(0)<cr>
imap <buffer> <middlemouse> <Plug>IMiddlemouse
ino <buffer> <silent> <Plug>IMiddlemouse <c-o><leftmouse><c-o>:call <SID>NetrwPrevWinOpen(0)<cr>
imap <buffer> <s-leftmouse> <Plug>ISLeftmouse
ino <buffer> <silent> <Plug>ISLeftmouse <c-o><leftmouse><c-o>:call <SID>NetrwMarkFile(0,<SID>NetrwGetWord())<cr>
exe 'nnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
exe 'vnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
exe 'inoremap <buffer> <silent> <rightmouse> <c-o><leftmouse><c-o>:call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
endif
exe 'nnoremap <buffer> <silent> <del> :call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
exe 'nnoremap <buffer> <silent> d :call <SID>NetrwMakeDir("'.mapsafeusermach.'")<cr>'
exe 'nnoremap <buffer> <silent> D :call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
exe 'nnoremap <buffer> <silent> R :call <SID>NetrwRemoteRename("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
exe 'vnoremap <buffer> <silent> <del> :call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
exe 'vnoremap <buffer> <silent> D :call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
exe 'vnoremap <buffer> <silent> R :call <SID>NetrwRemoteRename("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
exe 'inoremap <buffer> <silent> <del> <c-o>:call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
exe 'inoremap <buffer> <silent> d <c-o>:call <SID>NetrwMakeDir("'.mapsafeusermach.'")<cr>'
exe 'inoremap <buffer> <silent> D <c-o>:call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
exe 'inoremap <buffer> <silent> R <c-o>:call <SID>NetrwRemoteRename("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
nnoremap <buffer> <F1> :he netrw-quickhelp<cr>
inoremap <buffer> <F1> <c-o>:he netrw-quickhelp<cr>
endif
keepj call s:SetRexDir(a:islocal,b:netrw_curdir)
" call Dret("s:NetrwMaps")
endfun
" ---------------------------------------------------------------------
" s:ExplorePatHls: converts an Explore pattern into a regular expression search pattern {{{2
fun! s:ExplorePatHls(pattern)
" call Dfunc("s:ExplorePatHls(pattern<".a:pattern.">)")
let repat= substitute(a:pattern,'^**/\{1,2}','','')
" call Decho("repat<".repat.">")
let repat= escape(repat,'][.\')
" call Decho("repat<".repat.">")
let repat= '\<'.substitute(repat,'\*','\\(\\S\\+ \\)*\\S\\+','g').'\>'
" call Dret("s:ExplorePatHls repat<".repat.">")
return repat
endfun
" ---------------------------------------------------------------------
" s:NetrwBookHistHandler: {{{2
" 0: (user: <mb>) bookmark current directory
" 1: (user: <gb>) change to the bookmarked directory
" 2: (user: <qb>) list bookmarks
" 3: (browsing) record current directory history
" 4: (user: <u>) go up (previous) bookmark
" 5: (user: <U>) go down (next) bookmark
" 6: (user: <mB>) delete bookmark
fun! s:NetrwBookHistHandler(chg,curdir)
" call Dfunc("s:NetrwBookHistHandler(chg=".a:chg." curdir<".a:curdir.">) cnt=".v:count." histcnt=".g:netrw_dirhist_cnt." histmax=".g:netrw_dirhistmax)
if a:chg == 0
" bookmark the current directory
" call Decho("(user: <b>) bookmark the current directory")
if !exists("g:netrw_bookmarklist")
let g:netrw_bookmarklist= []
endif
if index(g:netrw_bookmarklist,a:curdir) == -1
" curdir not currently in g:netrw_bookmarklist, so include it
call add(g:netrw_bookmarklist,a:curdir)
call sort(g:netrw_bookmarklist)
endif
echo "bookmarked the current directory"
elseif a:chg == 1
" change to the bookmarked directory
" call Decho("(user: <".v:count."mb>) change to the bookmarked directory")
if exists("g:netrw_bookmarklist[v:count-1]")
exe "keepj e ".fnameescape(g:netrw_bookmarklist[v:count-1])
else
echomsg "Sorry, bookmark#".v:count." doesn't exist!"
endif
elseif a:chg == 2
" redraw!
let didwork= 0
" list user's bookmarks
" call Decho("(user: <q>) list user's bookmarks")
if exists("g:netrw_bookmarklist")
" call Decho('list '.len(g:netrw_bookmarklist).' bookmarks')
let cnt= 1
for bmd in g:netrw_bookmarklist
" call Decho("Netrw Bookmark#".cnt.": ".g:netrw_bookmarklist[cnt-1])
echo "Netrw Bookmark#".cnt.": ".g:netrw_bookmarklist[cnt-1]
let didwork = 1
let cnt = cnt + 1
endfor
endif
" list directory history
let cnt = g:netrw_dirhist_cnt
let first = 1
let histcnt = 0
if g:netrw_dirhistmax > 0
while ( first || cnt != g:netrw_dirhist_cnt )
" call Decho("first=".first." cnt=".cnt." dirhist_cnt=".g:netrw_dirhist_cnt)
let histcnt= histcnt + 1
if exists("g:netrw_dirhist_{cnt}")
" call Decho("Netrw History#".histcnt.": ".g:netrw_dirhist_{cnt})
echo "Netrw History#".histcnt.": ".g:netrw_dirhist_{cnt}
let didwork= 1
endif
let first = 0
let cnt = ( cnt - 1 ) % g:netrw_dirhistmax
if cnt < 0
let cnt= cnt + g:netrw_dirhistmax
endif
endwhile
else
let g:netrw_dirhist_cnt= 0
endif
if didwork
call inputsave()|call input("Press <cr> to continue")|call inputrestore()
endif
elseif a:chg == 3
" saves most recently visited directories (when they differ)
" call Decho("(browsing) record curdir history")
if !exists("g:netrw_dirhist_cnt") || !exists("g:netrw_dirhist_{g:netrw_dirhist_cnt}") || g:netrw_dirhist_{g:netrw_dirhist_cnt} != a:curdir
if g:netrw_dirhistmax > 0
let g:netrw_dirhist_cnt = ( g:netrw_dirhist_cnt + 1 ) % g:netrw_dirhistmax
let g:netrw_dirhist_{g:netrw_dirhist_cnt} = a:curdir
endif
" call Decho("save dirhist#".g:netrw_dirhist_cnt."<".g:netrw_dirhist_{g:netrw_dirhist_cnt}.">")
endif
elseif a:chg == 4
" u: change to the previous directory stored on the history list
" call Decho("(user: <u>) chg to prev dir from history")
if g:netrw_dirhistmax > 0
let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt - 1 ) % g:netrw_dirhistmax
if g:netrw_dirhist_cnt < 0
let g:netrw_dirhist_cnt= g:netrw_dirhist_cnt + g:netrw_dirhistmax
endif
else
let g:netrw_dirhist_cnt= 0
endif
if exists("g:netrw_dirhist_{g:netrw_dirhist_cnt}")
" call Decho("changedir u#".g:netrw_dirhist_cnt."<".g:netrw_dirhist_{g:netrw_dirhist_cnt}.">")
if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir")
setl ma noro
" call Decho("(NetrwBookHistHandler) setl ma noro")
sil! keepj %d
setl nomod
" call Decho("(NetrwBookHistHandler) setl nomod")
" call Decho("(NetrwBookHistHandler) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")
endif
" " call Decho("exe e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt}))
exe "keepj e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt})
else
if g:netrw_dirhistmax > 0
let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt + 1 ) % g:netrw_dirhistmax
else
let g:netrw_dirhist_cnt= 0
endif
echo "Sorry, no predecessor directory exists yet"
endif
elseif a:chg == 5
" U: change to the subsequent directory stored on the history list
" call Decho("(user: <U>) chg to next dir from history")
if g:netrw_dirhistmax > 0
let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt + 1 ) % g:netrw_dirhistmax
if exists("g:netrw_dirhist_{g:netrw_dirhist_cnt}")
" call Decho("changedir U#".g:netrw_dirhist_cnt."<".g:netrw_dirhist_{g:netrw_dirhist_cnt}.">")
if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir")
" call Decho("(NetrwBookHistHandler) setl ma noro")
setl ma noro
sil! keepj %d
" call Decho("removed all lines from buffer (%d)")
" call Decho("(NetrwBookHistHandler) setl nomod")
setl nomod
" call Decho("(set nomod) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")
endif
" call Decho("exe e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt}))
exe "keepj e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt})
else
let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt - 1 ) % g:netrw_dirhistmax
if g:netrw_dirhist_cnt < 0
let g:netrw_dirhist_cnt= g:netrw_dirhist_cnt + g:netrw_dirhistmax
endif
echo "Sorry, no successor directory exists yet"
endif
else
let g:netrw_dirhist_cnt= 0
echo "Sorry, no successor directory exists yet (g:netrw_dirhistmax is ".g:netrw_dirhistmax.")"
endif
elseif a:chg == 6
" delete the v:count'th bookmark
" call Decho("delete bookmark#".v:count."<".g:netrw_bookmarklist[v:count-1].">")
let savefile= s:NetrwHome()."/.netrwbook"
if filereadable(savefile)
keepj call s:NetrwBookHistSave() " done here to merge bookmarks first
keepj call delete(savefile)
endif
keepj call remove(g:netrw_bookmarklist,v:count-1)
endif
call s:NetrwBookmarkMenu()
" call Dret("s:NetrwBookHistHandler")
endfun
" ---------------------------------------------------------------------
" s:NetrwBookHistRead: this function reads bookmarks and history {{{2
" Sister function: s:NetrwBookHistSave()
fun! s:NetrwBookHistRead()
" call Dfunc("s:NetrwBookHistRead()")
if !exists("s:netrw_initbookhist")
let home = s:NetrwHome()
let savefile= home."/.netrwbook"
if filereadable(savefile)
" call Decho("sourcing .netrwbook")
exe "keepj so ".savefile
endif
if g:netrw_dirhistmax > 0
let savefile= home."/.netrwhist"
if filereadable(savefile)
" call Decho("sourcing .netrwhist")
exe "keepj so ".savefile
endif
let s:netrw_initbookhist= 1
au VimLeave * call s:NetrwBookHistSave()
endif
endif
" call Dret("s:NetrwBookHistRead")
endfun
" ---------------------------------------------------------------------
" s:NetrwBookHistSave: this function saves bookmarks and history {{{2
" Sister function: s:NetrwBookHistRead()
" I used to do this via viminfo but that appears to
" be unreliable for long-term storage
fun! s:NetrwBookHistSave()
" call Dfunc("s:NetrwBookHistSave() dirhistmax=".g:netrw_dirhistmax)
if g:netrw_dirhistmax <= 0
" call Dret("s:NetrwBookHistSave : dirhistmax=".g:netrw_dirhistmax)
return
endif
let savefile= s:NetrwHome()."/.netrwhist"
1split
call s:NetrwEnew()
setlocal cino= com= cpo-=a cpo-=A fo=nroql2 tw=0 report=10000 noswf
setlocal nocin noai noci magic nospell nohid wig= noaw
setlocal ma noro write
if exists("&acd") | setlocal noacd | endif
sil! keepj keepalt %d
" save .netrwhist -- no attempt to merge
sil! file .netrwhist
call setline(1,"let g:netrw_dirhistmax =".g:netrw_dirhistmax)
call setline(2,"let g:netrw_dirhist_cnt =".g:netrw_dirhist_cnt)
let lastline = line("$")
let cnt = 1
while cnt <= g:netrw_dirhist_cnt
call setline((cnt+lastline),'let g:netrw_dirhist_'.cnt."='".g:netrw_dirhist_{cnt}."'")
let cnt= cnt + 1
endwhile
exe "sil! w! ".savefile
sil keepj %d
if exists("g:netrw_bookmarklist") && g:netrw_bookmarklist != []
" merge and write .netrwbook
let savefile= s:NetrwHome()."/.netrwbook"
if filereadable(savefile)
let booklist= deepcopy(g:netrw_bookmarklist)
exe "sil keepj so ".savefile
for bdm in booklist
if index(g:netrw_bookmarklist,bdm) == -1
call add(g:netrw_bookmarklist,bdm)
endif
endfor
call sort(g:netrw_bookmarklist)
exe "sil! w! ".savefile
endif
" construct and save .netrwbook
call setline(1,"let g:netrw_bookmarklist= ".string(g:netrw_bookmarklist))
exe "sil! w! ".savefile
endif
let bgone= bufnr("%")
q!
exe bgone."bwipe!"
" call Dret("s:NetrwBookHistSave")
endfun
" ---------------------------------------------------------------------
" s:NetrwBrowse: This function uses the command in g:netrw_list_cmd to provide a {{{2
" list of the contents of a local or remote directory. It is assumed that the
" g:netrw_list_cmd has a string, USEPORT HOSTNAME, that needs to be substituted
" with the requested remote hostname first.
fun! s:NetrwBrowse(islocal,dirname)
if !exists("w:netrw_liststyle")|let w:netrw_liststyle= g:netrw_liststyle|endif
" call Dfunc("s:NetrwBrowse(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".w:netrw_liststyle." ".g:loaded_netrw." buf#".bufnr("%")."<".bufname("%")."> win#".winnr())
" call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")." modified=".&modified." modifiable=".&modifiable." readonly=".&readonly)
" call Dredir("ls!")
if !exists("s:netrw_initbookhist")
keepj call s:NetrwBookHistRead()
endif
" simplify the dirname (especially for ".."s in dirnames)
if a:dirname !~ '^\a\+://'
let dirname= simplify(a:dirname)
else
let dirname= a:dirname
endif
if exists("s:netrw_skipbrowse")
unlet s:netrw_skipbrowse
" call Decho("(NetrwBrowse) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")
" call Dret("s:NetrwBrowse : s:netrw_skipbrowse=".s:netrw_skipbrowse)
return
endif
if !exists("*shellescape")
keepj call netrw#ErrorMsg(s:ERROR,"netrw can't run -- your vim is missing shellescape()",69)
" call Dret("s:NetrwBrowse : missing shellescape()")
return
endif
if !exists("*fnameescape")
keepj call netrw#ErrorMsg(s:ERROR,"netrw can't run -- your vim is missing fnameescape()",70)
" call Dret("s:NetrwBrowse : missing fnameescape()")
return
endif
call s:NetrwOptionSave("w:")
" re-instate any marked files
if exists("s:netrwmarkfilelist_{bufnr('%')}")
" call Decho("clearing marked files")
exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/"
endif
if a:islocal && exists("w:netrw_acdkeep") && w:netrw_acdkeep
" call Decho("handle w:netrw_acdkeep:")
" call Decho("keepjumps lcd ".fnameescape(dirname)." (due to w:netrw_acdkeep=".w:netrw_acdkeep." - acd=".&acd.")")
exe 'keepj lcd '.fnameescape(dirname)
call s:NetrwSafeOptions()
" call Decho("getcwd<".getcwd().">")
elseif !a:islocal && dirname !~ '[\/]$' && dirname !~ '^"'
" looks like a regular file, attempt transfer
" call Decho("attempt transfer as regular file<".dirname.">")
" remove any filetype indicator from end of dirname, except for the {{{3
" "this is a directory" indicator (/).
" There shouldn't be one of those here, anyway.
let path= substitute(dirname,'[*=@|]\r\=$','','e')
" call Decho("new path<".path.">")
call s:RemotePathAnalysis(dirname)
" remote-read the requested file into current buffer {{{3
keepj mark '
call s:NetrwEnew(dirname)
call s:NetrwSafeOptions()
setlocal ma noro
" call Decho("setlocal ma noro")
let b:netrw_curdir = dirname
let url = s:method."://".s:user.s:machine.(s:port ? ":".s:port : "")."/".s:path
" call Decho("exe sil! keepalt file ".fnameescape(url)." (bt=".&bt.")")
exe "sil! keepj keepalt file ".fnameescape(url)
exe "sil! keepj keepalt doau BufReadPre ".fnameescape(s:fname)
sil call netrw#NetRead(2,url)
if s:path !~ '.tar.bz2$' && s:path !~ '.tar.gz' && s:path !~ '.tar.xz' && s:path !~ '.txz'
" netrw.vim and tar.vim have already handled decompression of the tarball; avoiding gzip.vim error
exe "sil keepj keepalt doau BufReadPost ".fnameescape(s:fname)
endif
" save certain window-oriented variables into buffer-oriented variables {{{3
call s:SetBufWinVars()
call s:NetrwOptionRestore("w:")
" call Decho("setl ma nomod")
setl ma nomod
" call Decho("(NetrwBrowse) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")
" call Dret("s:NetrwBrowse : file<".s:fname.">")
return
endif
" use buffer-oriented WinVars if buffer variables exist but associated window variables don't {{{3
call s:UseBufWinVars()
" set up some variables {{{3
let b:netrw_browser_active = 1
let dirname = dirname
let s:last_sort_by = g:netrw_sort_by
" set up menu {{{3
keepj call s:NetrwMenu(1)
" set up buffer {{{3
let reusing= s:NetrwGetBuffer(a:islocal,dirname)
" maintain markfile highlighting
if exists("s:netrwmarkfilemtch_{bufnr('%')}") && s:netrwmarkfilemtch_{bufnr("%")} != ""
" call Decho("bufnr(%)=".bufnr('%'))
" call Decho("exe 2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/")
exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/"
else
" call Decho("2match none")
2match none
endif
if reusing
call s:NetrwOptionRestore("w:")
" call Decho("(NetrwBrowse) setl noma nomod nowrap")
setl noma nomod nowrap
" call Decho("(set noma nomod nowrap) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")
" call Dret("s:NetrwBrowse : re-using buffer")
return
endif
" set b:netrw_curdir to the new directory name {{{3
" call Decho("set b:netrw_curdir to the new directory name: (buf#".bufnr("%").")")
let b:netrw_curdir= dirname
if b:netrw_curdir =~ '[/\\]$'
let b:netrw_curdir= substitute(b:netrw_curdir,'[/\\]$','','e')
endif
if b:netrw_curdir == ''
if has("amiga")
" On the Amiga, the empty string connotes the current directory
let b:netrw_curdir= getcwd()
else
" under unix, when the root directory is encountered, the result
" from the preceding substitute is an empty string.
let b:netrw_curdir= '/'
endif
endif
if !a:islocal && b:netrw_curdir !~ '/$'
let b:netrw_curdir= b:netrw_curdir.'/'
endif
" call Decho("b:netrw_curdir<".b:netrw_curdir.">")
" ------------
" (local only) {{{3
" ------------
if a:islocal
" call Decho("local only:")
" Set up ShellCmdPost handling. Append current buffer to browselist
call s:LocalFastBrowser()
" handle g:netrw_keepdir: set vim's current directory to netrw's notion of the current directory {{{3
if !g:netrw_keepdir
" call Decho("handle g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd)
" call Decho("l:acd".(exists("&l:acd")? "=".&l:acd : " doesn't exist"))
if !exists("&l:acd") || !&l:acd
" call Decho('exe keepjumps lcd '.fnameescape(b:netrw_curdir))
try
exe 'keepj lcd '.fnameescape(b:netrw_curdir)
catch /^Vim\%((\a\+)\)\=:E472/
call netrw#ErrorMsg(s:ERROR,"unable to change directory to <".b:netrw_curdir."> (permissions?)",61)
if exists("w:netrw_prvdir")
let b:netrw_curdir= w:netrw_prvdir
else
call s:NetrwOptionRestore("w:")
" call Decho("(NetrwBrowse) setl noma nomod nowrap")
setl noma nomod nowrap
" call Decho("(NetrwBrowse) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")
let b:netrw_curdir= dirname
" call Dret("s:NetrwBrowse : reusing buffer#".(exists("bufnum")? bufnum : 'N/A')."<".dirname."> getcwd<".getcwd().">")
return
endif
endtry
endif
endif
" --------------------------------
" remote handling: {{{3
" --------------------------------
else
" call Decho("remote only:")
" analyze dirname and g:netrw_list_cmd {{{4
" call Decho("b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "doesn't exist")."> dirname<".dirname.">")
if dirname =~ "^NetrwTreeListing\>"
let dirname= b:netrw_curdir
" call Decho("(dirname was ".dirname.") dirname<".dirname.">")
elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir")
let dirname= substitute(b:netrw_curdir,'\\','/','g')
if dirname !~ '/$'
let dirname= dirname.'/'
endif
let b:netrw_curdir = dirname
" call Decho("(liststyle is TREELIST) dirname<".dirname.">")
else
let dirname = substitute(dirname,'\\','/','g')
" call Decho("(normal) dirname<".dirname.">")
endif
let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/]\+\)/\(.*\)$'
if dirname !~ dirpat
if !exists("g:netrw_quiet")
keepj call netrw#ErrorMsg(s:ERROR,"netrw doesn't understand your dirname<".dirname.">",20)
endif
keepj call s:NetrwOptionRestore("w:")
" call Decho("(NetrwBrowse) setl noma nomod nowrap")
setl noma nomod nowrap
" call Decho("(NetrwBrowse) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")
" call Dret("s:NetrwBrowse : badly formatted dirname<".dirname.">")
return
endif
let b:netrw_curdir= dirname
" call Decho("b:netrw_curdir<".b:netrw_curdir."> (remote)")
endif " (additional remote handling)
" -----------------------
" Directory Listing: {{{3
" -----------------------
keepj call s:NetrwMaps(a:islocal)
keepj call s:PerformListing(a:islocal)
if v:version >= 700 && has("balloon_eval") && &beval == 0 && &l:bexpr == "" && !exists("g:netrw_nobeval")
let &l:bexpr= "netrw#NetrwBalloonHelp()"
" call Decho("set up balloon help: l:bexpr=".&l:bexpr)
set beval
endif
call s:NetrwOptionRestore("w:")
" The s:LocalBrowseShellCmdRefresh() function is called by an autocmd
" installed by s:LocalFastBrowser() when g:netrw_fastbrowse <= 1 (ie. slow, medium speed).
" However, s:NetrwBrowse() causes the ShellCmdPost event itself to fire once; setting
" the variable below avoids that second refresh of the screen. The s:LocalBrowseShellCmdRefresh()
" function gets called due to that autocmd; it notices that the following variable is set
" and skips the refresh and sets s:locbrowseshellcmd to zero. Oct 13, 2008
let s:locbrowseshellcmd= 1
" call Decho("(NetrwBrowse) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")
" call Dret("s:NetrwBrowse : did PerformListing ft<".&ft.">")
return
endfun
" ---------------------------------------------------------------------
" s:NetrwFileInfo: supports qf (query for file information) {{{2
fun! s:NetrwFileInfo(islocal,fname)
" call Dfunc("s:NetrwFileInfo(islocal=".a:islocal." fname<".a:fname.">)")
if a:islocal
if (has("unix") || has("macunix")) && executable("/bin/ls")
if exists("b:netrw_curdir")
" call Decho('using ls with b:netrw_curdir<'.b:netrw_curdir.'>')
if b:netrw_curdir =~ '/$'
echo system("/bin/ls -lsad ".shellescape(b:netrw_curdir.a:fname))
else
echo system("/bin/ls -lsad ".shellescape(b:netrw_curdir."/".a:fname))
endif
else
" call Decho('using ls '.a:fname." using cwd<".getcwd().">")
echo system("/bin/ls -lsad ".shellescape(a:fname))
endif
else
" use vim functions to return information about file below cursor
" call Decho("using vim functions to query for file info")
if !isdirectory(a:fname) && !filereadable(a:fname) && a:fname =~ '[*@/]'
let fname= substitute(a:fname,".$","","")
else
let fname= a:fname
endif
let t = getftime(fname)
let sz = getfsize(fname)
echo a:fname.": ".sz." ".strftime(g:netrw_timefmt,getftime(fname))
" call Decho(fname.": ".sz." ".strftime(g:netrw_timefmt,getftime(fname)))
endif
else
echo "sorry, \"qf\" not supported yet for remote files"
endif
" call Dret("s:NetrwFileInfo")
endfun
" ---------------------------------------------------------------------
" s:NetrwGetBuffer: {{{2
" returns 0=cleared buffer
" 1=re-used buffer
fun! s:NetrwGetBuffer(islocal,dirname)
" call Dfunc("s:NetrwGetBuffer(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".g:netrw_liststyle)
let dirname= a:dirname
" re-use buffer if possible {{{3
" call Decho("--re-use a buffer if possible--")
if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST
" find NetrwTreeList buffer if there is one
" call Decho("find NetrwTreeList buffer if there is one")
if exists("w:netrw_treebufnr") && w:netrw_treebufnr > 0
" call Decho(" re-use w:netrw_treebufnr=".w:netrw_treebufnr)
let eikeep= &ei
set ei=all
exe "sil! b ".w:netrw_treebufnr
let &ei= eikeep
" call Dret("s:NetrwGetBuffer : bufnum#".w:netrw_treebufnr."<NetrwTreeListing>")
return
endif
let bufnum= -1
" call Decho(" liststyle=TREE but w:netrw_treebufnr doesn't exist")
else
" find buffer number of buffer named precisely the same as dirname {{{3
" call Decho("--find buffer numnber of buffer named precisely the same as dirname--")
" call Dredir("ls!")
" get dirname and associated buffer number
let bufnum = bufnr(escape(dirname,'\'))
" call Decho(" find buffer<".dirname.">'s number ")
" call Decho(" bufnr(dirname<".escape(dirname,'\').">)=".bufnum)
if bufnum < 0 && dirname !~ '/$'
" try appending a trailing /
" call Decho(" try appending a trailing / to dirname<".dirname.">")
let bufnum= bufnr(escape(dirname.'/','\'))
if bufnum > 0
let dirname= dirname.'/'
endif
endif
if bufnum < 0 && dirname =~ '/$'
" try removing a trailing /
" call Decho(" try removing a trailing / from dirname<".dirname.">")
let bufnum= bufnr(escape(substitute(dirname,'/$','',''),'\'))
if bufnum > 0
let dirname= substitute(dirname,'/$','','')
endif
endif
" call Decho(" findbuf1: bufnum=bufnr('".dirname."')=".bufnum." bufname(".bufnum.")<".bufname(bufnum)."> (initial)")
" note: !~ was used just below, but that means using ../ to go back would match (ie. abc/def/ and abc/ matches)
if bufnum > 0 && bufname(bufnum) != dirname && bufname(bufnum) != '.'
" handle approximate matches
" call Decho(" handling approx match: bufnum#".bufnum."<".bufname(bufnum)."> approx-dirname<".dirname.">")
let ibuf = 1
let buflast = bufnr("$")
" call Decho(" findbuf2: buflast=bufnr($)=".buflast)
while ibuf <= buflast
let bname= substitute(bufname(ibuf),'\\','/','g')
let bname= substitute(bname,'.\zs/$','','')
" call Decho(" findbuf3: while [ibuf=",ibuf."]<=[buflast=".buflast."]: dirname<".dirname."> bname=bufname(".ibuf.")<".bname.">")
if bname != '' && dirname =~ '/'.bname.'/\=$' && dirname !~ '^/'
" bname is not empty
" dirname ends with bname,
" dirname doesn't start with /, so its not a absolute path
" call Decho(" findbuf3a: passes test 1 : dirname<".dirname.'> =~ /'.bname.'/\=$ && dirname !~ ^/')
break
endif
if bname =~ '^'.dirname.'/\=$'
" bname begins with dirname
" call Decho(' findbuf3b: passes test 2 : bname<'.bname.'>=~^'.dirname.'/\=$')
break
endif
if dirname =~ '^'.bname.'/$'
" call Decho(' findbuf3c: passes test 3 : dirname<'.dirname.'>=~^'.bname.'/$')
break
endif
if bname != '' && dirname =~ '/'.bname.'$' && bname == bufname("%") && line("$") == 1
" call Decho(' findbuf3d: passes test 4 : dirname<'.dirname.'>=~ /'.bname.'$')
break
endif
let ibuf= ibuf + 1
endwhile
if ibuf > buflast
let bufnum= -1
else
let bufnum= ibuf
endif
" call Decho(" findbuf4: bufnum=".bufnum." (ibuf=".ibuf." buflast=".buflast.")")
endif
endif
" get enew buffer and name it -or- re-use buffer {{{3
sil! keepj mark '
if bufnum < 0 || !bufexists(bufnum)
" call Decho("--get enew buffer and name it (bufexists([bufnum=".bufnum."])=".bufexists(bufnum).")")
call s:NetrwEnew(dirname)
" call Decho(" got enew buffer#".bufnr("%")." (altbuf<".expand("#").">)")
" name the buffer
if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST
" Got enew buffer; transform into a NetrwTreeListing
" call Decho("--transform enew buffer#".bufnr("%")." into a NetrwTreeListing --")
if !exists("s:netrw_treelistnum")
let s:netrw_treelistnum= 1
else
let s:netrw_treelistnum= s:netrw_treelistnum + 1
endif
let w:netrw_treebufnr= bufnr("%")
" call Decho(" exe sil! keepalt file NetrwTreeListing ".fnameescape(s:netrw_treelistnum))
exe 'sil! keepalt file NetrwTreeListing\ '.fnameescape(s:netrw_treelistnum)
set bt=nofile noswf
nnoremap <silent> <buffer> [ :sil call <SID>TreeListMove('[')<cr>
nnoremap <silent> <buffer> ] :sil call <SID>TreeListMove(']')<cr>
nnoremap <silent> <buffer> [[ :sil call <SID>TreeListMove('[')<cr>
nnoremap <silent> <buffer> ]] :sil call <SID>TreeListMove(']')<cr>
" call Decho(" tree listing#".s:netrw_treelistnum." bufnr=".w:netrw_treebufnr)
else
" let v:errmsg= "" " Decho
let escdirname= fnameescape(dirname)
" call Decho(" errmsg<".v:errmsg."> bufnr(escdirname<".escdirname.">)=".bufnr(escdirname)." bufname()<".bufname(bufnr(escdirname)).">")
" call Decho(' exe sil! keepalt file '.escdirname)
" let v:errmsg= "" " Decho
exe 'sil! keepalt file '.escdirname
" call Decho(" errmsg<".v:errmsg."> bufnr(".escdirname.")=".bufnr(escdirname)."<".bufname(bufnr(escdirname)).">")
endif
" call Decho(" named enew buffer#".bufnr("%")."<".bufname("%").">")
else " Re-use the buffer
" call Decho("--re-use buffer#".bufnum." (bufexists([bufnum=".bufnum."])=".bufexists(bufnum).")")
let eikeep= &ei
set ei=all
if getline(2) =~ '^" Netrw Directory Listing'
" call Decho(" re-use buffer#".bufnum."<".((bufnum > 0)? bufname(bufnum) : "")."> using: keepalt b ".bufnum)
exe "sil! keepalt b ".bufnum
else
" call Decho(" reusing buffer#".bufnum."<".((bufnum > 0)? bufname(bufnum) : "")."> using: b ".bufnum)
exe "sil! b ".bufnum
endif
if bufname("%") == '.'
" call Decho("exe sil! keepalt file ".fnameescape(getcwd()))
exe "sil! keepalt file ".fnameescape(getcwd())
endif
let &ei= eikeep
if line("$") <= 1
keepj call s:NetrwListSettings(a:islocal)
" call Dret("s:NetrwGetBuffer 0 : re-using buffer#".bufnr("%").", but its empty, so refresh it")
return 0
elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST
" call Decho("--re-use tree listing--")
" call Decho(" clear buffer<".expand("%")."> with :%d")
sil keepj %d
keepj call s:NetrwListSettings(a:islocal)
" call Dret("s:NetrwGetBuffer 0 : re-using buffer#".bufnr("%").", but treelist mode always needs a refresh")
return 0
else
" call Dret("s:NetrwGetBuffer 1 : buf#".bufnr("%"))
return 1
endif
endif
" do netrw settings: make this buffer not-a-file, modifiable, not line-numbered, etc {{{3
" fastbrowse Local Remote Hiding a buffer implies it may be re-used (fast)
" slow 0 D D Deleting a buffer implies it will not be re-used (slow)
" med 1 D H
" fast 2 H H
" call Decho("--do netrw settings: make this buffer#".bufnr("%")." not-a-file, modifiable, not line-numbered, etc--")
let fname= expand("%")
keepj call s:NetrwListSettings(a:islocal)
" call Decho("exe sil! keepalt file ".fnameescape(fname))
exe "sil! keepj keepalt file ".fnameescape(fname)
" delete all lines from buffer {{{3
" call Decho("--delete all lines from buffer--")
" call Decho(" clear buffer<".expand("%")."> with :%d")
sil! keepalt keepj %d
" call Dret("s:NetrwGetBuffer 0 : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> modified=".&modified." modifiable=".&modifiable." readonly=".&readonly)
return 0
endfun
" ---------------------------------------------------------------------
" s:NetrwGetcwd: get the current directory. {{{2
" Change backslashes to forward slashes, if any.
" If doesc is true, escape certain troublesome characters
fun! s:NetrwGetcwd(doesc)
" call Dfunc("NetrwGetcwd(doesc=".a:doesc.")")
let curdir= substitute(getcwd(),'\\','/','ge')
if curdir !~ '[\/]$'
let curdir= curdir.'/'
endif
if a:doesc
let curdir= fnameescape(curdir)
endif
" call Dret("NetrwGetcwd <".curdir.">")
return curdir