11" netrw.vim: Handles file transfer and remote directory listing across
22" AUTOLOAD SECTION
3- " Date: Nov 29, 2019
4- " Version: 167
5- " Maintainer: Charles E Campbell <
[email protected] -NOSPAM>
3+ " Date: Jan 07, 2020
4+ " Version: 168
5+ " Maintainer: Charles E Campbell <
[email protected] -NOSPAM>
66" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
77" Copyright: Copyright (C) 2016 Charles E. Campbell {{{1
88" Permission is hereby granted to use and distribute this code,
@@ -43,7 +43,7 @@ if exists("s:needspatches")
4343 endfor
4444endif
4545
46- let g:loaded_netrw = "v167 "
46+ let g:loaded_netrw = "v168 "
4747if !exists("s:NOTE")
4848 let s:NOTE = 0
4949 let s:WARNING = 1
@@ -68,7 +68,7 @@ setl cpo&vim
6868" Usage: netrw#ErrorMsg(s:NOTE | s:WARNING | s:ERROR,"some message",error-number)
6969" netrw#ErrorMsg(s:NOTE | s:WARNING | s:ERROR,["message1","message2",...],error-number)
7070" (this function can optionally take a list of messages)
71- " Mar 21, 2017 : max errnum currently is 105
71+ " Dec 2, 2019 : max errnum currently is 106
7272fun! netrw#ErrorMsg(level,msg,errnum)
7373" call Dfunc("netrw#ErrorMsg(level=".a:level." msg<".a:msg."> errnum=".a:errnum.") g:netrw_use_errorwindow=".g:netrw_use_errorwindow)
7474
@@ -447,23 +447,9 @@ if !exists("g:netrw_localmovecmd")
447447 let g:netrw_localmovecmd= ""
448448 endif
449449endif
450- if v:version < 704 || (v:version == 704 && !has("patch1107"))
451- " 1109 provides for delete(tmpdir,"d") which is what will be used
452- if exists("g:netrw_local_rmdir")
453- let g:netrw_localrmdir= g:netrw_local_rmdir
454- call netrw#ErrorMsg(s:NOTE,"g:netrw_local_rmdir is deprecated in favor of g:netrw_localrmdir",86)
455- endif
456- if has("win32") || has("win95") || has("win64") || has("win16")
457- if g:netrw_cygwin
458- call s:NetrwInit("g:netrw_localrmdir","rmdir")
459- else
460- let g:netrw_localrmdir = expand("$COMSPEC")
461- let g:netrw_localrmdiropt= " /c rmdir"
462- endif
463- else
464- call s:NetrwInit("g:netrw_localrmdir","rmdir")
465- endif
466- endif
450+ " following serves as an example for how to insert a version&patch specific test
451+ "if v:version < 704 || (v:version == 704 && !has("patch1107"))
452+ "endif
467453call s:NetrwInit("g:netrw_liststyle" , s:THINLIST)
468454" sanity checks
469455if g:netrw_liststyle < 0 || g:netrw_liststyle >= s:MAXLIST
@@ -5217,8 +5203,8 @@ fun! netrw#BrowseX(fname,remote)
52175203 if a:remote == 0 && isdirectory(a:fname)
52185204 " if its really just a local directory, then do a "gf" instead
52195205" call Decho("remote≡0 and a:fname<".a:fname."> ".(isdirectory(a:fname)? "is a directory" : "is not a directory"),'~'.expand("<slnum>"))
5220- " call Decho("..appears to be a local directory; using gf instead",'~'.expand("<slnum>"))
5221- norm! gf
5206+ " call Decho("..appears to be a local directory; using e ".a:fname." instead",'~'.expand("<slnum>"))
5207+ exe "e ".a:fname
52225208" call Dret("netrw#BrowseX")
52235209 return
52245210 elseif a:remote == 1 && a:fname !~ '^https\=:' && a:fname =~ '/$'
@@ -7158,17 +7144,8 @@ fun! s:NetrwMarkFileCopy(islocal,...)
71587144" call Dret("s:NetrwMarkFileCopy : lcd failure")
71597145 return
71607146 endif
7161- if v:version < 704 || (v:version == 704 && !has("patch1107"))
7162- call s:NetrwExe("sil !".g:netrw_localrmdir.g:netrw_localrmdiropt." ".s:ShellEscape(tmpdir,1))
7163- if v:shell_error != 0
7164- call netrw#ErrorMsg(s:WARNING,"consider setting g:netrw_localrmdir<".g:netrw_localrmdir."> to something that works",80)
7165- " " call Dret("s:NetrwMarkFileCopy : failed: sil !".g:netrw_localrmdir." ".s:ShellEscape(tmpdir,1) )
7166- return
7167- endif
7168- else
7169- if delete(tmpdir,"d")
7170- call netrw#ErrorMsg(s:ERROR,"unable to delete directory <".tmpdir.">!",103)
7171- endif
7147+ if delete(tmpdir,"d")
7148+ call netrw#ErrorMsg(s:ERROR,"unable to delete directory <".tmpdir.">!",103)
71727149 endif
71737150 else
71747151 if s:NetrwLcd(curdir)
@@ -9587,13 +9564,15 @@ fun! s:NetrwWideListing()
95879564" call Decho("setl ma noro",'~'.expand("<slnum>"))
95889565 let b:netrw_cpf= 0
95899566 if line("$") >= w:netrw_bannercnt
9567+ " determine the maximum filename size; use that to set cpf
95909568 exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$g/^./if virtcol("$") > b:netrw_cpf|let b:netrw_cpf= virtcol("$")|endif'
95919569 NetrwKeepj call histdel("/",-1)
95929570 else
95939571 let @a= keepa
95949572" call Dret("NetrwWideListing")
95959573 return
95969574 endif
9575+ " allow for two spaces to separate columns
95979576 let b:netrw_cpf= b:netrw_cpf + 2
95989577" call Decho("b:netrw_cpf=max_filename_length+2=".b:netrw_cpf,'~'.expand("<slnum>"))
95999578
@@ -9621,10 +9600,11 @@ fun! s:NetrwWideListing()
96219600 if newcolend > line("$") | let newcolend= line("$") | endif
96229601 let newcolqty= newcolend - newcolstart
96239602 exe newcolstart
9603+ " COMBAK: both of the visual-mode using lines below are problematic vis-a-vis @*
96249604 if newcolqty == 0
96259605 exe "sil! NetrwKeepj norm! 0\<c-v>$h\"ax".w:netrw_bannercnt."G$\"ap"
96269606 else
9627- exe "sil! NetrwKeepj norm! 0\<c-v>".newcolqty.'j$h\ "ax'.w:netrw_bannercnt.'G$\ "ap'
9607+ exe "sil! NetrwKeepj norm! 0\<c-v>".newcolqty.'j$h"ax'.w:netrw_bannercnt.'G$"ap'
96289608 endif
96299609 exe "sil! NetrwKeepj ".newcolstart.','.newcolend.'d _'
96309610 exe 'sil! NetrwKeepj '.w:netrw_bannercnt
@@ -11048,9 +11028,10 @@ fun! s:NetrwLocalRename(path) range
1104811028" call Dfunc("NetrwLocalRename(path<".a:path.">)")
1104911029
1105011030 " preparation for removing multiple files/directories
11051- let ykeep = @@
11052- let ctr = a:firstline
11053- let svpos = winsaveview()
11031+ let ykeep = @@
11032+ let ctr = a:firstline
11033+ let svpos = winsaveview()
11034+ let all = 0
1105411035" call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
1105511036
1105611037 " rename files given by the markfilelist
@@ -11078,6 +11059,23 @@ fun! s:NetrwLocalRename(path) range
1107811059 let newname = substitute(oldname,subfrom,subto,'')
1107911060 endif
1108011061 endif
11062+ if !all && filereadable(newname)
11063+ call inputsave()
11064+ let response= input("File<".newname."> already exists; do you want to overwrite it? (y/all/n) ")
11065+ call inputrestore()
11066+ if response == "all"
11067+ let all= 1
11068+ elseif response != "y" && response != "yes"
11069+ " refresh the directory
11070+ " call Decho("refresh the directory listing",'~'.expand("<slnum>"))
11071+ NetrwKeepj call s:NetrwRefresh(1,s:NetrwBrowseChgDir(1,'./'))
11072+ " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))
11073+ NetrwKeepj call winrestview(svpos)
11074+ let @@= ykeep
11075+ " call Dret("NetrwLocalRename")
11076+ return
11077+ endif
11078+ endif
1108111079 call rename(oldname,newname)
1108211080 endfor
1108311081 call s:NetrwUnmarkList(bufnr("%"),b:netrw_curdir)
@@ -11101,14 +11099,14 @@ fun! s:NetrwLocalRename(path) range
1110111099
1110211100 NetrwKeepj norm! 0
1110311101 let oldname= s:ComposePath(a:path,curword)
11104- " call Decho("oldname<".oldname.">",'~'.expand("<slnum>"))
11102+ " call Decho("oldname<".oldname.">",'~'.expand("<slnum>"))
1110511103
1110611104 call inputsave()
1110711105 let newname= input("Moving ".oldname." to : ",substitute(oldname,'/*$','','e'))
1110811106 call inputrestore()
1110911107
1111011108 call rename(oldname,newname)
11111- " call Decho("renaming <".oldname."> to <".newname.">",'~'.expand("<slnum>"))
11109+ " call Decho("renaming <".oldname."> to <".newname.">",'~'.expand("<slnum>"))
1111211110
1111311111 let ctr= ctr + 1
1111411112 endwhile
@@ -11896,6 +11894,9 @@ fun! s:NetrwExe(cmd)
1189611894" call Decho("exe ".a:cmd,'~'.expand("<slnum>"))
1189711895 exe a:cmd
1189811896 endif
11897+ if v:shell_error
11898+ call netrw#ErrorMsg(s:WARNING,"shell signalled an error",106)
11899+ endif
1189911900" call Dret("s:NetrwExe : v:shell_error=".v:shell_error)
1190011901endfun
1190111902
0 commit comments