diff options
author | Bram Moolenaar <Bram@vim.org> | 2011-06-19 05:09:16 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2011-06-19 05:09:16 +0200 |
commit | 251e19127170e7387da1f10b9c99c957b16477fc (patch) | |
tree | b286383f88539796b7ce8d724cf9872f8910bf72 /runtime/autoload/netrw.vim | |
parent | d6761c3cdf9d15c0f64253dcd8049ff9f25aa987 (diff) | |
download | vim-git-251e19127170e7387da1f10b9c99c957b16477fc.tar.gz |
Updated runtime files.
Diffstat (limited to 'runtime/autoload/netrw.vim')
-rw-r--r-- | runtime/autoload/netrw.vim | 146 |
1 files changed, 91 insertions, 55 deletions
diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 8476022f7..ab6370a8e 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -1,7 +1,7 @@ " netrw.vim: Handles file transfer and remote directory listing across " AUTOLOAD SECTION -" Date: Apr 01, 2011 -" Version: 141 +" Date: May 31, 2011 +" Version: 142 " Maintainer: Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM> " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " Copyright: Copyright (C) 1999-2010 Charles E. Campbell, Jr. {{{1 @@ -22,7 +22,7 @@ if &cp || exists("g:loaded_netrw") finish endif -let g:loaded_netrw = "v141" +let g:loaded_netrw = "v142" if v:version < 702 echohl WarningMsg echo "***warning*** this version of netrw needs vim 7.2" @@ -291,7 +291,7 @@ call s:NetrwInit("g:netrw_timefmt","%c") call s:NetrwInit("g:netrw_xstrlen",0) call s:NetrwInit("g:NetrwTopLvlMenu","Netrw.") call s:NetrwInit("g:netrw_win95ftp",1) -call s:NetrwInit("g:netrw_winsize",25) +call s:NetrwInit("g:netrw_winsize",50) " --------------------------------------------------------------------- " Default values for netrw's script variables: {{{2 call s:NetrwInit("g:netrw_fname_escape",' ?&;%') @@ -1518,6 +1518,14 @@ endfun fun! s:NetrwMethod(choice) " call Dfunc("NetrwMethod(a:choice<".a:choice.">)") + " sanity check: choice should have at least three slashes in it + if strlen(substitute(a:choice,'[^/]','','g')) < 3 + call netrw#ErrorMsg(s:ERROR,"not a netrw-style url; netrw uses protocol://[user@]hostname[:port]/[path])",78) + let b:netrw_method = -1 +" call Dret("NetrwMethod : incorrect url format<".a:choice.">") + return + endif + " record current g:netrw_machine, if any " curmachine used if protocol == ftp and no .netrc if exists("g:netrw_machine") @@ -1813,6 +1821,25 @@ endfun " s:NetrwMaps: {{{2 fun! s:NetrwMaps(islocal) " call Dfunc("s:NetrwMaps(islocal=".a:islocal.") b:netrw_curdir<".b:netrw_curdir.">") + + " set up Rexplore and [ 2-leftmouse-click -or- c-leftmouse ] +" call Decho("set up Rexplore command") + com! Rexplore call s:NetrwRexplore(w:netrw_rexlocal,exists("w:netrw_rexdir")? w:netrw_rexdir : ".") + if g:netrw_mousemaps && g:netrw_retmap +" call Decho("set up Rexplore 2-leftmouse") + if !hasmapto("<Plug>NetrwReturn") + if maparg("<2-leftmouse>","n") == "" || maparg("<2-leftmouse>","n") =~ '^-$' +" call Decho("making map for 2-leftmouse") + nmap <unique> <silent> <2-leftmouse> <Plug>NetrwReturn + elseif maparg("<c-leftmouse>","n") == "" +" call Decho("making map for c-leftmouse") + nmap <unique> <silent> <c-leftmouse> <Plug>NetrwReturn + endif + endif + nno <silent> <Plug>NetrwReturn :Rexplore<cr> +" call Decho("made <Plug>NetrwReturn map") + endif + if a:islocal " call Decho("make local maps") inoremap <buffer> <silent> a <c-o>:call <SID>NetrwHide(1)<cr> @@ -1925,15 +1952,22 @@ fun! s:NetrwMaps(islocal) endif let mapsafecurdir = escape(b:netrw_curdir, s:netrw_map_escape) if g:netrw_mousemaps == 1 - nnoremap <buffer> <silent> <leftmouse> <leftmouse>:call <SID>NetrwLeftmouse(1)<cr> - nnoremap <buffer> <silent> <middlemouse> <leftmouse>:call <SID>NetrwPrevWinOpen(1)<cr> - nnoremap <buffer> <silent> <s-leftmouse> <leftmouse>:call <SID>NetrwMarkFile(1,<SID>NetrwGetWord())<cr> - nmap <buffer> <silent> <2-leftmouse> - + nmap <buffer> <leftmouse> <Plug>NetrwLeftmouse + nno <buffer> <silent> <Plug>NetrwLeftmouse <leftmouse>:call <SID>NetrwLeftmouse(1)<cr> + nmap <buffer> <middlemouse> <Plug>NetrwMiddlemouse + nno <buffer> <silent> <Plug>NetrwMiddlemouse <leftmouse>:call <SID>NetrwPrevWinOpen(1)<cr> + nmap <buffer> <s-leftmouse> <Plug>NetrwSLeftmouse + nno <buffer> <silent> <Plug>NetrwSLeftmouse <leftmouse>:call <SID>NetrwMarkFile(1,<SID>NetrwGetWord())<cr> + nmap <buffer> <2-leftmouse> <Plug>Netrw2Leftmouse + nmap <buffer> <silent> <Plug>Netrw2Leftmouse - + imap <buffer> <leftmouse> <Plug>ILeftmouse + ino <buffer> <silent> <Plug>ILeftmouse <c-o><leftmouse><c-o>:call <SID>NetrwLeftmouse(1)<cr> + imap <buffer> <middlemouse> <Plug>IMiddlemouse + ino <buffer> <silent> <Plug>IMiddlemouse <c-o><leftmouse><c-o>:call <SID>NetrwPrevWinOpen(1)<cr> + imap <buffer> <s-leftmouse> <Plug>ISLeftmouse + ino <buffer> <silent> <Plug>ISLeftmouse <c-o><leftmouse><c-o>:call <SID>NetrwMarkFile(1,<SID>NetrwGetWord())<cr> exe 'nnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' exe 'vnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' - inoremap <buffer> <silent> <leftmouse> <c-o><leftmouse><c-o>:call <SID>NetrwLeftmouse(1)<cr> - inoremap <buffer> <silent> <middlemouse> <c-o><leftmouse><c-o>:call <SID>NetrwPrevWinOpen(1)<cr> - inoremap <buffer> <silent> <s-leftmouse> <c-o><leftmouse><c-o>:call <SID>NetrwMarkFile(1,<SID>NetrwGetWord())<cr> exe 'inoremap <buffer> <silent> <rightmouse> <c-o><leftmouse><c-o>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' endif exe 'nnoremap <buffer> <silent> <del> :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' @@ -2053,17 +2087,24 @@ fun! s:NetrwMaps(islocal) let mapsafepath = escape(s:path, s:netrw_map_escape) let mapsafeusermach = escape(s:user.s:machine, s:netrw_map_escape) - nnoremap <buffer> <silent> <Plug>NetrwRefresh :call <SID>NetrwRefresh(0,<SID>NetrwBrowseChgDir(0,'./'))<cr> + nnoremap <buffer> <silent> <Plug>NetrwRefresh :call <SID>NetrwRefresh(0,<SID>NetrwBrowseChgDir(0,'./'))<cr> if g:netrw_mousemaps == 1 - nnoremap <buffer> <silent> <leftmouse> <leftmouse>:call <SID>NetrwLeftmouse(0)<cr> - nnoremap <buffer> <silent> <middlemouse> <leftmouse>:call <SID>NetrwPrevWinOpen(0)<cr> - nnoremap <buffer> <silent> <s-leftmouse> <leftmouse>:call <SID>NetrwMarkFile(0,<SID>NetrwGetWord())<cr> - nmap <buffer> <silent> <2-leftmouse> - + nmap <leftmouse> <Plug>NetrwLeftmouse + nno <buffer> <silent> <Plug>NetrwLeftmouse <leftmouse>:call <SID>NetrwLeftmouse(0)<cr> + nmap <middlemouse> <Plug>NetrwMiddlemouse + nno <buffer> <silent> <middlemouse> <Plug>NetrwMiddlemouse <leftmouse>:call <SID>NetrwPrevWinOpen(0)<cr> + nmap <buffer> <s-leftmouse> <Plug>NetrwSLeftmouse + nno <buffer> <silent> <Plug>NetrwSLeftmouse <leftmouse>:call <SID>NetrwMarkFile(0,<SID>NetrwGetWord())<cr> + nmap <buffer> <2-leftmouse> <Plug>Netrw2Leftmouse + nmap <buffer> <silent> <Plug>Netrw2Leftmouse - + imap <buffer> <leftmouse> <Plug>ILeftmouse + ino <buffer> <silent> <Plug>ILeftmouse <c-o><leftmouse><c-o>:call <SID>NetrwLeftmouse(0)<cr> + imap <buffer> <middlemouse> <Plug>IMiddlemouse + ino <buffer> <silent> <Plug>IMiddlemouse <c-o><leftmouse><c-o>:call <SID>NetrwPrevWinOpen(0)<cr> + imap <buffer> <s-leftmouse> <Plug>ISLeftmouse + ino <buffer> <silent> <Plug>ISLeftmouse <c-o><leftmouse><c-o>:call <SID>NetrwMarkFile(0,<SID>NetrwGetWord())<cr> exe 'nnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>' exe 'vnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>' - inoremap <buffer> <silent> <leftmouse> <c-o><leftmouse><c-o>:call <SID>NetrwLeftmouse(0)<cr> - inoremap <buffer> <silent> <middlemouse> <c-o><leftmouse><c-o>:call <SID>NetrwPrevWinOpen(0)<cr> - inoremap <buffer> <silent> <s-leftmouse> <c-o><leftmouse><c-o>:call <SID>NetrwMarkFile(0,<SID>NetrwGetWord())<cr> exe 'inoremap <buffer> <silent> <rightmouse> <c-o><leftmouse><c-o>:call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>' endif exe 'nnoremap <buffer> <silent> <del> :call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>' @@ -2081,23 +2122,8 @@ fun! s:NetrwMaps(islocal) inoremap <buffer> <F1> <c-o>:he netrw-quickhelp<cr> endif - " set up Rexplore and leftmouse-double-click - com! Rexplore call s:NetrwRexplore(w:netrw_rexlocal,exists("w:netrw_rexdir")? w:netrw_rexdir : ".") - if g:netrw_mousemaps && g:netrw_retmap - if !hasmapto("<Plug>NetrwReturn") - if maparg("<2-leftmouse>","n") == "" || maparg("<2-leftmouse>","n") =~ '^-$' -" call Decho("making map for 2-leftmouse") - nmap <unique> <silent> <2-leftmouse> <Plug>NetrwReturn - elseif maparg("<c-leftmouse>","n") == "" -" call Decho("making map for c-leftmouse") - nmap <unique> <silent> <c-leftmouse> <Plug>NetrwReturn - endif - endif - exe 'nnoremap <silent> <Plug>NetrwReturn :Rexplore<cr>' -" call Decho("made <Plug>NetrwReturn map") - endif - keepj call s:SetRexDir(a:islocal,b:netrw_curdir) + " call Dret("s:NetrwMaps") endfun @@ -3647,34 +3673,40 @@ fun! netrw#Explore(indx,dosplit,style,...) if a:dosplit || &modified || a:style == 6 " call Decho("case dosplit=".a:dosplit." modified=".&modified." a:style=".a:style.": dosplit or file has been modified") call s:SaveWinVars() - let winsize= g:netrw_winsize + let winsz= g:netrw_winsize if a:indx > 0 - let winsize= a:indx + let winsz= a:indx endif if a:style == 0 " Explore, Sexplore " call Decho("style=0: Explore or Sexplore") - exe winsize."wincmd s" + let winsz= (winsz*winheight(0))/100 + exe winsz."wincmd s" elseif a:style == 1 "Explore!, Sexplore! " call Decho("style=1: Explore! or Sexplore!") - exe winsize."wincmd v" + let winsz= (winsz*winheight(0))/100 + exe winsz."wincmd v" elseif a:style == 2 " Hexplore " call Decho("style=2: Hexplore") - exe "bel ".winsize."wincmd s" + let winsz= (winsz*winheight(0))/100 + exe "bel ".winsz."wincmd s" elseif a:style == 3 " Hexplore! " call Decho("style=3: Hexplore!") - exe "abo ".winsize."wincmd s" + let winsz= (winsz*winheight(0))/100 + exe "abo ".winsz."wincmd s" elseif a:style == 4 " Vexplore " call Decho("style=4: Vexplore") - exe "lefta ".winsize."wincmd v" + let winsz= (winsz*winheight(0))/100 + exe "lefta ".winsz."wincmd v" elseif a:style == 5 " Vexplore! " call Decho("style=5: Vexplore!") - exe "rightb ".winsize."wincmd v" + let winsz= (winsz*winheight(0))/100 + exe "rightb ".winsz."wincmd v" elseif a:style == 6 " Texplore call s:SaveBufVars() @@ -4618,13 +4650,13 @@ fun! s:NetrwMarkFileCopy(islocal) " sanity checks if !exists("s:netrwmarkfilelist_{bufnr('%')}") || empty(s:netrwmarkfilelist_{bufnr('%')}) - keepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) + keepj call netrw#ErrorMsg(s:ERROR,"there are no marked files in this window (:help netrw-mf)",66) " call Dret("s:NetrwMarkFileCopy 0") return 0 endif " call Decho("sanity chk passed: s:netrwmarkfilelist_".bufnr('%')."<".string(s:netrwmarkfilelist_{bufnr('%')})) if !exists("s:netrwmftgt") - keepj call netrw#ErrorMsg(2,"your marked file target is empty! (:help netrw-mt)",67) + keepj call netrw#ErrorMsg(s:ERROR,"your marked file target is empty! (:help netrw-mt)",67) " call Dret("s:NetrwMarkFileCopy 0") return 0 endif @@ -6143,7 +6175,8 @@ fun! s:NetrwSplit(mode) if a:mode == 0 " remote and o " call Decho("exe ".(g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s") - exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s" + let winsz= (g:netrw_winsize*winheight(0))/100 + exe (g:netrw_alto? "bel " : "abo ").winsz."wincmd s" let s:didsplit= 1 keepj call s:RestoreWinVars() keepj call s:NetrwBrowse(0,s:NetrwBrowseChgDir(0,s:NetrwGetWord())) @@ -6162,7 +6195,8 @@ fun! s:NetrwSplit(mode) elseif a:mode == 2 " remote and v " call Decho("exe ".(g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v") - exe (g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v" + let winsz= (g:netrw_winsize*winwidth(0))/100 + exe (g:netrw_altv? "rightb " : "lefta ").winsz."wincmd v" let s:didsplit= 1 keepj call s:RestoreWinVars() keepj call s:NetrwBrowse(0,s:NetrwBrowseChgDir(0,s:NetrwGetWord())) @@ -6171,7 +6205,8 @@ fun! s:NetrwSplit(mode) elseif a:mode == 3 " local and o " call Decho("exe ".(g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s") - exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s" + let winsz= (g:netrw_winsize*winheight(0))/100 + exe (g:netrw_alto? "bel " : "abo ").winsz."wincmd s" let s:didsplit= 1 keepj call s:RestoreWinVars() keepj call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,s:NetrwGetWord())) @@ -6192,7 +6227,8 @@ fun! s:NetrwSplit(mode) elseif a:mode == 5 " local and v " call Decho("exe ".(g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v") - exe (g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v" + let winsz= (g:netrw_winsize*winwidth(0))/100 + exe (g:netrw_altv? "rightb " : "lefta ").winsz."wincmd v" let s:didsplit= 1 keepj call s:RestoreWinVars() keepj call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,s:NetrwGetWord())) @@ -6826,8 +6862,8 @@ fun! s:NetrwRemoteListing() " call Decho("2: exe sil r! ".listcmd) exe "sil! keepalt r! ".listcmd else -" call Decho("3: exe sil r! ".listcmd.' '.shellescape(s:path,1)) - exe "sil! keepalt r! ".listcmd.' '.shellescape(s:path,1) +" call Decho("3: exe sil r! ".listcmd.' '.shellescape(fnameescape(s:path),1)) + exe "sil! keepalt r! ".listcmd.' '.shellescape(fnameescape(s:path),1) " call Decho("listcmd<".listcmd."> path<".s:path.">") endif endif @@ -7278,12 +7314,12 @@ fun! s:LocalListing() " get the list of files contained in the current directory let dirname = b:netrw_curdir let dirnamelen = s:Strlen(b:netrw_curdir) - let filelist = glob(s:ComposePath(dirname,"*")) + let filelist = glob(s:ComposePath(fnameescape(dirname),"*")) " call Decho("glob(dirname<".dirname."/*>)=".filelist) if filelist != "" let filelist= filelist."\n" endif - let filelist= filelist.glob(s:ComposePath(dirname,".*")) + let filelist= filelist.glob(s:ComposePath(fnameescape(dirname),".*")) " call Decho("glob(dirname<".dirname."/.*>)=".filelist) " Coding choice: either elide ./ if present @@ -7797,7 +7833,7 @@ endfun " 0=note = s:NOTE " 1=warning = s:WARNING " 2=error = s:ERROR -" Dec 03, 2009 : max errnum currently is 77 +" Apr 18, 2011 : max errnum currently is 78 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) @@ -8326,7 +8362,7 @@ endfun " --------------------------------------------------------------------- " s:RemotePathAnalysis: {{{2 fun! s:RemotePathAnalysis(dirname) -" call Dfunc("s:RemotePathAnalysis()") +" call Dfunc("s:RemotePathAnalysis(a:dirname<".a:dirname.">)") let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/:#]\+\)\%([:#]\(\d\+\)\)\=/\(.*\)$' let s:method = substitute(a:dirname,dirpat,'\1','') |