" 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)
-" Mar 03, 2025 : max errnum currently is 107
-function! netrw#ErrorMsg(level, msg, errnum)
- if has('nvim')
- call v:lua.vim.notify(a:msg, a:level + 2)
- else
- call netrw#msg#Notify(a:level, a:msg)
- endif
-endfunction
-
" s:NetrwInit: initializes variables if they haven't been defined {{{2
" Loosely, varname = value.
fun s:NetrwInit(varname,value)
call s:NetrwInit("s:MAXLIST" ,4)
endif
-let s:NOTE = 0
-let s:WARNING = 1
-let s:ERROR = 2
-let g:_netrw_log = {'NOTE': 0, 'WARN': 1, 'ERROR': 2}
-
let s:has_balloon = !has('nvim') &&
\ has("balloon_eval") &&
\ has("syntax") &&
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
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
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")
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
if s:has_balloon
function! netrw#BalloonHelp()
- " popup error window is still showing
- " s:pouperr_id and s:popuperr_text are set up in netrw#ErrorMsg()
if exists("s:popuperr_id") && popup_getpos(s:popuperr_id) != {}
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
if indx == -1
" Nexplore
if !exists("w:netrw_explore_list") " sanity check
- NetrwKeepj call netrw#ErrorMsg(s:WARNING,"using Nexplore or <s-down> improperly; see help for netrw-starstar",40)
+ call netrw#msg#Notify('WARNING', 'using Nexplore or <s-down> improperly; see help for netrw-starstar')
if has("clipboard") && g:netrw_clipboard
if @* != keepregstar | sil! let @* = keepregstar | endif
if @+ != keepregplus | sil! let @+ = keepregplus | endif
elseif indx == -2
" Pexplore
if !exists("w:netrw_explore_list") " sanity check
- NetrwKeepj call netrw#ErrorMsg(s:WARNING,"using Pexplore or <s-up> improperly; see help for netrw-starstar",41)
+ call netrw#msg#Notify('WARNING', 'using Pexplore or <s-up> improperly; see help for netrw-starstar')
if has("clipboard") && g:netrw_clipboard
if @* != keepregstar | sil! let @* = keepregstar | endif
if @+ != keepregplus | sil! let @+ = keepregplus | endif
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 netrw#msg#Notify('WARNING', printf("no match with pattern<%s>", pattern))
return
endtry
let w:netrw_explore_list = s:NetrwExploreListUniq(map(getqflist(),'bufname(v:val.bufnr)'))
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)
+ call netrw#msg#Notify('WARNING', printf('no files matched pattern<%s>', pattern))
if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif
if has("clipboard") && g:netrw_clipboard
if @* != keepregstar | sil! let @* = keepregstar | endif
let w:netrw_explore_listlen = len(w:netrw_explore_list)
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)
+ call netrw#msg#Notify('WARNING', 'no files matched')
if has("clipboard") && g:netrw_clipboard
if @* != keepregstar | sil! let @* = keepregstar | endif
if @+ != keepregplus | sil! let @+ = keepregplus | endif
if indx >= w:netrw_explore_listlen || indx < 0
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)
+ call netrw#msg#Notify('NOTE', 'no more files match Explore pattern')
endif
exe "let dirfile= w:netrw_explore_list[".indx."]"
else
if !exists("g:netrw_quiet")
- keepalt NetrwKeepj call netrw#ErrorMsg(s:WARNING,"your vim needs the +path_extra feature for Exploring with **!",44)
+ call netrw#msg#Notify('WARNING', 'your vim needs the +path_extra feature for Exploring with **!')
endif
if has("clipboard") && g:netrw_clipboard
if @* != keepregstar | sil! let @* = keepregstar | endif
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 netrw#msg#Notify('ERROR', 'attempting to use NetrwObtain on something not a filename or a list')
return
endif
if a:0 > 0
for fname in fnamelist
call system(g:netrw_localcopycmd.g:netrw_localcopycmdopt." ".netrw#os#Escape(fname)." ".netrw#os#Escape(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 netrw#msg#Notify('WARNING', printf('consider setting g:netrw_localcopycmd<%s> to something that works', g:netrw_localcopycmd))
return
endif
endfor
let filelist= join(map(deepcopy(fnamelist),"netrw#os#Escape(v:val)"))
call system(g:netrw_localcopycmd.g:netrw_localcopycmdopt." ".filelist." ".netrw#os#Escape(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 netrw#msg#Notify('WARNING', printf('consider setting g:netrw_localcopycmd<%s> to something that works', g:netrw_localcopycmd))
return
endif
endif
elseif !exists("b:netrw_curdir")
- call netrw#ErrorMsg(s:ERROR,"local browsing directory doesn't exist!",36)
+ call netrw#msg#Notify('ERROR', "local browsing directory doesn't exist!")
else
- call netrw#ErrorMsg(s:WARNING,"local browsing directory and current directory are identical",37)
+ call netrw#msg#Notify('WARNING', 'local browsing directory and current directory are identical')
endif
else
endif
call s:NetrwMethod(b:netrw_curdir)
if !s:NetrwValidateHostname(g:netrw_machine)
- call netrw#ErrorMsg(s:ERROR,"Rejecting invalid hostname: <" .. g:netrw_machine .. ">",107)
+ call netrw#msg#Notify('ERROR', 'Rejecting invalid hostname: <%s>', g:netrw_machine)
return
endif
if getline(1) !~ "^$" && !exists("g:netrw_quiet") && getline(1) !~ '^Trying '
let debugkeep= &debug
setl debug=msg
- call netrw#ErrorMsg(s:ERROR,getline(1),4)
+ call netrw#msg#Notify('ERROR', getline(1))
let &debug= debugkeep
endif
" If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
if getline(1) !~ "^$"
if !exists("g:netrw_quiet")
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,getline(1),5)
+ call netrw#msg#Notify('ERROR', getline(1))
endif
endif
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)
+ call netrw#msg#Notify('ERROR', 'current protocol not supported for obtaining file')
endif
return
endif
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)
+ call netrw#msg#Notify('ERROR', printf("(s:NetrwRestoreSetting) doesn't know how to restore %s with a safesetting of type#%s", a:setting, type(a:safesetting)))
endif
endif
endif
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)
+ call netrw#msg#Notify('ERROR', printf("(s:NetrwRestoreSetting) doesn't know how to restore %s with a setting of type#%s", a:keepvar, type(a:setting)))
endif
endif
let ichoice = ichoice + 1
if ichoice > a:0
if !exists("g:netrw_quiet")
- call netrw#ErrorMsg(s:ERROR,"Unbalanced string in filename '". wholechoice ."'",3)
+ call netrw#msg#Notify('ERROR', printf('Unbalanced string in filename "%s"', wholechoice))
endif
return
endif
return
endif
if !s:NetrwValidateHostname(g:netrw_machine)
- call netrw#ErrorMsg(s:ERROR,"Rejecting invalid hostname: <" .. g:netrw_machine .. ">",107)
+ call netrw#msg#Notify('ERROR', printf('Rejecting invalid hostname: <%s>', g:netrw_machine))
return
endif
let tmpfile= s:GetTempfile(b:netrw_fname) " apply correct suffix
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)
+ call netrw#msg#Notify('ERROR', getline(1))
let &debug = debugkeep
endif
call s:SaveBufVars()
" If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
if getline(1) !~ "^$"
if !exists("g:netrw_quiet")
- call netrw#ErrorMsg(s:ERROR,getline(1),5)
+ call netrw#msg#Notify('ERROR', getline(1))
endif
endif
call s:SaveBufVars()|keepj bd!|call s:RestoreBufVars()
elseif b:netrw_method == 5
if g:netrw_http_cmd == ""
if !exists("g:netrw_quiet")
- call netrw#ErrorMsg(s:ERROR,"neither the wget nor the fetch command is available",6)
+ call netrw#msg#Notify('ERROR', 'neither the wget nor the fetch command is available')
endif
return
endif
elseif b:netrw_method == 6
if !executable(g:netrw_dav_cmd)
- call netrw#ErrorMsg(s:ERROR,g:netrw_dav_cmd." is not executable",73)
+ call netrw#msg#Notify('ERROR', printf('%s is not executable', g:netrw_dav_cmd))
return
endif
if g:netrw_dav_cmd =~ "curl"
elseif b:netrw_method == 8
if g:netrw_fetch_cmd == ""
if !exists("g:netrw_quiet")
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,"fetch command not available",7)
+ call netrw#msg#Notify('ERROR', "fetch command not available")
endif
return
endif
".........................................
" NetRead: Complain {{{3
else
- call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . choice . ">",8)
+ call netrw#msg#Notify('WARNING', printf('unable to comply with your request<%s>', choice))
endif
endwhile
let ichoice = ichoice + 1
if choice > a:0
if !exists("g:netrw_quiet")
- call netrw#ErrorMsg(s:ERROR,"Unbalanced string in filename '". wholechoice ."'",13)
+ call netrw#msg#Notify('ERROR', printf('Unbalanced string in filename "%s"', wholechoice))
endif
return
endif
return
endif
if !s:NetrwValidateHostname(g:netrw_machine)
- call netrw#ErrorMsg(s:ERROR,"Rejecting invalid hostname: <" .. g:netrw_machine .. ">",107)
+ call netrw#msg#Notify('ERROR', printf('Rejecting invalid hostname: <%s>', g:netrw_machine))
return
endif
" If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
if getline(1) !~ "^$"
if !exists("g:netrw_quiet")
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,getline(1),14)
+ call netrw#msg#Notify('ERROR', getline(1))
endif
let mod=1
endif
" If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
if getline(1) !~ "^$"
if !exists("g:netrw_quiet")
- call netrw#ErrorMsg(s:ERROR,getline(1),15)
+ call netrw#msg#Notify('ERROR', getline(1))
endif
let mod=1
endif
let url= g:netrw_choice
call netrw#os#Execute(s:netrw_silentxfer."!".g:netrw_http_put_cmd." ".netrw#os#Escape(tmpfile,1)." ".netrw#os#Escape(url,1) )
elseif !exists("g:netrw_quiet")
- call netrw#ErrorMsg(s:ERROR,"can't write to http using <".g:netrw_http_put_cmd.">",16)
+ call netrw#msg#Notify('ERROR', printf("can't write to http using <%s>", g:netrw_http_put_cmd))
endif
".........................................
".........................................
" NetWrite: Complain {{{3
else
- call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . choice . ">",17)
+ call netrw#msg#Notify('WARNING', printf('unable to comply with your request<%s>', choice))
let leavemod= 1
endif
endwhile
if s:FileReadable(s:netrw_tmpfile)
exe "so ".fnameescape(s:netrw_tmpfile)
if delete(s:netrw_tmpfile)
- call netrw#ErrorMsg(s:ERROR,"unable to delete directory <".s:netrw_tmpfile.">!",103)
+ call netrw#msg#Notify('ERROR', 'unable to delete directory <%s>', s:netrw_tmpfile)
endif
unlet s:netrw_tmpfile
else
- call netrw#ErrorMsg(s:ERROR,"unable to source <".a:{i}.">!",48)
+ call netrw#msg#Notify('ERROR', printf('unable to source <%s>!', a:{i}))
endif
let i= i + 1
endwhile
" normally the cursor is left in the message window.
" However, here this results in the directory being listed in the message window, which is not wanted.
let netrwbuf= bufnr("%")
- call netrw#ErrorMsg(s:ERROR,"sorry, ".a:1." doesn't seem to be a directory!",95)
+ call netrw#msg#Notify('ERROR', printf("sorry, %s doesn't seem to be a directory!", a:1))
exe bufwinnr(netrwbuf)."wincmd w"
let treedir = "."
let s:netrw_treetop = getcwd()
elseif !&ma
" attempting to read a file after the current line in the file, but the buffer is not modifiable
- NetrwKeepj call netrw#ErrorMsg(s:WARNING,"attempt to read<".a:tfile."> into a non-modifiable buffer!",94)
+ call netrw#msg#Notify('WARNING', printf('attempt to read<%s> into a non-modifiable buffer!', a:tfile))
return
elseif s:FileReadable(a:tfile)
else
" not readable
- NetrwKeepj call netrw#ErrorMsg(s:WARNING,"file <".a:tfile."> not readable",9)
+ call netrw#msg#Notify('WARNING', printf('file <%s> not readable', a:tfile))
return
endif
" sanity check: choice should have at least three slashes in it
if strlen(substitute(a:choice,'[^/]','','g')) < 3
- call netrw#ErrorMsg(s:ERROR,"not a netrw-style url; netrw uses protocol://[user@]hostname[:port]/[path])",78)
+ call netrw#msg#Notify('ERROR', 'not a netrw-style url; netrw uses protocol://[user@]hostname[:port]/[path])')
let b:netrw_method = -1
return
endif
" Cannot Determine Method {{{3
else
if !exists("g:netrw_quiet")
- call netrw#ErrorMsg(s:WARNING,"cannot determine method (format: protocol://[user@]hostname[:port]/[path])",45)
+ call netrw#msg#Notify('WARNING', 'cannot determine method (format: protocol://[user@]hostname[:port]/[path])')
endif
let b:netrw_method = -1
endif
return
endif
if !exists("*shellescape")
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,"netrw can't run -- your vim is missing shellescape()",69)
+ call netrw#msg#Notify('ERROR', "netrw can't run -- your vim is missing shellescape()")
return
endif
if !exists("*fnameescape")
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,"netrw can't run -- your vim is missing fnameescape()",70)
+ call netrw#msg#Notify('ERROR', "netrw can't run -- your vim is missing fnameescape()")
return
endif
let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/]\+\)/\(.*\)$'
if dirname !~ dirpat
if !exists("g:netrw_quiet")
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,"netrw doesn't understand your dirname<".dirname.">",20)
+ call netrw#msg#Notify('ERROR', printf("netrw doesn't understand your dirname<%s>", dirname))
endif
NetrwKeepj call s:NetrwOptionsRestore("w:")
setl noma nomod nowrap
let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge')
else
- NetrwKeepj call netrw#ErrorMsg(s:WARNING,"bad value for g:netrw_liststyle (=".w:netrw_liststyle.")",46)
+ call netrw#msg#Notify('WARNING', printf('bad value for g:netrw_liststyle (=%s)', w:netrw_liststyle))
let g:netrw_liststyle = s:THINLIST
let w:netrw_liststyle = g:netrw_liststyle
let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge')
fun! s:NetrwBrowseChgDir(islocal,newdir,cursor,...)
let ykeep= @@
if !exists("b:netrw_curdir")
- " Don't try to change-directory: this can happen, for example, when netrw#ErrorMsg has been called
- " and the current window is the NetrwMessage window.
let @@= ykeep
return
endif
let g:netrw_hide=(g:netrw_hide+1)%3
exe "NetrwKeepj norm! 0"
if g:netrw_hide && g:netrw_list_hide == ""
- NetrwKeepj call netrw#ErrorMsg(s:WARNING,"your hiding list is empty!",49)
+ call netrw#msg#Notify('WARNING', 'your hiding list is empty!')
let @@= ykeep
return
endif
let fullnewdir= b:netrw_curdir.'/'.newdirname
if isdirectory(s:NetrwFile(fullnewdir))
if !exists("g:netrw_quiet")
- NetrwKeepj call netrw#ErrorMsg(s:WARNING,"<".newdirname."> is already a directory!",24)
+ call netrw#msg#Notify('WARNING', printf('<%s> is already a directory!', newdirname))
endif
let @@= ykeep
return
endif
if s:FileReadable(fullnewdir)
if !exists("g:netrw_quiet")
- NetrwKeepj call netrw#ErrorMsg(s:WARNING,"<".newdirname."> is already a file!",25)
+ call netrw#msg#Notify('WARNING', printf('<%s> is already a file!', newdirname))
endif
let @@= ykeep
return
call netrw#os#Execute("sil! !".g:netrw_localmkdir.g:netrw_localmkdiropt.' '.netrw#os#Escape(newdirname,1))
if v:shell_error != 0
let @@= ykeep
- call netrw#ErrorMsg(s:ERROR,"consider setting g:netrw_localmkdir<".g:netrw_localmkdir."> to something that works",80)
+ call netrw#msg#Notify('ERROR', printf('consider setting g:netrw_localmkdir<%s> to something that works', g:netrw_localmkdir))
return
endif
if !g:netrw_keepdir
call s:NetrwRefresh(1,s:NetrwBrowseChgDir(1,'./',0))
call winrestview(svpos)
elseif !exists("g:netrw_quiet")
- call netrw#ErrorMsg(s:ERROR,"unable to make directory<".newdirname.">",26)
+ call netrw#msg#Notify('ERROR', printf('unable to make directory<%s>', newdirname))
endif
elseif !exists("b:netrw_method") || b:netrw_method == 4
NetrwKeepj call s:NetrwRefresh(0,s:NetrwBrowseChgDir(0,'./',0))
NetrwKeepj call winrestview(svpos)
elseif !exists("g:netrw_quiet")
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,"unable to make directory<".newdirname.">",27)
+ call netrw#msg#Notify('ERROR', printf('unable to make directory<%s>', newdirname))
endif
elseif b:netrw_method == 2
com! -nargs=* -complete=file -bang NetrwMB call s:NetrwBookmark(<bang>0,<f-args>)
com! -nargs=* NetrwC call s:NetrwSetChgwin(<q-args>)
- com! Rexplore if exists("w:netrw_rexlocal")|call s:NetrwRexplore(w:netrw_rexlocal,exists("w:netrw_rexdir")? w:netrw_rexdir : ".")|else|call netrw#ErrorMsg(s:WARNING,"win#".winnr()." not a former netrw window",79)|endif
+ com! Rexplore if exists("w:netrw_rexlocal")|call s:NetrwRexplore(w:netrw_rexlocal,exists("w:netrw_rexdir")? w:netrw_rexdir : ".")|else|call netrw#msg#Notify('WARNING', "win#".winnr()." not a former netrw window")|endif
if a:islocal
com! -buffer -nargs=+ -complete=file MF call s:NetrwMarkFiles(1,<f-args>)
else
" sanity check
if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr})
- NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66)
+ call netrw#msg#Notify('ERROR', 'there are no marked files in this window (:help netrw-mf)')
return
endif
endif
call system(exe." ".fname)
if v:shell_error
- NetrwKeepj call netrw#ErrorMsg(s:WARNING,"unable to apply<".exe."> to file<".fname.">",50)
+ call netrw#msg#Notify('WARNING', printf('unable to apply<%s> to file<%s>', exe, fname))
endif
else
let fname= netrw#os#Escape(b:netrw_curdir.fname,1)
" fname not a compressed file, so compress it
call system(netrw#fs#WinPath(g:netrw_compress)." ".netrw#os#Escape(netrw#fs#ComposePath(b:netrw_curdir,fname)))
if v:shell_error
- call netrw#ErrorMsg(s:WARNING,"consider setting g:netrw_compress<".g:netrw_compress."> to something that works",104)
+ call netrw#msg#Notify('WARNING', printf('consider setting g:netrw_compress<%s> to something that works', g:netrw_compress))
endif
else
" fname not a compressed file, so compress it
" sanity check
if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr})
- NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66)
+ call netrw#msg#Notify('ERROR', 'there are no marked files in this window (:help netrw-mf)')
return
endif
if !exists("s:netrwmftgt")
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,"your marked file target is empty! (:help netrw-mt)",67)
+ call netrw#msg#Notify('ERROR', 'your marked file target is empty! (:help netrw-mt)')
return 0
endif
if a:islocal && s:netrwmftgt_islocal
" Copy marked files, local directory to local directory
if !executable(g:netrw_localcopycmd)
- call netrw#ErrorMsg(s:ERROR,"g:netrw_localcopycmd<".g:netrw_localcopycmd."> not executable on your system, aborting",91)
+ call netrw#msg#Notify('ERROR', printf('g:netrw_localcopycmd<%s> not executable on your system, aborting', g:netrw_localcopycmd))
return
endif
call system(printf("%s %s '%s' '%s'", copycmd, copycmdopt, args, tgt))
if v:shell_error != 0
if exists("b:netrw_curdir") && b:netrw_curdir != getcwd() && g:netrw_keepdir
- call netrw#ErrorMsg(s:ERROR,"copy failed; perhaps due to vim's current directory<".getcwd()."> not matching netrw's (".b:netrw_curdir.") (see :help netrw-cd)",101)
+ call netrw#msg#Notify('ERROR', printf("copy failed; perhaps due to vim's current directory<%s> not matching netrw's (%s) (see :help netrw-cd)", getcwd(), b:netrw_curdir))
else
- call netrw#ErrorMsg(s:ERROR,"tried using g:netrw_localcopycmd<".g:netrw_localcopycmd.">; it doesn't work!",80)
+ call netrw#msg#Notify('ERROR', printf("tried using g:netrw_localcopycmd<%s>; it doesn't work!", g:netrw_localcopycmd))
endif
return 0
endif
else
call netrw#os#Execute("sil! !".g:netrw_localmkdir.g:netrw_localmkdiropt.' '.netrw#os#Escape(tmpdir,1))
if v:shell_error != 0
- call netrw#ErrorMsg(s:WARNING,"consider setting g:netrw_localmkdir<".g:netrw_localmkdir."> to something that works",80)
+ call netrw#msg#Notify('WARNING', printf("consider setting g:netrw_localmkdir<%s> to something that works", g:netrw_localmkdir))
return
endif
endif
return
endif
if delete(tmpdir,"d")
- call netrw#ErrorMsg(s:ERROR,"unable to delete directory <".tmpdir.">!",103)
+ call netrw#msg#Notify('ERROR', printf('unable to delete directory <%s>!', tmpdir))
endif
else
if s:NetrwLcd(curdir)
" sanity check
if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr})
- NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66)
+ call netrw#msg#Notify('ERROR', 'there are no marked files in this window (:help netrw-mf)')
return
endif
let curdir= s:NetrwGetCurdir(a:islocal)
" sanity check
if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr})
- NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66)
+ call netrw#msg#Notify('ERROR', 'there are no marked files in this window (:help netrw-mf)')
return
endif
endfor
echo "(use me to edit marked files)"
else
- call netrw#ErrorMsg(s:WARNING,"can't convert quickfix error list; its empty!",92)
+ call netrw#msg#Notify('WARNING', "can't convert quickfix error list; its empty!")
endif
endfun
" individually apply command to files, one at a time
" sanity check
if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr})
- NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66)
+ call netrw#msg#Notify('ERROR', 'there are no marked files in this window (:help netrw-mf)')
return
endif
let ret= s:RemoteSystem(xcmd)
endif
if v:shell_error < 0
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,"command<".xcmd."> failed, aborting",54)
+ call netrw#msg#Notify('ERROR', printf('command<%s> failed, aborting', xcmd))
break
else
if ret !=# ''
NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./',0))
NetrwKeepj call winrestview(svpos)
else
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,"no files marked!",59)
+ call netrw#msg#Notify('ERROR', 'no files marked!')
endif
else " apply command to global list of files, en bloc
if a:islocal
call system(cmd)
if v:shell_error < 0
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,"command<".xcmd."> failed, aborting",54)
+ call netrw#msg#Notify('ERROR', printf('command<%s> failed, aborting',xcmd))
endif
else
let ret= s:RemoteSystem(cmd)
NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./',0))
NetrwKeepj call winrestview(svpos)
else
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,"no files marked!",59)
+ call netrw#msg#Notify('ERROR', 'no files marked!')
endif
endfun
" sanity check
if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr})
- NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66)
+ call netrw#msg#Notify('ERROR', 'there are no marked files in this window (:help netrw-mf)')
return
endif
NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./',0))
NetrwKeepj call winrestview(svpos)
else
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,"no files marked!",59)
+ call netrw#msg#Notify('ERROR', 'no files marked!')
endif
endfun
NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./',0))
NetrwKeepj call winrestview(svpos)
else
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,"no files marked!",59)
+ call netrw#msg#Notify('ERROR', 'no files marked!')
endif
endfun
try
exe "NetrwKeepj noautocmd vimgrep".patbang." ".pat." ".netrwmarkfilelist
catch /^Vim\%((\a\+)\)\=:E480/
- NetrwKeepj call netrw#ErrorMsg(s:WARNING,"no match with pattern<".pat.">",76)
+ call netrw#msg#Notify('WARNING', printf('no match with pattern<%s>', pat))
return
endtry
echo "(use :cn, :cp to navigate, :Rex to return)"
" sanity check
if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr})
- NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66)
+ call netrw#msg#Notify('ERROR', 'there are no marked files in this window (:help netrw-mf)')
return
endif
if !exists("s:netrwmftgt")
- NetrwKeepj call netrw#ErrorMsg(2,"your marked file target is empty! (:help netrw-mt)",67)
+ call netrw#msg#Notify('ERROR', 'your marked file target is empty! (:help netrw-mt)')
return 0
endif
if a:islocal && s:netrwmftgt_islocal
" move: local -> local
if !executable(g:netrw_localmovecmd)
- call netrw#ErrorMsg(s:ERROR,"g:netrw_localmovecmd<".g:netrw_localmovecmd."> not executable on your system, aborting",90)
+ call netrw#msg#Notify('ERROR', printf('g:netrw_localmovecmd<%s> not executable on your system, aborting', g:netrw_localmovecmd))
return
endif
let tgt = netrw#os#Escape(s:netrwmftgt)
let ret= system(movecmd.g:netrw_localmovecmdopt." ".netrw#os#Escape(fname)." ".tgt)
if v:shell_error != 0
if exists("b:netrw_curdir") && b:netrw_curdir != getcwd() && !g:netrw_keepdir
- call netrw#ErrorMsg(s:ERROR,"move failed; perhaps due to vim's current directory<".getcwd()."> not matching netrw's (".b:netrw_curdir.") (see :help netrw-cd)",100)
+ call netrw#msg#Notify('ERROR', printf("move failed; perhaps due to vim's current directory<%s> not matching netrw's (%s) (see :help netrw-cd)", getcwd(), b:netrw_curdir))
else
- call netrw#ErrorMsg(s:ERROR,"tried using g:netrw_localmovecmd<".g:netrw_localmovecmd.">; it doesn't work!",54)
+ call netrw#msg#Notify('ERROR', printf("tried using g:netrw_localmovecmd<%s>; it doesn't work!", g:netrw_localmovecmd))
endif
break
endif
" sanity check
if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr})
- NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66)
+ call netrw#msg#Notify('ERROR', 'there are no marked files in this window (:help netrw-mf)')
return
endif
let curdir= s:NetrwGetCurdir(a:islocal)
" sanity check
if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr})
- NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66)
+ call netrw#msg#Notify('ERROR', 'there are no marked files in this window (:help netrw-mf)')
return
endif
let curdir= s:NetrwGetCurdir(a:islocal)
" sanity check
if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr})
- NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66)
+ call netrw#msg#Notify('ERROR', 'there are no marked files in this window (:help netrw-mf)')
return
endif
call system(g:netrw_ctags." ".netrwmarkfilelist)
if v:shell_error
- call netrw#ErrorMsg(s:ERROR,"g:netrw_ctags<".g:netrw_ctags."> is not executable!",51)
+ call netrw#msg#Notify('ERROR', printf('g:netrw_ctags<%s> is not executable!', g:netrw_ctags))
endif
else
let v:errmsg= ""
sil w
if v:errmsg != ""
- call netrw#ErrorMsg(s:ERROR,"unable to write <".(exists("prevbufname")? prevbufname : 'n/a').">!",30)
+ call netrw#msg#Notify('ERROR', printf('unable to write <%s>!', (exists("prevbufname") ? prevbufname : 'n/a')))
exe origwin."wincmd w"
let &ei = eikeep
let @@ = ykeep
elseif a:tgt =~ '^ftp:'
call s:NetrwMethod(a:tgt)
if !s:NetrwValidateHostname(g:netrw_machine)
- call netrw#ErrorMsg(s:ERROR,"Rejecting invalid hostname: <" .. g:netrw_machine .. ">",107)
+ call netrw#msg#Notify('ERROR', printf('Rejecting invalid hostname: <%s>', g:netrw_machine))
return
endif
sil NetrwKeepj g/Local directory now/d
call histdel("/",-1)
if getline(1) !~ "^$" && !exists("g:netrw_quiet") && getline(1) !~ '^Trying '
- call netrw#ErrorMsg(s:ERROR,getline(1),14)
+ call netrw#msg#Notify('ERROR', getline(1))
else
bw!|q
endif
if getline(1) !~ "^$" && !exists("g:netrw_quiet") && getline(1) !~ '^Trying '
let debugkeep= &debug
setl debug=msg
- call netrw#ErrorMsg(s:ERROR,getline(1),15)
+ call netrw#msg#Notify('ERROR', getline(1))
let &debug = debugkeep
let mod = 1
else
return
endif
else
- call netrw#ErrorMsg(s:ERROR,"can't obtain files with protocol from<".a:tgt.">",63)
+ call netrw#msg#Notify('ERROR', printf("can't obtain files with protocol from<%s>", a:tgt))
endif
endif
let &pvh= pvhkeep
endif
elseif !exists("g:netrw_quiet")
- NetrwKeepj call netrw#ErrorMsg(s:WARNING,"sorry, cannot preview a directory such as <".a:path.">",38)
+ call netrw#msg#Notify('WARNING', printf('sorry, cannot preview a directory such as <%s>', a:path))
endif
elseif !exists("g:netrw_quiet")
- NetrwKeepj call netrw#ErrorMsg(s:WARNING,"sorry, to preview your vim needs the quickfix feature compiled in",39)
+ call netrw#msg#Notify('WARNING', 'sorry, to preview your vim needs the quickfix feature compiled in')
endif
NetrwKeepj call s:NetrwOptionsRestore("s:")
let @@= ykeep
unlet s:didsplit
else
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,"(NetrwSplit) unsupported mode=".a:mode,45)
+ call netrw#msg#Notify('ERROR', '(NetrwSplit) unsupported mode='.a:mode)
endif
let @@= ykeep
if exists("b:netrw_method")
let w:netrw_method= b:netrw_method
else
- call netrw#ErrorMsg(2,"(s:NetrwRemoteFtpCmd) internal netrw error",93)
+ call netrw#msg#Notify('ERROR', '(s:NetrwRemoteFtpCmd) internal netrw error')
return
endif
endif
".........................................
else " {{{3
- NetrwKeepj call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . bufname("%") . ">",23)
+ call netrw#msg#Notify('WARNING', printf('unable to comply with your request<%s>', bufname("%")))
endif
" cleanup for Windows " {{{3
if exists("b:netrw_method") && b:netrw_method =~ '[235]'
if !executable("ftp")
if !exists("g:netrw_quiet")
- call netrw#ErrorMsg(s:ERROR,"this system doesn't support remote directory listing via ftp",18)
+ call netrw#msg#Notify('ERROR', "this system doesn't support remote directory listing via ftp")
endif
call s:NetrwOptionsRestore("w:")
return -1
elseif !exists("g:netrw_list_cmd") || g:netrw_list_cmd == ''
if !exists("g:netrw_quiet")
if g:netrw_list_cmd == ""
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,"your g:netrw_list_cmd is empty; perhaps ".g:netrw_ssh_cmd." is not executable on your system",47)
+ call netrw#msg#Notify('ERROR', printf('your g:netrw_list_cmd is empty; perhaps %s is not executable on your system', g:netrw_ssh_cmd))
else
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,"this system doesn't support remote directory listing via ".g:netrw_list_cmd,19)
+ call netrw#msg#Notify('ERROR', "this system doesn't support remote directory listing via ".g:netrw_list_cmd)
endif
endif
setl noma
endif
NetrwKeepj call s:NetrwOptionsRestore("w:")
- call netrw#ErrorMsg(s:WARNING,mesg,96)
+ call netrw#msg#Notify('WARNING', mesg)
return -1
endif
else
let netrw_rm_cmd= s:MakeSshCmd(g:netrw_rm_cmd)
if !exists("b:netrw_curdir")
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,"for some reason b:netrw_curdir doesn't exist!",53)
+ call netrw#msg#Notify('ERROR', "for some reason b:netrw_curdir doesn't exist!")
let ok="q"
else
let remotedir= substitute(b:netrw_curdir,'^.\{-}//[^/]\+/\(.*\)$','\1','')
let ret= system(netrw_rm_cmd)
if v:shell_error != 0
if exists("b:netrw_curdir") && b:netrw_curdir != getcwd() && !g:netrw_keepdir
- call netrw#ErrorMsg(s:ERROR,"remove failed; perhaps due to vim's current directory<".getcwd()."> not matching netrw's (".b:netrw_curdir.") (see :help netrw-cd)",102)
+ call netrw#msg#Notify('ERROR', printf("remove failed; perhaps due to vim's current directory<%s> not matching netrw's (%s) (see :help netrw-cd)", getcwd(), b:netrw_curdir))
else
- call netrw#ErrorMsg(s:WARNING,"cmd<".netrw_rm_cmd."> failed",60)
+ call netrw#msg#Notify('WARNING', printf('cmd<%s> failed', netrw_rm_cmd))
endif
elseif ret != 0
- call netrw#ErrorMsg(s:WARNING,"cmd<".netrw_rm_cmd."> failed",60)
+ call netrw#msg#Notify('WARNING', printf('cmd<%s> failed', netrw_rm_cmd))
endif
endif
endif
let ret= system(netrw_rmf_cmd)
if v:shell_error != 0 && !exists("g:netrw_quiet")
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,"unable to remove directory<".rmfile."> -- is it empty?",22)
+ call netrw#msg#Notify('ERROR', printf('unable to remove directory<%s> -- is it empty?', rmfile))
endif
endif
endif
let ykeep= @@
" sanity check
if !executable(a:cmd)
- call netrw#ErrorMsg(s:ERROR,"the file<".a:cmd."> is not executable!",89)
+ call netrw#msg#Notify('ERROR', printf("the file<%s> is not executable!", a:cmd))
let @@= ykeep
return
endif
if !dir && (all || empty(ok))
" This works because delete return 0 if successful
if netrw#fs#Remove(rmfile)
- call netrw#ErrorMsg(s:ERROR, printf("unable to delete <%s>!", rmfile), 103)
+ call netrw#msg#Notify('ERROR', printf("unable to delete <%s>!", rmfile))
else
" Remove file only if there are no pending changes
execute printf('silent! bwipeout %s', rmfile)
" Remove trailing /
let rmfile = substitute(rmfile, '[\/]$', '', 'e')
if delete(rmfile, "rf")
- call netrw#ErrorMsg(s:ERROR, printf("unable to delete directory <%s>!", rmfile), 103)
+ call netrw#msg#Notify('ERROR', printf("unable to delete directory <%s>!", rmfile))
endif
endif
return call("s:".a:funcname,a:000)
endfun
-" netrw#LogLevel: returns the specified loglevel
-fun! netrw#LogLevel(level)
- if a:level == 'WARNING'
- return s:WARNING
- elseif a:level == 'NOTE'
- return s:NOTE
- elseif a:level == 'ERROR'
- return s:ERROR
- endif
-endfun
-
" netrw#Expose: allows UserMaps and pchk to look at otherwise script-local variables {{{2
" I expect this function to be used in
" :PChkAssert netrw#Expose("netrwmarkfilelist")
if type(umap[0]) == 1 && type(umap[1]) == 1
exe "nno <buffer> <silent> ".umap[0]." :call <SID>UserMaps(".a:islocal.",'".umap[1]."')<cr>"
else
- call netrw#ErrorMsg(s:WARNING,"ignoring usermap <".string(umap[0])."> -- not a [string,funcref] entry",99)
+ call netrw#msg#Notify('WARNING', printf('ignoring usermap <%s> -- not a [string,funcref] entry', string(umap[0])))
endif
endfor
endif
" sanity check -- does the temporary file's directory exist?
if !isdirectory(s:NetrwFile(substitute(tmpfile,'[^/]\+$','','e')))
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,"your <".substitute(tmpfile,'[^/]\+$','','e')."> directory is missing!",2)
+ call netrw#msg#Notify('ERROR', printf('your <%s> directory is missing!', substitute(tmpfile,'[^/]\+$','','e')))
return ""
endif
endtry
if err472
- call netrw#ErrorMsg(s:ERROR,"unable to change directory to <".a:newdir."> (permissions?)",61)
+ call netrw#msg#Notify('ERROR', printf('unable to change directory to <%s> (permissions?)', a:newdir))
if exists("w:netrw_prvdir")
let a:newdir= w:netrw_prvdir
else
" Note that it doesn't do netrw#os#Escape(a:cmd)!
fun! s:RemoteSystem(cmd)
if !executable(g:netrw_ssh_cmd)
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,"g:netrw_ssh_cmd<".g:netrw_ssh_cmd."> is not executable!",52)
+ call netrw#msg#Notify('ERROR', printf('g:netrw_ssh_cmd<%s> is not executable!', g:netrw_ssh_cmd))
elseif !exists("b:netrw_curdir")
- NetrwKeepj call netrw#ErrorMsg(s:ERROR,"for some reason b:netrw_curdir doesn't exist!",53)
+ call netrw#msg#Notify('ERROR', "for some reason b:netrw_curdir doesn't exist!")
else
let cmd = s:MakeSshCmd(g:netrw_ssh_cmd." USEPORT HOSTNAME")
let remotedir= substitute(b:netrw_curdir,'^.*//[^/]\+/\(.*\)$','\1','')