diff options
Diffstat (limited to 'runtime/autoload/netrw.vim')
-rw-r--r-- | runtime/autoload/netrw.vim | 357 |
1 files changed, 222 insertions, 135 deletions
diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 10dd28542..efd528a15 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -1,28 +1,36 @@ " netrw.vim: Handles file transfer and remote directory listing across a network " AUTOLOAD PORTION -" Last Change: Aug 29, 2005 +" Date: Sep 29, 2005 +" Version: 72 " Maintainer: Charles E Campbell, Jr <drchipNOSPAM at campbellfamily dot biz> " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " Copyright: Copyright (C) 1999-2005 Charles E. Campbell, Jr. {{{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 is provided *as is* and comes 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 +" netrw.vim, netrwPlugin.vim, and netrwSettings.vim are provided +" *as is* and comes 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. " of this software. " " But be doers of the Word, and not only hearers, deluding your own selves {{{1 " (James 1:22 RSV) " =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -let s:keepcpo= &cpo -set cpo&vim -" call Decho("doing autoload/netrw.vim") + +" Exception for &cp: {{{1 +if &cp || exists("g:loaded_netrw") + finish +endif if v:version < 700 echohl WarningMsg | echo "***netrw*** you need vim version 7.0 or later for version ".g:loaded_netrw." of netrw" | echohl None finish endif +let g:loaded_netrw = "v72" +let s:keepcpo = &cpo +set cpo&vim +" call Decho("doing autoload/netrw.vim") " --------------------------------------------------------------------- " Default values for global netrw variables {{{1 @@ -403,12 +411,14 @@ fun! netrw#NetRead(...) "......................................... " ftp + <.netrc>: NetRead Method #2 elseif b:netrw_method == 2 " read with ftp + <.netrc> -" call Decho("read via ftp+.netrc (method #2)") +" call Decho("read via ftp+.netrc (method #2)") let netrw_fname= b:netrw_fname new setlocal ff=unix exe "put ='".g:netrw_ftpmode."'" - exe "put ='"."get ".netrw_fname." ".tmpfile."'" +" call Decho("filter input: ".getline(".")) + exe "put ='".'get \"'.netrw_fname.'\" '.tmpfile."'" +" call Decho("filter input: ".getline(".")) if exists("g:netrw_port") && g:netrw_port != "" " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port) exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port @@ -438,27 +448,33 @@ fun! netrw#NetRead(...) setlocal ff=unix if exists("g:netrw_port") && g:netrw_port != "" put ='open '.g:netrw_machine.' '.g:netrw_port +" call Decho("filter input: ".getline(".")) else put ='open '.g:netrw_machine +" call Decho("filter input: ".getline(".")) endif if exists("g:netrw_ftp") && g:netrw_ftp == 1 put =g:netrw_uid - put =g:netrw_passwd +" call Decho("filter input: ".getline(".")) + put ='\"'.g:netrw_passwd.'\"' +" call Decho("filter input: ".getline(".")) else - put ='user '.g:netrw_uid.' '.g:netrw_passwd + put ='user \"'.g:netrw_uid.'\" \"'.g:netrw_passwd.'\"' +" call Decho("filter input: ".getline(".")) endif if exists("g:netrw_ftpmode") && g:netrw_ftpmode != "" put =g:netrw_ftpmode +" call Decho("filter input: ".getline(".")) endif - put ='get '.netrw_fname.' '.tmpfile + put ='get \"'.netrw_fname.'\" '.tmpfile +" call Decho("filter input: ".getline(".")) " 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 -" call Decho('performing ftp -i -n') norm! 1Gdd " call Decho("executing: %!".g:netrw_ftp_cmd." -i -n") exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n" @@ -502,7 +518,8 @@ fun! netrw#NetRead(...) echohl Error | echo "***netrw*** neither wget nor fetch command is available" | echohl None call inputsave()|call input("Press <cr> to continue")|call inputrestore() endif - exit +" call Dret("NetRead") + return endif if match(b:netrw_fname,"#") == -1 @@ -581,7 +598,7 @@ fun! netrw#NetRead(...) echohl Error | echo "***netrw*** fetch command not available" | echohl None call inputsave()|call input("Press <cr> to continue")|call inputrestore() endif - exit +" call Dret("NetRead") endif if exists("g:netrw_option") && g:netrw_option == ":http" let netrw_option= "http" @@ -655,7 +672,7 @@ fun! s:NetGetFile(readcmd, fname, method) endif else let fname= a:fname -" call Decho("(copied) fname<".fname.">") +" call Decho("fname=a:fname<".fname.">") endif if a:readcmd[0] == '0' @@ -688,8 +705,12 @@ fun! s:NetGetFile(readcmd, fname, method) exe a:readcmd." ".v:cmdarg." ".fname let line1 = curline + 1 let line2 = line("$") - lastline + 1 + else " not readable +" call Dfunc("NetGetFile(readcmd<".a:readcmd.">,fname<".a:fname."> method<".a:method.">)") + echohl WarningMsg | echo "***netrw*** file <".fname."> not readable"| echohl None + call inputsave()|call input("Press <cr> to continue")|call inputrestore() " call Dret("NetGetFile : fname<".fname."> not readable") return endif @@ -729,7 +750,7 @@ fun! netrw#NetWrite(...) range if !isdirectory(substitute(tmpfile,'[^/]\+$','','e')) echohl Error | echo "***netrw*** your ".substitute(tmpfile,'[^/]\+$','','e')." directory is missing!" call inputsave()|call input("Press <cr> to continue")|call inputrestore() -" call Dret("NetRead") +" call Dret("NetWrite") return endif @@ -839,9 +860,9 @@ fun! netrw#NetWrite(...) range new setlocal ff=unix exe "put ='".g:netrw_ftpmode."'" -" call Decho(" NetWrite: put ='".g:netrw_ftpmode."'") - exe "put ='"."put ".tmpfile." ".netrw_fname."'" -" call Decho("put ='"."put ".tmpfile." ".netrw_fname."'") +" call Decho(" filter input: ".getline(".")) + exe "put ='"."put ".tmpfile.' \"'.netrw_fname.'\"'."'" +" call Decho(" filter input: ".getline(".")) if exists("g:netrw_port") && g:netrw_port != "" " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port) exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port @@ -868,16 +889,22 @@ fun! netrw#NetWrite(...) range setlocal ff=unix if exists("g:netrw_port") && g:netrw_port != "" put ='open '.g:netrw_machine.' '.g:netrw_port +" call Decho("filter input: ".getline(".")) else put ='open '.g:netrw_machine +" call Decho("filter input: ".getline(".")) endif if exists("g:netrw_ftp") && g:netrw_ftp == 1 put =g:netrw_uid - put =g:netrw_passwd +" call Decho("filter input: ".getline(".")) + put ='\"'.g:netrw_passwd.'\"' +" call Decho("filter input: ".getline(".")) else - put ='user '.g:netrw_uid.' '.g:netrw_passwd + put ='user \"'.g:netrw_uid.'\" \"'.g:netrw_passwd.'\"' +" call Decho("filter input: ".getline(".")) endif - put ='put '.tmpfile.' '.netrw_fname + put ='put '.tmpfile.' \"'.netrw_fname.'\"' +" call Decho("filter input: ".getline(".")) " save choice/id/password for future use let b:netrw_lastfile = choice @@ -885,7 +912,6 @@ fun! netrw#NetWrite(...) range " -i : turns off interactive prompting from ftp " -n unix : DON'T use <.netrc>, even though it exists " -n win32: quit being obnoxious about password -" call Decho('performing ftp -i -n') norm! 1Gdd " call Decho("executing: %!".g:netrw_ftp_cmd." -i -n") exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n" @@ -1056,7 +1082,7 @@ fun! s:NetBrowse(dirname) " analyze a:dirname and g:netrw_list_cmd let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/]\+\)/\(.*\)$' let dirname = substitute(a:dirname,'\\','/','ge') -" call Decho("dirpat<".dirpat.">") +" call Decho("dirname<".dirname.">") if dirname !~ dirpat if !exists("g:netrw_quiet") echohl Error | echo "***netrw*** netrw doesn't understand your dirname<".dirname.">" | echohl None @@ -1126,9 +1152,9 @@ fun! s:NetBrowse(dirname) " call Decho("new path<".path.">") " remote-read the requested file into current buffer - enew! + keepjumps keepalt enew! set ma -" call Decho("exe file .method."://".user.machine."/".escape(path,s:netrw_cd_escape)) +" call Decho("exe file ".method."://".user.machine."/".escape(path,s:netrw_cd_escape)) exe "file ".method."://".user.machine."/".escape(path,s:netrw_cd_escape) exe "silent doau BufReadPre ".fname silent call netrw#NetRead(method."://".user.machine."/".path) @@ -1136,7 +1162,7 @@ fun! s:NetBrowse(dirname) keepjumps 1d " save certain window-oriented variables into buffer-oriented variables - call s:BufWinVars() + call s:SetBufWinVars() call s:NetOptionRestore() setlocal nomod @@ -1162,7 +1188,7 @@ fun! s:NetBrowse(dirname) endif else " call Decho("generate a new buffer") - enew! + keepjumps keepalt enew! endif " rename file to reflect where its from @@ -1200,7 +1226,7 @@ fun! s:NetBrowse(dirname) nnoremap <buffer> <silent> U :<c-u>call <SID>NetBookmarkDir(5,expand("%"))<cr> nnoremap <buffer> <silent> v :call <SID>NetSplit(1)<cr> nnoremap <buffer> <silent> x :call <SID>NetBrowseX(<SID>NetBrowseChgDir(expand("%"),<SID>NetGetWord()),1)<cr> - nnoremap <buffer> <silent> <2-leftmouse> :call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),<SID>NetGetWord()))<cr> + nnoremap <buffer> <silent> <2-leftmouse> :call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),<SID>NetGetWord()))<cr> exe 'nnoremap <buffer> <silent> <del> :call <SID>NetBrowseRm("'.user.machine.'","'.path.'")<cr>' exe 'vnoremap <buffer> <silent> <del> :call <SID>NetBrowseRm("'.user.machine.'","'.path.'")<cr>' exe 'nnoremap <buffer> <silent> d :call <SID>NetMakeDir("'.user.machine.'")<cr>' @@ -1260,6 +1286,7 @@ fun! s:NetBrowse(dirname) if g:netrw_ftp_browse_reject != "" exe "silent! g/".g:netrw_ftp_browse_reject."/keepjumps d" endif + silent! keepjumps %s/\r$//e " if there's no ../ listed, then put ./ and ../ in let line1= line(".") @@ -1274,9 +1301,9 @@ fun! s:NetBrowse(dirname) keepjumps norm! 0 " more cleanup - exe 'keepjumps silent! '.w:netrw_bannercnt.',$s/^\(\%(\S\+\s\+\)\{7}\S\+\)\s\+\(\S.*\)$/\2/e' - exe "keepjumps silent! ".w:netrw_bannercnt.',$g/ -> /s# -> .*/$#/#e' - exe "keepjumps silent! ".w:netrw_bannercnt.',$g/ -> /s# -> .*$#/#e' + exe 'silent! keepjumps '.w:netrw_bannercnt.',$s/^\(\%(\S\+\s\+\)\{7}\S\+\)\s\+\(\S.*\)$/\2/e' + exe "silent! keepjumps ".w:netrw_bannercnt.',$g/ -> /s# -> .*/$#/#e' + exe "silent! keepjumps ".w:netrw_bannercnt.',$g/ -> /s# -> .*$#/#e' endif else @@ -1333,33 +1360,33 @@ fun! s:NetBrowse(dirname) keepjumps norm! 0 endif - exe 'keepjumps silent '.w:netrw_bannercnt.',$s/ -> .*$//e' - exe 'keepjumps silent '.w:netrw_bannercnt.',$s/^\(\%(\S\+\s\+\)\{7}\S\+\)\s\+\(\S.*\)$/\2\t\1/e' - exe w:netrw_bannercnt + exe 'silent keepjumps '.w:netrw_bannercnt.',$s/ -> .*$//e' + exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\(\%(\S\+\s\+\)\{7}\S\+\)\s\+\(\S.*\)$/\2\t\1/e' + exe 'silent keepjumps '.w:netrw_bannercnt endif if line("$") >= w:netrw_bannercnt if g:netrw_sort_by =~ "^n" call s:SetSort() if g:netrw_sort_direction =~ 'n' - exe 'keepjumps silent '.w:netrw_bannercnt.',$sort' + exe 'silent keepjumps '.w:netrw_bannercnt.',$sort' else - exe 'keepjumps silent '.w:netrw_bannercnt.',$sort!' + exe 'silent keepjumps '.w:netrw_bannercnt.',$sort!' endif - exe 'keepjumps silent '.w:netrw_bannercnt.',$s/^\d\{3}\///e' + exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\d\{3}\///e' endif if w:netrw_longlist == 1 " shorten the list to keep its width <= winwidth characters - exe "keepjumps silent ".w:netrw_bannercnt.',$s/\t[-dstrwx]\+/\t/e' + exe "silent keepjumps ".w:netrw_bannercnt.',$s/\t[-dstrwx]\+/\t/e' endif endif endif - " cleanup any windows mess at end-of-line - keepjumps silent! %s/\r$//e call s:NetrwWideListing() if line("$") >= w:netrw_bannercnt + " place cursor on the top-left corner of the file listing exe "keepjumps ".w:netrw_bannercnt + norm! 0 endif call s:NetOptionRestore() @@ -1449,7 +1476,7 @@ fun! s:NetGetWord() let s:netrw_skipbrowse= 1 echo 'Pressing "a" also works' elseif line("$") > w:netrw_bannercnt - exe w:netrw_bannercnt + exe 'silent keepjumps '.w:netrw_bannercnt endif elseif w:netrw_longlist == 0 @@ -1690,7 +1717,7 @@ fun! s:NetBrowseX(fname,remote) " create a local copy let fname= tempname().".".exten " call Decho("create a local copy of <".a:fname."> as <".fname.">") - exe "keepjumps silent bot 1new ".a:fname + exe "silent keepjumps bot 1new ".a:fname set bh=delete exe "w! ".fname q @@ -1765,11 +1792,11 @@ fun! s:NetBrowseFtpCmd(path,cmd) if w:netrw_method == 2 || w:netrw_method == 5 " ftp + <.netrc>: Method #2 if a:path != "" - put ='cd '.a:path -" call Decho("ftp: cd ".a:path) + put ='cd \"'.a:path.'\"' +" call Decho('ftp: '.getline(".")) endif exe "put ='".a:cmd."'" -" call Decho("ftp: ".a:cmd) +" call Decho("ftp: ".getline(".")) " redraw!|call inputsave()|call input("Pausing...")|call inputrestore() if exists("g:netrw_port") && g:netrw_port != "" " call Decho("exe ".g:netrw_silentxfer.curline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port) @@ -1791,13 +1818,13 @@ fun! s:NetBrowseFtpCmd(path,cmd) if exists("g:netrw_ftp") && g:netrw_ftp == 1 put =g:netrw_uid - put =g:netrw_passwd + put ='\"'.g:netrw_passwd.'\"' else - put ='user '.g:netrw_uid.' '.g:netrw_passwd + put ='user \"'.g:netrw_uid.'\" \"'.g:netrw_passwd.'\"' endif if a:path != "" - put ='cd '.a:path + put ='cd \"'.a:path.'\"' endif exe "put ='".a:cmd."'" @@ -1815,14 +1842,14 @@ fun! s:NetBrowseFtpCmd(path,cmd) " cleanup for Windows if has("win32") || has("win95") || has("win64") || has("win16") - keepjumps silent!! %s/\r$//e + silent! keepjumps! %s/\r$//e endif if a:cmd == "dir" " infer directory/link based on the file permission string - keepjumps silent! g/d\%([-r][-w][-x]\)\{3}/s@$@/@ - keepjumps silent! g/l\%([-r][-w][-x]\)\{3}/s/$/@/ + silent! keepjumps g/d\%([-r][-w][-x]\)\{3}/s@$@/@ + silent! keepjumps g/l\%([-r][-w][-x]\)\{3}/s/$/@/ if w:netrw_longlist == 0 || w:netrw_longlist == 2 - exe "keepjumps silent! ".curline.',$s/^\%(\S\+\s\+\)\{8}//e' + exe "silent! keepjumps ".curline.',$s/^\%(\S\+\s\+\)\{8}//e' endif endif @@ -1860,9 +1887,9 @@ fun! s:NetrwListHide() " Prune the list by hiding any files which match " call Decho("pruning <".hide."> listhide<".listhide.">") if g:netrw_hide == 1 - exe 'keepjumps silent '.w:netrw_bannercnt.',$g~'.hide.'~d' + exe 'silent keepjumps '.w:netrw_bannercnt.',$g~'.hide.'~d' elseif g:netrw_hide == 2 - exe 'keepjumps silent '.w:netrw_bannercnt.',$v~'.hide.'~d' + exe 'silent keepjumps '.w:netrw_bannercnt.',$v~'.hide.'~d' endif endwhile @@ -1996,10 +2023,10 @@ fun! s:NetrwWideListing() exe "silent keepjumps norm! 0\<c-v>".newcolqty.'j$hx'.w:netrw_bannercnt.'G$p' endif exe "silent keepjumps ".newcolstart.','.newcolend.'d' - exe w:netrw_bannercnt + exe 'silent keepjumps '.w:netrw_bannercnt endwhile exe "silent keepjumps ".w:netrw_bannercnt.',$s/\s\+$//e' - set noma nomod + setlocal noma nomod endif " call Dret("NetrwWideListing") @@ -2130,9 +2157,12 @@ fun! s:NetBookmarkDir(chg,curdir) if exists("w:netrw_bannercnt") && line(".") <= w:netrw_bannercnt " looks like a "b" was pressed while in the banner region if line("$") > w:netrw_bannercnt - exe w:netrw_bannercnt + exe 'silent keepjumps '.w:netrw_bannercnt + endif + if &ch > 1 + " "clear" the message + echo "" endif - echo "" " call Dret("NetBookmarkDir - ignoring") return endif @@ -2229,12 +2259,10 @@ endfun " --------------------------------------------------------------------- " NetObtain: obtain file under cursor (for remote browsing support) {{{2 fun! s:NetObtain() - if !exists("s:netrw_users_stl") - let s:netrw_users_stl= &stl - endif let fname= expand("<cWORD>") - exe 'set stl=%f\ %h%m%r%=Obtaining\ '.escape(fname,' ') - redraw! + + " NetrwStatusLine support - for obtaining support + call s:SetupNetrwStatusLine('%f %h%m%r%=%9*Obtaining '.fname) " call Dfunc("NetObtain() method=".w:netrw_method) if exists("w:netrw_method") && w:netrw_method =~ '[235]' @@ -2277,11 +2305,11 @@ fun! s:NetObtain() if exists("g:netrw_ftp") && g:netrw_ftp == 1 put =g:netrw_uid - put =g:netrw_passwd + put ='\"'.g:netrw_passwd.'\"' " call Decho('ftp: g:netrw_uid') " call Decho('ftp: g:netrw_passwd') else - put ='user '.g:netrw_uid.' '.g:netrw_passwd + put ='user \"'.g:netrw_uid.'\" \"'.g:netrw_passwd.'\"' " call Decho('user '.g:netrw_uid.' '.g:netrw_passwd) endif @@ -2306,12 +2334,14 @@ fun! s:NetObtain() " restore exe "silent! ".endline.",$d" exe "keepjumps ".curline - set noma nomod + setlocal noma nomod else if !exists("g:netrw_quiet") echohl Error | echo "***netrw*** this system doesn't support ftp" | echohl None call inputsave()|call input("Press <cr> to continue")|call inputrestore() endif + let &stl = s:netrw_users_stl + let &laststatus = s:netrw_users_ls " call Dret("NetObtain") return endif @@ -2335,7 +2365,8 @@ fun! s:NetObtain() endif " restore status line - let &stl= s:netrw_users_stl + let &stl = s:netrw_users_stl + let &laststatus = s:netrw_users_ls redraw! " call Dret("NetObtain") @@ -2404,7 +2435,7 @@ fun! netrw#DirBrowse(dirname) " get cleared buffer if bufnum < 0 || !bufexists(bufnum) - keepalt enew! + keepjumps keepalt enew! " call Decho("enew buffer") else exe "keepalt b ".bufnum @@ -2496,7 +2527,7 @@ fun! netrw#DirBrowse(dirname) nnoremap <buffer> <silent> U :<c-u>call <SID>NetBookmarkDir(5,expand("%"))<cr> nnoremap <buffer> <silent> v :call <SID>NetSplit(3)<cr> nnoremap <buffer> <silent> x :call <SID>NetBrowseX(<SID>LocalBrowseChgDir(b:netrw_curdir,<SID>NetGetWord(),0),0)"<cr> - nnoremap <buffer> <silent> <2-leftmouse> :exe "call <SID>LocalRefresh(<SID>LocalBrowseChgDir(b:netrw_curdir,<SID>NetGetWord()))"<cr> + nnoremap <buffer> <silent> <2-leftmouse> :call <SID>LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,<SID>NetGetWord()))<cr> nnoremap <buffer> <silent> <s-up> :Pexplore<cr> nnoremap <buffer> <silent> <s-down> :Nexplore<cr> exe 'nnoremap <buffer> <silent> <del> :call <SID>LocalBrowseRm("'.b:netrw_curdir.'")<cr>' @@ -2574,19 +2605,19 @@ fun! netrw#DirBrowse(dirname) call s:SetSort() if g:netrw_sort_direction =~ 'n' - exe 'keepjumps silent '.w:netrw_bannercnt.',$sort' + exe 'silent keepjumps '.w:netrw_bannercnt.',$sort' else - exe 'keepjumps silent '.w:netrw_bannercnt.',$sort!' + exe 'silent keepjumps '.w:netrw_bannercnt.',$sort!' endif - exe 'keepjumps silent '.w:netrw_bannercnt.',$s/^\d\{3}\///e' + exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\d\{3}\///e' else if g:netrw_sort_direction =~ 'n' - exe 'keepjumps silent '.w:netrw_bannercnt.',$sort' + exe 'silent keepjumps '.w:netrw_bannercnt.',$sort' else - exe 'keepjumps silent '.w:netrw_bannercnt.',$sort!' + exe 'silent keepjumps '.w:netrw_bannercnt.',$sort!' endif - exe 'keepjumps silent '.w:netrw_bannercnt.',$s/^\d\{-}\///e' + exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\d\{-}\///e' endif endif @@ -2594,14 +2625,16 @@ fun! netrw#DirBrowse(dirname) call s:NetrwWideListing() if exists("w:netrw_bannercnt") && line("$") > w:netrw_bannercnt - exe w:netrw_bannercnt + " place cursor on the top-left corner of the file listing + exe 'silent '.w:netrw_bannercnt + norm! 0 endif " record previous current directory let w:netrw_prvdir= b:netrw_curdir " save certain window-oriented variables into buffer-oriented variables - call s:BufWinVars() + call s:SetBufWinVars() call s:NetOptionRestore() setlocal noma nomod nonu bh=hide nobl @@ -2701,7 +2734,7 @@ fun! s:LocalBrowseList() endwhile " cleanup any windows mess at end-of-line - keepjumps silent! %s/\r$//e + silent! keepjumps %s/\r$//e setlocal ts=32 " call Dret("LocalBrowseList") @@ -3032,12 +3065,8 @@ fun! netrw#Explore(indx,dosplit,style,...) endif endif - " NetrwStatusLine support + " NetrwStatusLine support - for exploring support let w:netrw_explore_indx= indx - if !exists("s:netrw_users_stl") - let s:netrw_users_stl= &stl - endif - set stl=%f\ %h%m%r%=%{NetrwStatusLine()} " call Decho("explorelist<".join(w:netrw_explore_list,',')."> len=".w:netrw_explore_listlen) " sanity check @@ -3050,15 +3079,21 @@ fun! netrw#Explore(indx,dosplit,style,...) endif exe "let dirfile= w:netrw_explore_list[".indx."]" -" call Decho("dirfile<".dirfile."> indx=".indx) +" call Decho("dirfile=w:netrw_explore_list[indx=".indx."]= <".dirfile.">") let newdir= substitute(dirfile,'/[^/]*$','','e') " call Decho("newdir<".newdir.">") + " call Decho("calling LocalBrowse(newdir<".newdir.">)") call s:LocalBrowse(newdir) - call search(substitute(dirfile,"^.*/","",""),"W") + if w:netrw_longlist == 0 || w:netrw_longlist == 1 + call search('^'.substitute(dirfile,"^.*/","","").'\>',"W") + else + 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(".") + 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) else @@ -3078,12 +3113,73 @@ fun! netrw#Explore(indx,dosplit,style,...) endfun " --------------------------------------------------------------------- +" SetupNetrwStatusLine: {{{2 +fun! s:SetupNetrwStatusLine(statline) +" call Dfunc("SetupNetrwStatusLine(statline<".a:statline.">)") + + if !exists("s:netrw_setup_statline") + let s:netrw_setup_statline= 1 +" call Decho("do first-time status line setup") + + if !exists("s:netrw_users_stl") + let s:netrw_users_stl= &stl + endif + if !exists("s:netrw_users_ls") + let s:netrw_users_ls= &laststatus + endif + + " set up User9 highlighting as needed + let keepa= @a + redir @a + try + hi User9 + catch /^Vim\%((\a\+)\)\=:E411/ + if &bg == "dark" + hi User9 ctermfg=yellow ctermbg=blue guifg=yellow guibg=blue + else + hi User9 ctermbg=yellow ctermfg=blue guibg=yellow guifg=blue + endif + endtry + redir END + let @a= keepa + endif + + " set up status line (may use User9 highlighting) + " insure that windows have a statusline + " make sure statusline is displayed + let &stl=a:statline + set laststatus=2 +" call Decho("stl=".&stl) + redraw! + +" call Dret("SetupNetrwStatusLine : stl=".&stl) +endfun + +" --------------------------------------------------------------------- " NetrwStatusLine: {{{2 fun! NetrwStatusLine() -" let g:stlmsg= "Xbufnr=".w:netrw_explore_bufnr." bufnr=".bufnr(".")." Xline#".w:netrw_explore_line." line#".line(".") + + " vvv NetrwStatusLine() debugging vvv +" let g:stlmsg="" +" if !exists("w:netrw_explore_bufnr") +" let g:stlmsg="!X<explore_bufnr>" +" elseif w:netrw_explore_bufnr != bufnr(".") +" let g:stlmsg="explore_bufnr!=".bufnr(".") +" endif +" if !exists("w:netrw_explore_line") +" let g:stlmsg=" !X<explore_line>" +" elseif w:netrw_explore_line != line(".") +" let g:stlmsg=" explore_line!={line(.)<".line(".").">" +" endif +" if !exists("w:netrw_explore_list") +" let g:stlmsg=" !X<explore_list>" +" 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 &stl= s:netrw_users_stl + let &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 "" @@ -3146,7 +3242,7 @@ fun! s:NetMethod(choice) " globals: method machine id passwd fname let ftpurm = '^ftp://\(\([^/@]\{-}\)@\)\=\([^/#:]\{-}\)\([#:]\d\+\)\=/\(.*\)$' let rcpurm = '^rcp://\%(\([^/@]\{-}\)@\)\=\([^/]\{-}\)/\(.*\)$' let rcphf = '^\(\(\h\w*\)@\)\=\(\h\w*\):\([^@]\+\)$' - let scpurm = '^scp://\([^/]\{-}\)\([#:]\d\+\)\=/\(.*\)$' + let scpurm = '^scp://\([^/#:]\+\)\%([#:]\(\d\+\)\)\=/\(.*\)$' let httpurm = '^http://\([^/]\{-}\)\(/.*\)\=$' let davurm = '^s\=dav://\([^/]\+\)/\(.*/\)\([-_.~[:alnum:]]\+\)$' let rsyncurm = '^rsync://\([^/]\{-}\)/\(.*\)\=$' @@ -3336,6 +3432,7 @@ fun! NetUserPass(...) " call Decho("a:0=".a:0." case >1: a:2<".a:2.">") let g:netrw_passwd=a:2 endif + " call Dret("NetUserPass") endfun @@ -3357,20 +3454,21 @@ fun! s:NetOptionSave() let w:acdkeep = &autochdir set noautochdir endif - let w:cinkeep = &cin - let w:cinokeep = &cino - let w:comkeep = &com - let w:cpokeep = &cpo + let w:cinkeep = &cin + let w:cinokeep = &cino + let w:comkeep = &com + let w:cpokeep = &cpo if !g:netrw_keepdir - let w:dirkeep = getcwd() + let w:dirkeep = getcwd() endif - let w:gdkeep = &gd - let w:repkeep = &report - let w:twkeep = &tw + let w:gdkeep = &gd + let w:repkeep = &report + let w:spellkeep = &spell + let w:twkeep = &tw setlocal cino = setlocal com = setlocal cpo -=aA - setlocal nocin noai + setlocal nocin noai nospell setlocal tw =0 setlocal report=10000 if has("win32") && !has("win95") @@ -3392,22 +3490,22 @@ fun! s:NetOptionRestore() endif unlet w:netoptionsave - let &ai = w:aikeep - if has("netbeans_intg") || has("sun_workshop") - let &acd = w:acdkeep - endif - let &cin = w:cinkeep - let &cino = w:cinokeep - let &com = w:comkeep - let &cpo = w:cpokeep - if exists("w:dirkeep") - exe "lcd ".w:dirkeep - endif - let &gd = w:gdkeep - let &report = w:repkeep - let &tw = w:twkeep + if exists("w:aikeep")| let &ai= w:aikeep|endif + if (has("netbeans_intg") || has("sun_workshop")) && exists("w:acdkeep") + let &acd= w:acdkeep + unlet w:acdkeep + endif + if exists("w:cinkeep") |let &cin = w:cinkeep |unlet w:cinkeep |endif + if exists("w:cinokeep") |let &cino = w:cinokeep |unlet w:cinokeep |endif + if exists("w:comkeep") |let &com = w:comkeep |unlet w:comkeep |endif + if exists("w:cpokeep") |let &cpo = w:cpokeep |unlet w:cpokeep |endif + if exists("w:dirkeep") |exe "lcd ".w:dirkeep |unlet w:dirkeep |endif + if exists("w:gdkeep") |let &gd = w:gdkeep |unlet w:gdkeep |endif + if exists("w:repkeep") |let &report = w:repkeep |unlet w:repkeep |endif + if exists("w:spellkeep")|let &spell = w:spellkeep |unlet w:spellkeep|endif + if exists("w:twkeep") |let &tw = w:twkeep |unlet w:twkeep |endif if exists("w:swfkeep") - if &directory == "" + if &directory == "" && exists("w:swfkeep") " user hasn't specified a swapfile directory; " netrw will temporarily make the swapfile " directory the current local one. @@ -3419,17 +3517,6 @@ fun! s:NetOptionRestore() endif unlet w:swfkeep endif - unlet w:aikeep - unlet w:cinkeep - unlet w:cinokeep - unlet w:comkeep - unlet w:cpokeep - unlet w:gdkeep - unlet w:repkeep - unlet w:twkeep - if exists("w:dirkeep") - unlet w:dirkeep - endif " call Dret("NetOptionRestore") endfun @@ -3441,7 +3528,7 @@ endfun " example and as a fix for a Windows 95 problem: in my " experience, win95's ftp always dumped four blank lines " at the end of the transfer. -if has("win95") && g:netrw_win95ftp +if has("win95") && exists("g:netrw_win95ftp") && g:netrw_win95ftp fun! NetReadFixup(method, line1, line2) " call Dfunc("NetReadFixup(method<".a:method."> line1=".a:line1." line2=".a:line2.")") if method == 3 " ftp (no <.netrc>) @@ -3542,14 +3629,14 @@ fun! s:SetSort() return endif if seq == '*' - exe 'keepjumps silent '.w:netrw_bannercnt.',$v/^\d\{3}\//s/^/'.spriority.'/' + exe 'silent keepjumps '.w:netrw_bannercnt.',$v/^\d\{3}\//s/^/'.spriority.'/' else - exe 'keepjumps silent '.w:netrw_bannercnt.',$g/'.eseq.'/s/^/'.spriority.'/' + exe 'silent keepjumps '.w:netrw_bannercnt.',$g/'.eseq.'/s/^/'.spriority.'/' endif let priority = priority + 1 endwhile - exe 'keepjumps silent '.w:netrw_bannercnt.',$s/^\(\d\{3}\/\)\%(\d\{3}\/\)\+/\1/e' + exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\(\d\{3}\/\)\%(\d\{3}\/\)\+/\1/e' " call Dret("SetSort") endfun @@ -3587,14 +3674,14 @@ fun! s:CopyWinVars() endfun " --------------------------------------------------------------------- -" BufWinVars: (used by NetBrowse() and LocalBrowse()) {{{1 +" SetBufWinVars: (used by NetBrowse() and LocalBrowse()) {{{1 " To allow separate windows to have their own activities, such as " Explore **/pattern, several variables have been made window-oriented. " However, when the user splits a browser window (ex: ctrl-w s), these -" variables are not inherited by the new window. BufWinVars() and +" variables are not inherited by the new window. SetBufWinVars() and " UseBufWinVars() get around that. -fun! s:BufWinVars() -" call Dfunc("BufWinVars()") +fun! s:SetBufWinVars() +" call Dfunc("SetBufWinVars()") if exists("w:netrw_longlist") |let b:netrw_longlist = w:netrw_longlist |endif if exists("w:netrw_bannercnt") |let b:netrw_bannercnt = w:netrw_bannercnt |endif if exists("w:netrw_method") |let b:netrw_method = w:netrw_method |endif @@ -3605,7 +3692,7 @@ fun! s:BufWinVars() if exists("w:netrw_explore_bufnr") |let b:netrw_explore_bufnr = w:netrw_explore_bufnr |endif if exists("w:netrw_explore_line") |let b:netrw_explore_line = w:netrw_explore_line |endif if exists("w:netrw_explore_list") |let b:netrw_explore_list = w:netrw_explore_list |endif -" call Dret("BufWinVars") +" call Dret("SetBufWinVars") endfun " --------------------------------------------------------------------- |