vim-patch:7e47c1e: runtime(netrw): remove g:netrw_quiet and reindent to 4 spaces

closes: vim/vim#17539

7e47c1e735

Co-authored-by: Luca Saccarola <github.e41mv@aleeas.com>
This commit is contained in:
Jaehwang Jung
2025-09-13 01:40:48 +09:00
parent 4644e69bdc
commit 7b2a42e962

View File

@@ -805,9 +805,7 @@ fun! netrw#Explore(indx,dosplit,style,...)
keepalt NetrwKeepj call s:SetupNetrwStatusLine('%f %h%m%r%=%9*%{NetrwStatusLine()}') keepalt NetrwKeepj call s:SetupNetrwStatusLine('%f %h%m%r%=%9*%{NetrwStatusLine()}')
else else
if !exists("g:netrw_quiet")
call netrw#msg#Notify('WARNING', 'your vim needs the +path_extra feature for Exploring with **!') call netrw#msg#Notify('WARNING', 'your vim needs the +path_extra feature for Exploring with **!')
endif
if !has('nvim') && has("clipboard") && g:netrw_clipboard if !has('nvim') && has("clipboard") && g:netrw_clipboard
if @* != keepregstar | sil! let @* = keepregstar | endif if @* != keepregstar | sil! let @* = keepregstar | endif
if @+ != keepregplus | sil! let @+ = keepregplus | endif if @+ != keepregplus | sil! let @+ = keepregplus | endif
@@ -1099,7 +1097,7 @@ fun! netrw#Obtain(islocal,fname,...)
call netrw#os#Execute(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".netrw#os#Escape(g:netrw_machine,1)) call netrw#os#Execute(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".netrw#os#Escape(g:netrw_machine,1))
endif endif
" If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) " 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 ' if getline(1) !~ "^$" && getline(1) !~ '^Trying '
let debugkeep= &debug let debugkeep= &debug
setl debug=msg setl debug=msg
call netrw#msg#Notify('ERROR', getline(1)) call netrw#msg#Notify('ERROR', getline(1))
@@ -1157,10 +1155,8 @@ fun! netrw#Obtain(islocal,fname,...)
call netrw#os#Execute(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." ".g:netrw_ftp_options) call netrw#os#Execute(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 the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
if getline(1) !~ "^$" if getline(1) !~ "^$"
if !exists("g:netrw_quiet")
call netrw#msg#Notify('ERROR', getline(1)) call netrw#msg#Notify('ERROR', getline(1))
endif endif
endif
elseif b:netrw_method == 9 elseif b:netrw_method == 9
" obtain file using sftp " obtain file using sftp
@@ -1177,9 +1173,7 @@ fun! netrw#Obtain(islocal,fname,...)
else else
" protocol recognized but not supported for Obtain (yet?) " protocol recognized but not supported for Obtain (yet?)
if !exists("g:netrw_quiet")
call netrw#msg#Notify('ERROR', 'current protocol not supported for obtaining file') call netrw#msg#Notify('ERROR', 'current protocol not supported for obtaining file')
endif
return return
endif endif
@@ -1623,9 +1617,7 @@ fun! netrw#NetRead(mode,...)
let wholechoice = wholechoice . " " . choice let wholechoice = wholechoice . " " . choice
let ichoice = ichoice + 1 let ichoice = ichoice + 1
if ichoice > a:0 if ichoice > a:0
if !exists("g:netrw_quiet")
call netrw#msg#Notify('ERROR', printf('Unbalanced string in filename "%s"', wholechoice)) call netrw#msg#Notify('ERROR', printf('Unbalanced string in filename "%s"', wholechoice))
endif
return return
endif endif
let choice= a:{ichoice} let choice= a:{ichoice}
@@ -1704,7 +1696,7 @@ fun! netrw#NetRead(mode,...)
call netrw#os#Execute(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".netrw#os#Escape(g:netrw_machine,1)) call netrw#os#Execute(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".netrw#os#Escape(g:netrw_machine,1))
endif endif
" If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) " 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 ' if getline(1) !~ "^$" && getline(1) !~ '^Trying '
let debugkeep = &debug let debugkeep = &debug
setl debug=msg setl debug=msg
call netrw#msg#Notify('ERROR', getline(1)) call netrw#msg#Notify('ERROR', getline(1))
@@ -1761,10 +1753,8 @@ fun! netrw#NetRead(mode,...)
call netrw#os#Execute(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." ".g:netrw_ftp_options) call netrw#os#Execute(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 the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
if getline(1) !~ "^$" if getline(1) !~ "^$"
if !exists("g:netrw_quiet")
call netrw#msg#Notify('ERROR', getline(1)) call netrw#msg#Notify('ERROR', getline(1))
endif endif
endif
call s:SaveBufVars()|keepj bd!|call s:RestoreBufVars() call s:SaveBufVars()|keepj bd!|call s:RestoreBufVars()
let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)
let b:netrw_lastfile = choice let b:netrw_lastfile = choice
@@ -1792,9 +1782,7 @@ fun! netrw#NetRead(mode,...)
" NetRead: (http) NetRead Method #5 (wget) {{{3 " NetRead: (http) NetRead Method #5 (wget) {{{3
elseif b:netrw_method == 5 elseif b:netrw_method == 5
if g:netrw_http_cmd == "" if g:netrw_http_cmd == ""
if !exists("g:netrw_quiet")
call netrw#msg#Notify('ERROR', 'neither the wget nor the fetch command is available') call netrw#msg#Notify('ERROR', 'neither the wget nor the fetch command is available')
endif
return return
endif endif
@@ -1864,9 +1852,7 @@ fun! netrw#NetRead(mode,...)
" fetch://[user@]host[:http]/path " fetch://[user@]host[:http]/path
elseif b:netrw_method == 8 elseif b:netrw_method == 8
if g:netrw_fetch_cmd == "" if g:netrw_fetch_cmd == ""
if !exists("g:netrw_quiet")
call netrw#msg#Notify('ERROR', "fetch command not available") call netrw#msg#Notify('ERROR', "fetch command not available")
endif
return return
endif endif
if exists("g:netrw_option") && g:netrw_option =~ ":https\=" if exists("g:netrw_option") && g:netrw_option =~ ":https\="
@@ -2000,9 +1986,7 @@ fun! netrw#NetWrite(...) range
let wholechoice= wholechoice . " " . choice let wholechoice= wholechoice . " " . choice
let ichoice = ichoice + 1 let ichoice = ichoice + 1
if choice > a:0 if choice > a:0
if !exists("g:netrw_quiet")
call netrw#msg#Notify('ERROR', printf('Unbalanced string in filename "%s"', wholechoice)) call netrw#msg#Notify('ERROR', printf('Unbalanced string in filename "%s"', wholechoice))
endif
return return
endif endif
let choice= a:{ichoice} let choice= a:{ichoice}
@@ -2073,9 +2057,7 @@ fun! netrw#NetWrite(...) range
endif endif
" If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
if getline(1) !~ "^$" if getline(1) !~ "^$"
if !exists("g:netrw_quiet")
call netrw#msg#Notify('ERROR', getline(1)) call netrw#msg#Notify('ERROR', getline(1))
endif
let mod=1 let mod=1
endif endif
@@ -2131,9 +2113,7 @@ fun! netrw#NetWrite(...) range
call netrw#os#Execute(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." ".g:netrw_ftp_options) call netrw#os#Execute(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 the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
if getline(1) !~ "^$" if getline(1) !~ "^$"
if !exists("g:netrw_quiet")
call netrw#msg#Notify('ERROR', getline(1)) call netrw#msg#Notify('ERROR', getline(1))
endif
let mod=1 let mod=1
endif endif
@@ -2161,7 +2141,7 @@ fun! netrw#NetWrite(...) range
if executable(curl) if executable(curl)
let url= g:netrw_choice 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) ) 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") else
call netrw#msg#Notify('ERROR', printf("can't write to http using <%s>", g:netrw_http_put_cmd)) call netrw#msg#Notify('ERROR', printf("can't write to http using <%s>", g:netrw_http_put_cmd))
endif endif
@@ -2653,9 +2633,7 @@ fun! s:NetrwMethod(choice)
" Cannot Determine Method {{{3 " Cannot Determine Method {{{3
else else
if !exists("g:netrw_quiet")
call netrw#msg#Notify('WARNING', 'cannot determine method (format: protocol://[user@]hostname[:port]/[path])') call netrw#msg#Notify('WARNING', 'cannot determine method (format: protocol://[user@]hostname[:port]/[path])')
endif
let b:netrw_method = -1 let b:netrw_method = -1
endif endif
"}}}3 "}}}3
@@ -3255,9 +3233,7 @@ fun! s:NetrwBrowse(islocal,dirname)
let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/]\+\)/\(.*\)$' let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/]\+\)/\(.*\)$'
if dirname !~ dirpat if dirname !~ dirpat
if !exists("g:netrw_quiet")
call netrw#msg#Notify('ERROR', printf("netrw doesn't understand your dirname<%s>", dirname)) call netrw#msg#Notify('ERROR', printf("netrw doesn't understand your dirname<%s>", dirname))
endif
NetrwKeepj call s:NetrwOptionsRestore("w:") NetrwKeepj call s:NetrwOptionsRestore("w:")
setl noma nomod nowrap setl noma nomod nowrap
return return
@@ -4899,16 +4875,12 @@ fun! s:NetrwMakeDir(usrhost)
" sanity checks " sanity checks
let fullnewdir= b:netrw_curdir.'/'.newdirname let fullnewdir= b:netrw_curdir.'/'.newdirname
if isdirectory(s:NetrwFile(fullnewdir)) if isdirectory(s:NetrwFile(fullnewdir))
if !exists("g:netrw_quiet")
call netrw#msg#Notify('WARNING', printf('<%s> is already a directory!', newdirname)) call netrw#msg#Notify('WARNING', printf('<%s> is already a directory!', newdirname))
endif
let @@= ykeep let @@= ykeep
return return
endif endif
if s:FileReadable(fullnewdir) if s:FileReadable(fullnewdir)
if !exists("g:netrw_quiet")
call netrw#msg#Notify('WARNING', printf('<%s> is already a file!', newdirname)) call netrw#msg#Notify('WARNING', printf('<%s> is already a file!', newdirname))
endif
let @@= ykeep let @@= ykeep
return return
endif endif
@@ -4944,7 +4916,7 @@ fun! s:NetrwMakeDir(usrhost)
let svpos= winsaveview() let svpos= winsaveview()
call s:NetrwRefresh(1,s:NetrwBrowseChgDir(1,'./',0)) call s:NetrwRefresh(1,s:NetrwBrowseChgDir(1,'./',0))
call winrestview(svpos) call winrestview(svpos)
elseif !exists("g:netrw_quiet") else
call netrw#msg#Notify('ERROR', printf('unable to make directory<%s>', newdirname)) call netrw#msg#Notify('ERROR', printf('unable to make directory<%s>', newdirname))
endif endif
@@ -4958,7 +4930,7 @@ fun! s:NetrwMakeDir(usrhost)
let svpos= winsaveview() let svpos= winsaveview()
NetrwKeepj call s:NetrwRefresh(0,s:NetrwBrowseChgDir(0,'./',0)) NetrwKeepj call s:NetrwRefresh(0,s:NetrwBrowseChgDir(0,'./',0))
NetrwKeepj call winrestview(svpos) NetrwKeepj call winrestview(svpos)
elseif !exists("g:netrw_quiet") else
call netrw#msg#Notify('ERROR', printf('unable to make directory<%s>', newdirname)) call netrw#msg#Notify('ERROR', printf('unable to make directory<%s>', newdirname))
endif endif
@@ -6482,10 +6454,6 @@ fun! s:NetrwOpenFile(islocal)
" Does the filename contain a path? " Does the filename contain a path?
if fname !~ '[/\\]' if fname !~ '[/\\]'
if exists("b:netrw_curdir") if exists("b:netrw_curdir")
if exists("g:netrw_quiet")
let netrw_quiet_keep = g:netrw_quiet
endif
let g:netrw_quiet = 1
" save position for benefit of Rexplore " save position for benefit of Rexplore
let s:rexposn_{bufnr("%")}= winsaveview() let s:rexposn_{bufnr("%")}= winsaveview()
if b:netrw_curdir =~ '/$' if b:netrw_curdir =~ '/$'
@@ -6493,11 +6461,6 @@ fun! s:NetrwOpenFile(islocal)
else else
exe "e ".fnameescape(b:netrw_curdir."/".fname) exe "e ".fnameescape(b:netrw_curdir."/".fname)
endif endif
if exists("netrw_quiet_keep")
let g:netrw_quiet= netrw_quiet_keep
else
unlet g:netrw_quiet
endif
endif endif
else else
exe "NetrwKeepj e ".fnameescape(fname) exe "NetrwKeepj e ".fnameescape(fname)
@@ -6963,7 +6926,7 @@ fun! s:NetrwUpload(fname,tgt,...)
" If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
sil NetrwKeepj g/Local directory now/d sil NetrwKeepj g/Local directory now/d
call histdel("/",-1) call histdel("/",-1)
if getline(1) !~ "^$" && !exists("g:netrw_quiet") && getline(1) !~ '^Trying ' if getline(1) !~ "^$" && getline(1) !~ '^Trying '
call netrw#msg#Notify('ERROR', getline(1)) call netrw#msg#Notify('ERROR', getline(1))
else else
bw!|q bw!|q
@@ -7016,7 +6979,7 @@ fun! s:NetrwUpload(fname,tgt,...)
" If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
sil NetrwKeepj g/Local directory now/d sil NetrwKeepj g/Local directory now/d
call histdel("/",-1) call histdel("/",-1)
if getline(1) !~ "^$" && !exists("g:netrw_quiet") && getline(1) !~ '^Trying ' if getline(1) !~ "^$" && getline(1) !~ '^Trying '
let debugkeep= &debug let debugkeep= &debug
setl debug=msg setl debug=msg
call netrw#msg#Notify('ERROR', getline(1)) call netrw#msg#Notify('ERROR', getline(1))
@@ -7072,10 +7035,10 @@ fun! s:NetrwPreview(path) range
if exists("pvhkeep") if exists("pvhkeep")
let &pvh= pvhkeep let &pvh= pvhkeep
endif endif
elseif !exists("g:netrw_quiet") else
call netrw#msg#Notify('WARNING', printf('sorry, cannot preview a directory such as <%s>', a:path)) call netrw#msg#Notify('WARNING', printf('sorry, cannot preview a directory such as <%s>', a:path))
endif endif
elseif !exists("g:netrw_quiet") else
call netrw#msg#Notify('WARNING', 'sorry, to preview your vim needs the quickfix feature compiled in') call netrw#msg#Notify('WARNING', 'sorry, to preview your vim needs the quickfix feature compiled in')
endif endif
NetrwKeepj call s:NetrwOptionsRestore("s:") NetrwKeepj call s:NetrwOptionsRestore("s:")
@@ -8176,21 +8139,17 @@ fun! s:NetrwRemoteListing()
" sanity check: " sanity check:
if exists("b:netrw_method") && b:netrw_method =~ '[235]' if exists("b:netrw_method") && b:netrw_method =~ '[235]'
if !executable("ftp") if !executable("ftp")
if !exists("g:netrw_quiet")
call netrw#msg#Notify('ERROR', "this system doesn't support remote directory listing via ftp") call netrw#msg#Notify('ERROR', "this system doesn't support remote directory listing via ftp")
endif
call s:NetrwOptionsRestore("w:") call s:NetrwOptionsRestore("w:")
return -1 return -1
endif endif
elseif !exists("g:netrw_list_cmd") || g:netrw_list_cmd == '' elseif !exists("g:netrw_list_cmd") || g:netrw_list_cmd == ''
if !exists("g:netrw_quiet")
if g:netrw_list_cmd == "" if g:netrw_list_cmd == ""
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)) 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 else
call netrw#msg#Notify('ERROR', "this system doesn't support remote directory listing via ".g:netrw_list_cmd) call netrw#msg#Notify('ERROR', "this system doesn't support remote directory listing via ".g:netrw_list_cmd)
endif endif
endif
NetrwKeepj call s:NetrwOptionsRestore("w:") NetrwKeepj call s:NetrwOptionsRestore("w:")
return -1 return -1
@@ -8458,7 +8417,7 @@ fun! s:NetrwRemoteRmFile(path,rmfile,all)
let netrw_rmf_cmd= s:MakeSshCmd(netrw#fs#WinPath(g:netrw_rmf_cmd)).' '.netrw#os#Escape(netrw#fs#WinPath(substitute(rmfile,'[\/]$','','e'))) let netrw_rmf_cmd= s:MakeSshCmd(netrw#fs#WinPath(g:netrw_rmf_cmd)).' '.netrw#os#Escape(netrw#fs#WinPath(substitute(rmfile,'[\/]$','','e')))
let ret= system(netrw_rmf_cmd) let ret= system(netrw_rmf_cmd)
if v:shell_error != 0 && !exists("g:netrw_quiet") if v:shell_error != 0
call netrw#msg#Notify('ERROR', printf('unable to remove directory<%s> -- is it empty?', rmfile)) call netrw#msg#Notify('ERROR', printf('unable to remove directory<%s> -- is it empty?', rmfile))
endif endif
endif endif