FILE: C:\Program Files\Git\usr\share\vim\vim91\autoload\netrw.vim
--
" netrw.vim: Handles file transfer and remote directory listing across
" AUTOLOAD SECTION
" Maintainer: This runtime file is looking for a new maintainer.
" Date: May 03, 2023
" Version: 173a
" Last Change: {{{1
" 2023 Nov 21 by Vim Project: ignore wildignore when expanding $COMSPEC (v173a)
" 2023 Nov 22 by Vim Project: fix handling of very long filename on longlist style (v173a)
" 2024 Feb 19 by Vim Project: (announce adoption)
" 2024 Feb 29 by Vim Project: handle symlinks in tree mode correctly
" 2024 Apr 03 by Vim Project: detect filetypes for remote edited files
" 2024 May 08 by Vim Project: cleanup legacy Win9X checks
" 2024 May 09 by Vim Project: remove hard-coded private.ppk
" 2024 May 10 by Vim Project: recursively delete directories by default
" 2024 May 13 by Vim Project: prefer scp over pscp
" 2024 Jun 04 by Vim Project: set bufhidden if buffer changed, nohidden is set and buffer shall be switched (#14915)
" 2024 Jun 13 by Vim Project: glob() on Windows fails when a directory name contains [] (#14952)
" 2024 Jun 23 by Vim Project: save ad restore registers when liststyle = WIDELIST (#15077, #15114)
" 2024 Jul 22 by Vim Project: avoid endless recursion (#15318)
" 2024 Jul 23 by Vim Project: escape filename before trying to delete it (#15330)
" 2024 Jul 30 by Vim Project: handle mark-copy to same target directory (#12112)
" 2024 Aug 02 by Vim Project: honor g:netrw_alt{o,v} for :{S,H,V}explore (#15417)
" 2024 Aug 15 by Vim Project: style changes, prevent E121 (#15501)
" 2024 Aug 22 by Vim Project: fix mf-selection highlight (#15551)
" 2024 Aug 22 by Vim Project: adjust echo output of mx command (#15550)
" 2024 Sep 15 by Vim Project: more strict confirmation dialog (#15680)
" 2024 Sep 19 by Vim Project: mf-selection highlight uses wrong pattern (#15700)
" 2024 Sep 21 by Vim Project: remove extraneous closing bracket (#15718)
" }}}
" Former Maintainer: Charles E Campbell
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
" Copyright: Copyright (C) 2016 Charles E. Campbell {{{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.
"
" Note: the code here was started in 1999 under a much earlier version of vim. The directory browsing
" code was written using vim v6, which did not have Lists (Lists were first offered with vim-v7).
"
"redraw!|call DechoSep()|call inputsave()|call input("Press 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
" Check that vim has patches that netrw requires.
" Patches needed for v7.4: 1557, and 213.
" (netrw will benefit from vim's having patch#656, too)
let s:needspatches=[1557,213]
if exists("s:needspatches")
for ptch in s:needspatches
if v:version < 704 || (v:version == 704 && !has("patch".ptch))
if !exists("s:needpatch{ptch}")
unsilent echomsg "***sorry*** this version of netrw requires vim v7.4 with patch#".ptch
endif
let s:needpatch{ptch}= 1
finish
endif
endfor
endif
let g:loaded_netrw = "v173"
let s:keepcpo= &cpo
setl cpo&vim
"DechoFuncName 1
"DechoRemOn
"call Decho("doing autoload/netrw.vim version ".g:loaded_netrw,'~'.expand(""))
" ======================
" Netrw Variables: {{{1
" ======================
" ---------------------------------------------------------------------
" netrw#ErrorMsg: {{{2
" 0=note = s:NOTE
" 1=warning = s:WARNING
" 2=error = s:ERROR
" Usage: netrw#ErrorMsg(s:NOTE | s:WARNING | s:ERROR,"some message",error-number)
" netrw#ErrorMsg(s:NOTE | s:WARNING | s:ERROR,["message1","message2",...],error-number)
" (this function can optionally take a list of messages)
" Dec 2, 2019 : max errnum currently is 106
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,'~'.expand(""))
if g:netrw_use_errorwindow == 2 && exists("*popup_atcursor")
" use popup window
if type(a:msg) == 3
let msg = [level]+a:msg
else
let msg= level.a:msg
endif
let s:popuperr_id = popup_atcursor(msg,{})
let s:popuperr_text= ""
elseif g:netrw_use_errorwindow
" (default) netrw creates a one-line window to show error/warning
" messages (reliably displayed)
" record current window number
let s:winBeforeErr= winnr()
" call Decho("s:winBeforeErr=".s:winBeforeErr,'~'.expand(""))
" 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",'~'.expand(""))
exe bufwinnr("NetrwMessage")."wincmd w"
" call Decho("setl ma noro",'~'.expand(""))
setl ma noro
if type(a:msg) == 3
for msg in a:msg
NetrwKeepj call setline(line("$")+1,level.msg)
endfor
else
NetrwKeepj call setline(line("$")+1,level.a:msg)
endif
NetrwKeepj $
else
" call Decho("create a NetrwMessage buffer window",'~'.expand(""))
bo 1split
sil! call s:NetrwEnew()
sil! NetrwKeepj call s:NetrwOptionsSafe(1)
setl bt=nofile
NetrwKeepj file NetrwMessage
" call Decho("setl ma noro",'~'.expand(""))
setl ma noro
if type(a:msg) == 3
for msg in a:msg
NetrwKeepj call setline(line("$")+1,level.msg)
endfor
else
NetrwKeepj call setline(line("$"),level.a:msg)
endif
NetrwKeepj $
endif
" call Decho("wrote msg<".level.a:msg."> to NetrwMessage win#".winnr(),'~'.expand(""))
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("setl noma ro bh=wipe",'~'.expand(""))
setl ro nomod noma 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
if type(a:msg) == 3
for msg in a:msg
unsilent echomsg level.msg
endfor
else
unsilent echomsg level.a:msg
endif
" call Decho("echomsg ***netrw*** ".a:msg,'~'.expand(""))
echohl None
endif
" call Dret("netrw#ErrorMsg")
endfun
" ---------------------------------------------------------------------
" s:NetrwInit: initializes variables if they haven't been defined {{{2
" Loosely, varname = value.
fun s:NetrwInit(varname,value)
" call Decho("varname<".a:varname."> value=".a:value,'~'.expand(""))
if !exists(a:varname)
if type(a:value) == 0
exe "let ".a:varname."=".a:value
elseif type(a:value) == 1 && a:value =~ '^[{[]'
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_dirhistcnt",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
let s:NOTE = 0
let s:WARNING = 1
let s:ERROR = 2
call s:NetrwInit("g:netrw_errorlvl", s:NOTE)
" ---------------------------------------------------------------------
" Default option values: {{{2
let g:netrw_localcopycmdopt = ""
let g:netrw_localcopydircmdopt = ""
let g:netrw_localmkdiropt = ""
let g:netrw_localmovecmdopt = ""
" ---------------------------------------------------------------------
" Default values for netrw's global protocol variables {{{2
if exists("*popup_atcursor")
\ && has("syntax")
\ && exists("g:syntax_on")
\ && has("mouse")
call s:NetrwInit("g:netrw_use_errorwindow",2)
else
call s:NetrwInit("g:netrw_use_errorwindow",1)
endif
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_file_cmd")
if executable("elinks")
call s:NetrwInit("g:netrw_file_cmd","elinks")
elseif executable("links")
call s:NetrwInit("g:netrw_file_cmd","links")
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("wget")
let g:netrw_http_cmd = "wget"
call s:NetrwInit("g:netrw_http_xcmd","-q -O")
elseif executable("curl")
let g:netrw_http_cmd = "curl"
call s:NetrwInit("g:netrw_http_xcmd","-L -o")
elseif executable("elinks")
let g:netrw_http_cmd = "elinks"
call s:NetrwInit("g:netrw_http_xcmd","-source >")
elseif executable("fetch")
let g:netrw_http_cmd = "fetch"
call s:NetrwInit("g:netrw_http_xcmd","-o")
elseif executable("links")
let g:netrw_http_cmd = "links"
call s:NetrwInit("g:netrw_http_xcmd","-http.extra-header ".shellescape("Accept-Encoding: identity", 1)." -source >")
else
let g:netrw_http_cmd = ""
endif
endif
call s:NetrwInit("g:netrw_http_put_cmd","curl -T")
call s:NetrwInit("g:netrw_keepj","keepj")
call s:NetrwInit("g:netrw_rcp_cmd" , "rcp")
call s:NetrwInit("g:netrw_rsync_cmd", "rsync")
call s:NetrwInit("g:netrw_rsync_sep", "/")
if !exists("g:netrw_scp_cmd")
if executable("scp")
call s:NetrwInit("g:netrw_scp_cmd" , "scp -q")
elseif executable("pscp")
call s:NetrwInit("g:netrw_scp_cmd", 'pscp -q')
else
call s:NetrwInit("g:netrw_scp_cmd" , "scp -q")
endif
endif
call s:NetrwInit("g:netrw_sftp_cmd" , "sftp")
call s:NetrwInit("g:netrw_ssh_cmd" , "ssh")
if has("win32")
\ && 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("win32unix") && &shell =~ '\%(\\|\\)\%(\.exe\)\=$'
let g:netrw_cygwin= 1
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 nornu")
call s:NetrwInit("g:netrw_chgwin" , -1)
call s:NetrwInit("g:netrw_clipboard" , 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
"call Decho("(netrw) COMBAK: cuc=".&l:cuc." cul=".&l:cul." initialization of s:netrw_cu[cl]")
call s:NetrwInit("g:netrw_cygdrive","/cygdrive")
" Default values - d-g ---------- {{{3
call s:NetrwInit("s:didstarstar",0)
call s:NetrwInit("g:netrw_dirhistcnt" , 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_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")
if exists("g:netrw_list_cmd_options")
let g:netrw_list_cmd= g:netrw_scp_cmd." -ls USEPORT HOSTNAME: ".g:netrw_list_cmd_options
else
let g:netrw_list_cmd= g:netrw_scp_cmd." -ls USEPORT HOSTNAME:"
endif
elseif executable(g:netrw_ssh_cmd)
" provide a scp-based default listing command
if exists("g:netrw_list_cmd_options")
let g:netrw_list_cmd= g:netrw_ssh_cmd." USEPORT HOSTNAME ls -FLa ".g:netrw_list_cmd_options
else
let g:netrw_list_cmd= g:netrw_ssh_cmd." USEPORT HOSTNAME ls -FLa"
endif
else
" call Decho(g:netrw_ssh_cmd." is not executable",'~'.expand(""))
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_localcmdshell")
let g:netrw_localcmdshell= ""
endif
if !exists("g:netrw_localcopycmd")
if has("win32")
if g:netrw_cygwin
let g:netrw_localcopycmd= "cp"
else
let g:netrw_localcopycmd = expand("$COMSPEC", v:true)
let g:netrw_localcopycmdopt= " /c copy"
endif
elseif has("unix") || has("macunix")
let g:netrw_localcopycmd= "cp"
else
let g:netrw_localcopycmd= ""
endif
endif
if !exists("g:netrw_localcopydircmd")
if has("win32")
if g:netrw_cygwin
let g:netrw_localcopydircmd = "cp"
let g:netrw_localcopydircmdopt= " -R"
else
let g:netrw_localcopydircmd = expand("$COMSPEC", v:true)
let g:netrw_localcopydircmdopt= " /c xcopy /e /c /h /i /k"
endif
elseif has("unix")
let g:netrw_localcopydircmd = "cp"
let g:netrw_localcopydircmdopt= " -R"
elseif has("macunix")
let g:netrw_localcopydircmd = "cp"
let g:netrw_localcopydircmdopt= " -R"
else
let g:netrw_localcopydircmd= ""
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
if has("win32")
if g:netrw_cygwin
call s:NetrwInit("g:netrw_localmkdir","mkdir")
else
let g:netrw_localmkdir = expand("$COMSPEC", v:true)
let g:netrw_localmkdiropt= " /c mkdir"
endif
else
call s:NetrwInit("g:netrw_localmkdir","mkdir")
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")
if g:netrw_cygwin
let g:netrw_localmovecmd= "mv"
else
let g:netrw_localmovecmd = expand("$COMSPEC", v:true)
let g:netrw_localmovecmdopt= " /c move"
endif
elseif has("unix") || has("macunix")
let g:netrw_localmovecmd= "mv"
else
let g:netrw_localmovecmd= ""
endif
endif
" following serves as an example for how to insert a version&patch specific test
"if v:version < 704 || (v:version == 704 && !has("patch1107"))
"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")
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_servername" , "NETRWSERVER")
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 - q-s ---------- {{{3
call s:NetrwInit("g:netrw_quickhelp",0)
let s:QuickHelp= ["-:go up dir D:delete R:rename s:sort-by x:special",
\ "(create new) %:file d:directory",
\ "(windows split&open) o:horz v:vert p:preview",
\ "i:style qf:file info O:obtain r:reverse",
\ "(marks) mf:mark file mt:set target mm:move mc:copy",
\ "(bookmarks) mb:make mB:delete qb:list gb:go to",
\ "(history) qb:list u:go up U:go down",
\ "(targets) mt:target Tb:use bookmark Th:use history"]
" 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")? "\" : "\")
if !exists("g:netrw_keepj") || g:netrw_keepj == "keepj"
call s:NetrwInit("s:netrw_silentxfer" , (exists("g:netrw_silent") && g:netrw_silent != 0)? "sil keepj " : "keepj ")
else
call s:NetrwInit("s:netrw_silentxfer" , (exists("g:netrw_silent") && g:netrw_silent != 0)? "sil " : " ")
endif
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= '[\/]$,\,\.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_suppress_gx_mesg", 1)
call s:NetrwInit("g:netrw_use_noswf" , 1)
call s:NetrwInit("g:netrw_sizestyle" ,"b")
" Default values - t-w ---------- {{{3
call s:NetrwInit("g:netrw_timefmt","%c")
if !exists("g:netrw_xstrlen")
if exists("g:Align_xstrlen")
let g:netrw_xstrlen= g:Align_xstrlen
elseif exists("g:drawit_xstrlen")
let g:netrw_xstrlen= g:drawit_xstrlen
elseif &enc == "latin1" || !has("multi_byte")
let g:netrw_xstrlen= 0
else
let g:netrw_xstrlen= 1
endif
endif
call s:NetrwInit("g:NetrwTopLvlMenu","Netrw.")
call s:NetrwInit("g:netrw_winsize",50)
call s:NetrwInit("g:netrw_wiw",1)
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")
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\\\\"")
if has("gui_running") && (&enc == 'utf-8' || &enc == 'utf-16' || &enc == 'ucs-4')
let s:treedepthstring= "│ "
else
let s:treedepthstring= "| "
endif
call s:NetrwInit("s:netrw_posn",'{}')
" 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")
" call Decho("installed beval events",'~'.expand(""))
let &l:bexpr = "netrw#BalloonHelp()"
" call Decho("&l:bexpr<".&l:bexpr."> buf#".bufnr())
au FileType netrw setl beval
au WinLeave * if &ft == "netrw" && exists("s:initbeval")|let &beval= s:initbeval|endif
au VimEnter * let s:initbeval= &beval
"else " Decho
" if v:version < 700 | call Decho("did not install beval events: v:version=".v:version." < 700","~".expand("")) | endif
" if !has("balloon_eval") | call Decho("did not install beval events: does not have balloon_eval","~".expand("")) | endif
" if exists("s:initbeval") | call Decho("did not install beval events: s:initbeval exists","~".expand("")) | endif
" if exists("g:netrw_nobeval") | call Decho("did not install beval events: g:netrw_nobeval exists","~".expand("")) | endif
" if !has("syntax") | call Decho("did not install beval events: does not have syntax highlighting","~".expand("")) | endif
" if exists("g:syntax_on") | call Decho("did not install beval events: g:syntax_on exists","~".expand("")) | endif
endif
au WinEnter * if &ft == "netrw"|call s:NetrwInsureWinVars()|endif
if g:netrw_keepj =~# "keepj"
com! -nargs=* NetrwKeepj keepj
else
let g:netrw_keepj= ""
com! -nargs=* NetrwKeepj
endif
" ==============================
" Netrw Utility Functions: {{{1
" ==============================
" ---------------------------------------------------------------------
" netrw#BalloonHelp: {{{2
if v:version >= 700 && has("balloon_eval") && has("syntax") && exists("g:syntax_on") && !exists("g:netrw_nobeval")
" call Decho("loading netrw#BalloonHelp()",'~'.expand(""))
fun! netrw#BalloonHelp()
if &ft != "netrw"
return ""
endif
if exists("s:popuperr_id") && popup_getpos(s:popuperr_id) != {}
" popup error window is still showing
" s:pouperr_id and s:popuperr_text are set up in netrw#ErrorMsg()
if exists("s:popuperr_text") && s:popuperr_text != "" && v:beval_text != s:popuperr_text
" text under mouse hasn't changed; only close window when it changes
call popup_close(s:popuperr_id)
unlet s:popuperr_text
else
let s:popuperr_text= v:beval_text
endif
let mesg= ""
elseif !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 = ": 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, file size, extension 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 "
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
"else " Decho
" if v:version < 700 |call Decho("did not load netrw#BalloonHelp(): vim version ".v:version." < 700 -","~".expand(""))|endif
" if !has("balloon_eval") |call Decho("did not load netrw#BalloonHelp(): does not have balloon eval","~".expand("")) |endif
" if !has("syntax") |call Decho("did not load netrw#BalloonHelp(): syntax disabled","~".expand("")) |endif
" if !exists("g:syntax_on") |call Decho("did not load netrw#BalloonHelp(): g:syntax_on n/a","~".expand("")) |endif
" if exists("g:netrw_nobeval") |call Decho("did not load netrw#BalloonHelp(): g:netrw_nobeval exists","~".expand("")) |endif
endif
" ------------------------------------------------------------------------
" netrw#Explore: launch the local browser in the directory of the current file {{{2
" indx: == -1: Nexplore
" == -2: Pexplore
" == +: this is overloaded:
" * If Nexplore/Pexplore is in use, then this refers to the
" indx'th item in the w:netrw_explore_list[] of items which
" matched the */pattern **/pattern *//pattern **//pattern
" * If Hexplore or Vexplore, then this will override
" g:netrw_winsize to specify the qty of rows or columns the
" newly split window should have.
" dosplit==0: the window will be split iff the current file has been modified and hidden not set
" dosplit==1: the window will be split before running the local browser
" style == 0: Explore style == 1: Explore!
" == 2: Hexplore style == 3: Hexplore!
" == 4: Vexplore style == 5: Vexplore!
" == 6: Texplore
fun! netrw#Explore(indx,dosplit,style,...)
" call Dfunc("netrw#Explore(indx=".a:indx." dosplit=".a:dosplit." style=".a:style.",a:1<".a:1.">) &modified=".&modified." modifiable=".&modifiable." a:0=".a:0." win#".winnr()." buf#".bufnr("%")." ft=".&ft)
" call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand(""))
if !exists("b:netrw_curdir")
let b:netrw_curdir= getcwd()
" call Decho("set b:netrw_curdir<".b:netrw_curdir."> (used getcwd)",'~'.expand(""))
endif
" record current file for Rexplore's benefit
if &ft != "netrw"
let w:netrw_rexfile= expand("%:p")
endif
" record current directory
let curdir = simplify(b:netrw_curdir)
let curfiledir = substitute(expand("%:p"),'^\(.*[/\\]\)[^/\\]*$','\1','e')
if !exists("g:netrw_cygwin") && has("win32")
let curdir= substitute(curdir,'\','/','g')
endif
" call Decho("curdir<".curdir."> curfiledir<".curfiledir.">",'~'.expand(""))
" using completion, directories with spaces in their names (thanks, Bill Gates, for a truly dumb idea)
" will end up with backslashes here. Solution: strip off backslashes that precede white space and
" try Explore again.
if a:0 > 0
" call Decho('considering retry: a:1<'.a:1.'>: '.
\ ((a:1 =~ "\\\s")? 'has backslash whitespace' : 'does not have backslash whitespace').', '.
\ ((filereadable(s:NetrwFile(a:1)))? 'is readable' : 'is not readable').', '.
\ ((isdirectory(s:NetrwFile(a:1))))? 'is a directory' : 'is not a directory',
\ '~'.expand(""))
if a:1 =~ "\\\s" && !filereadable(s:NetrwFile(a:1)) && !isdirectory(s:NetrwFile(a:1))
let a1 = substitute(a:1, '\\\(\s\)', '\1', 'g')
if a1 != a:1
call netrw#Explore(a:indx, a:dosplit, a:style, a1)
return
endif
endif
endif
" save registers
if has("clipboard") && g:netrw_clipboard
" call Decho("(netrw#Explore) save @* and @+",'~'.expand(""))
sil! let keepregstar = @*
sil! let keepregplus = @+
endif
sil! let keepregslash= @/
" if dosplit
" -or- file has been modified AND file not hidden when abandoned
" -or- Texplore used
if a:dosplit || (&modified && &hidden == 0 && &bufhidden != "hide") || a:style == 6
call s:SaveWinVars()
let winsz= g:netrw_winsize
if a:indx > 0
let winsz= a:indx
endif
if a:style == 0 " Explore, Sexplore
let winsz= (winsz > 0)? (winsz*winheight(0))/100 : -winsz
if winsz == 0|let winsz= ""|endif
exe "noswapfile ".(g:netrw_alto ? "below " : "above ").winsz."wincmd s"
elseif a:style == 1 " Explore!, Sexplore!
let winsz= (winsz > 0)? (winsz*winwidth(0))/100 : -winsz
if winsz == 0|let winsz= ""|endif
exe "keepalt noswapfile ".(g:netrw_altv ? "rightbelow " : "leftabove ").winsz."wincmd v"
elseif a:style == 2 " Hexplore
let winsz= (winsz > 0)? (winsz*winheight(0))/100 : -winsz
if winsz == 0|let winsz= ""|endif
exe "keepalt noswapfile ".(g:netrw_alto ? "below " : "above ").winsz."wincmd s"
elseif a:style == 3 " Hexplore!
let winsz= (winsz > 0)? (winsz*winheight(0))/100 : -winsz
if winsz == 0|let winsz= ""|endif
exe "keepalt noswapfile ".(!g:netrw_alto ? "below " : "above ").winsz."wincmd s"
elseif a:style == 4 " Vexplore
let winsz= (winsz > 0)? (winsz*winwidth(0))/100 : -winsz
if winsz == 0|let winsz= ""|endif
exe "keepalt noswapfile ".(g:netrw_altv ? "rightbelow " : "leftabove ").winsz."wincmd v"
elseif a:style == 5 " Vexplore!
let winsz= (winsz > 0)? (winsz*winwidth(0))/100 : -winsz
if winsz == 0|let winsz= ""|endif
exe "keepalt noswapfile ".(!g:netrw_altv ? "rightbelow " : "leftabove ").winsz."wincmd v"
elseif a:style == 6 " Texplore
call s:SaveBufVars()
exe "keepalt tabnew ".fnameescape(curdir)
call s:RestoreBufVars()
endif
call s:RestoreWinVars()
endif
NetrwKeepj norm! 0
if a:0 > 0
" call Decho("case [a:0=".a:0."] > 0: a:1<".a:1.">",'~'.expand(""))
if a:1 =~ '^\~' && (has("unix") || (exists("g:netrw_cygwin") && g:netrw_cygwin))
" call Decho("..case a:1<".a:1.">: starts with ~ and unix or cygwin",'~'.expand(""))
let dirname= simplify(substitute(a:1,'\~',expand("$HOME"),''))
" call Decho("..using dirname<".dirname."> (case: ~ && unix||cygwin)",'~'.expand(""))
elseif a:1 == '.'
" call Decho("..case a:1<".a:1.">: matches .",'~'.expand(""))
let dirname= simplify(exists("b:netrw_curdir")? b:netrw_curdir : getcwd())
if dirname !~ '/$'
let dirname= dirname."/"
endif
" call Decho("..using dirname<".dirname."> (case: ".(exists("b:netrw_curdir")? "b:netrw_curdir" : "getcwd()").")",'~'.expand(""))
elseif a:1 =~ '\$'
" call Decho("..case a:1<".a:1.">: matches ending $",'~'.expand(""))
let dirname= simplify(expand(a:1))
" call Decho("..using user-specified dirname<".dirname."> with $env-var",'~'.expand(""))
elseif a:1 !~ '^\*\{1,2}/' && a:1 !~ '^\a\{3,}://'
" call Decho("..case a:1<".a:1.">: other, not pattern or filepattern",'~'.expand(""))
let dirname= simplify(a:1)
" call Decho("..using user-specified dirname<".dirname.">",'~'.expand(""))
else
" call Decho("..case a:1: pattern or filepattern",'~'.expand(""))
let dirname= a:1
endif
else
" clear explore
" call Decho("case a:0=".a:0.": clearing Explore list",'~'.expand(""))
call s:NetrwClearExplore()
" call Dret("netrw#Explore : cleared list")
return
endif
" call Decho("dirname<".dirname.">",'~'.expand(""))
if dirname =~ '\.\./\=$'
let dirname= simplify(fnamemodify(dirname,':p:h'))
elseif dirname =~ '\.\.' || dirname == '.'
let dirname= simplify(fnamemodify(dirname,':p'))
endif
" call Decho("dirname<".dirname."> (after simplify)",'~'.expand(""))
if dirname =~ '^\*//'
" starpat=1: Explore *//pattern (current directory only search for files containing pattern)
" call Decho("case starpat=1: Explore *//pattern",'~'.expand(""))
let pattern= substitute(dirname,'^\*//\(.*\)$','\1','')
let starpat= 1
" call Decho("..Explore *//pat: (starpat=".starpat.") dirname<".dirname."> -> pattern<".pattern.">",'~'.expand(""))
if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif
elseif dirname =~ '^\*\*//'
" starpat=2: Explore **//pattern (recursive descent search for files containing pattern)
" call Decho("case starpat=2: Explore **//pattern",'~'.expand(""))
let pattern= substitute(dirname,'^\*\*//','','')
let starpat= 2
" call Decho("..Explore **//pat: (starpat=".starpat.") dirname<".dirname."> -> pattern<".pattern.">",'~'.expand(""))
elseif dirname =~ '/\*\*/'
" handle .../**/.../filepat
" call Decho("case starpat=4: Explore .../**/.../filepat",'~'.expand(""))
let prefixdir= substitute(dirname,'^\(.\{-}\)\*\*.*$','\1','')
if prefixdir =~ '^/' || (prefixdir =~ '^\a:/' && has("win32"))
let b:netrw_curdir = prefixdir
else
let b:netrw_curdir= getcwd().'/'.prefixdir
endif
let dirname= substitute(dirname,'^.\{-}\(\*\*/.*\)$','\1','')
let starpat= 4
" call Decho("..pwd<".getcwd()."> dirname<".dirname.">",'~'.expand(""))
" call Decho("..case Explore ../**/../filepat (starpat=".starpat.")",'~'.expand(""))
elseif dirname =~ '^\*/'
" case starpat=3: Explore */filepat (search in current directory for filenames matching filepat)
let starpat= 3
" call Decho("case starpat=3: Explore */filepat (starpat=".starpat.")",'~'.expand(""))
elseif dirname=~ '^\*\*/'
" starpat=4: Explore **/filepat (recursive descent search for filenames matching filepat)
let starpat= 4
" call Decho("case starpat=4: Explore **/filepat (starpat=".starpat.")",'~'.expand(""))
else
let starpat= 0
" call Decho("case starpat=0: default",'~'.expand(""))
endif
if starpat == 0 && a:indx >= 0
" [Explore Hexplore Vexplore Sexplore] [dirname]
" call Decho("case starpat==0 && a:indx=".a:indx.": dirname<".dirname.">, handles Explore Hexplore Vexplore Sexplore",'~'.expand(""))
if dirname == ""
let dirname= curfiledir
" call Decho("..empty dirname, using current file's directory<".dirname.">",'~'.expand(""))
endif
if dirname =~# '^scp://' || dirname =~ '^ftp://'
call netrw#Nread(2,dirname)
else
if dirname == ""
let dirname= getcwd()
elseif has("win32") && !g:netrw_cygwin
" Windows : check for a drive specifier, or else for a remote share name ('\\Foo' or '//Foo',
" depending on whether backslashes have been converted to forward slashes by earlier code).
if dirname !~ '^[a-zA-Z]:' && dirname !~ '^\\\\\w\+' && dirname !~ '^//\w\+'
let dirname= b:netrw_curdir."/".dirname
endif
elseif dirname !~ '^/'
let dirname= b:netrw_curdir."/".dirname
endif
" call Decho("..calling LocalBrowseCheck(dirname<".dirname.">)",'~'.expand(""))
call netrw#LocalBrowseCheck(dirname)
" call Decho(" modified=".&modified." modifiable=".&modifiable." readonly=".&readonly,'~'.expand(""))
" call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand(""))
endif
if exists("w:netrw_bannercnt")
" done to handle P08-Ingelrest. :Explore will _Always_ go to the line just after the banner.
" If one wants to return the same place in the netrw window, use :Rex instead.
exe w:netrw_bannercnt
endif
" call Decho("curdir<".curdir.">",'~'.expand(""))
" ---------------------------------------------------------------------
" Jan 24, 2013: not sure why the following was present. See P08-Ingelrest
" if has("win32") || has("win95") || has("win64") || has("win16")
" NetrwKeepj call search('\<'.substitute(curdir,'^.*[/\\]','','e').'\>','cW')
" else
" NetrwKeepj call search('\<'.substitute(curdir,'^.*/','','e').'\>','cW')
" endif
" ---------------------------------------------------------------------
" starpat=1: Explore *//pattern (current directory only search for files containing pattern)
" starpat=2: Explore **//pattern (recursive descent search for files containing pattern)
" starpat=3: Explore */filepat (search in current directory for filenames matching filepat)
" starpat=4: Explore **/filepat (recursive descent search for filenames matching filepat)
elseif a:indx <= 0
" Nexplore, Pexplore, Explore: handle starpat
" call Decho("case a:indx<=0: Nexplore, Pexplore, , starpat=".starpat." a:indx=".a:indx,'~'.expand(""))
if !mapcheck("","n") && !mapcheck("","n") && exists("b:netrw_curdir")
" call Decho("..set up and maps",'~'.expand(""))
let s:didstarstar= 1
nnoremap :Pexplore
nnoremap :Nexplore
endif
if has("path_extra")
" call Decho("..starpat=".starpat.": has +path_extra",'~'.expand(""))
if !exists("w:netrw_explore_indx")
let w:netrw_explore_indx= 0
endif
let indx = a:indx
" call Decho("..starpat=".starpat.": set indx= [a:indx=".indx."]",'~'.expand(""))
if indx == -1
" Nexplore
" call Decho("..case Nexplore with starpat=".starpat.": (indx=".indx.")",'~'.expand(""))
if !exists("w:netrw_explore_list") " sanity check
NetrwKeepj call netrw#ErrorMsg(s:WARNING,"using Nexplore or improperly; see help for netrw-starstar",40)
if has("clipboard") && g:netrw_clipboard
" call Decho("(netrw#Explore) restore @* and @+",'~'.expand(""))
if @* != keepregstar | sil! let @* = keepregstar | endif
if @+ != keepregplus | sil! let @+ = keepregplus | endif
endif
sil! let @/ = keepregslash
" call Dret("netrw#Explore")
return
endif
let indx= w:netrw_explore_indx
if indx < 0 | let indx= 0 | endif
if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif
let curfile= w:netrw_explore_list[indx]
" call Decho("....indx=".indx." curfile<".curfile.">",'~'.expand(""))
while indx < w:netrw_explore_listlen && curfile == w:netrw_explore_list[indx]
let indx= indx + 1
" call Decho("....indx=".indx." (Nexplore while loop)",'~'.expand(""))
endwhile
if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif
" call Decho("....Nexplore: indx= [w:netrw_explore_indx=".w:netrw_explore_indx."]=".indx,'~'.expand(""))
elseif indx == -2
" Pexplore
" call Decho("case Pexplore with starpat=".starpat.": (indx=".indx.")",'~'.expand(""))
if !exists("w:netrw_explore_list") " sanity check
NetrwKeepj call netrw#ErrorMsg(s:WARNING,"using Pexplore or improperly; see help for netrw-starstar",41)
if has("clipboard") && g:netrw_clipboard
" call Decho("(netrw#Explore) restore @* and @+",'~'.expand(""))
if @* != keepregstar | sil! let @* = keepregstar | endif
if @+ != keepregplus | sil! let @+ = keepregplus | endif
endif
sil! let @/ = keepregslash
" call Dret("netrw#Explore")
return
endif
let indx= w:netrw_explore_indx
if indx < 0 | let indx= 0 | endif
if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif
let curfile= w:netrw_explore_list[indx]
" call Decho("....indx=".indx." curfile<".curfile.">",'~'.expand(""))
while indx >= 0 && curfile == w:netrw_explore_list[indx]
let indx= indx - 1
" call Decho("....indx=".indx." (Pexplore while loop)",'~'.expand(""))
endwhile
if indx < 0 | let indx= 0 | endif
" call Decho("....Pexplore: indx= [w:netrw_explore_indx=".w:netrw_explore_indx."]=".indx,'~'.expand(""))
else
" Explore -- initialize
" build list of files to Explore with Nexplore/Pexplore
" call Decho("..starpat=".starpat.": case Explore: initialize (indx=".indx.")",'~'.expand(""))
NetrwKeepj keepalt call s:NetrwClearExplore()
let w:netrw_explore_indx= 0
if !exists("b:netrw_curdir")
let b:netrw_curdir= getcwd()
endif
" call Decho("....starpat=".starpat.": b:netrw_curdir<".b:netrw_curdir.">",'~'.expand(""))
" switch on starpat to build the w:netrw_explore_list of files
if starpat == 1
" starpat=1: Explore *//pattern (current directory only search for files containing pattern)
" call Decho("..case starpat=".starpat.": build *//pattern list (curdir-only srch for files containing pattern) &hls=".&hls,'~'.expand(""))
" call Decho("....pattern<".pattern.">",'~'.expand(""))
try
exe "NetrwKeepj noautocmd vimgrep /".pattern."/gj ".fnameescape(b:netrw_curdir)."/*"
catch /^Vim\%((\a\+)\)\=:E480/
keepalt call netrw#ErrorMsg(s:WARNING,"no match with pattern<".pattern.">",76)
" call Dret("netrw#Explore : unable to find pattern<".pattern.">")
return
endtry
let w:netrw_explore_list = s:NetrwExploreListUniq(map(getqflist(),'bufname(v:val.bufnr)'))
if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif
elseif starpat == 2
" starpat=2: Explore **//pattern (recursive descent search for files containing pattern)
" call Decho("..case starpat=".starpat.": build **//pattern list (recursive descent files containing pattern)",'~'.expand(""))
" call Decho("....pattern<".pattern.">",'~'.expand(""))
try
exe "sil NetrwKeepj noautocmd keepalt vimgrep /".pattern."/gj "."**/*"
catch /^Vim\%((\a\+)\)\=:E480/
keepalt call netrw#ErrorMsg(s:WARNING,'no files matched pattern<'.pattern.'>',45)
if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif
if has("clipboard") && g:netrw_clipboard
" call Decho("(netrw#Explore) restore @* and @+",'~'.expand(""))
if @* != keepregstar | sil! let @* = keepregstar | endif
if @+ != keepregplus | sil! let @+ = keepregplus | endif
endif
sil! let @/ = keepregslash
" call Dret("netrw#Explore : no files matched pattern")
return
endtry
let s:netrw_curdir = b:netrw_curdir
let w:netrw_explore_list = getqflist()
let w:netrw_explore_list = s:NetrwExploreListUniq(map(w:netrw_explore_list,'s:netrw_curdir."/".bufname(v:val.bufnr)'))
if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif
elseif starpat == 3
" starpat=3: Explore */filepat (search in current directory for filenames matching filepat)
" call Decho("..case starpat=".starpat.": build */filepat list (curdir-only srch filenames matching filepat) &hls=".&hls,'~'.expand(""))
let filepat= substitute(dirname,'^\*/','','')
let filepat= substitute(filepat,'^[%#<]','\\&','')
" call Decho("....b:netrw_curdir<".b:netrw_curdir.">",'~'.expand(""))
" call Decho("....filepat<".filepat.">",'~'.expand(""))
let w:netrw_explore_list= s:NetrwExploreListUniq(split(expand(b:netrw_curdir."/".filepat),'\n'))
if &hls | let keepregslash= s:ExplorePatHls(filepat) | endif
elseif starpat == 4
" starpat=4: Explore **/filepat (recursive descent search for filenames matching filepat)
" call Decho("..case starpat=".starpat.": build **/filepat list (recursive descent srch filenames matching filepat) &hls=".&hls,'~'.expand(""))
let w:netrw_explore_list= s:NetrwExploreListUniq(split(expand(b:netrw_curdir."/".dirname),'\n'))
if &hls | let keepregslash= s:ExplorePatHls(dirname) | endif
endif " switch on starpat to build w:netrw_explore_list
let w:netrw_explore_listlen = len(w:netrw_explore_list)
" call Decho("....w:netrw_explore_list<".string(w:netrw_explore_list).">",'~'.expand(""))
" call Decho("....w:netrw_explore_listlen=".w:netrw_explore_listlen,'~'.expand(""))
if w:netrw_explore_listlen == 0 || (w:netrw_explore_listlen == 1 && w:netrw_explore_list[0] =~ '\*\*\/')
keepalt NetrwKeepj call netrw#ErrorMsg(s:WARNING,"no files matched",42)
if has("clipboard") && g:netrw_clipboard
" call Decho("(netrw#Explore) restore @* and @+",'~'.expand(""))
if @* != keepregstar | sil! let @* = keepregstar | endif
if @+ != keepregplus | sil! let @+ = keepregplus | endif
endif
sil! let @/ = keepregslash
" call Dret("netrw#Explore : no files matched")
return
endif
endif " if indx ... endif
" NetrwStatusLine support - for exploring support
let w:netrw_explore_indx= indx
" call Decho("....w:netrw_explore_list<".join(w:netrw_explore_list,',')."> len=".w:netrw_explore_listlen,'~'.expand(""))
" wrap the indx around, but issue a note
if indx >= w:netrw_explore_listlen || indx < 0
" call Decho("....wrap indx (indx=".indx." listlen=".w:netrw_explore_listlen.")",'~'.expand(""))
let indx = (indx < 0)? ( w:netrw_explore_listlen - 1 ) : 0
let w:netrw_explore_indx= indx
keepalt NetrwKeepj call netrw#ErrorMsg(s:NOTE,"no more files match Explore pattern",43)
endif
exe "let dirfile= w:netrw_explore_list[".indx."]"
" call Decho("....dirfile=w:netrw_explore_list[indx=".indx."]= <".dirfile.">",'~'.expand(""))
let newdir= substitute(dirfile,'/[^/]*$','','e')
" call Decho("....newdir<".newdir.">",'~'.expand(""))
" call Decho("....calling LocalBrowseCheck(newdir<".newdir.">)",'~'.expand(""))
call netrw#LocalBrowseCheck(newdir)
if !exists("w:netrw_liststyle")
let w:netrw_liststyle= g:netrw_liststyle
endif
if w:netrw_liststyle == s:THINLIST || w:netrw_liststyle == s:LONGLIST
keepalt NetrwKeepj call search('^'.substitute(dirfile,"^.*/","","").'\>',"W")
else
keepalt NetrwKeepj call search('\<'.substitute(dirfile,"^.*/","","").'\>',"w")
endif
let w:netrw_explore_mtchcnt = indx + 1
let w:netrw_explore_bufnr = bufnr("%")
let w:netrw_explore_line = line(".")
keepalt NetrwKeepj call s:SetupNetrwStatusLine('%f %h%m%r%=%9*%{NetrwStatusLine()}')
" call Decho("....explore: mtchcnt=".w:netrw_explore_mtchcnt." bufnr=".w:netrw_explore_bufnr." line#".w:netrw_explore_line,'~'.expand(""))
else
" call Decho("..your vim does not have +path_extra",'~'.expand(""))
if !exists("g:netrw_quiet")
keepalt NetrwKeepj call netrw#ErrorMsg(s:WARNING,"your vim needs the +path_extra feature for Exploring with **!",44)
endif
if has("clipboard") && g:netrw_clipboard
" call Decho("(netrw#Explore) restore @* and @+",'~'.expand(""))
if @* != keepregstar | sil! let @* = keepregstar | endif
if @+ != keepregplus | sil! let @+ = keepregplus | endif
endif
sil! let @/ = keepregslash
" call Dret("netrw#Explore : missing +path_extra")
return
endif
else
" call Decho("..default case: Explore newdir<".dirname.">",'~'.expand(""))
if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && dirname =~ '/'
sil! unlet w:netrw_treedict
sil! unlet w:netrw_treetop
endif
let newdir= dirname
if !exists("b:netrw_curdir")
NetrwKeepj call netrw#LocalBrowseCheck(getcwd())
else
NetrwKeepj call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,newdir))
endif
endif
" visual display of **/ **// */ Exploration files
" call Decho("w:netrw_explore_indx=".(exists("w:netrw_explore_indx")? w:netrw_explore_indx : "doesn't exist"),'~'.expand(""))
" call Decho("b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "n/a").">",'~'.expand(""))
if exists("w:netrw_explore_indx") && exists("b:netrw_curdir")
" call Decho("s:explore_prvdir<".(exists("s:explore_prvdir")? s:explore_prvdir : "-doesn't exist-"),'~'.expand(""))
if !exists("s:explore_prvdir") || s:explore_prvdir != b:netrw_curdir
" only update match list when current directory isn't the same as before
" call Decho("only update match list when current directory not the same as before",'~'.expand(""))
let s:explore_prvdir = b:netrw_curdir
let s:explore_match = ""
let dirlen = strlen(b:netrw_curdir)
if b:netrw_curdir !~ '/$'
let dirlen= dirlen + 1
endif
let prvfname= ""
for fname in w:netrw_explore_list
" call Decho("fname<".fname.">",'~'.expand(""))
if fname =~ '^'.b:netrw_curdir
if s:explore_match == ""
let s:explore_match= '\<'.escape(strpart(fname,dirlen),g:netrw_markfileesc).'\>'
else
let s:explore_match= s:explore_match.'\|\<'.escape(strpart(fname,dirlen),g:netrw_markfileesc).'\>'
endif
elseif fname !~ '^/' && fname != prvfname
if s:explore_match == ""
let s:explore_match= '\<'.escape(fname,g:netrw_markfileesc).'\>'
else
let s:explore_match= s:explore_match.'\|\<'.escape(fname,g:netrw_markfileesc).'\>'
endif
endif
let prvfname= fname
endfor
" call Decho("explore_match<".s:explore_match.">",'~'.expand(""))
if has("syntax") && exists("g:syntax_on") && g:syntax_on
exe "2match netrwMarkFile /".s:explore_match."/"
endif
endif
echo "==Pexplore ==Nexplore"
else
2match none
if exists("s:explore_match") | unlet s:explore_match | endif
if exists("s:explore_prvdir") | unlet s:explore_prvdir | endif
" call Decho("cleared explore match list",'~'.expand(""))
endif
" since Explore may be used to initialize netrw's browser,
" there's no danger of a late FocusGained event on initialization.
" Consequently, set s:netrw_events to 2.
let s:netrw_events= 2
if has("clipboard") && g:netrw_clipboard
" call Decho("(netrw#Explore) restore @* and @+",'~'.expand(""))
if @* != keepregstar | sil! let @* = keepregstar | endif
if @+ != keepregplus | sil! let @+ = keepregplus | endif
endif
sil! let @/ = keepregslash
" call Dret("netrw#Explore : @/<".@/.">")
endfun
" ---------------------------------------------------------------------
" netrw#Lexplore: toggle Explorer window, keeping it on the left of the current tab {{{2
" Uses g:netrw_chgwin : specifies the window where Lexplore files are to be opened
" t:netrw_lexposn : winsaveview() output (used on Lexplore window)
" t:netrw_lexbufnr: the buffer number of the Lexplore buffer (internal to this function)
" s:lexplore_win : window number of Lexplore window (serves to indicate which window is a Lexplore window)
" w:lexplore_buf : buffer number of Lexplore window (serves to indicate which window is a Lexplore window)
fun! netrw#Lexplore(count,rightside,...)
" call Dfunc("netrw#Lexplore(count=".a:count." rightside=".a:rightside.",...) a:0=".a:0." ft=".&ft)
let curwin= winnr()
if a:0 > 0 && a:1 != ""
" if a netrw window is already on the left-side of the tab
" and a directory has been specified, explore with that
" directory.
" call Decho("case has input argument(s) (a:1<".a:1.">)")
let a1 = expand(a:1)
" call Decho("a:1<".a:1."> curwin#".curwin,'~'.expand(""))
exe "1wincmd w"
if &ft == "netrw"
" call Decho("exe Explore ".fnameescape(a:1),'~'.expand(""))
exe "Explore ".fnameescape(a1)
exe curwin."wincmd w"
let s:lexplore_win= curwin
let w:lexplore_buf= bufnr("%")
if exists("t:netrw_lexposn")
" call Decho("forgetting t:netrw_lexposn",'~'.expand(""))
unlet t:netrw_lexposn
endif
" call Dret("netrw#Lexplore")
return
endif
exe curwin."wincmd w"
else
let a1= ""
" call Decho("no input arguments")
endif
if exists("t:netrw_lexbufnr")
" check if t:netrw_lexbufnr refers to a netrw window
let lexwinnr = bufwinnr(t:netrw_lexbufnr)
" call Decho("lexwinnr= bufwinnr(t:netrw_lexbufnr#".t:netrw_lexbufnr.")=".lexwinnr)
else
let lexwinnr= 0
" call Decho("t:netrw_lexbufnr doesn't exist")
endif
" call Decho("lexwinnr=".lexwinnr,'~'.expand(""))
if lexwinnr > 0
" close down netrw explorer window
" call Decho("t:netrw_lexbufnr#".t:netrw_lexbufnr.": close down netrw window",'~'.expand(""))
exe lexwinnr."wincmd w"
let g:netrw_winsize = -winwidth(0)
let t:netrw_lexposn = winsaveview()
" call Decho("saving posn to t:netrw_lexposn<".string(t:netrw_lexposn).">",'~'.expand(""))
" call Decho("saving t:netrw_lexposn",'~'.expand(""))
close
if lexwinnr < curwin
let curwin= curwin - 1
endif
if lexwinnr != curwin
exe curwin."wincmd w"
endif
unlet t:netrw_lexbufnr
" call Decho("unlet t:netrw_lexbufnr")
else
" open netrw explorer window
" call Decho("t:netrw_lexbufnr: open netrw explorer window",'~'.expand(""))
exe "1wincmd w"
let keep_altv = g:netrw_altv
let g:netrw_altv = 0
if a:count != 0
let netrw_winsize = g:netrw_winsize
let g:netrw_winsize = a:count
endif
let curfile= expand("%")
" call Decho("curfile<".curfile.">",'~'.expand(""))
exe (a:rightside? "botright" : "topleft")." vertical ".((g:netrw_winsize > 0)? (g:netrw_winsize*winwidth(0))/100 : -g:netrw_winsize) . " new"
" call Decho("new buf#".bufnr("%")." win#".winnr())
if a:0 > 0 && a1 != ""
" call Decho("case 1: Explore ".a1,'~'.expand(""))
call netrw#Explore(0,0,0,a1)
exe "Explore ".fnameescape(a1)
elseif curfile =~ '^\a\{3,}://'
" call Decho("case 2: Explore ".substitute(curfile,'[^/\\]*$','',''),'~'.expand(""))
call netrw#Explore(0,0,0,substitute(curfile,'[^/\\]*$','',''))
else
" call Decho("case 3: Explore .",'~'.expand(""))
call netrw#Explore(0,0,0,".")
endif
if a:count != 0
let g:netrw_winsize = netrw_winsize
endif
setlocal winfixwidth
let g:netrw_altv = keep_altv
let t:netrw_lexbufnr = bufnr("%")
" done to prevent build-up of hidden buffers due to quitting and re-invocation of :Lexplore.
" Since the intended use of :Lexplore is to have an always-present explorer window, the extra
" effort to prevent mis-use of :Lex is warranted.
set bh=wipe
" call Decho("let t:netrw_lexbufnr=".t:netrw_lexbufnr)
" call Decho("t:netrw_lexposn".(exists("t:netrw_lexposn")? string(t:netrw_lexposn) : " n/a"))
if exists("t:netrw_lexposn")
" call Decho("restoring to t:netrw_lexposn",'~'.expand(""))
" call Decho("restoring posn to t:netrw_lexposn<".string(t:netrw_lexposn).">",'~'.expand(""))
call winrestview(t:netrw_lexposn)
unlet t:netrw_lexposn
endif
endif
" set up default window for editing via
if exists("g:netrw_chgwin") && g:netrw_chgwin == -1
if a:rightside
let g:netrw_chgwin= 1
else
let g:netrw_chgwin= 2
endif
" call Decho("let g:netrw_chgwin=".g:netrw_chgwin)
endif
" call Dret("netrw#Lexplore")
endfun
" ---------------------------------------------------------------------
" netrw#Clean: remove netrw {{{2
" supports :NetrwClean -- remove netrw from first directory on runtimepath
" :NetrwClean! -- remove netrw from all directories on runtimepath
fun! netrw#Clean(sys)
" call Dfunc("netrw#Clean(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,'~'.expand(""))
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,'~'.expand(""))
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#Clean")
endfun
" ---------------------------------------------------------------------
" netrw#MakeTgt: make a target out of the directory name provided {{{2
fun! netrw#MakeTgt(dname)
" call Dfunc("netrw#MakeTgt(dname<".a:dname.">)")
" simplify the target (eg. /abc/def/../ghi -> /abc/ghi)
let svpos = winsaveview()
" call Decho("saving posn to svpos<".string(svpos).">",'~'.expand(""))
let s:netrwmftgt_islocal= (a:dname !~ '^\a\{3,}://')
" call Decho("s:netrwmftgt_islocal=".s:netrwmftgt_islocal,'~'.expand(""))
if s:netrwmftgt_islocal
let netrwmftgt= simplify(a:dname)
else
let netrwmftgt= a:dname
endif
if exists("s:netrwmftgt") && netrwmftgt == s:netrwmftgt
" re-selected target, so just clear it
unlet s:netrwmftgt s:netrwmftgt_islocal
else
let s:netrwmftgt= netrwmftgt
endif
if g:netrw_fastbrowse <= 1
call s:NetrwRefresh((b:netrw_curdir !~ '\a\{3,}://'),b:netrw_curdir)
endif
" call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand(""))"
call winrestview(svpos)
" call Dret("netrw#MakeTgt")
endfun
" ---------------------------------------------------------------------
" netrw#Obtain: {{{2
" netrw#Obtain(islocal,fname[,tgtdirectory])
" islocal=0 obtain from remote source
" =1 obtain from local source
" fname : a filename or a list of filenames
" tgtdir : optional place where files are to go (not present, uses getcwd())
fun! netrw#Obtain(islocal,fname,...)
" call Dfunc("netrw#Obtain(islocal=".a:islocal." fname<".((type(a:fname) == 1)? a:fname : string(a:fname)).">) a:0=".a:0)
" NetrwStatusLine support - for obtaining support
if type(a:fname) == 1
let fnamelist= [ a:fname ]
elseif type(a:fname) == 3
let fnamelist= a:fname
else
call netrw#ErrorMsg(s:ERROR,"attempting to use NetrwObtain on something not a filename or a list",62)
" call Dret("netrw#Obtain")
return
endif
" call Decho("fnamelist<".string(fnamelist).">",'~'.expand(""))
if a:0 > 0
let tgtdir= a:1
else
let tgtdir= getcwd()
endif
" call Decho("tgtdir<".tgtdir.">",'~'.expand(""))
if exists("b:netrw_islocal") && b:netrw_islocal
" obtain a file from local b:netrw_curdir to (local) tgtdir
" call Decho("obtain a file from local ".b:netrw_curdir." to ".tgtdir,'~'.expand(""))
if exists("b:netrw_curdir") && getcwd() != b:netrw_curdir
let topath= s:ComposePath(tgtdir,"")
if has("win32")
" transfer files one at time
" call Decho("transfer files one at a time",'~'.expand(""))
for fname in fnamelist
" call Decho("system(".g:netrw_localcopycmd." ".s:ShellEscape(fname)." ".s:ShellEscape(topath).")",'~'.expand(""))
call system(g:netrw_localcopycmd.g:netrw_localcopycmdopt." ".s:ShellEscape(fname)." ".s:ShellEscape(topath))
if v:shell_error != 0
call netrw#ErrorMsg(s:WARNING,"consider setting g:netrw_localcopycmd<".g:netrw_localcopycmd."> to something that works",80)
" call Dret("s:NetrwObtain 0 : failed: ".g:netrw_localcopycmd." ".s:ShellEscape(fname)." ".s:ShellEscape(topath))
return
endif
endfor
else
" transfer files with one command
" call Decho("transfer files with one command",'~'.expand(""))
let filelist= join(map(deepcopy(fnamelist),"s:ShellEscape(v:val)"))
" call Decho("system(".g:netrw_localcopycmd." ".filelist." ".s:ShellEscape(topath).")",'~'.expand(""))
call system(g:netrw_localcopycmd.g:netrw_localcopycmdopt." ".filelist." ".s:ShellEscape(topath))
if v:shell_error != 0
call netrw#ErrorMsg(s:WARNING,"consider setting g:netrw_localcopycmd<".g:netrw_localcopycmd."> to something that works",80)
" call Dret("s:NetrwObtain 0 : failed: ".g:netrw_localcopycmd." ".filelist." ".s:ShellEscape(topath))
return
endif
endif
elseif !exists("b:netrw_curdir")
call netrw#ErrorMsg(s:ERROR,"local browsing directory doesn't exist!",36)
else
call netrw#ErrorMsg(s:WARNING,"local browsing directory and current directory are identical",37)
endif
else
" obtain files from remote b:netrw_curdir to local tgtdir
" call Decho("obtain a file from remote ".b:netrw_curdir." to ".tgtdir,'~'.expand(""))
if type(a:fname) == 1
call s:SetupNetrwStatusLine('%f %h%m%r%=%9*Obtaining '.a:fname)
endif
call s:NetrwMethod(b:netrw_curdir)
if b:netrw_method == 4
" obtain file using scp
" call Decho("obtain via scp (method#4)",'~'.expand(""))
if exists("g:netrw_port") && g:netrw_port != ""
let useport= " ".g:netrw_scpport." ".g:netrw_port
else
let useport= ""
endif
if b:netrw_fname =~ '/'
let path= substitute(b:netrw_fname,'^\(.*/\).\{-}$','\1','')
else
let path= ""
endif
let filelist= join(map(deepcopy(fnamelist),'escape(s:ShellEscape(g:netrw_machine.":".path.v:val,1)," ")'))
call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_scp_cmd.s:ShellEscape(useport,1)." ".filelist." ".s:ShellEscape(tgtdir,1))
elseif b:netrw_method == 2
" obtain file using ftp + .netrc
" call Decho("obtain via ftp+.netrc (method #2)",'~'.expand(""))
call s:SaveBufVars()|sil NetrwKeepj new|call s:RestoreBufVars()
let tmpbufnr= bufnr("%")
setl ff=unix
if exists("g:netrw_ftpmode") && g:netrw_ftpmode != ""
NetrwKeepj put =g:netrw_ftpmode
" call Decho("filter input: ".getline('$'),'~'.expand(""))
endif
if exists("b:netrw_fname") && b:netrw_fname != ""
call setline(line("$")+1,'cd "'.b:netrw_fname.'"')
" call Decho("filter input: ".getline('$'),'~'.expand(""))
endif
if exists("g:netrw_ftpextracmd")
NetrwKeepj put =g:netrw_ftpextracmd
" call Decho("filter input: ".getline('$'),'~'.expand(""))
endif
for fname in fnamelist
call setline(line("$")+1,'get "'.fname.'"')
" call Decho("filter input: ".getline('$'),'~'.expand(""))
endfor
if exists("g:netrw_port") && g:netrw_port != ""
call s:NetrwExe(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".s:ShellEscape(g:netrw_machine,1)." ".s:ShellEscape(g:netrw_port,1))
else
call s:NetrwExe(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".s: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
setl debug=msg
call netrw#ErrorMsg(s:ERROR,getline(1),4)
let &debug= debugkeep
endif
elseif b:netrw_method == 3
" obtain with ftp + machine, id, passwd, and fname (ie. no .netrc)
" call Decho("obtain via ftp+mipf (method #3)",'~'.expand(""))
call s:SaveBufVars()|sil NetrwKeepj new|call s:RestoreBufVars()
let tmpbufnr= bufnr("%")
setl ff=unix
if exists("g:netrw_port") && g:netrw_port != ""
NetrwKeepj put ='open '.g:netrw_machine.' '.g:netrw_port
" call Decho("filter input: ".getline('$'),'~'.expand(""))
else
NetrwKeepj put ='open '.g:netrw_machine
" call Decho("filter input: ".getline('$'),'~'.expand(""))
endif
if exists("g:netrw_uid") && g:netrw_uid != ""
if exists("g:netrw_ftp") && g:netrw_ftp == 1
NetrwKeepj put =g:netrw_uid
" call Decho("filter input: ".getline('$'),'~'.expand(""))
if exists("s:netrw_passwd") && s:netrw_passwd != ""
NetrwKeepj put ='\"'.s:netrw_passwd.'\"'
endif
" call Decho("filter input: ".getline('$'),'~'.expand(""))
elseif exists("s:netrw_passwd")
NetrwKeepj put ='user \"'.g:netrw_uid.'\" \"'.s:netrw_passwd.'\"'
" call Decho("filter input: ".getline('$'),'~'.expand(""))
endif
endif
if exists("g:netrw_ftpmode") && g:netrw_ftpmode != ""
NetrwKeepj put =g:netrw_ftpmode
" call Decho("filter input: ".getline('$'),'~'.expand(""))
endif
if exists("b:netrw_fname") && b:netrw_fname != ""
NetrwKeepj call setline(line("$")+1,'cd "'.b:netrw_fname.'"')
" call Decho("filter input: ".getline('$'),'~'.expand(""))
endif
if exists("g:netrw_ftpextracmd")
NetrwKeepj put =g:netrw_ftpextracmd
" call Decho("filter input: ".getline('$'),'~'.expand(""))
endif
if exists("g:netrw_ftpextracmd")
NetrwKeepj put =g:netrw_ftpextracmd
" call Decho("filter input: ".getline('$'),'~'.expand(""))
endif
for fname in fnamelist
NetrwKeepj call setline(line("$")+1,'get "'.fname.'"')
endfor
" call Decho("filter input: ".getline('$'),'~'.expand(""))
" 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
" Note: using "_dd to delete to the black hole register; avoids messing up @@
NetrwKeepj norm! 1G"_dd
call s:NetrwExe(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).">",'~'.expand(""))
if !exists("g:netrw_quiet")
NetrwKeepj call netrw#ErrorMsg(s:ERROR,getline(1),5)
endif
endif
elseif b:netrw_method == 9
" obtain file using sftp
" call Decho("obtain via sftp (method #9)",'~'.expand(""))
if a:fname =~ '/'
let localfile= substitute(a:fname,'^.*/','','')
else
let localfile= a:fname
endif
call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_sftp_cmd." ".s:ShellEscape(g:netrw_machine.":".b:netrw_fname,1).s:ShellEscape(localfile)." ".s:ShellEscape(tgtdir))
elseif !exists("b:netrw_method") || b:netrw_method < 0
" probably a badly formed url; protocol not recognized
" call Dret("netrw#Obtain : unsupported method")
return
else
" protocol recognized but not supported for Obtain (yet?)
if !exists("g:netrw_quiet")
NetrwKeepj call netrw#ErrorMsg(s:ERROR,"current protocol not supported for obtaining file",97)
endif
" call Dret("netrw#Obtain : current protocol not supported for obtaining file")
return
endif
" restore status line
if type(a:fname) == 1 && exists("s:netrw_users_stl")
NetrwKeepj call s:SetupNetrwStatusLine(s:netrw_users_stl)
endif
endif
" cleanup
if exists("tmpbufnr")
if bufnr("%") != tmpbufnr
exe tmpbufnr."bw!"
else
q!
endif
endif
" call Dret("netrw#Obtain")
endfun
" ---------------------------------------------------------------------
" netrw#Nread: save position, call netrw#NetRead(), and restore position {{{2
fun! netrw#Nread(mode,fname)
" call Dfunc("netrw#Nread(mode=".a:mode." fname<".a:fname.">)")
let svpos= winsaveview()
" call Decho("saving posn to svpos<".string(svpos).">",'~'.expand(""))
call netrw#NetRead(a:mode,a:fname)
" call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand(""))
call winrestview(svpos)
if exists("w:netrw_liststyle") && w:netrw_liststyle != s:TREELIST
if exists("w:netrw_bannercnt")
" start with cursor just after the banner
exe w:netrw_bannercnt
endif
endif
" call Dret("netrw#Nread")
endfun
" ------------------------------------------------------------------------
" s:NetrwOptionsSave: save options prior to setting to "netrw-buffer-standard" form {{{2
" Options get restored by s:NetrwOptionsRestore()
"
" Option handling:
" * save user's options (s:NetrwOptionsSave)
" * set netrw-safe options (s:NetrwOptionsSafe)
" - change an option only when user option != safe option (s:netrwSetSafeSetting)
" * restore user's options (s:netrwOPtionsRestore)
" - restore a user option when != safe option (s:NetrwRestoreSetting)
" vt: (variable type) normally its either "w:" or "s:"
fun! s:NetrwOptionsSave(vt)
" call Dfunc("s:NetrwOptionsSave(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")."<".bufname(bufnr("%")).">"." winnr($)=".winnr("$")." mod=".&mod." ma=".&ma)
" call Decho(a:vt."netrw_optionsave".(exists("{a:vt}netrw_optionsave")? ("=".{a:vt}netrw_optionsave) : " doesn't exist"),'~'.expand(""))
" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt." hid=".&hid,'~'.expand(""))
" call Decho("(s:NetrwOptionsSave) lines=".&lines)
if !exists("{a:vt}netrw_optionsave")
let {a:vt}netrw_optionsave= 1
else
" call Dret("s:NetrwOptionsSave : options already saved")
return
endif
" call Decho("prior to save: fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist")." diff=".&l:diff,'~'.expand(""))
" Save current settings and current directory
" call Decho("saving current settings and current directory",'~'.expand(""))
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_cedit = &cedit
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_cuckeep = &l:cuc
let {a:vt}netrw_culkeep = &l:cul
" call Decho("(s:NetrwOptionsSave) COMBAK: cuc=".&l:cuc." cul=".&l:cul)
let {a:vt}netrw_diffkeep = &l:diff
let {a:vt}netrw_fenkeep = &l:fen
if !exists("g:netrw_ffkeep") || g:netrw_ffkeep
let {a:vt}netrw_ffkeep = &l:ff
endif
let {a:vt}netrw_fokeep = &l:fo " formatoptions
let {a:vt}netrw_gdkeep = &l:gd " gdefault
let {a:vt}netrw_gokeep = &go " guioptions
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_lines = &lines
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_rnukeep = &l:rnu
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
if !g:netrw_use_noswf
let {a:vt}netrw_swfkeep = &l:swf
endif
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
" save a few selected netrw-related variables
" call Decho("saving a few selected netrw-related variables",'~'.expand(""))
if g:netrw_keepdir
let {a:vt}netrw_dirkeep = getcwd()
" call Decho("saving to ".a:vt."netrw_dirkeep<".{a:vt}netrw_dirkeep.">",'~'.expand(""))
endif
if has("clipboard") && g:netrw_clipboard
sil! let {a:vt}netrw_starkeep = @*
sil! let {a:vt}netrw_pluskeep = @+
endif
sil! let {a:vt}netrw_slashkeep= @/
" call Decho("(s:NetrwOptionsSave) lines=".&lines)
" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand(""))
" call Dret("s:NetrwOptionsSave : tab#".tabpagenr()." win#".winnr())
endfun
" ---------------------------------------------------------------------
" s:NetrwOptionsSafe: sets options to help netrw do its job {{{2
" Use s:NetrwSaveOptions() to save user settings
" Use s:NetrwOptionsRestore() to restore user settings
fun! s:NetrwOptionsSafe(islocal)
" call Dfunc("s:NetrwOptionsSafe(islocal=".a:islocal.") win#".winnr()." buf#".bufnr("%")."<".bufname(bufnr("%"))."> winnr($)=".winnr("$"))
" call Decho("win#".winnr()."'s ft=".&ft,'~'.expand(""))
" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand(""))
if exists("+acd") | call s:NetrwSetSafeSetting("&l:acd",0)|endif
call s:NetrwSetSafeSetting("&l:ai",0)
call s:NetrwSetSafeSetting("&l:aw",0)
call s:NetrwSetSafeSetting("&l:bl",0)
call s:NetrwSetSafeSetting("&l:bomb",0)
if a:islocal
call s:NetrwSetSafeSetting("&l:bt","nofile")
else
call s:NetrwSetSafeSetting("&l:bt","acwrite")
endif
call s:NetrwSetSafeSetting("&l:ci",0)
call s:NetrwSetSafeSetting("&l:cin",0)
if g:netrw_fastbrowse > a:islocal
call s:NetrwSetSafeSetting("&l:bh","hide")
else
call s:NetrwSetSafeSetting("&l:bh","delete")
endif
call s:NetrwSetSafeSetting("&l:cino","")
call s:NetrwSetSafeSetting("&l:com","")
if &cpo =~ 'a' | call s:NetrwSetSafeSetting("&cpo",substitute(&cpo,'a','','g')) | endif
if &cpo =~ 'A' | call s:NetrwSetSafeSetting("&cpo",substitute(&cpo,'A','','g')) | endif
setl fo=nroql2
if &go =~ 'a' | set go-=a | endif
if &go =~ 'A' | set go-=A | endif
if &go =~ 'P' | set go-=P | endif
call s:NetrwSetSafeSetting("&l:hid",0)
call s:NetrwSetSafeSetting("&l:im",0)
setl isk+=@ isk+=* isk+=/
call s:NetrwSetSafeSetting("&l:magic",1)
if g:netrw_use_noswf
call s:NetrwSetSafeSetting("swf",0)
endif
call s:NetrwSetSafeSetting("&l:report",10000)
call s:NetrwSetSafeSetting("&l:sel","inclusive")
call s:NetrwSetSafeSetting("&l:spell",0)
call s:NetrwSetSafeSetting("&l:tw",0)
call s:NetrwSetSafeSetting("&l:wig","")
setl cedit&
" set up cuc and cul based on g:netrw_cursor and listing style
" COMBAK -- cuc cul related
call s:NetrwCursor(0)
" allow the user to override safe options
" call Decho("ft<".&ft."> ei=".&ei,'~'.expand(""))
if &ft == "netrw"
" call Decho("do any netrw FileType autocmds (doau FileType netrw)",'~'.expand(""))
keepalt NetrwKeepj doau FileType netrw
endif
" call Decho("fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist")." bh=".&l:bh." bt<".&bt.">",'~'.expand(""))
" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand(""))
" call Dret("s:NetrwOptionsSafe")
endfun
" ---------------------------------------------------------------------
" s:NetrwOptionsRestore: restore options (based on prior s:NetrwOptionsSave) {{{2
fun! s:NetrwOptionsRestore(vt)
" call Dfunc("s:NetrwOptionsRestore(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> winnr($)=".winnr("$"))
" call Decho("(s:NetrwOptionsRestore) lines=".&lines)
" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand(""))
if !exists("{a:vt}netrw_optionsave")
" call Decho("case ".a:vt."netrw_optionsave : doesn't exist",'~'.expand(""))
" filereadable() returns zero for remote files (e.g. scp://localhost//etc/fstab)
if filereadable(expand("%")) || expand("%") =~# '^\w\+://\f\+/'
" call Decho("..doing filetype detect anyway")
filetype detect
" call Decho("..settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand(""))
else
setl ft=netrw
endif
" call Decho("..ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand(""))
" call Dret("s:NetrwOptionsRestore : ".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("g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd,'~'.expand(""))
let curdir = getcwd()
let &l:acd = {a:vt}netrw_acdkeep
unlet {a:vt}netrw_acdkeep
if &l:acd
call s:NetrwLcd(curdir)
endif
endif
endif
" call Decho("(s:NetrwOptionsRestore) #1 lines=".&lines)
call s:NetrwRestoreSetting(a:vt."netrw_aikeep","&l:ai")
call s:NetrwRestoreSetting(a:vt."netrw_awkeep","&l:aw")
call s:NetrwRestoreSetting(a:vt."netrw_blkeep","&l:bl")
call s:NetrwRestoreSetting(a:vt."netrw_btkeep","&l:bt")
call s:NetrwRestoreSetting(a:vt."netrw_bombkeep","&l:bomb")
" call Decho("(s:NetrwOptionsRestore) #2 lines=".&lines)
call s:NetrwRestoreSetting(a:vt."netrw_cedit","&cedit")
call s:NetrwRestoreSetting(a:vt."netrw_cikeep","&l:ci")
call s:NetrwRestoreSetting(a:vt."netrw_cinkeep","&l:cin")
call s:NetrwRestoreSetting(a:vt."netrw_cinokeep","&l:cino")
call s:NetrwRestoreSetting(a:vt."netrw_comkeep","&l:com")
" call Decho("(s:NetrwOptionsRestore) #3 lines=".&lines)
call s:NetrwRestoreSetting(a:vt."netrw_cpokeep","&l:cpo")
call s:NetrwRestoreSetting(a:vt."netrw_diffkeep","&l:diff")
call s:NetrwRestoreSetting(a:vt."netrw_fenkeep","&l:fen")
if exists("g:netrw_ffkeep") && g:netrw_ffkeep
call s:NetrwRestoreSetting(a:vt."netrw_ffkeep")","&l:ff")
endif
" call Decho("(s:NetrwOptionsRestore) #4 lines=".&lines)
call s:NetrwRestoreSetting(a:vt."netrw_fokeep" ,"&l:fo")
call s:NetrwRestoreSetting(a:vt."netrw_gdkeep" ,"&l:gd")
call s:NetrwRestoreSetting(a:vt."netrw_gokeep" ,"&go")
call s:NetrwRestoreSetting(a:vt."netrw_hidkeep" ,"&l:hidden")
" call Decho("(s:NetrwOptionsRestore) #5 lines=".&lines)
call s:NetrwRestoreSetting(a:vt."netrw_imkeep" ,"&l:im")
call s:NetrwRestoreSetting(a:vt."netrw_iskkeep" ,"&l:isk")
" call Decho("(s:NetrwOptionsRestore) #6 lines=".&lines)
call s:NetrwRestoreSetting(a:vt."netrw_lines" ,"&lines")
" call Decho("(s:NetrwOptionsRestore) #7 lines=".&lines)
call s:NetrwRestoreSetting(a:vt."netrw_lskeep" ,"&l:ls")
call s:NetrwRestoreSetting(a:vt."netrw_makeep" ,"&l:ma")
call s:NetrwRestoreSetting(a:vt."netrw_magickeep","&l:magic")
call s:NetrwRestoreSetting(a:vt."netrw_modkeep" ,"&l:mod")
call s:NetrwRestoreSetting(a:vt."netrw_nukeep" ,"&l:nu")
" call Decho("(s:NetrwOptionsRestore) #8 lines=".&lines)
call s:NetrwRestoreSetting(a:vt."netrw_rnukeep" ,"&l:rnu")
call s:NetrwRestoreSetting(a:vt."netrw_repkeep" ,"&l:report")
call s:NetrwRestoreSetting(a:vt."netrw_rokeep" ,"&l:ro")
call s:NetrwRestoreSetting(a:vt."netrw_selkeep" ,"&l:sel")
" call Decho("(s:NetrwOptionsRestore) #9 lines=".&lines)
call s:NetrwRestoreSetting(a:vt."netrw_spellkeep","&l:spell")
call s:NetrwRestoreSetting(a:vt."netrw_twkeep" ,"&l:tw")
call s:NetrwRestoreSetting(a:vt."netrw_wigkeep" ,"&l:wig")
call s:NetrwRestoreSetting(a:vt."netrw_wrapkeep" ,"&l:wrap")
call s:NetrwRestoreSetting(a:vt."netrw_writekeep","&l:write")
" call Decho("(s:NetrwOptionsRestore) #10 lines=".&lines)
call s:NetrwRestoreSetting("s:yykeep","@@")
" former problem: start with liststyle=0; press : result, following line resets l:ts.
" Fixed; in s:PerformListing, when w:netrw_liststyle is s:LONGLIST, will use a printf to pad filename with spaces
" rather than by appending a tab which previously was using "&ts" to set the desired spacing. (Sep 28, 2018)
call s:NetrwRestoreSetting(a:vt."netrw_tskeep","&l:ts")
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
setl directory=
unlet {a:vt}netrw_swfkeep
elseif &l:swf != {a:vt}netrw_swfkeep
if !g:netrw_use_noswf
" following line causes a Press ENTER in windows -- can't seem to work around it!!!
sil! let &l:swf= {a:vt}netrw_swfkeep
endif
unlet {a:vt}netrw_swfkeep
endif
endif
if exists("{a:vt}netrw_dirkeep") && isdirectory(s:NetrwFile({a:vt}netrw_dirkeep)) && g:netrw_keepdir
let dirkeep = substitute({a:vt}netrw_dirkeep,'\\','/','g')
if exists("{a:vt}netrw_dirkeep")
call s:NetrwLcd(dirkeep)
unlet {a:vt}netrw_dirkeep
endif
endif
if has("clipboard") && g:netrw_clipboard
" call Decho("has clipboard",'~'.expand(""))
call s:NetrwRestoreSetting(a:vt."netrw_starkeep","@*")
call s:NetrwRestoreSetting(a:vt."netrw_pluskeep","@+")
endif
call s:NetrwRestoreSetting(a:vt."netrw_slashkeep","@/")
" call Decho("g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd,'~'.expand(""))
" call Decho("fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist"),'~'.expand(""))
" call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand(""))
" call Decho("diff=".&l:diff." win#".winnr()." w:netrw_diffkeep=".(exists("w:netrw_diffkeep")? w:netrw_diffkeep : "doesn't exist"),'~'.expand(""))
" call Decho("ts=".&l:ts,'~'.expand(""))
" Moved the filetype detect here from NetrwGetFile() because remote files
" were having their filetype detect-generated settings overwritten by
" NetrwOptionRestore.
if &ft != "netrw"
" call Decho("before: filetype detect (ft=".&ft.")",'~'.expand(""))
filetype detect
" call Decho("after : filetype detect (ft=".&ft.")",'~'.expand(""))
endif
" call Decho("(s:NetrwOptionsRestore) lines=".&lines)
" call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand(""))
" call Dret("s:NetrwOptionsRestore : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> modified=".&modified." modifiable=".&modifiable." readonly=".&readonly)
endfun
" ---------------------------------------------------------------------
" s:NetrwSetSafeSetting: sets an option to a safe setting {{{2
" but only when the options' value and the safe setting differ
" Doing this means that netrw will not come up as having changed a
" setting last when it really didn't actually change it.
"
" Called from s:NetrwOptionsSafe
" ex. call s:NetrwSetSafeSetting("&l:sel","inclusive")
fun! s:NetrwSetSafeSetting(setting,safesetting)
" call Dfunc("s:NetrwSetSafeSetting(setting<".a:setting."> safesetting<".a:safesetting.">)")
if a:setting =~ '^&'
" call Decho("fyi: a:setting starts with &")
exe "let settingval= ".a:setting
" call Decho("fyi: settingval<".settingval.">")
if settingval != a:safesetting
" call Decho("set setting<".a:setting."> to option value<".a:safesetting.">")
if type(a:safesetting) == 0
exe "let ".a:setting."=".a:safesetting
elseif type(a:safesetting) == 1
exe "let ".a:setting."= '".a:safesetting."'"
else
call netrw#ErrorMsg(s:ERROR,"(s:NetrwRestoreSetting) doesn't know how to restore ".a:setting." with a safesetting of type#".type(a:safesetting),105)
endif
endif
endif
" call Dret("s:NetrwSetSafeSetting")
endfun
" ------------------------------------------------------------------------
" s:NetrwRestoreSetting: restores specified setting using associated keepvar, {{{2
" but only if the setting value differs from the associated keepvar.
" Doing this means that netrw will not come up as having changed a
" setting last when it really didn't actually change it.
"
" Used by s:NetrwOptionsRestore() to restore each netrw-sensitive setting
" keepvars are set up by s:NetrwOptionsSave
fun! s:NetrwRestoreSetting(keepvar,setting)
""" call Dfunc("s:NetrwRestoreSetting(a:keepvar<".a:keepvar."> a:setting<".a:setting.">)")
" typically called from s:NetrwOptionsRestore
" call s:NetrwRestoreSettings(keep-option-variable-name,'associated-option')
" ex. call s:NetrwRestoreSetting(a:vt."netrw_selkeep","&l:sel")
" Restores option (but only if different) from a:keepvar
if exists(a:keepvar)
exe "let keepvarval= ".a:keepvar
exe "let setting= ".a:setting
"" call Decho("fyi: a:keepvar<".a:keepvar."> exists")
"" call Decho("fyi: keepvarval=".keepvarval)
"" call Decho("fyi: a:setting<".a:setting."> setting<".setting.">")
if setting != keepvarval
"" call Decho("restore setting<".a:setting."> (currently=".setting.") to keepvarval<".keepvarval.">")
if type(a:setting) == 0
exe "let ".a:setting."= ".keepvarval
elseif type(a:setting) == 1
exe "let ".a:setting."= '".substitute(keepvarval,"'","''","g")."'"
else
call netrw#ErrorMsg(s:ERROR,"(s:NetrwRestoreSetting) doesn't know how to restore ".a:keepvar." with a setting of type#".type(a:setting),105)
endif
endif
exe "unlet ".a:keepvar
endif
"" call Dret("s:NetrwRestoreSetting")
endfun
" ---------------------------------------------------------------------
" NetrwStatusLine: {{{2
fun! NetrwStatusLine()
" vvv NetrwStatusLine() debugging vvv
" let g:stlmsg=""
" if !exists("w:netrw_explore_bufnr")
" let g:stlmsg="!X"
" elseif w:netrw_explore_bufnr != bufnr("%")
" let g:stlmsg="explore_bufnr!=".bufnr("%")
" endif
" if !exists("w:netrw_explore_line")
" let g:stlmsg=" !X"
" elseif w:netrw_explore_line != line(".")
" let g:stlmsg=" explore_line!={line(.)<".line(".").">"
" endif
" if !exists("w:netrw_explore_list")
" let g:stlmsg=" !X"
" endif
" ^^^ NetrwStatusLine() debugging ^^^
if !exists("w:netrw_explore_bufnr") || w:netrw_explore_bufnr != bufnr("%") || !exists("w:netrw_explore_line") || w:netrw_explore_line != line(".") || !exists("w:netrw_explore_list")
" restore user's status line
let &l:stl = s:netrw_users_stl
let &laststatus = s:netrw_users_ls
if exists("w:netrw_explore_bufnr")|unlet w:netrw_explore_bufnr|endif
if exists("w:netrw_explore_line") |unlet w:netrw_explore_line |endif
return ""
else
return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen
endif
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.((a:0 > 0)? " a:1<".a:1.">" : ""))
" NetRead: save options {{{3
call s:NetrwOptionsSave("w:")
call s:NetrwOptionsSafe(0)
call s:RestoreCursorline()
" NetrwSafeOptions sets a buffer up for a netrw listing, which includes buflisting off.
" However, this setting is not wanted for a remote editing session. The buffer should be "nofile", still.
setl bl
" call Decho("buf#".bufnr("%")."<".bufname("%")."> bl=".&bl." bt=".&bt." bh=".&bh,'~'.expand(""))
" 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,'~'.expand(""))
" 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 . ">",'~'.expand(""))
let choice = b:netrw_lastfile
let ichoice= ichoice + 1
else
exe "let choice= a:" . ichoice
" call Decho("no lastfile: choice<" . choice . ">",'~'.expand(""))
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 file:///path uses elinks'
echomsg ':Nread https://[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",'~'.expand(""))
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 . ">",'~'.expand(""))
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 Dret("netrw#NetRead : unsupported method")
return
endif
let tmpfile= s:GetTempfile(b:netrw_fname) " apply correct suffix
" Check whether or not NetrwBrowse() should be handling this request
" call Decho("checking if NetrwBrowse() should handle choice<".choice."> with netrw_list_cmd<".g:netrw_list_cmd.">",'~'.expand(""))
if choice =~ "^.*[\/]$" && b:netrw_method != 5 && choice !~ '^https\=://'
" call Decho("yes, choice matches '^.*[\/]$'",'~'.expand(""))
NetrwKeepj 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)",'~'.expand(""))
" ER: nothing done with g:netrw_uid yet?
" ER: on Win2K" rcp machine[.user]:file tmpfile
" ER: when 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 s:NetrwExe(s:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".s:ShellEscape(uid_machine.":".b:netrw_fname,1)." ".s: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)",'~'.expand(""))
let netrw_fname= b:netrw_fname
NetrwKeepj call s:SaveBufVars()|new|NetrwKeepj call s:RestoreBufVars()
let filtbuf= bufnr("%")
setl ff=unix
NetrwKeepj put =g:netrw_ftpmode
" call Decho("filter input: ".getline(line("$")),'~'.expand(""))
if exists("g:netrw_ftpextracmd")
NetrwKeepj put =g:netrw_ftpextracmd
" call Decho("filter input: ".getline(line("$")),'~'.expand(""))
endif
call setline(line("$")+1,'get "'.netrw_fname.'" '.tmpfile)
" call Decho("filter input: ".getline(line("$")),'~'.expand(""))
if exists("g:netrw_port") && g:netrw_port != ""
call s:NetrwExe(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".s:ShellEscape(g:netrw_machine,1)." ".s:ShellEscape(g:netrw_port,1))
else
call s:NetrwExe(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".s: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
setl debug=msg
NetrwKeepj call netrw#ErrorMsg(s:ERROR,getline(1),4)
let &debug = debugkeep
endif
call s:SaveBufVars()
keepj 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)",'~'.expand(""))
let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
NetrwKeepj call s:SaveBufVars()|new|NetrwKeepj call s:RestoreBufVars()
let filtbuf= bufnr("%")
setl ff=unix
if exists("g:netrw_port") && g:netrw_port != ""
NetrwKeepj put ='open '.g:netrw_machine.' '.g:netrw_port
" call Decho("filter input: ".getline('.'),'~'.expand(""))
else
NetrwKeepj put ='open '.g:netrw_machine
" call Decho("filter input: ".getline('.'),'~'.expand(""))
endif
if exists("g:netrw_uid") && g:netrw_uid != ""
if exists("g:netrw_ftp") && g:netrw_ftp == 1
NetrwKeepj put =g:netrw_uid
" call Decho("filter input: ".getline('.'),'~'.expand(""))
if exists("s:netrw_passwd")
NetrwKeepj put ='\"'.s:netrw_passwd.'\"'
endif
" call Decho("filter input: ".getline('.'),'~'.expand(""))
elseif exists("s:netrw_passwd")
NetrwKeepj put ='user \"'.g:netrw_uid.'\" \"'.s:netrw_passwd.'\"'
" call Decho("filter input: ".getline('.'),'~'.expand(""))
endif
endif
if exists("g:netrw_ftpmode") && g:netrw_ftpmode != ""
NetrwKeepj put =g:netrw_ftpmode
" call Decho("filter input: ".getline('.'),'~'.expand(""))
endif
if exists("g:netrw_ftpextracmd")
NetrwKeepj put =g:netrw_ftpextracmd
" call Decho("filter input: ".getline('.'),'~'.expand(""))
endif
NetrwKeepj put ='get \"'.netrw_fname.'\" '.tmpfile
" call Decho("filter input: ".getline('.'),'~'.expand(""))
" 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
NetrwKeepj norm! 1G"_dd
call s:NetrwExe(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).">",'~'.expand(""))
if !exists("g:netrw_quiet")
call netrw#ErrorMsg(s:ERROR,getline(1),5)
endif
endif
call s:SaveBufVars()|keepj 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)",'~'.expand(""))
if exists("g:netrw_port") && g:netrw_port != ""
let useport= " ".g:netrw_scpport." ".g:netrw_port
else
let useport= ""
endif
" 'C' in 'C:\path\to\file' is handled as hostname on windows.
" This is workaround to avoid mis-handle windows local-path:
if g:netrw_scp_cmd =~ '^scp' && has("win32")
let tmpfile_get = substitute(tr(tmpfile, '\', '/'), '^\(\a\):[/\\]\(.*\)$', '/\1/\2', '')
else
let tmpfile_get = tmpfile
endif
call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".escape(s:ShellEscape(g:netrw_machine.":".b:netrw_fname,1),' ')." ".s:ShellEscape(tmpfile_get,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)",'~'.expand(""))
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.">)",'~'.expand(""))
if exists("g:netrw_http_xcmd")
call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_http_cmd." ".s:ShellEscape(b:netrw_http."://".g:netrw_machine.b:netrw_fname,1)." ".g:netrw_http_xcmd." ".s:ShellEscape(tmpfile,1))
else
call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_http_cmd." ".s:ShellEscape(tmpfile,1)." ".s:ShellEscape(b:netrw_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.">)",'~'.expand(""))
let netrw_html= substitute(b:netrw_fname,"#.*$","","")
let netrw_tag = substitute(b:netrw_fname,"^.*#","","")
" call Decho("netrw_html<".netrw_html.">",'~'.expand(""))
" call Decho("netrw_tag <".netrw_tag.">",'~'.expand(""))
call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_http_cmd." ".s:ShellEscape(tmpfile,1)." ".s:ShellEscape(b:netrw_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.'"/','~'.expand(""))
exe 'NetrwKeepj norm! 1G/<\s*a\s*name=\s*"'.netrw_tag.'"/'."\"
endif
let b:netrw_lastfile = choice
" call Decho("setl ro",'~'.expand(""))
setl ro nomod
".........................................
" NetRead: (dav) NetRead Method #6 {{{3
elseif b:netrw_method == 6
" call Decho("read via cadaver (method #6)",'~'.expand(""))
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 s:NetrwExe(s:netrw_silentxfer."!".g:netrw_dav_cmd." ".s:ShellEscape("dav://".g:netrw_machine.b:netrw_fname,1)." ".s: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
setl ff=unix
if exists("g:netrw_port") && g:netrw_port != ""
NetrwKeepj put ='open '.g:netrw_machine.' '.g:netrw_port
else
NetrwKeepj put ='open '.g:netrw_machine
endif
if exists("g:netrw_uid") && exists("s:netrw_passwd") && g:netrw_uid != ""
NetrwKeepj put ='user '.g:netrw_uid.' '.s:netrw_passwd
endif
NetrwKeepj put ='get '.netrw_fname.' '.tmpfile
NetrwKeepj put ='quit'
" perform cadaver operation:
NetrwKeepj norm! 1G"_dd
call s:NetrwExe(s:netrw_silentxfer."%!".g:netrw_dav_cmd)
keepj 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)",'~'.expand(""))
call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_rsync_cmd." ".s:ShellEscape(g:netrw_machine.g:netrw_rsync_sep.b:netrw_fname,1)." ".s: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)",'~'.expand(""))
if g:netrw_fetch_cmd == ""
if !exists("g:netrw_quiet")
NetrwKeepj 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,'~'.expand(""))
if exists("g:netrw_uid") && g:netrw_uid != "" && exists("s:netrw_passwd") && s:netrw_passwd != ""
call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_fetch_cmd." ".s:ShellEscape(tmpfile,1)." ".s:ShellEscape(netrw_option."://".g:netrw_uid.':'.s:netrw_passwd.'@'.g:netrw_machine."/".b:netrw_fname,1))
else
call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_fetch_cmd." ".s:ShellEscape(tmpfile,1)." ".s: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("setl ro",'~'.expand(""))
setl ro nomod
".........................................
" NetRead: (sftp) NetRead Method #9 {{{3
elseif b:netrw_method == 9
" call Decho("read via sftp (method #9)",'~'.expand(""))
call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_sftp_cmd." ".s:ShellEscape(g:netrw_machine.":".b:netrw_fname,1)." ".tmpfile)
let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)
let b:netrw_lastfile = choice
".........................................
" NetRead: (file) NetRead Method #10 {{{3
elseif b:netrw_method == 10 && exists("g:netrw_file_cmd")
" " call Decho("read via ".b:netrw_file_cmd." (method #10)",'~'.expand("