diff options
author | Bram Moolenaar <Bram@vim.org> | 2013-04-24 18:51:19 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2013-04-24 18:51:19 +0200 |
commit | ff0341946eabf4dcb616a2bbe7a2e9d69ae46e57 (patch) | |
tree | 0444bd0917a2d95ee299383bce98e78caa19380b /runtime/autoload | |
parent | 7afea82f507c0614a22b27d592adf65f5656c2df (diff) | |
download | vim-ff0341946eabf4dcb616a2bbe7a2e9d69ae46e57.zip |
Updated runtime files.
Diffstat (limited to 'runtime/autoload')
-rw-r--r-- | runtime/autoload/getscript.vim | 17 | ||||
-rw-r--r-- | runtime/autoload/netrw.vim | 2771 | ||||
-rw-r--r-- | runtime/autoload/netrwFileHandlers.vim | 4 | ||||
-rw-r--r-- | runtime/autoload/netrwSettings.vim | 6 | ||||
-rw-r--r-- | runtime/autoload/tar.vim | 49 | ||||
-rw-r--r-- | runtime/autoload/zip.vim | 30 |
6 files changed, 1650 insertions, 1227 deletions
diff --git a/runtime/autoload/getscript.vim b/runtime/autoload/getscript.vim index 34f5970c3..6b74d37da 100644 --- a/runtime/autoload/getscript.vim +++ b/runtime/autoload/getscript.vim @@ -1,8 +1,8 @@ " --------------------------------------------------------------------- " getscript.vim -" Author: Charles E. Campbell, Jr. -" Date: Jan 17, 2012 -" Version: 34 +" Author: Charles E. Campbell +" Date: Apr 17, 2013 +" Version: 35 " Installing: :help glvs-install " Usage: :help glvs " @@ -15,7 +15,7 @@ if exists("g:loaded_getscript") finish endif -let g:loaded_getscript= "v34" +let g:loaded_getscript= "v35" if &cp echoerr "GetLatestVimScripts is not vi-compatible; not loaded (you need to set nocp)" finish @@ -74,6 +74,11 @@ if !exists("g:GetLatestVimScripts_allowautoinstall") let g:GetLatestVimScripts_allowautoinstall= 1 endif +" set up default scriptaddr address +if !exists("g:GetLatestVimScripts_scriptaddr") + let g:GetLatestVimScripts_scriptaddr = 'http://vim.sourceforge.net/script.php?script_id=' +endif + "" For debugging: "let g:GetLatestVimScripts_wget = "echo" "let g:GetLatestVimScripts_options = "options" @@ -314,7 +319,7 @@ fun! getscript#GetLatestVimScripts() if &mod silent! w! endif - q + q! " restore events and current directory exe "cd ".fnameescape(substitute(origdir,'\','/','ge')) @@ -415,7 +420,7 @@ fun! s:GetOneScript(...) echo 'considering <'.aicmmnt.'> scriptid='.scriptid.' srcid='.srcid " grab a copy of the plugin's vim.sourceforge.net webpage - let scriptaddr = 'http://vim.sourceforge.net/script.php?script_id='.scriptid + let scriptaddr = g:GetLatestVimScripts_scriptaddr.scriptid let tmpfile = tempname() let v:errmsg = "" diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 3e9bd34b1..8422d9dea 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -1,10 +1,10 @@ " netrw.vim: Handles file transfer and remote directory listing across " AUTOLOAD SECTION -" Date: Oct 25, 2012 -" Version: 146 -" Maintainer: Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM> +" Date: Apr 16, 2013 +" Version: 148 +" Maintainer: Charles E Campbell <NdrOchip@ScampbellPfamily.AbizM-NOSPAM> " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim -" Copyright: Copyright (C) 1999-2012 Charles E. Campbell, Jr. {{{1 +" Copyright: Copyright (C) 1999-2012 Charles E. Campbell {{{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, @@ -22,10 +22,10 @@ if &cp || exists("g:loaded_netrw") finish endif -let g:loaded_netrw = "v146" -if v:version < 702 +let g:loaded_netrw = "v148" +if v:version < 703 || (v:version == 703 && !has("patch465")) echohl WarningMsg - echo "***warning*** this version of netrw needs vim 7.2" + echo "***warning*** this version of netrw needs vim 7.3.465 or later" echohl Normal finish endif @@ -35,12 +35,6 @@ if !exists("s:NOTE") let s:ERROR = 2 endif -" sanity checks -if v:version < 700 - call netrw#ErrorMsg(s:WARNING,"you need vim version 7.0 or later for version ".g:loaded_netrw." of netrw",1) - finish -endif - let s:keepcpo= &cpo set cpo&vim "DechoTabOn @@ -55,7 +49,7 @@ set cpo&vim " 0=note = s:NOTE " 1=warning = s:WARNING " 2=error = s:ERROR -" Oct 24, 2012 : max errnum currently is 91 +" Apr 02, 2013 : max errnum currently is 92 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) @@ -97,7 +91,7 @@ fun! netrw#ErrorMsg(level,msg,errnum) sil! keepj call s:NetrwSafeOptions() setl bt=nofile keepj file NetrwMessage -" call Decho("setlocal ma noro") +" call Decho("setl ma noro") setl ma noro call setline(line("$"),level.a:msg) endif @@ -134,9 +128,12 @@ endfun " NetrwInit: initializes variables if they haven't been defined {{{2 " Loosely, varname = value. fun s:NetrwInit(varname,value) +" call Decho("varname<".a:varname."> value=".a:value) if !exists(a:varname) if type(a:value) == 0 exe "let ".a:varname."=".a:value + elseif type(a:value) == 1 && a:value =~ '^[{[]' + exe "let ".a:varname."=".a:value elseif type(a:value) == 1 exe "let ".a:varname."="."'".a:value."'" else @@ -251,6 +248,7 @@ call s:NetrwInit("g:netrw_cursor" , 2) let s:netrw_usercul = &cursorline let s:netrw_usercuc = &cursorcolumn " Default values - d-g ---------- {{{3 +call s:NetrwInit("s:didstarstar",0) call s:NetrwInit("g:netrw_dirhist_cnt" , 0) call s:NetrwInit("g:netrw_decompress" , '{ ".gz" : "gunzip", ".bz2" : "bunzip2", ".zip" : "unzip", ".tar" : "tar -xf", ".xz" : "unxz" }') call s:NetrwInit("g:netrw_dirhistmax" , 10) @@ -297,7 +295,7 @@ 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" + 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") @@ -323,7 +321,7 @@ endif call s:NetrwInit("g:netrw_localmkdir","mkdir") call s:NetrwInit("g:netrw_remote_mkdir","mkdir") if exists("g:netrw_local_movecmd") - let g:netrw_localmovecmd= 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") @@ -341,7 +339,7 @@ if !exists("g:netrw_localmovecmd") endif call s:NetrwInit("g:netrw_localrmdir", "rmdir") if exists("g:netrw_local_rmdir") - let g:netrw_localrmdir= g:netrw_local_rmdir" + let g:netrw_localrmdir= g:netrw_local_rmdir call netrw#ErrorMsg(s:NOTE,"g:netrw_local_rmdir is deprecated in favor of g:netrw_localrmdir",86) endif call s:NetrwInit("g:netrw_liststyle" , s:THINLIST) @@ -357,7 +355,7 @@ call s:NetrwInit("g:netrw_markfileesc" , '*./[\~') call s:NetrwInit("g:netrw_maxfilenamelen", 32) call s:NetrwInit("g:netrw_menu" , 1) call s:NetrwInit("g:netrw_mkdir_cmd" , g:netrw_ssh_cmd." USEPORT HOSTNAME mkdir") -call s:NetrwInit("g:netrw_mousemaps" , (exists("&mouse") && &mouse =~ '[anh]')) +call s:NetrwInit("g:netrw_mousemaps" , (exists("+mouse") && &mouse =~ '[anh]')) call s:NetrwInit("g:netrw_retmap" , 0) if has("unix") || (exists("g:netrw_cygwin") && g:netrw_cygwin) call s:NetrwInit("g:netrw_chgperm" , "chmod PERM FILENAME") @@ -392,7 +390,17 @@ call s:NetrwInit("g:netrw_ssh_browse_reject", '^total\s\+\d\+$') call s:NetrwInit("g:netrw_use_noswf" , 0) " Default values - t-w ---------- {{{3 call s:NetrwInit("g:netrw_timefmt","%c") -call s:NetrwInit("g:netrw_xstrlen",0) +if !exists("g:netrw_xstrlen") + if exists("g:Align_xstrlen") + let g:netrw_xstrlen= g:Align_xstrlen + elseif exists("g:drawit_xstrlen") + let g:netrw_xstrlen= g:drawit_xstrlen + elseif &enc == "latin1" || !has("multi_byte") + let g:netrw_xstrlen= 0 + else + let g:netrw_xstrlen= 1 + endif +endif call s:NetrwInit("g:NetrwTopLvlMenu","Netrw.") call s:NetrwInit("g:netrw_win95ftp",1) call s:NetrwInit("g:netrw_winsize",50) @@ -402,11 +410,11 @@ if g:netrw_winsize > 100|let g:netrw_winsize= 100|endif " Default values for netrw's script variables: {{{2 call s:NetrwInit("g:netrw_fname_escape",' ?&;%') if has("win32") || has("win95") || has("win64") || has("win16") - call s:NetrwInit("g:netrw_glob_escape",'[]*?`{$') + call s:NetrwInit("g:netrw_glob_escape",'*?`{[]$') else - call s:NetrwInit("g:netrw_glob_escape",'[]*?`{~$\') + call s:NetrwInit("g:netrw_glob_escape",'*[]?`{~$\') endif -call s:NetrwInit("g:netrw_menu_escape",'./&? \') +call s:NetrwInit("g:netrw_menu_escape",'.&? \') call s:NetrwInit("g:netrw_tmpfile_escape",' &;') call s:NetrwInit("s:netrw_map_escape","<|\n\r\\\<C-V>\"") @@ -459,7 +467,7 @@ if v:version >= 700 && has("balloon_eval") && &beval == 1 && has("syntax") && ex endif " ------------------------------------------------------------------------ -" s:NetrwOptionSave: save options and set to "standard" form {{{2 +" s:NetrwOptionSave: save options prior to setting to "netrw-buffer-standard" form {{{2 " 06/08/07 : removed call to NetrwSafeOptions(), either placed " immediately after NetrwOptionSave() calls in NetRead " and NetWrite, or after the s:NetrwEnew() call in @@ -475,7 +483,7 @@ fun! s:NetrwOptionSave(vt) " call Dret("s:NetrwOptionSave : options already saved") return endif -" call Decho("fo=".&fo.(exists("&acd")? " acd=".&acd : " acd doesn't exist")." diff=".&l:diff) +" call Decho("fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist")." diff=".&l:diff) " Save current settings and current directory " call Decho("saving current settings and current directory") @@ -487,6 +495,7 @@ fun! s:NetrwOptionSave(vt) let {a:vt}netrw_blkeep = &l:bl let {a:vt}netrw_btkeep = &l:bt let {a:vt}netrw_bombkeep = &l:bomb + let {a:vt}netrw_cedit = &cedit let {a:vt}netrw_cikeep = &l:ci let {a:vt}netrw_cinkeep = &l:cin let {a:vt}netrw_cinokeep = &l:cino @@ -552,7 +561,7 @@ fun! s:NetrwOptionRestore(vt) endif unlet {a:vt}netrw_optionsave - if exists("&acd") + if exists("+acd") if exists("{a:vt}netrw_acdkeep") " call Decho("(NetrwOptionRestore) g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd) let curdir = getcwd() @@ -572,10 +581,13 @@ fun! s:NetrwOptionRestore(vt) endif if exists("{a:vt}netrw_aikeep") |let &l:ai = {a:vt}netrw_aikeep |unlet {a:vt}netrw_aikeep |endif if exists("{a:vt}netrw_awkeep") |let &l:aw = {a:vt}netrw_awkeep |unlet {a:vt}netrw_awkeep |endif - if exists("{a:vt}netrw_bhkeep") |let &l:bh = {a:vt}netrw_bhkeep |unlet {a:vt}netrw_bhkeep |endif + if g:netrw_liststyle != s:TREELIST + if exists("{a:vt}netrw_bhkeep") |let &l:bh = {a:vt}netrw_bhkeep |unlet {a:vt}netrw_bhkeep |endif + endif if exists("{a:vt}netrw_blkeep") |let &l:bl = {a:vt}netrw_blkeep |unlet {a:vt}netrw_blkeep |endif if exists("{a:vt}netrw_btkeep") |let &l:bt = {a:vt}netrw_btkeep |unlet {a:vt}netrw_btkeep |endif if exists("{a:vt}netrw_bombkeep") |let &l:bomb = {a:vt}netrw_bombkeep |unlet {a:vt}netrw_bombkeep |endif + if exists("{a:vt}netrw_cedit") |let &cedit = {a:vt}netrw_cedit |unlet {a:vt}netrw_cedit |endif if exists("{a:vt}netrw_cikeep") |let &l:ci = {a:vt}netrw_cikeep |unlet {a:vt}netrw_cikeep |endif if exists("{a:vt}netrw_cinkeep") |let &l:cin = {a:vt}netrw_cinkeep |unlet {a:vt}netrw_cinkeep |endif if exists("{a:vt}netrw_cinokeep") |let &l:cino = {a:vt}netrw_cinokeep |unlet {a:vt}netrw_cinokeep |endif @@ -612,7 +624,7 @@ fun! s:NetrwOptionRestore(vt) " to the current directory as returned by getcwd(). let &l:directory = getcwd() sil! let &l:swf = {a:vt}netrw_swfkeep - setlocal directory= + setl directory= unlet {a:vt}netrw_swfkeep elseif &l:swf != {a:vt}netrw_swfkeep " following line causes a Press ENTER in windows -- can't seem to work around it!!! @@ -636,55 +648,549 @@ fun! s:NetrwOptionRestore(vt) endif " call Decho("(NetrwOptionRestore) g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd) -" call Decho("(NetrwOptionRestore) fo=".&fo.(exists("&acd")? " acd=".&acd : " acd doesn't exist")) +" call Decho("(NetrwOptionRestore) fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist")) " call Decho("(NetrwOptionRestore) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") " call Decho("(NetrwOptionRestore) diff=".&l:diff." win#".winnr()." w:netrw_diffkeep=".(exists("w:netrw_diffkeep")? w:netrw_diffkeep : "doesn't exist")) " call Decho("(NetrwOptionRestore) ts=".&l:ts) + " Moved the filetype detect here from NetrwGetFile() because remote files + " were having their filetype detect-generated settings overwritten by + " NetrwOptionRestore. + if &ft != "netrw" +" call Decho("(NetrwOptionRestore) filetype detect (ft=".&ft.")") + filetype detect + endif " call Dret("s:NetrwOptionRestore : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) endfun " --------------------------------------------------------------------- " s:NetrwSafeOptions: sets options to help netrw do its job {{{2 +" Use s:NetrwSaveOptions() to save user settings +" Use s:NetrwOptionRestore() to restore user settings fun! s:NetrwSafeOptions() " call Dfunc("s:NetrwSafeOptions() win#".winnr()." buf#".bufnr("%")."<".bufname(bufnr("%"))."> winnr($)=".winnr("$")) " call Decho("win#".winnr()."'s ft=".&ft) - if exists("&acd") | setlocal noacd | endif - setlocal noai - setlocal noaw - setlocal nobomb - setlocal noci - setlocal nocin - setlocal cino= - setlocal com= - setlocal cpo-=a - setlocal cpo-=A - setlocal fo=nroql2 - setlocal nohid - setlocal noim - setlocal isk+=@ isk+=* isk+=/ - setlocal magic - setlocal report=10000 - setlocal sel=inclusive - setlocal nospell - setlocal tw=0 - setlocal wig= + if exists("+acd") | setl noacd | endif + setl noai + setl noaw + setl nobomb + setl noci + setl nocin + if g:netrw_liststyle == s:TREELIST + setl bh=hide + endif + setl cino= + setl com= + setl cpo-=a + setl cpo-=A + setl fo=nroql2 + setl nohid + setl noim + setl isk+=@ isk+=* isk+=/ + setl magic + setl report=10000 + setl sel=inclusive + setl nospell + setl tw=0 + setl wig= + set cedit& if g:netrw_use_noswf && has("win32") && !has("win95") - setlocal noswf + setl noswf endif call s:NetrwCursor() " allow the user to override safe options " call Decho("ft<".&ft."> ei=".&ei) if &ft == "netrw" -" call Decho("do any netrw FileType autocmds") +" call Decho("do any netrw FileType autocmds (doau FileType netrw)") sil! keepalt keepj doau FileType netrw endif -" call Decho("fo=".&fo.(exists("&acd")? " acd=".&acd : " acd doesn't exist")) +" call Decho("fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist")." bh=".&l:bh) " call Dret("s:NetrwSafeOptions") endfun " --------------------------------------------------------------------- +" netrw#Explore: launch the local browser in the directory of the current file {{{2 +" indx: == -1: Nexplore +" == -2: Pexplore +" == +: this is overloaded: +" * If Nexplore/Pexplore is in use, then this refers to the +" indx'th item in the w:netrw_explore_list[] of items which +" matched the */pattern **/pattern *//pattern **//pattern +" * If Hexplore or Vexplore, then this will override +" g:netrw_winsize to specify the qty of rows or columns the +" newly split window should have. +" dosplit==0: the window will be split iff the current file has been modified +" dosplit==1: the window will be split before running the local browser +" style == 0: Explore style == 1: Explore! +" == 2: Hexplore style == 3: Hexplore! +" == 4: Vexplore style == 5: Vexplore! +" == 6: Texplore +fun! netrw#Explore(indx,dosplit,style,...) +" call Dfunc("netrw#Explore(indx=".a:indx." dosplit=".a:dosplit." style=".a:style.",a:1<".a:1.">) &modified=".&modified." modifiable=".&modifiable." a:0=".a:0." win#".winnr()." buf#".bufnr("%")) + if !exists("b:netrw_curdir") + let b:netrw_curdir= getcwd() +" call Decho("(Explore) set b:netrw_curdir<".b:netrw_curdir."> (used getcwd)") + endif + let curdir = simplify(b:netrw_curdir) + let curfiledir = substitute(expand("%:p"),'^\(.*[/\\]\)[^/\\]*$','\1','e') +" call Decho("(Explore) curdir<".curdir."> curfiledir<".curfiledir.">") + + " save registers + sil! let keepregstar = @* + sil! let keepregplus = @+ + sil! let keepregslash= @/ + + " if dosplit or file has been modified + if a:dosplit || &modified || a:style == 6 +" call Decho("(Explore) case dosplit=".a:dosplit." modified=".&modified." a:style=".a:style.": dosplit or file has been modified") + call s:SaveWinVars() + let winsz= g:netrw_winsize + if a:indx > 0 + let winsz= a:indx + endif + + if a:style == 0 " Explore, Sexplore +" call Decho("(Explore) style=0: Explore or Sexplore") + let winsz= (winsz > 0)? (winsz*winheight(0))/100 : -winsz + exe winsz."wincmd s" + + elseif a:style == 1 "Explore!, Sexplore! +" call Decho("(Explore) style=1: Explore! or Sexplore!") + let winsz= (winsz > 0)? (winsz*winwidth(0))/100 : -winsz + exe "keepalt ".winsz."wincmd v" + + elseif a:style == 2 " Hexplore +" call Decho("(Explore) style=2: Hexplore") + let winsz= (winsz > 0)? (winsz*winheight(0))/100 : -winsz + exe "keepalt bel ".winsz."wincmd s" + + elseif a:style == 3 " Hexplore! +" call Decho("(Explore) style=3: Hexplore!") + let winsz= (winsz > 0)? (winsz*winheight(0))/100 : -winsz + exe "keepalt abo ".winsz."wincmd s" + + elseif a:style == 4 " Vexplore +" call Decho("(Explore) style=4: Vexplore") + let winsz= (winsz > 0)? (winsz*winwidth(0))/100 : -winsz + exe "keepalt lefta ".winsz."wincmd v" + + elseif a:style == 5 " Vexplore! +" call Decho("(Explore) style=5: Vexplore!") + let winsz= (winsz > 0)? (winsz*winwidth(0))/100 : -winsz + exe "keepalt rightb ".winsz."wincmd v" + + elseif a:style == 6 " Texplore + call s:SaveBufVars() +" call Decho("(Explore) style = 6: Texplore") + exe "keepalt tabnew ".fnameescape(curdir) + call s:RestoreBufVars() + endif + call s:RestoreWinVars() +" else " Decho +" call Decho("(Explore) case a:dosplit=".a:dosplit." AND modified=".&modified." AND a:style=".a:style." is not 6") + endif + keepj norm! 0 + + if a:0 > 0 +" call Decho("(Explore) case [a:0=".a:0."] > 0") + if a:1 =~ '^\~' && (has("unix") || (exists("g:netrw_cygwin") && g:netrw_cygwin)) +" call Decho("(Explore) ..case a:1<".a:1.">: starts with ~ and unix or cygwin") + let dirname= simplify(substitute(a:1,'\~',expand("$HOME"),'')) +" call Decho("(Explore) ..using dirname<".dirname."> (case: ~ && unix||cygwin)") + elseif a:1 == '.' +" call Decho("(Explore) ..case a:1<".a:1.">: matches .") + let dirname= simplify(exists("b:netrw_curdir")? b:netrw_curdir : getcwd()) + if dirname !~ '/$' + let dirname= dirname."/" + endif +" call Decho("(Explore) ..using dirname<".dirname."> (case: ".(exists("b:netrw_curdir")? "b:netrw_curdir" : "getcwd()").")") + elseif a:1 =~ '\$' +" call Decho("(Explore) ..case a:1<".a:1.">: matches ending $") + let dirname= simplify(expand(a:1)) +" call Decho("(Explore) ..using user-specified dirname<".dirname."> with $env-var") + elseif a:1 !~ '^\*\{1,2}/' +" call Decho("(Explore) ..case a:1<".a:1.">: other, not pattern or filepattern") + let dirname= simplify(a:1) +" call Decho("(Explore) ..using user-specified dirname<".dirname.">") + else +" call Decho("(Explore) ..case a:1: pattern or filepattern") + let dirname= a:1 + endif + else + " clear explore +" call Decho("(Explore) case a:0=".a:0.": clearing Explore list") + call s:NetrwClearExplore() +" call Dret("netrw#Explore : cleared list") + return + endif + +" call Decho("(Explore) dirname<".dirname.">") + if dirname =~ '\.\./\=$' + let dirname= simplify(fnamemodify(dirname,':p:h')) + elseif dirname =~ '\.\.' || dirname == '.' + let dirname= simplify(fnamemodify(dirname,':p')) + endif +" call Decho("(Explore) dirname<".dirname."> (after simplify)") + + if dirname =~ '^\*//' + " starpat=1: Explore *//pattern (current directory only search for files containing pattern) +" call Decho("(Explore) case Explore *//pattern") + let pattern= substitute(dirname,'^\*//\(.*\)$','\1','') + let starpat= 1 +" call Decho("(Explore) ..Explore *//pat: (starpat=".starpat.") dirname<".dirname."> -> pattern<".pattern.">") + if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif + + elseif dirname =~ '^\*\*//' + " starpat=2: Explore **//pattern (recursive descent search for files containing pattern) +" call Decho("(Explore) case Explore **//pattern") + let pattern= substitute(dirname,'^\*\*//','','') + let starpat= 2 +" call Decho("(Explore) ..Explore **//pat: (starpat=".starpat.") dirname<".dirname."> -> pattern<".pattern.">") + + elseif dirname =~ '/\*\*/' + " handle .../**/.../filepat +" call Decho("(Explore) case Explore .../**/.../filepat") + let prefixdir= substitute(dirname,'^\(.\{-}\)\*\*.*$','\1','') + if prefixdir =~ '^/' || (prefixdir =~ '^\a:/' && (has("win32") || has("win95") || has("win64") || has("win16"))) + let b:netrw_curdir = prefixdir + else + let b:netrw_curdir= getcwd().'/'.prefixdir + endif + let dirname= substitute(dirname,'^.\{-}\(\*\*/.*\)$','\1','') + let starpat= 4 +" call Decho("(Explore) ..pwd<".getcwd()."> dirname<".dirname.">") +" call Decho("(Explore) ..case Explore ../**/../filepat (starpat=".starpat.")") + + elseif dirname =~ '^\*/' + " starpat=3: Explore */filepat (search in current directory for filenames matching filepat) + let starpat= 3 +" call Decho("(Explore) case Explore */filepat (starpat=".starpat.")") + + elseif dirname=~ '^\*\*/' + " starpat=4: Explore **/filepat (recursive descent search for filenames matching filepat) + let starpat= 4 +" call Decho("(Explore) case Explore **/filepat (starpat=".starpat.")") + + else + let starpat= 0 +" call Decho("(Explore) default case: starpat=".starpat) + endif + + if starpat == 0 && a:indx >= 0 + " [Explore Hexplore Vexplore Sexplore] [dirname] +" call Decho("(Explore) case starpat==0 && a:indx=".a:indx.": dirname<".dirname."> Explore Hexplore Vexplore Sexplore") + if dirname == "" + let dirname= curfiledir +" call Decho("(Explore) ..empty dirname, using current file's directory<".dirname.">") + endif + if dirname =~ '^scp:' || dirname =~ '^ftp:' +" call Decho("(Explore) ..calling NetrwBrowse(0,dirname<".dirname.">)") + call s:NetrwBrowse(0,dirname) + else + if dirname == ""|let dirname= getcwd()|endif +" call Decho("(Explore) ..calling LocalBrowseCheck(dirname<".dirname.">)") + call netrw#LocalBrowseCheck(dirname) +" call Decho("(Explore) win#".winnr()." buf#".bufnr("%")." modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) + endif + if exists("w:netrw_bannercnt") + " done to handle P08-Ingelrest. :Explore will _Always_ go to the line just after the banner. + " If one wants to return the same place in the netrw window, use :Rex instead. + exe w:netrw_bannercnt + endif + +" call Decho("(Explore) curdir<".curdir.">") + " --------------------------------------------------------------------- + " Jan 24, 2013: not sure why the following was present. See P08-Ingelrest +" if has("win32") || has("win95") || has("win64") || has("win16") +" keepj call search('\<'.substitute(curdir,'^.*[/\\]','','e').'\>','cW') +" else +" keepj call search('\<'.substitute(curdir,'^.*/','','e').'\>','cW') +" endif + " --------------------------------------------------------------------- + + " starpat=1: Explore *//pattern (current directory only search for files containing pattern) + " starpat=2: Explore **//pattern (recursive descent search for files containing pattern) + " starpat=3: Explore */filepat (search in current directory for filenames matching filepat) + " starpat=4: Explore **/filepat (recursive descent search for filenames matching filepat) + elseif a:indx <= 0 + " Nexplore, Pexplore, Explore: handle starpat +" call Decho("(Explore) case a:indx<=0: Nexplore, Pexplore, <s-down>, <s-up> starpat=".starpat." a:indx=".a:indx) + if !mapcheck("<s-up>","n") && !mapcheck("<s-down>","n") && exists("b:netrw_curdir") +" call Decho("(Explore) ..set up <s-up> and <s-down> maps") + let s:didstarstar= 1 + nnoremap <buffer> <silent> <s-up> :Pexplore<cr> + nnoremap <buffer> <silent> <s-down> :Nexplore<cr> + endif + + if has("path_extra") +" call Decho("(Explore) ..starpat=".starpat.": has +path_extra") + if !exists("w:netrw_explore_indx") + let w:netrw_explore_indx= 0 + endif + + let indx = a:indx +" call Decho("(Explore) ..starpat=".starpat.": set indx= [a:indx=".indx."]") + + if indx == -1 + " Nexplore +" call Decho("(Explore) ..case Nexplore with starpat=".starpat.": (indx=".indx.")") + if !exists("w:netrw_explore_list") " sanity check + keepj call netrw#ErrorMsg(s:WARNING,"using Nexplore or <s-down> improperly; see help for netrw-starstar",40) + sil! let @* = keepregstar + sil! let @+ = keepregstar + sil! let @/ = keepregslash +" call Dret("netrw#Explore") + return + endif + let indx= w:netrw_explore_indx + if indx < 0 | let indx= 0 | endif + if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif + let curfile= w:netrw_explore_list[indx] +" call Decho("(Explore) ....indx=".indx." curfile<".curfile.">") + while indx < w:netrw_explore_listlen && curfile == w:netrw_explore_list[indx] + let indx= indx + 1 +" call Decho("(Explore) ....indx=".indx." (Nexplore while loop)") + endwhile + if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif +" call Decho("(Explore) ....Nexplore: indx= [w:netrw_explore_indx=".w:netrw_explore_indx."]=".indx) + + elseif indx == -2 + " Pexplore +" call Decho("(Explore) case Pexplore with starpat=".starpat.": (indx=".indx.")") + if !exists("w:netrw_explore_list") " sanity check + keepj call netrw#ErrorMsg(s:WARNING,"using Pexplore or <s-up> improperly; see help for netrw-starstar",41) + sil! let @* = keepregstar + sil! let @+ = keepregstar + sil! let @/ = keepregslash +" call Dret("netrw#Explore") + return + endif + let indx= w:netrw_explore_indx + if indx < 0 | let indx= 0 | endif + if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif + let curfile= w:netrw_explore_list[indx] +" call Decho("(Explore) ....indx=".indx." curfile<".curfile.">") + while indx >= 0 && curfile == w:netrw_explore_list[indx] + let indx= indx - 1 +" call Decho("(Explore) ....indx=".indx." (Pexplore while loop)") + endwhile + if indx < 0 | let indx= 0 | endif +" call Decho("(Explore) ....Pexplore: indx= [w:netrw_explore_indx=".w:netrw_explore_indx."]=".indx) + + else + " Explore -- initialize + " build list of files to Explore with Nexplore/Pexplore +" call Decho("(Explore) ..starpat=".starpat.": case Explore: initialize (indx=".indx.")") + keepj keepalt call s:NetrwClearExplore() + let w:netrw_explore_indx= 0 + if !exists("b:netrw_curdir") + let b:netrw_curdir= getcwd() + endif +" call Decho("(Explore) ....starpat=".starpat.": b:netrw_curdir<".b:netrw_curdir.">") + + " switch on starpat to build the w:netrw_explore_list of files + if starpat == 1 + " starpat=1: Explore *//pattern (current directory only search for files containing pattern) +" call Decho("(Explore) ..case starpat=".starpat.": build *//pattern list (curdir-only srch for files containing pattern) &hls=".&hls) +" call Decho("(Explore) ....pattern<".pattern.">") + try + exe "keepj 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 Dret("netrw#Explore : unable to find pattern<".pattern.">") + return + endtry + let w:netrw_explore_list = s:NetrwExploreListUniq(map(getqflist(),'bufname(v:val.bufnr)')) + if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif + + elseif starpat == 2 + " starpat=2: Explore **//pattern (recursive descent search for files containing pattern) +" call Decho("(Explore) ..case starpat=".starpat.": build **//pattern list (recursive descent files containing pattern)") +" call Decho("(Explore) ....pattern<".pattern.">") + try + exe "sil keepj noautocmd keepalt vimgrep /".pattern."/gj "."**/*" + catch /^Vim\%((\a\+)\)\=:E480/ + keepalt call netrw#ErrorMsg(s:WARNING,'no files matched pattern<'.pattern.'>',45) + if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif + sil! let @* = keepregstar + sil! let @+ = keepregstar + sil! let @/ = keepregslash +" call Dret("netrw#Explore : no files matched pattern") + return + endtry + let s:netrw_curdir = b:netrw_curdir + let w:netrw_explore_list = getqflist() + let w:netrw_explore_list = s:NetrwExploreListUniq(map(w:netrw_explore_list,'s:netrw_curdir."/".bufname(v:val.bufnr)')) + if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif + + elseif starpat == 3 + " starpat=3: Explore */filepat (search in current directory for filenames matching filepat) +" call Decho("(Explore) ..case starpat=".starpat.": build */filepat list (curdir-only srch filenames matching filepat) &hls=".&hls) + let filepat= substitute(dirname,'^\*/','','') + let filepat= substitute(filepat,'^[%#<]','\\&','') +" call Decho("(Explore) ....b:netrw_curdir<".b:netrw_curdir.">") +" call Decho("(Explore) ....filepat<".filepat.">") + let w:netrw_explore_list= s:NetrwExploreListUniq(split(expand(b:netrw_curdir."/".filepat),'\n')) + if &hls | let keepregslash= s:ExplorePatHls(filepat) | endif + + elseif starpat == 4 + " starpat=4: Explore **/filepat (recursive descent search for filenames matching filepat) +" call Decho("(Explore) ..case starpat=".starpat.": build **/filepat list (recursive descent srch filenames matching filepat) &hls=".&hls) + let w:netrw_explore_list= s:NetrwExploreListUniq(split(expand(b:netrw_curdir."/".dirname),'\n')) + if &hls | let keepregslash= s:ExplorePatHls(dirname) | endif + endif " switch on starpat to build w:netrw_explore_list + + let w:netrw_explore_listlen = len(w:netrw_explore_list) +" call Decho("(Explore) ....w:netrw_explore_list<".string(w:netrw_explore_list).">") +" call Decho("(Explore) ....w:netrw_explore_listlen=".w:netrw_explore_listlen) + + if w:netrw_explore_listlen == 0 || (w:netrw_explore_listlen == 1 && w:netrw_explore_list[0] =~ '\*\*\/') + keepalt keepj call netrw#ErrorMsg(s:WARNING,"no files matched",42) + sil! let @* = keepregstar + sil! let @+ = keepregstar + sil! let @/ = keepregslash +" call Dret("netrw#Explore : no files matched") + return + endif + endif " if indx ... endif + + " NetrwStatusLine support - for exploring support + let w:netrw_explore_indx= indx +" call Decho("(Explore) ....w:netrw_explore_list<".join(w:netrw_explore_list,',')."> len=".w:netrw_explore_listlen) + + " wrap the indx around, but issue a note + if indx >= w:netrw_explore_listlen || indx < 0 +" call Decho("(Explore) ....wrap indx (indx=".indx." listlen=".w:netrw_explore_listlen.")") + let indx = (indx < 0)? ( w:netrw_explore_listlen - 1 ) : 0 + let w:netrw_explore_indx= indx + keepalt keepj call netrw#ErrorMsg(s:NOTE,"no more files match Explore pattern",43) + endif + + exe "let dirfile= w:netrw_explore_list[".indx."]" +" call Decho("(Explore) ....dirfile=w:netrw_explore_list[indx=".indx."]= <".dirfile.">") + let newdir= substitute(dirfile,'/[^/]*$','','e') +" call Decho("(Explore) ....newdir<".newdir.">") + +" call Decho("(Explore) ....calling LocalBrowseCheck(newdir<".newdir.">)") + call netrw#LocalBrowseCheck(newdir) + if !exists("w:netrw_liststyle") + let w:netrw_liststyle= g:netrw_liststyle + endif + if w:netrw_liststyle == s:THINLIST || w:netrw_liststyle == s:LONGLIST + keepalt keepj call search('^'.substitute(dirfile,"^.*/","","").'\>',"W") + else + keepalt keepj 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(".") + keepalt keepj call s:SetupNetrwStatusLine('%f %h%m%r%=%9*%{NetrwStatusLine()}') +" call Decho("(Explore) ....explore: mtchcnt=".w:netrw_explore_mtchcnt." bufnr=".w:netrw_explore_bufnr." line#".w:netrw_explore_line) + + else +" call Decho("(Explore) ..your vim does not have +path_extra") + if !exists("g:netrw_quiet") + keepalt keepj call netrw#ErrorMsg(s:WARNING,"your vim needs the +path_extra feature for Exploring with **!",44) + endif + sil! let @* = keepregstar + sil! let @+ = keepregstar + sil! let @/ = keepregslash +" call Dret("netrw#Explore : missing +path_extra") + return + endif + + else +" call Decho("(Explore) ..default case: Explore newdir<".dirname.">") + if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && dirname =~ '/' + sil! unlet w:netrw_treedict + sil! unlet w:netrw_treetop + endif + let newdir= dirname + if !exists("b:netrw_curdir") + keepj call netrw#LocalBrowseCheck(getcwd()) + else + keepj call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,newdir)) + endif + endif + + " visual display of **/ **// */ Exploration files +" call Decho("(Explore) w:netrw_explore_indx=".(exists("w:netrw_explore_indx")? w:netrw_explore_indx : "doesn't exist")) +" call Decho("(Explore) b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "n/a").">") + if exists("w:netrw_explore_indx") && exists("b:netrw_curdir") +" call Decho("(Explore) s:explore_prvdir<".(exists("s:explore_prvdir")? s:explore_prvdir : "-doesn't exist-")) + if !exists("s:explore_prvdir") || s:explore_prvdir != b:netrw_curdir + " only update match list if current directory isn't the same as before +" call Decho("(Explore) only update match list if current directory not the same as before") + let s:explore_prvdir = b:netrw_curdir + let s:explore_match = "" + let dirlen = s:Strlen(b:netrw_curdir) + if b:netrw_curdir !~ '/$' + let dirlen= dirlen + 1 + endif + let prvfname= "" + for fname in w:netrw_explore_list +" call Decho("(Explore) fname<".fname.">") + if fname =~ '^'.b:netrw_curdir + if s:explore_match == "" + let s:explore_match= '\<'.escape(strpart(fname,dirlen),g:netrw_markfileesc).'\>' + else + let s:explore_match= s:explore_match.'\|\<'.escape(strpart(fname,dirlen),g:netrw_markfileesc).'\>' + endif + elseif fname !~ '^/' && fname != prvfname + if s:explore_match == "" + let s:explore_match= '\<'.escape(fname,g:netrw_markfileesc).'\>' + else + let s:explore_match= s:explore_match.'\|\<'.escape(fname,g:netrw_markfileesc).'\>' + endif + endif + let prvfname= fname + endfor +" call Decho("(Explore) explore_match<".s:explore_match.">") + exe "2match netrwMarkFile /".s:explore_match."/" + endif + echo "<s-up>==Pexplore <s-down>==Nexplore" + else + 2match none + if exists("s:explore_match") | unlet s:explore_match | endif + if exists("s:explore_prvdir") | unlet s:explore_prvdir | endif + echo " " +" call Decho("(Explore) cleared explore match list") + endif + + sil! let @* = keepregstar + sil! let @+ = keepregstar + sil! let @/ = keepregslash +" call Dret("netrw#Explore : @/<".@/.">") +endfun + +" --------------------------------------------------------------------- +" netrw#NetrwMakeTgt: make a target out of the directory name provided {{{2 +fun! netrw#NetrwMakeTgt(dname) +" call Dfunc("netrw#NetrwMakeTgt(dname<".a:dname.">)") + " simplify the target (eg. /abc/def/../ghi -> /abc/ghi) + let svpos = netrw#NetrwSavePosn() + let s:netrwmftgt_islocal= (a:dname !~ '^\a\+://') +" call Decho("s:netrwmftgt_islocal=".s:netrwmftgt_islocal) + if s:netrwmftgt_islocal + let netrwmftgt= simplify(a:dname) + else + let netrwmftgt= a:dname + endif + if exists("s:netrwmftgt") && netrwmftgt == s:netrwmftgt + " re-selected target, so just clear it + unlet s:netrwmftgt s:netrwmftgt_islocal + else + let s:netrwmftgt= netrwmftgt + endif + if g:netrw_fastbrowse <= 1 + call s:NetrwRefresh((b:netrw_curdir !~ '\a\+://'),b:netrw_curdir) + endif + call netrw#NetrwRestorePosn(svpos) +" call Dret("netrw#NetrwMakeTgt") +endfun + +" --------------------------------------------------------------------- " netrw#NetrwClean: remove netrw {{{2 " supports :NetrwClean -- remove netrw from first directory on runtimepath " :NetrwClean! -- remove netrw from all directories on runtimepath @@ -741,6 +1247,257 @@ fun! netrw#Nread(mode,fname) endfun " ------------------------------------------------------------------------ +" netrw#NetrwObtain: {{{2 +" netrw#NetrwObtain(islocal,fname[,tgtdirectory]) +" islocal=0 obtain from remote source +" =1 obtain from local source +" fname : a filename or a list of filenames +" tgtdir : optional place where files are to go (not present, uses getcwd()) +fun! netrw#NetrwObtain(islocal,fname,...) +" call Dfunc("netrw#NetrwObtain(islocal=".a:islocal." fname<".((type(a:fname) == 1)? a:fname : string(a:fname)).">) a:0=".a:0) + " NetrwStatusLine support - for obtaining support + + if type(a:fname) == 1 + let fnamelist= [ a:fname ] + 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 Dret("netrw#NetrwObtain") + return + endif +" call Decho("fnamelist<".string(fnamelist).">") + if a:0 > 0 + let tgtdir= a:1 + else + let tgtdir= getcwd() + endif +" call Decho("tgtdir<".tgtdir.">") + + if exists("b:netrw_islocal") && b:netrw_islocal + " obtain a file from local b:netrw_curdir to (local) tgtdir +" call Decho("obtain a file from local ".b:netrw_curdir." to ".tgtdir) + if exists("b:netrw_curdir") && getcwd() != b:netrw_curdir + let topath= s:ComposePath(tgtdir,"") + if (has("win32") || has("win95") || has("win64") || has("win16")) + " transfer files one at time +" call Decho("transfer files one at a time") + for fname in fnamelist +" call Decho("system(".g:netrw_localcopycmd." ".shellescape(fname)." ".shellescape(topath).")") + call system(g:netrw_localcopycmd." ".shellescape(fname)." ".shellescape(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 Dret("s:NetrwObtain 0 : failed: ".g:netrw_localcopycmd." ".shellescape(fname)." ".shellescape(topath)) + return + endif + endfor + else + " transfer files with one command +" call Decho("transfer files with one command") + let filelist= join(map(deepcopy(fnamelist),"shellescape(v:val)")) +" call Decho("system(".g:netrw_localcopycmd." ".filelist." ".shellescape(topath).")") + call system(g:netrw_localcopycmd." ".filelist." ".shellescape(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 Dret("s:NetrwObtain 0 : failed: ".g:netrw_localcopycmd." ".filelist." ".shellescape(topath)) + return + endif + endif + elseif !exists("b:netrw_curdir") + call netrw#ErrorMsg(s:ERROR,"local browsing directory doesn't exist!",36) + else + call netrw#ErrorMsg(s:WARNING,"local browsing directory and current directory are identical",37) + endif + + else + " obtain files from remote b:netrw_curdir to local tgtdir +" call Decho("obtain a file from remote ".b:netrw_curdir." to ".tgtdir) + if type(a:fname) == 1 + call s:SetupNetrwStatusLine('%f %h%m%r%=%9*Obtaining '.a:fname) + endif + call s:NetrwMethod(b:netrw_curdir) + + if b:netrw_method == 4 + " obtain file using scp +" call Decho("obtain via scp (method#4)") + if exists("g:netrw_port") && g:netrw_port != "" + let useport= " ".g:netrw_scpport." ".g:netrw_port + else + let useport= "" + endif + if b:netrw_fname =~ '/' + let path= substitute(b:netrw_fname,'^\(.*/\).\{-}$','\1','') + else + let path= "" + endif + let filelist= join(map(deepcopy(fnamelist),'shellescape(g:netrw_machine.":".path.v:val,1)')) +" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_scp_cmd.shellescape(useport,1)." ".filelist." ".shellescape(tgtdir,1)) + exe s:netrw_silentxfer."!".g:netrw_scp_cmd.shellescape(useport,1)." ".filelist." ".shellescape(tgtdir,1) + + elseif b:netrw_method == 2 + " obtain file using ftp + .netrc +" call Decho("obtain via ftp+.netrc (method #2)") + call s:SaveBufVars()|sil keepjumps new|call s:RestoreBufVars() + let tmpbufnr= bufnr("%") + setl ff=unix + if exists("g:netrw_ftpmode") && g:netrw_ftpmode != "" + keepj put =g:netrw_ftpmode +" call Decho("filter input: ".getline('$')) + endif + + if exists("b:netrw_fname") && b:netrw_fname != "" + call setline(line("$")+1,'cd "'.b:netrw_fname.'"') +" call Decho("filter input: ".getline('$')) + endif + + if exists("g:netrw_ftpextracmd") + keepj put =g:netrw_ftpextracmd +" call Decho("filter input: ".getline('$')) + endif + for fname in fnamelist + call setline(line("$")+1,'get "'.fname.'"') +" call Decho("filter input: ".getline('$')) + endfor + if exists("g:netrw_port") && g:netrw_port != "" +" call Decho("executing: %!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1)) + exe s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1) + else +" call Decho("executing: %!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)) + exe s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1) + endif + " 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 ' + let debugkeep= &debug + setl debug=msg + call netrw#ErrorMsg(s:ERROR,getline(1),4) + let &debug= debugkeep + endif + + elseif b:netrw_method == 3 + " obtain with ftp + machine, id, passwd, and fname (ie. no .netrc) +" call Decho("obtain via ftp+mipf (method #3)") + call s:SaveBufVars()|sil keepjumps new|call s:RestoreBufVars() + let tmpbufnr= bufnr("%") + setl ff=unix + + if exists("g:netrw_port") && g:netrw_port != "" + keepj put ='open '.g:netrw_machine.' '.g:netrw_port +" call Decho("filter input: ".getline('$')) + else + keepj put ='open '.g:netrw_machine +" call Decho("filter input: ".getline('$')) + endif + + if exists("g:netrw_uid") && g:netrw_uid != "" + if exists("g:netrw_ftp") && g:netrw_ftp == 1 + keepj put =g:netrw_uid +" call Decho("filter input: ".getline('$')) + if exists("s:netrw_passwd") && s:netrw_passwd != "" + keepj put ='\"'.s:netrw_passwd.'\"' + endif +" call Decho("filter input: ".getline('$')) + elseif exists("s:netrw_passwd") + keepj put ='user \"'.g:netrw_uid.'\" \"'.s:netrw_passwd.'\"' +" call Decho("filter input: ".getline('$')) + endif + endif + + if exists("g:netrw_ftpmode") && g:netrw_ftpmode != "" + keepj put =g:netrw_ftpmode +" call Decho("filter input: ".getline('$')) + endif + + if exists("b:netrw_fname") && b:netrw_fname != "" + keepj call setline(line("$")+1,'cd "'.b:netrw_fname.'"') +" call Decho("filter input: ".getline('$')) + endif + + if exists("g:netrw_ftpextracmd") + keepj put =g:netrw_ftpextracmd +" call Decho("filter input: ".getline('$')) + endif + + if exists("g:netrw_ftpextracmd") + keepj put =g:netrw_ftpextracmd +" call Decho("filter input: ".getline('$')) + endif + for fname in fnamelist + keepj call setline(line("$")+1,'get "'.fname.'"') + endfor +" 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 + keepj norm! 1Gdd +" call Decho("executing: %!".s:netrw_ftp_cmd." ".g:netrw_ftp_options) + exe 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 getline(1) !~ "^$" +" call Decho("error<".getline(1).">") + if !exists("g:netrw_quiet") + keepj call netrw#ErrorMsg(s:ERROR,getline(1),5) + endif + endif + elseif !exists("b:netrw_method") || b:netrw_method < 0 +" call Dfunc("netrw#NetrwObtain : unsupported method") + return + endif + + " restore status line + if type(a:fname) == 1 && exists("s:netrw_users_stl") + keepj call s:SetupNetrwStatusLine(s:netrw_users_stl) + endif + + endif + + " cleanup + if exists("tmpbufnr") + if bufnr("%") != tmpbufnr + exe tmpbufnr."bw!" + else + q! + endif + endif + +" call Dret("netrw#NetrwObtain") +endfun + +" --------------------------------------------------------------------- +" NetrwStatusLine: {{{2 +fun! NetrwStatusLine() + +" 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 &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 "" + else + return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen + endif +endfun + +" --------------------------------------------------------------------- " Netrw Transfer Functions: {{{1 " =============================== @@ -899,7 +1656,7 @@ fun! netrw#NetRead(mode,...) let netrw_fname= b:netrw_fname keepj call s:SaveBufVars()|new|keepj call s:RestoreBufVars() let filtbuf= bufnr("%") - setlocal ff=unix + setl ff=unix keepj put =g:netrw_ftpmode " call Decho("filter input: ".getline(line("$"))) if exists("g:netrw_ftpextracmd") @@ -918,7 +1675,7 @@ fun! netrw#NetRead(mode,...) " 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 ' let debugkeep = &debug - setlocal debug=msg + setl debug=msg keepj call netrw#ErrorMsg(s:ERROR,getline(1),4) let &debug = debugkeep endif @@ -940,7 +1697,7 @@ fun! netrw#NetRead(mode,...) let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape) keepj call s:SaveBufVars()|new|keepj call s:RestoreBufVars() let filtbuf= bufnr("%") - setlocal ff=unix + setl ff=unix if exists("g:netrw_port") && g:netrw_port != "" keepj put ='open '.g:netrw_machine.' '.g:netrw_port " call Decho("filter input: ".getline('.')) @@ -1064,7 +1821,7 @@ fun! netrw#NetRead(mode,...) " Construct execution string (four lines) which will be passed through filter let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape) new - setlocal ff=unix + setl ff=unix if exists("g:netrw_port") && g:netrw_port != "" keepj put ='open '.g:netrw_machine.' '.g:netrw_port else @@ -1307,11 +2064,11 @@ fun! netrw#NetWrite(...) range " formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead let bhkeep = &l:bh let curbuf = bufnr("%") - setlocal bh=hide - enew + setl bh=hide + keepalt enew " call Decho("filter input window#".winnr()) - setlocal ff=unix + setl ff=unix keepj put =g:netrw_ftpmode " call Decho("filter input: ".getline('$')) if exists("g:netrw_ftpextracmd") @@ -1354,9 +2111,9 @@ fun! netrw#NetWrite(...) range " formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead let curbuf = bufnr("%") - setlocal bh=hide - enew - setlocal ff=unix + setl bh=hide + keepalt enew + setl ff=unix if exists("g:netrw_port") && g:netrw_port != "" keepj put ='open '.g:netrw_machine.' '.g:netrw_port @@ -1442,10 +2199,10 @@ fun! netrw#NetWrite(...) range " formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead let curbuf = bufnr("%") - setlocal bh=hide - enew + setl bh=hide + keepalt enew - setlocal ff=unix + setl ff=unix if exists("g:netrw_port") && g:netrw_port != "" keepj put ='open '.g:netrw_machine.' '.g:netrw_port else @@ -1491,10 +2248,10 @@ fun! netrw#NetWrite(...) range " formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead let bhkeep = &l:bh let curbuf = bufnr("%") - setlocal bh=hide - enew + setl bh=hide + keepalt enew - setlocal ff=unix + setl ff=unix call setline(1,'put "'.escape(tmpfile,'\').'" '.netrw_fname) " call Decho("filter input: ".getline('.')) " call Decho("executing: %!".g:netrw_sftp_cmd.' '.shellescape(uid_machine,1)) @@ -1647,7 +2404,7 @@ fun! s:NetrwGetFile(readcmd, tfile, method) " call Decho("detect filetype of local version of remote file") let iskkeep= &l:isk setl isk-=/ - filetype detect + " filetype detect " COMBAK - trying filetype detect in NetrwOptionRestore Jan 24, 2013 let &l:isk= iskkeep " call Dredir("renamed buffer back to remote filename<".rfile."> : expand(%)<".expand("%").">","ls!") let line1 = 1 @@ -2104,25 +2861,25 @@ 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") +" call Decho("(NetrwMaps) set up Rexplore command") 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,"not a former netrw window",79)|endif if g:netrw_mousemaps && g:netrw_retmap -" call Decho("set up Rexplore 2-leftmouse") +" call Decho("(NetrwMaps) 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") +" call Decho("(NetrwMaps) making map for 2-leftmouse") nmap <unique> <silent> <2-leftmouse> <Plug>NetrwReturn elseif maparg("<c-leftmouse>","n") == "" -" call Decho("making map for c-leftmouse") +" call Decho("(NetrwMaps) 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") +" call Decho("(NetrwMaps) made <Plug>NetrwReturn map") endif if a:islocal -" call Decho("make local maps") +" call Decho("(NetrwMaps) make local maps") " local normal-mode maps nnoremap <buffer> <silent> a :call <SID>NetrwHide(1)<cr> nnoremap <buffer> <silent> % :call <SID>NetrwOpenFile(1)<cr> @@ -2144,6 +2901,7 @@ fun! s:NetrwMaps(islocal) nnoremap <buffer> <silent> md :<c-u>call <SID>NetrwMarkFileDiff(1)<cr> nnoremap <buffer> <silent> me :<c-u>call <SID>NetrwMarkFileEdit(1)<cr> nnoremap <buffer> <silent> mf :<c-u>call <SID>NetrwMarkFile(1,<SID>NetrwGetWord())<cr> + nnoremap <buffer> <silent> mF :<c-u>call <SID>NetrwUnmarkList(bufnr("%"),b:netrw_curdir)<cr> nnoremap <buffer> <silent> mg :<c-u>call <SID>NetrwMarkFileGrep(1)<cr> nnoremap <buffer> <silent> mh :<c-u>call <SID>NetrwMarkHideSfx(1)<cr> nnoremap <buffer> <silent> mm :<c-u>call <SID>NetrwMarkFileMove(1)<cr> @@ -2162,11 +2920,13 @@ fun! s:NetrwMaps(islocal) nnoremap <buffer> <silent> P :call <SID>NetrwPrevWinOpen(1)<cr> nnoremap <buffer> <silent> qb :<c-u>call <SID>NetrwBookHistHandler(2,b:netrw_curdir)<cr> nnoremap <buffer> <silent> qf :<c-u>call <SID>NetrwFileInfo(1,<SID>NetrwGetWord())<cr> + nnoremap <buffer> <silent> qF :<c-u>call <SID>NetrwMarkFileQFEL(1,getqflist())<cr> nnoremap <buffer> <silent> r :let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetrwRefresh(1,<SID>NetrwBrowseChgDir(1,'./'))<cr> nnoremap <buffer> <silent> s :call <SID>NetrwSortStyle(1)<cr> nnoremap <buffer> <silent> S :call <SID>NetSortSequence(1)<cr> - nnoremap <buffer> <silent> T :call <SID>NetrwSplit(4)<bar>norm! gT<cr> nnoremap <buffer> <silent> t :call <SID>NetrwSplit(4)<cr> + nnoremap <buffer> <silent> Tb :<c-u>call <SID>NetrwSetTgt('b',v:count1)<cr> + nnoremap <buffer> <silent> Th :<c-u>call <SID>NetrwSetTgt('h',v:count)<cr> nnoremap <buffer> <silent> u :<c-u>call <SID>NetrwBookHistHandler(4,expand("%"))<cr> nnoremap <buffer> <silent> U :<c-u>call <SID>NetrwBookHistHandler(5,expand("%"))<cr> nnoremap <buffer> <silent> v :call <SID>NetrwSplit(5)<cr> @@ -2209,11 +2969,13 @@ fun! s:NetrwMaps(islocal) inoremap <buffer> <silent> P <c-o>:call <SID>NetrwPrevWinOpen(1)<cr> inoremap <buffer> <silent> qb <c-o>:<c-u>call <SID>NetrwBookHistHandler(2,b:netrw_curdir)<cr> inoremap <buffer> <silent> qf <c-o>:<c-u>call <SID>NetrwFileInfo(1,<SID>NetrwGetWord())<cr> + inoremap <buffer> <silent> qF :<c-u>call <SID>NetrwMarkFileQFEL(1,getqflist())<cr> inoremap <buffer> <silent> r <c-o>:let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetrwRefresh(1,<SID>NetrwBrowseChgDir(1,'./'))<cr> inoremap <buffer> <silent> s <c-o>:call <SID>NetrwSortStyle(1)<cr> inoremap <buffer> <silent> S <c-o>:call <SID>NetSortSequence(1)<cr> - inoremap <buffer> <silent> T <c-o>:call <SID>NetrwSplit(4)<bar>norm! gT<cr> inoremap <buffer> <silent> t <c-o>:call <SID>NetrwSplit(4)<cr> + inoremap <buffer> <silent> Tb <c-o>:<c-u>call <SID>NetrwSetTgt('b',v:count1)<cr> + inoremap <buffer> <silent> Th <c-o>:<c-u>call <SID>NetrwSetTgt('h',v:count)<cr> inoremap <buffer> <silent> u <c-o>:<c-u>call <SID>NetrwBookHistHandler(4,expand("%"))<cr> inoremap <buffer> <silent> U <c-o>:<c-u>call <SID>NetrwBookHistHandler(5,expand("%"))<cr> inoremap <buffer> <silent> v <c-o>:call <SID>NetrwSplit(5)<cr> @@ -2240,6 +3002,8 @@ fun! s:NetrwMaps(islocal) if g:netrw_mousemaps == 1 nmap <buffer> <leftmouse> <Plug>NetrwLeftmouse nno <buffer> <silent> <Plug>NetrwLeftmouse <leftmouse>:call <SID>NetrwLeftmouse(1)<cr> + nmap <buffer> <s-rightdrag> <Plug>NetrwRightdrag + nno <buffer> <silent> <Plug>NetrwRightdrag <leftmouse>:call <SID>NetrwRightdrag(1)<cr> nmap <buffer> <middlemouse> <Plug>NetrwMiddlemouse nno <buffer> <silent> <Plug>NetrwMiddlemouse <leftmouse>:call <SID>NetrwPrevWinOpen(1)<cr> nmap <buffer> <s-leftmouse> <Plug>NetrwSLeftmouse @@ -2270,7 +3034,7 @@ fun! s:NetrwMaps(islocal) nnoremap <buffer> <F1> :he netrw-quickhelp<cr> else " remote -" call Decho("make remote maps") +" call Decho("(NetrwMaps) make remote maps") call s:RemotePathAnalysis(b:netrw_curdir) " remote normal-mode maps nnoremap <buffer> <silent> <cr> :call <SID>NetrwBrowse(0,<SID>NetrwBrowseChgDir(0,<SID>NetrwGetWord()))<cr> @@ -2282,6 +3046,7 @@ fun! s:NetrwMaps(islocal) nnoremap <buffer> <silent> md :<c-u>call <SID>NetrwMarkFileDiff(0)<cr> nnoremap <buffer> <silent> me :<c-u>call <SID>NetrwMarkFileEdit(0)<cr> nnoremap <buffer> <silent> mf :<c-u>call <SID>NetrwMarkFile(0,<SID>NetrwGetWord())<cr> + nnoremap <buffer> <silent> mF :<c-u>call <SID>NetrwUnmarkList(bufnr("%"),b:netrw_curdir)<cr> nnoremap <buffer> <silent> mg :<c-u>call <SID>NetrwMarkFileGrep(0)<cr> nnoremap <buffer> <silent> mh :<c-u>call <SID>NetrwMarkHideSfx(0)<cr> nnoremap <buffer> <silent> mm :<c-u>call <SID>NetrwMarkFileMove(0)<cr> @@ -2309,11 +3074,13 @@ fun! s:NetrwMaps(islocal) nnoremap <buffer> <silent> qb :<c-u>call <SID>NetrwBookHistHandler(2,b:netrw_curdir)<cr> nnoremap <buffer> <silent> mB :<c-u>call <SID>NetrwBookHistHandler(6,b:netrw_curdir)<cr> nnoremap <buffer> <silent> qf :<c-u>call <SID>NetrwFileInfo(0,<SID>NetrwGetWord())<cr> + nnoremap <buffer> <silent> qF :<c-u>call <SID>NetrwMarkFileQFEL(0,getqflist())<cr> nnoremap <buffer> <silent> r :let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetrwBrowse(0,<SID>NetrwBrowseChgDir(0,'./'))<cr> nnoremap <buffer> <silent> s :call <SID>NetrwSortStyle(0)<cr> nnoremap <buffer> <silent> S :call <SID>NetSortSequence(0)<cr> nnoremap <buffer> <silent> t :call <SID>NetrwSplit(1)<cr> - nnoremap <buffer> <silent> T :call <SID>NetrwSplit(1)<bar>norm! gT<cr> + nnoremap <buffer> <silent> Tb :<c-u>call <SID>NetrwSetTgt('b',v:count1)<cr> + nnoremap <buffer> <silent> Th :<c-u>call <SID>NetrwSetTgt('h',v:count)<cr> nnoremap <buffer> <silent> u :<c-u>call <SID>NetrwBookHistHandler(4,b:netrw_curdir)<cr> nnoremap <buffer> <silent> U :<c-u>call <SID>NetrwBookHistHandler(5,b:netrw_curdir)<cr> nnoremap <buffer> <silent> v :call <SID>NetrwSplit(2)<cr> @@ -2354,11 +3121,13 @@ fun! s:NetrwMaps(islocal) inoremap <buffer> <silent> qb <c-o>:<c-u>call <SID>NetrwBookHistHandler(2,b:netrw_curdir)<cr> inoremap <buffer> <silent> mB <c-o>:<c-u>call <SID>NetrwBookHistHandler(6,b:netrw_curdir)<cr> inoremap <buffer> <silent> qf <c-o>:<c-u>call <SID>NetrwFileInfo(0,<SID>NetrwGetWord())<cr> + inoremap <buffer> <silent> qF :<c-u>call <SID>NetrwMarkFileQFEL(0,getqflist())<cr> inoremap <buffer> <silent> r <c-o>:let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetrwBrowse(0,<SID>NetrwBrowseChgDir(0,'./'))<cr> inoremap <buffer> <silent> s <c-o>:call <SID>NetrwSortStyle(0)<cr> inoremap <buffer> <silent> S <c-o>:call <SID>NetSortSequence(0)<cr> inoremap <buffer> <silent> t <c-o>:call <SID>NetrwSplit(1)<cr> - inoremap <buffer> <silent> T <c-o>:call <SID>NetrwSplit(1)<bar>norm! gT<cr> + inoremap <buffer> <silent> Tb <c-o>:<c-u>call <SID>NetrwSetTgt('b',v:count1)<cr> + inoremap <buffer> <silent> Th <c-o>:<c-u>call <SID>NetrwSetTgt('h',v:count)<cr> inoremap <buffer> <silent> u <c-o>:<c-u>call <SID>NetrwBookHistHandler(4,b:netrw_curdir)<cr> inoremap <buffer> <silent> U <c-o>:<c-u>call <SID>NetrwBookHistHandler(5,b:netrw_curdir)<cr> inoremap <buffer> <silent> v <c-o>:call <SID>NetrwSplit(2)<cr> @@ -2381,6 +3150,8 @@ fun! s:NetrwMaps(islocal) if g:netrw_mousemaps == 1 nmap <leftmouse> <Plug>NetrwLeftmouse nno <buffer> <silent> <Plug>NetrwLeftmouse <leftmouse>:call <SID>NetrwLeftmouse(0)<cr> + nmap <buffer> <leftdrag> <Plug>NetrwLeftdrag + nno <buffer> <silent> <Plug>NetrwLeftdrag :call <SID>NetrwLeftdrag(0)<cr> nmap <middlemouse> <Plug>NetrwMiddlemouse nno <buffer> <silent> <middlemouse> <Plug>NetrwMiddlemouse <leftmouse>:call <SID>NetrwPrevWinOpen(0)<cr> nmap <buffer> <s-leftmouse> <Plug>NetrwSLeftmouse @@ -2441,6 +3212,10 @@ endfun " 6: (user: <mB>) delete bookmark fun! s:NetrwBookHistHandler(chg,curdir) " call Dfunc("s:NetrwBookHistHandler(chg=".a:chg." curdir<".a:curdir.">) cnt=".v:count." histcnt=".g:netrw_dirhist_cnt." histmax=".g:netrw_dirhistmax) + if !exists("g:netrw_dirhistmax") || g:netrw_dirhistmax <= 0 +" " call Dret("s:NetrwBookHistHandler - suppressed due to g:netrw_dirhistmax") + return + endif let ykeep= @@ if a:chg == 0 @@ -2458,8 +3233,9 @@ fun! s:NetrwBookHistHandler(chg,curdir) elseif a:chg == 1 " change to the bookmarked directory -" call Decho("(user: <".v:count."mb>) change to the bookmarked directory") +" call Decho("(user: <".v:count."gb>) change to the bookmarked directory") if exists("g:netrw_bookmarklist[v:count-1]") +" call Decho("(user: <".v:count."gb>) bookmarklist=".string(g:netrw_bookmarklist)) exe "keepj e ".fnameescape(g:netrw_bookmarklist[v:count-1]) else echomsg "Sorry, bookmark#".v:count." doesn't exist!" @@ -2475,7 +3251,7 @@ fun! s:NetrwBookHistHandler(chg,curdir) let cnt= 1 for bmd in g:netrw_bookmarklist " call Decho("Netrw Bookmark#".cnt.": ".g:netrw_bookmarklist[cnt-1]) - echo "Netrw Bookmark#".cnt.": ".g:netrw_bookmarklist[cnt-1] + echo printf("Netrw Bookmark#%-2d: %s",cnt,g:netrw_bookmarklist[cnt-1]) let didwork = 1 let cnt = cnt + 1 endfor @@ -2488,14 +3264,14 @@ fun! s:NetrwBookHistHandler(chg,curdir) if g:netrw_dirhistmax > 0 while ( first || cnt != g:netrw_dirhist_cnt ) " call Decho("first=".first." cnt=".cnt." dirhist_cnt=".g:netrw_dirhist_cnt) - let histcnt= histcnt + 1 if exists("g:netrw_dirhist_{cnt}") " call Decho("Netrw History#".histcnt.": ".g:netrw_dirhist_{cnt}) - echo "Netrw History#".histcnt.": ".g:netrw_dirhist_{cnt} + echo printf("Netrw History#%-2d: %s",histcnt,g:netrw_dirhist_{cnt}) let didwork= 1 endif - let first = 0 - let cnt = ( cnt - 1 ) % g:netrw_dirhistmax + let histcnt = histcnt + 1 + let first = 0 + let cnt = ( cnt - 1 ) % g:netrw_dirhistmax if cnt < 0 let cnt= cnt + g:netrw_dirhistmax endif @@ -2522,7 +3298,7 @@ fun! s:NetrwBookHistHandler(chg,curdir) " u: change to the previous directory stored on the history list " call Decho("(user: <u>) chg to prev dir from history") if g:netrw_dirhistmax > 0 - let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt - 1 ) % g:netrw_dirhistmax + let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt - v:count1 ) % g:netrw_dirhistmax if g:netrw_dirhist_cnt < 0 let g:netrw_dirhist_cnt= g:netrw_dirhist_cnt + g:netrw_dirhistmax endif @@ -2543,7 +3319,7 @@ fun! s:NetrwBookHistHandler(chg,curdir) exe "keepj e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt}) else if g:netrw_dirhistmax > 0 - let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt + 1 ) % g:netrw_dirhistmax + let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt + v:count1 ) % g:netrw_dirhistmax else let g:netrw_dirhist_cnt= 0 endif @@ -2585,12 +3361,17 @@ fun! s:NetrwBookHistHandler(chg,curdir) " call Decho("delete bookmark#".v:count."<".g:netrw_bookmarklist[v:count-1].">") let savefile= s:NetrwHome()."/.netrwbook" if filereadable(savefile) +" call Decho("merge bookmarks (active and file)") keepj call s:NetrwBookHistSave() " done here to merge bookmarks first +" call Decho("bookmark delete savefile<".savefile.">") keepj call delete(savefile) endif +" call Decho("remove g:netrw_bookmarklist[".(v:count-1)."]") keepj call remove(g:netrw_bookmarklist,v:count-1) +" call Decho("resulting g:netrw_bookmarklist=".string(g:netrw_bookmarklist)) endif call s:NetrwBookmarkMenu() + call s:NetrwTgtMenu() let @@= ykeep " call Dret("s:NetrwBookHistHandler") endfun @@ -2600,19 +3381,23 @@ endfun " Sister function: s:NetrwBookHistSave() fun! s:NetrwBookHistRead() " call Dfunc("s:NetrwBookHistRead()") + if !exists("g:netrw_dirhistmax") || g:netrw_dirhistmax <= 0 +" " call Dret("s:NetrwBookHistRead - suppressed due to g:netrw_dirhistmax") + return + endif let ykeep= @@ if !exists("s:netrw_initbookhist") let home = s:NetrwHome() let savefile= home."/.netrwbook" if filereadable(savefile) " call Decho("sourcing .netrwbook") - exe "keepj so ".savefile + exe "keepalt keepj so ".savefile endif if g:netrw_dirhistmax > 0 let savefile= home."/.netrwhist" if filereadable(savefile) " call Decho("sourcing .netrwhist") - exe "keepj so ".savefile + exe "keepalt keepj so ".savefile endif let s:netrw_initbookhist= 1 au VimLeave * call s:NetrwBookHistSave() @@ -2629,7 +3414,7 @@ endfun " be unreliable for long-term storage fun! s:NetrwBookHistSave() " call Dfunc("s:NetrwBookHistSave() dirhistmax=".g:netrw_dirhistmax) - if g:netrw_dirhistmax <= 0 + if !exists("g:netrw_dirhistmax") || g:netrw_dirhistmax <= 0 " call Dret("s:NetrwBookHistSave : dirhistmax=".g:netrw_dirhistmax) return endif @@ -2637,14 +3422,14 @@ fun! s:NetrwBookHistSave() let savefile= s:NetrwHome()."/.netrwhist" 1split call s:NetrwEnew() - setlocal cino= com= cpo-=a cpo-=A fo=nroql2 tw=0 report=10000 noswf - setlocal nocin noai noci magic nospell nohid wig= noaw - setlocal ma noro write - if exists("&acd") | setlocal noacd | endif + setl cino= com= cpo-=a cpo-=A fo=nroql2 tw=0 report=10000 noswf + setl nocin noai noci magic nospell nohid wig= noaw + setl ma noro write + if exists("+acd") | setl noacd | endif sil! keepj keepalt %d " save .netrwhist -- no attempt to merge - sil! file .netrwhist + sil! keepalt file .netrwhist call setline(1,"let g:netrw_dirhistmax =".g:netrw_dirhistmax) call setline(2,"let g:netrw_dirhist_cnt =".g:netrw_dirhist_cnt) let lastline = line("$") @@ -2662,7 +3447,7 @@ fun! s:NetrwBookHistSave() if filereadable(savefile) let booklist= deepcopy(g:netrw_bookmarklist) - exe "sil keepj so ".savefile + exe "sil keepj keepalt so ".savefile for bdm in booklist if index(g:netrw_bookmarklist,bdm) == -1 call add(g:netrw_bookmarklist,bdm) @@ -2678,7 +3463,7 @@ fun! s:NetrwBookHistSave() endif let bgone= bufnr("%") q! - exe bgone."bwipe!" + exe "keepalt ".bgone."bwipe!" " call Dret("s:NetrwBookHistSave") endfun @@ -2691,7 +3476,7 @@ endfun fun! s:NetrwBrowse(islocal,dirname) if !exists("w:netrw_liststyle")|let w:netrw_liststyle= g:netrw_liststyle|endif " call Dfunc("s:NetrwBrowse(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".w:netrw_liststyle." ".g:loaded_netrw." buf#".bufnr("%")."<".bufname("%")."> win#".winnr()) -" call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")." modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) +" call Decho("(NetrwBrowse) tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")." modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) " call Dredir("ls!") " s:NetrwBrowse: initialize history {{{3 if !exists("s:netrw_initbookhist") @@ -2729,38 +3514,38 @@ fun! s:NetrwBrowse(islocal,dirname) " s:NetrwBrowse: re-instate any marked files {{{3 if exists("s:netrwmarkfilelist_{bufnr('%')}") -" call Decho("clearing marked files") +" call Decho("(NetrwBrowse) clearing marked files") exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/" endif if a:islocal && exists("w:netrw_acdkeep") && w:netrw_acdkeep " s:NetrwBrowse: set up "safe" options for local directory/file {{{3 -" call Decho("handle w:netrw_acdkeep:") -" call Decho("keepjumps lcd ".fnameescape(dirname)." (due to w:netrw_acdkeep=".w:netrw_acdkeep." - acd=".&acd.")") +" call Decho("(NetrwBrowse) handle w:netrw_acdkeep:") +" call Decho("(NetrwBrowse) keepjumps lcd ".fnameescape(dirname)." (due to w:netrw_acdkeep=".w:netrw_acdkeep." - acd=".&acd.")") exe 'keepj lcd '.fnameescape(dirname) call s:NetrwSafeOptions() -" call Decho("getcwd<".getcwd().">") +" call Decho("(NetrwBrowse) getcwd<".getcwd().">") elseif !a:islocal && dirname !~ '[\/]$' && dirname !~ '^"' " s:NetrwBrowse: looks like a remote regular file, attempt transfer {{{3 -" call Decho("attempt transfer as regular file<".dirname.">") +" call Decho("(NetrwBrowse) attempt transfer as regular file<".dirname.">") " remove any filetype indicator from end of dirname, except for the " "this is a directory" indicator (/). " There shouldn't be one of those here, anyway. let path= substitute(dirname,'[*=@|]\r\=$','','e') -" call Decho("new path<".path.">") +" call Decho("(NetrwBrowse) new path<".path.">") call s:RemotePathAnalysis(dirname) " s:NetrwBrowse: remote-read the requested file into current buffer {{{3 keepj mark ' call s:NetrwEnew(dirname) call s:NetrwSafeOptions() - setlocal ma noro -" call Decho("setlocal ma noro") + setl ma noro +" call Decho("(NetrwBrowse) setl ma noro") let b:netrw_curdir = dirname let url = s:method."://".s:user.s:machine.(s:port ? ":".s:port : "")."/".s:path -" call Decho("exe sil! keepalt file ".fnameescape(url)." (bt=".&bt.")") +" call Decho("(NetrwBrowse) exe sil! keepalt file ".fnameescape(url)." (bt=".&bt.")") exe "sil! keepj keepalt file ".fnameescape(url) exe "sil! keepj keepalt doau BufReadPre ".fnameescape(s:fname) sil call netrw#NetRead(2,url) @@ -2772,7 +3557,7 @@ fun! s:NetrwBrowse(islocal,dirname) " s:NetrwBrowse: save certain window-oriented variables into buffer-oriented variables {{{3 call s:SetBufWinVars() call s:NetrwOptionRestore("w:") -" call Decho("setl ma nomod") +" call Decho("(NetrwBrowse) setl ma nomod") setl ma nomod " call Decho("(NetrwBrowse) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") @@ -2795,24 +3580,24 @@ fun! s:NetrwBrowse(islocal,dirname) let reusing= s:NetrwGetBuffer(a:islocal,dirname) " maintain markfile highlighting if exists("s:netrwmarkfilemtch_{bufnr('%')}") && s:netrwmarkfilemtch_{bufnr("%")} != "" -" call Decho("bufnr(%)=".bufnr('%')) -" call Decho("exe 2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/") +" call Decho("(NetrwBrowse) bufnr(%)=".bufnr('%')) +" call Decho("(NetrwBrowse) exe 2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/") exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/" else -" call Decho("2match none") +" call Decho("(NetrwBrowse) 2match none") 2match none endif - if reusing + if reusing && line("$") > 1 call s:NetrwOptionRestore("w:") " call Decho("(NetrwBrowse) setl noma nomod nowrap") setl noma nomod nowrap -" call Decho("(set noma nomod nowrap) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") +" call Decho("(NetrwBrowse) (set noma nomod nowrap) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") " call Dret("s:NetrwBrowse : re-using buffer") return endif " set b:netrw_curdir to the new directory name {{{3 -" call Decho("set b:netrw_curdir to the new directory name: (buf#".bufnr("%").")") +" call Decho("(NetrwBrowse) set b:netrw_curdir to the new directory name: (buf#".bufnr("%").")") let b:netrw_curdir= dirname if b:netrw_curdir =~ '[/\\]$' let b:netrw_curdir= substitute(b:netrw_curdir,'[/\\]$','','e') @@ -2830,21 +3615,21 @@ fun! s:NetrwBrowse(islocal,dirname) if !a:islocal && b:netrw_curdir !~ '/$' let b:netrw_curdir= b:netrw_curdir.'/' endif -" call Decho("b:netrw_curdir<".b:netrw_curdir.">") +" call Decho("(NetrwBrowse) b:netrw_curdir<".b:netrw_curdir.">") " ------------ " (local only) {{{3 " ------------ if a:islocal -" call Decho("local only:") +" call Decho("(NetrwBrowse) local only:") " Set up ShellCmdPost handling. Append current buffer to browselist call s:LocalFastBrowser() " handle g:netrw_keepdir: set vim's current directory to netrw's notion of the current directory {{{3 if !g:netrw_keepdir -" call Decho("handle g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd) -" call Decho("l:acd".(exists("&l:acd")? "=".&l:acd : " doesn't exist")) +" call Decho("(NetrwBrowse) handle g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd) +" call Decho("(NetrwBrowse) l:acd".(exists("&l:acd")? "=".&l:acd : " doesn't exist")) if !exists("&l:acd") || !&l:acd " call Decho('exe keepjumps lcd '.fnameescape(b:netrw_curdir)) try @@ -2870,23 +3655,23 @@ fun! s:NetrwBrowse(islocal,dirname) " remote handling: {{{3 " -------------------------------- else -" call Decho("remote only:") +" call Decho("(NetrwBrowse) remote only:") " analyze dirname and g:netrw_list_cmd {{{3 -" call Decho("b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "doesn't exist")."> dirname<".dirname.">") +" call Decho("(NetrwBrowse) b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "doesn't exist")."> dirname<".dirname.">") if dirname =~ "^NetrwTreeListing\>" let dirname= b:netrw_curdir -" call Decho("(dirname was <NetrwTreeListing>) dirname<".dirname.">") +" call Decho("(NetrwBrowse) (dirname was <NetrwTreeListing>) dirname<".dirname.">") elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir") let dirname= substitute(b:netrw_curdir,'\\','/','g') if dirname !~ '/$' let dirname= dirname.'/' endif let b:netrw_curdir = dirname -" call Decho("(liststyle is TREELIST) dirname<".dirname.">") +" call Decho("(NetrwBrowse) (liststyle is TREELIST) dirname<".dirname.">") else let dirname = substitute(dirname,'\\','/','g') -" call Decho("(normal) dirname<".dirname.">") +" call Decho("(NetrwBrowse) (normal) dirname<".dirname.">") endif let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/]\+\)/\(.*\)$' @@ -2902,7 +3687,7 @@ fun! s:NetrwBrowse(islocal,dirname) return endif let b:netrw_curdir= dirname -" call Decho("b:netrw_curdir<".b:netrw_curdir."> (remote)") +" call Decho("(NetrwBrowse) b:netrw_curdir<".b:netrw_curdir."> (remote)") endif " (additional remote handling) " ----------------------- @@ -2912,7 +3697,7 @@ fun! s:NetrwBrowse(islocal,dirname) keepj call s:PerformListing(a:islocal) if v:version >= 700 && has("balloon_eval") && &beval == 0 && &l:bexpr == "" && !exists("g:netrw_nobeval") let &l:bexpr= "netrw#NetrwBalloonHelp()" -" call Decho("set up balloon help: l:bexpr=".&l:bexpr) +" call Decho("(NetrwBrowse) set up balloon help: l:bexpr=".&l:bexpr) set beval endif call s:NetrwOptionRestore("w:") @@ -2977,35 +3762,36 @@ fun! s:NetrwGetBuffer(islocal,dirname) let dirname= a:dirname " re-use buffer if possible {{{3 -" call Decho("--re-use a buffer if possible--") +" call Decho("(NetrwGetBuffer) --re-use a buffer if possible--") if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST " find NetrwTreeList buffer if there is one -" call Decho("case liststyle=treelist: find NetrwTreeList buffer if there is one") +" call Decho("(NetrwGetBuffer) case liststyle=treelist: find NetrwTreeList buffer if there is one") if exists("w:netrw_treebufnr") && w:netrw_treebufnr > 0 -" call Decho(" re-use w:netrw_treebufnr=".w:netrw_treebufnr) +" call Decho("(NetrwGetBuffer) re-use w:netrw_treebufnr=".w:netrw_treebufnr) + sil keepj %d let eikeep= &ei set ei=all - exe "sil! b ".w:netrw_treebufnr + exe "sil! keepalt b ".w:netrw_treebufnr let &ei= eikeep -" call Dret("s:NetrwGetBuffer 1<buffer not cleared> : bufnum#".w:netrw_treebufnr."<NetrwTreeListing>") - return 1 +" call Dret("s:NetrwGetBuffer 0<buffer cleared> : bufnum#".w:netrw_treebufnr."<NetrwTreeListing>") + return 0 endif let bufnum= -1 -" call Decho(" liststyle=TREE but w:netrw_treebufnr doesn't exist") +" call Decho("(NetrwGetBuffer) liststyle=TREE but w:netrw_treebufnr doesn't exist") else " find buffer number of buffer named precisely the same as dirname {{{3 -" call Decho("case listtyle not treelist: find buffer numnber of buffer named precisely the same as dirname--") +" call Decho("(NetrwGetBuffer) case listtyle not treelist: find buffer numnber of buffer named precisely the same as dirname--") " call Dredir("ls!") " get dirname and associated buffer number let bufnum = bufnr(escape(dirname,'\')) -" call Decho(" find buffer<".dirname.">'s number ") -" call Decho(" bufnr(dirname<".escape(dirname,'\').">)=".bufnum) +" call Decho("(NetrwGetBuffer) find buffer<".dirname.">'s number ") +" call Decho("(NetrwGetBuffer) bufnr(dirname<".escape(dirname,'\').">)=".bufnum) if bufnum < 0 && dirname !~ '/$' " try appending a trailing / -" call Decho(" try appending a trailing / to dirname<".dirname.">") +" call Decho("(NetrwGetBuffer) try appending a trailing / to dirname<".dirname.">") let bufnum= bufnr(escape(dirname.'/','\')) if bufnum > 0 let dirname= dirname.'/' @@ -3014,30 +3800,30 @@ fun! s:NetrwGetBuffer(islocal,dirname) if bufnum < 0 && dirname =~ '/$' " try removing a trailing / -" call Decho(" try removing a trailing / from dirname<".dirname.">") +" call Decho("(NetrwGetBuffer) try removing a trailing / from dirname<".dirname.">") let bufnum= bufnr(escape(substitute(dirname,'/$','',''),'\')) if bufnum > 0 let dirname= substitute(dirname,'/$','','') endif endif -" call Decho(" findbuf1: bufnum=bufnr('".dirname."')=".bufnum." bufname(".bufnum.")<".bufname(bufnum)."> (initial)") +" call Decho("(NetrwGetBuffer) findbuf1: bufnum=bufnr('".dirname."')=".bufnum." bufname(".bufnum.")<".bufname(bufnum)."> (initial)") " note: !~ was used just below, but that means using ../ to go back would match (ie. abc/def/ and abc/ matches) if bufnum > 0 && bufname(bufnum) != dirname && bufname(bufnum) != '.' " handle approximate matches -" call Decho(" handling approx match: bufnum#".bufnum.">0 AND bufname<".bufname(bufnum).">!=dirname<".dirname."> AND bufname(".bufnum.")!='.'") +" call Decho("(NetrwGetBuffer) handling approx match: bufnum#".bufnum.">0 AND bufname<".bufname(bufnum).">!=dirname<".dirname."> AND bufname(".bufnum.")!='.'") let ibuf = 1 let buflast = bufnr("$") -" call Decho(" findbuf2: buflast=bufnr($)=".buflast) +" call Decho("(NetrwGetBuffer) findbuf2: buflast=bufnr($)=".buflast) while ibuf <= buflast let bname= substitute(bufname(ibuf),'\\','/','g') let bname= substitute(bname,'.\zs/$','','') -" call Decho(" findbuf3: while [ibuf=",ibuf."]<=[buflast=".buflast."]: dirname<".dirname."> bname=bufname(".ibuf.")<".bname.">") +" call Decho("(NetrwGetBuffer) findbuf3: while [ibuf=",ibuf."]<=[buflast=".buflast."]: dirname<".dirname."> bname=bufname(".ibuf.")<".bname.">") if bname != '' && dirname =~ '/'.bname.'/\=$' && dirname !~ '^/' " bname is not empty " dirname ends with bname, " dirname doesn't start with /, so its not a absolute path -" call Decho(" findbuf3a: passes test 1 : dirname<".dirname.'> =~ /'.bname.'/\=$ && dirname !~ ^/') +" call Decho("(NetrwGetBuffer) findbuf3a: passes test 1 : dirname<".dirname.'> =~ /'.bname.'/\=$ && dirname !~ ^/') break endif if bname =~ '^'.dirname.'/\=$' @@ -3060,59 +3846,59 @@ fun! s:NetrwGetBuffer(islocal,dirname) else let bufnum= ibuf endif -" call Decho(" findbuf4: bufnum=".bufnum." (ibuf=".ibuf." buflast=".buflast.")") +" call Decho("(NetrwGetBuffer) findbuf4: bufnum=".bufnum." (ibuf=".ibuf." buflast=".buflast.")") endif endif " get enew buffer and name it -or- re-use buffer {{{3 -" call Decho(" get enew buffer and name it OR re-use buffer") - sil! keepj mark ' +" call Decho("(NetrwGetBuffer) get enew buffer and name it OR re-use buffer") + sil! keepj keepalt mark ' if bufnum < 0 || !bufexists(bufnum) -" call Decho("--get enew buffer and name it (bufnum#".bufnum."<0 OR bufexists(".bufnum.")=".bufexists(bufnum)."==0)") +" call Decho("(NetrwGetBuffer) --get enew buffer and name it (bufnum#".bufnum."<0 OR bufexists(".bufnum.")=".bufexists(bufnum)."==0)") call s:NetrwEnew(dirname) -" call Decho(" got enew buffer#".bufnr("%")." (altbuf<".expand("#").">)") +" call Decho("(NetrwGetBuffer) got enew buffer#".bufnr("%")." (altbuf<".expand("#").">)") " name the buffer if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST " Got enew buffer; transform into a NetrwTreeListing -" call Decho("--transform enew buffer#".bufnr("%")." into a NetrwTreeListing --") +" call Decho("(NetrwGetBuffer) --transform enew buffer#".bufnr("%")." into a NetrwTreeListing --") if !exists("s:netrw_treelistnum") let s:netrw_treelistnum= 1 else let s:netrw_treelistnum= s:netrw_treelistnum + 1 endif let w:netrw_treebufnr= bufnr("%") -" call Decho(" exe sil! keepalt file NetrwTreeListing ".fnameescape(s:netrw_treelistnum)) +" call Decho("(NetrwGetBuffer) exe sil! keepalt file NetrwTreeListing ".fnameescape(s:netrw_treelistnum)) exe 'sil! keepalt file NetrwTreeListing\ '.fnameescape(s:netrw_treelistnum) set bt=nofile noswf nnoremap <silent> <buffer> [ :sil call <SID>TreeListMove('[')<cr> nnoremap <silent> <buffer> ] :sil call <SID>TreeListMove(']')<cr> nnoremap <silent> <buffer> [[ :sil call <SID>TreeListMove('[')<cr> nnoremap <silent> <buffer> ]] :sil call <SID>TreeListMove(']')<cr> -" call Decho(" tree listing#".s:netrw_treelistnum." bufnr=".w:netrw_treebufnr) +" call Decho("(NetrwGetBuffer) tree listing#".s:netrw_treelistnum." bufnr=".w:netrw_treebufnr) else " let v:errmsg= "" " Decho let escdirname= fnameescape(dirname) -" call Decho(" errmsg<".v:errmsg."> bufnr(escdirname<".escdirname.">)=".bufnr(escdirname)." bufname()<".bufname(bufnr(escdirname)).">") +" call Decho("(NetrwGetBuffer) errmsg<".v:errmsg."> bufnr(escdirname<".escdirname.">)=".bufnr(escdirname)." bufname()<".bufname(bufnr(escdirname)).">") " call Decho(' exe sil! keepalt file '.escdirname) " let v:errmsg= "" " Decho exe 'sil! keepalt file '.escdirname -" call Decho(" errmsg<".v:errmsg."> bufnr(".escdirname.")=".bufnr(escdirname)."<".bufname(bufnr(escdirname)).">") +" call Decho("(NetrwGetBuffer) errmsg<".v:errmsg."> bufnr(".escdirname.")=".bufnr(escdirname)."<".bufname(bufnr(escdirname)).">") endif -" call Decho(" named enew buffer#".bufnr("%")."<".bufname("%").">") +" call Decho("(NetrwGetBuffer) named enew buffer#".bufnr("%")."<".bufname("%").">") else " Re-use the buffer -" call Decho("--re-use buffer#".bufnum." (bufnum#".bufnum.">=0 AND bufexists(".bufnum.")=".bufexists(bufnum)."!=0)") +" call Decho("(NetrwGetBuffer) --re-use buffer#".bufnum." (bufnum#".bufnum.">=0 AND bufexists(".bufnum.")=".bufexists(bufnum)."!=0)") let eikeep= &ei set ei=all if getline(2) =~ '^" Netrw Directory Listing' -" call Decho(" getline(2)<".getline(2).'> matches "Netrw Directory Listing" : using keepalt b '.bufnum) +" call Decho("(NetrwGetBuffer) getline(2)<".getline(2).'> matches "Netrw Directory Listing" : using keepalt b '.bufnum) exe "sil! keepalt b ".bufnum else -" call Decho(" getline(2)<".getline(2).'> does not match "Netrw Directory Listing" : using b '.bufnum) - exe "sil! b ".bufnum +" call Decho("(NetrwGetBuffer) getline(2)<".getline(2).'> does not match "Netrw Directory Listing" : using b '.bufnum) + exe "sil! keepalt b ".bufnum endif if bufname("%") == '.' -" call Decho("exe sil! keepalt file ".fnameescape(getcwd())) +" call Decho("(NetrwGetBuffer) exe sil! keepalt file ".fnameescape(getcwd())) exe "sil! keepalt file ".fnameescape(getcwd()) endif let &ei= eikeep @@ -3126,8 +3912,8 @@ fun! s:NetrwGetBuffer(islocal,dirname) " call Dret("s:NetrwGetBuffer 0<cleared buffer> : re-using buffer#".bufnr("%").", but refreshing due to g:netrw_fastbrowse=".g:netrw_fastbrowse) return 0 elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST -" call Decho("--re-use tree listing--") -" call Decho(" clear buffer<".expand("%")."> with :%d") +" call Decho("(NetrwGetBuffer) --re-use tree listing--") +" call Decho("(NetrwGetBuffer) clear buffer<".expand("%")."> with :%d") sil keepj %d keepj call s:NetrwListSettings(a:islocal) " call Dret("s:NetrwGetBuffer 0<cleared buffer> : re-using buffer#".bufnr("%").", but treelist mode always needs a refresh") @@ -3143,15 +3929,15 @@ fun! s:NetrwGetBuffer(islocal,dirname) " slow 0 D D Deleting a buffer implies it will not be re-used (slow) " med 1 D H " fast 2 H H -" call Decho("--do netrw settings: make this buffer#".bufnr("%")." not-a-file, modifiable, not line-numbered, etc--") +" call Decho("(NetrwGetBuffer) --do netrw settings: make this buffer#".bufnr("%")." not-a-file, modifiable, not line-numbered, etc--") let fname= expand("%") keepj call s:NetrwListSettings(a:islocal) -" call Decho("exe sil! keepalt file ".fnameescape(fname)) +" call Decho("(NetrwGetBuffer) exe sil! keepalt file ".fnameescape(fname)) exe "sil! keepj keepalt file ".fnameescape(fname) " delete all lines from buffer {{{3 -" call Decho("--delete all lines from buffer--") -" call Decho(" clear buffer<".expand("%")."> with :%d") +" call Decho("(NetrwGetBuffer) --delete all lines from buffer--") +" call Decho("(NetrwGetBuffer) clear buffer<".expand("%")."> with :%d") sil! keepalt keepj %d " call Dret("s:NetrwGetBuffer 0<cleared buffer> : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) @@ -3286,21 +4072,21 @@ endfun fun! s:NetrwListSettings(islocal) " call Dfunc("s:NetrwListSettings(islocal=".a:islocal.")") let fname= bufname("%") -" call Decho("setlocal bt=nofile nobl ma nonu nowrap noro") - setlocal bt=nofile nobl ma nonu nowrap noro -" call Decho("exe sil! keepalt file ".fnameescape(fname)) +" call Decho("(NetrwListSettings) setl bt=nofile nobl ma nonu nowrap noro") + setl bt=nofile nobl ma nonu nowrap noro +" call Decho("(NetrwListSettings) exe sil! keepalt file ".fnameescape(fname)) exe "sil! keepalt file ".fnameescape(fname) if g:netrw_use_noswf - setlocal noswf + setl noswf endif " call Dredir("ls!") -" call Decho("(LocalListing) exe setl ts=".(g:netrw_maxfilenamelen+1)) +" call Decho("(NetrwListSettings) exe setl ts=".(g:netrw_maxfilenamelen+1)) exe "setl ts=".(g:netrw_maxfilenamelen+1) - setlocal isk+=.,~,- + setl isk+=.,~,- if g:netrw_fastbrowse > a:islocal - setlocal bh=hide + setl bh=hide else - setlocal bh=delete + setl bh=delete endif " call Dret("s:NetrwListSettings") endfun @@ -3344,8 +4130,8 @@ fun! s:NetrwListStyle(islocal) let w:netrw_liststyle = g:netrw_liststyle let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge') endif - setlocal ma noro -" call Decho("setlocal ma noro") + setl ma noro +" call Decho("setl ma noro") " clear buffer - this will cause NetrwBrowse/LocalBrowseCheck to do a refresh " call Decho("clear buffer<".expand("%")."> with :%d") @@ -3422,7 +4208,7 @@ fun! s:NetrwBookmarkMenu() endif " show bookmarked places - if exists("g:netrw_bookmarklist") && g:netrw_bookmarklist != [] + if exists("g:netrw_bookmarklist") && g:netrw_bookmarklist != [] && g:netrw_dirhistmax > 0 let cnt= 1 for bmd in g:netrw_bookmarklist " call Decho('sil! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmark.'.bmd.' :e '.bmd) @@ -3509,19 +4295,19 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) " apparently vim is "recognizing" that it is in a directory and " is removing the trailing "/". Bad idea, so let's put it back. let dirname= dirname.'/' -" call Decho("adjusting dirname<".dirname.">") +" call Decho("(NetrwBrowseChgDir) adjusting dirname<".dirname.">") endif if newdir !~ dirpat " ------------------------------ " NetrwBrowseChgDir: edit a file {{{3 " ------------------------------ -" call Decho('(NetrwBrowseChgDir) case "handling a file": newdir<'.newdir.'> !~ dirpat<'.dirpat.">") +" call Decho('(NetrwBrowseChgDir:edit-a-file) case "handling a file": newdir<'.newdir.'> !~ dirpat<'.dirpat.">") " save position for benefit of Rexplore let s:rexposn_{bufnr("%")}= netrw#NetrwSavePosn() -" call Decho("(NetrwBrowseChgDir) setting s:rexposn_".bufnr("%")." to SavePosn") +" call Decho("(NetrwBrowseChgDir:edit-a-file) setting s:rexposn_".bufnr("%")." to SavePosn") if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") && newdir !~ '^\(/\|\a:\)' let dirname= s:NetrwTreeDir() if dirname =~ '/$' @@ -3529,35 +4315,35 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) else let dirname= s:NetrwTreeDir()."/".newdir endif -" call Decho("(NetrwBrowseChgDir) dirname<".dirname.">") -" call Decho("(NetrwBrowseChgDir) tree listing") +" call Decho("(NetrwBrowseChgDir:edit-a-file) dirname<".dirname.">") +" call Decho("(NetrwBrowseChgDir:edit-a-file) tree listing") elseif newdir =~ '^\(/\|\a:\)' let dirname= newdir else let dirname= s:ComposePath(dirname,newdir) endif -" call Decho("(NetrwBrowseChgDir) handling a file: dirname<".dirname."> (a:0=".a:0.")") +" call Decho("(NetrwBrowseChgDir:edit-a-file) handling a file: dirname<".dirname."> (a:0=".a:0.")") " this lets NetrwBrowseX avoid the edit if a:0 < 1 -" call Decho("(NetrwBrowseChgDir) set up windows for editing<".fnameescape(dirname)."> didsplit=".(exists("s:didsplit")? s:didsplit : "doesn't exist")) +" call Decho("(NetrwBrowseChgDir:edit-a-file) set up windows for editing<".fnameescape(dirname)."> didsplit=".(exists("s:didsplit")? s:didsplit : "doesn't exist")) keepj call s:NetrwOptionRestore("s:") if !exists("s:didsplit") -" call Decho("s:didsplit does not exist; g:netrw_browse_split=".g:netrw_browse_split." win#".winnr()) +" call Decho("(NetrwBrowseChgDir:edit-a-file) s:didsplit does not exist; g:netrw_browse_split=".g:netrw_browse_split." win#".winnr()) if g:netrw_browse_split == 1 " horizontally splitting the window first - new + keepalt new if !&ea - wincmd _ + keepalt wincmd _ endif elseif g:netrw_browse_split == 2 " vertically splitting the window first - rightb vert new + keepalt rightb vert new if !&ea - wincmd | + keepalt wincmd | endif elseif g:netrw_browse_split == 3 " open file in new tab - tabnew + keepalt tabnew elseif g:netrw_browse_split == 4 " act like "P" (ie. open previous window) if s:NetrwPrevWinOpen(2) == 3 @@ -3567,11 +4353,11 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) endif else " handling a file, didn't split, so remove menu -" call Decho("(NetrwBrowseChgDir) handling a file+didn't split, so remove menu") +" call Decho("(NetrwBrowseChgDir:edit-a-file) handling a file+didn't split, so remove menu") call s:NetrwMenu(0) " optional change to window if g:netrw_chgwin >= 1 - exe "keepjumps ".g:netrw_chgwin."wincmd w" + exe "keepj keepalt ".g:netrw_chgwin."wincmd w" endif endif endif @@ -3579,11 +4365,11 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) " the point where netrw actually edits the (local) file " if its local only: LocalBrowseCheck() doesn't edit a file, but NetrwBrowse() will if a:islocal -" call Decho("(NetrwBrowseChgDir) edit local file: exe e! ".fnameescape(dirname)) - exe "e! ".fnameescape(dirname) +" call Decho("(NetrwBrowseChgDir:edit-a-file) edit local file: exe e! ".fnameescape(dirname)) + exe "keepj keepalt e! ".fnameescape(dirname) call s:NetrwCursor() else -" call Decho("(NetrwBrowseChgDir) remote file: NetrwBrowse will edit it") +" call Decho("(NetrwBrowseChgDir:edit-a-file) remote file: NetrwBrowse will edit it") endif let dolockout= 1 @@ -3592,12 +4378,12 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) " or as a list of function references. It will ignore anything that's not " a function reference. See :help Funcref for information about function references. if exists("g:Netrw_funcref") -" call Decho("(NetrwBrowseChgDir) handle optional Funcrefs") +" call Decho("(NetrwBrowseChgDir:edit-a-file) handle optional Funcrefs") if type(g:Netrw_funcref) == 2 -" call Decho("(NetrwBrowseChgDir) handling a g:Netrw_funcref") +" call Decho("(NetrwBrowseChgDir:edit-a-file) handling a g:Netrw_funcref") keepj call g:Netrw_funcref() elseif type(g:Netrw_funcref) == 3 -" call Decho("(NetrwBrowseChgDir) handling a list of g:Netrw_funcrefs") +" call Decho("(NetrwBrowseChgDir:edit-a-file) handling a list of g:Netrw_funcrefs") for Fncref in g:Netrw_funcref if type(FncRef) == 2 keepj call FncRef() @@ -3611,7 +4397,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) " ---------------------------------------------------- " NetrwBrowseChgDir: just go to the new directory spec {{{3 " ---------------------------------------------------- -" call Decho('(NetrwBrowseChgDir) case "just go to new directory spec": newdir<'.newdir.'>') +" call Decho('(NetrwBrowseChgDir:goto-newdir) case "just go to new directory spec": newdir<'.newdir.'>') let dirname = newdir keepj call s:SetRexDir(a:islocal,dirname) keepj call s:NetrwOptionRestore("s:") @@ -3620,37 +4406,37 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) " --------------------------------------------- " NetrwBrowseChgDir: refresh the directory list {{{3 " --------------------------------------------- -" call Decho('(NetrwBrowseChgDir) case "refresh directory listing": newdir == "./"') +" call Decho('(NetrwBrowseChgDir:refresh-dirlist) case "refresh directory listing": newdir == "./"') keepj call s:SetRexDir(a:islocal,dirname) elseif newdir == '../' " -------------------------------------- " NetrwBrowseChgDir: go up one directory {{{3 " -------------------------------------- -" call Decho('(NetrwBrowseChgDir) case "go up one directory": newdir == "../"') +" call Decho('(NetrwBrowseChgDir:go-up) case "go up one directory": newdir == "../"') if w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") " force a refresh -" call Decho("(NetrwBrowseChgDir) clear buffer<".expand("%")."> with :%d") -" call Decho("(NetrwBrowseChgDir) setl noro ma") +" call Decho("(NetrwBrowseChgDir:go-up) clear buffer<".expand("%")."> with :%d") +" call Decho("(NetrwBrowseChgDir:go-up) setl noro ma") setl noro ma keepj %d endif if has("amiga") " amiga -" call Decho('(NetrwBrowseChgDir) case "go up one directory": newdir == "../" and amiga') +" call Decho('(NetrwBrowseChgDir:go-up) case "go up one directory": newdir == "../" and amiga') if a:islocal let dirname= substitute(dirname,'^\(.*[/:]\)\([^/]\+$\)','\1','') let dirname= substitute(dirname,'/$','','') else let dirname= substitute(dirname,'^\(.*[/:]\)\([^/]\+/$\)','\1','') endif -" call Decho("(NetrwBrowseChgDir) amiga: dirname<".dirname."> (go up one dir)") +" call Decho("(NetrwBrowseChgDir:go-up) amiga: dirname<".dirname."> (go up one dir)") else " unix or cygwin -" call Decho('(NetrwBrowseChgDir) case "go up one directory": newdir == "../" and unix or cygwin') +" call Decho('(NetrwBrowseChgDir:go-up) case "go up one directory": newdir == "../" and unix or cygwin') if a:islocal let dirname= substitute(dirname,'^\(.*\)/\([^/]\+\)/$','\1','') if dirname == "" @@ -3659,7 +4445,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) else let dirname= substitute(dirname,'^\(\a\+://.\{-}/\{1,2}\)\(.\{-}\)\([^/]\+\)/$','\1\2','') endif -" call Decho("(NetrwBrowseChgDir) unix: dirname<".dirname."> (go up one dir)") +" call Decho("(NetrwBrowseChgDir:go-up) unix: dirname<".dirname."> (go up one dir)") endif keepj call s:SetRexDir(a:islocal,dirname) @@ -3667,9 +4453,9 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) " -------------------------------------- " NetrwBrowseChgDir: Handle Tree Listing {{{3 " -------------------------------------- -" call Decho('(NetrwBrowseChgDir) case liststyle is TREELIST and w:netrw_treedict exists') +" call Decho('(NetrwBrowseChgDir:tree-list) case liststyle is TREELIST and w:netrw_treedict exists') " force a refresh (for TREELIST, wait for NetrwTreeDir() to force the refresh) -" call Decho("(NetrwBrowseChgDir) setl noro ma") +" call Decho("(NetrwBrowseChgDir) (treelist) setl noro ma") setl noro ma if !(exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir")) " call Decho("(NetrwBrowseChgDir) clear buffer<".expand("%")."> with :%d") @@ -3678,24 +4464,24 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) let treedir = s:NetrwTreeDir() let s:treecurpos = nbcd_curpos let haskey= 0 -" call Decho("(NetrwBrowseChgDir) w:netrw_treedict<".string(w:netrw_treedict).">") +" call Decho("(NetrwBrowseChgDir:tree-list) w:netrw_treedict<".string(w:netrw_treedict).">") " search treedict for tree dir as-is if has_key(w:netrw_treedict,treedir) -" call Decho('(NetrwBrowseChgDir) ....searched for treedir<'.treedir.'> : found it!') +" call Decho('(NetrwBrowseChgDir:tree-list) ....searched for treedir<'.treedir.'> : found it!') let haskey= 1 else -" call Decho('(NetrwBrowseChgDir) ....searched for treedir<'.treedir.'> : not found') +" call Decho('(NetrwBrowseChgDir:tree-list) ....searched for treedir<'.treedir.'> : not found') endif " search treedict for treedir with a / appended if !haskey && treedir !~ '/$' if has_key(w:netrw_treedict,treedir."/") let treedir= treedir."/" -" call Decho('(NetrwBrowseChgDir) ....searched.for treedir<'.treedir.'> found it!') +" call Decho('(NetrwBrowseChgDir:tree-list) ....searched.for treedir<'.treedir.'> found it!') let haskey = 1 else -" call Decho('(NetrwBrowseChgDir) ....searched for treedir<'.treedir.'/> : not found') +" call Decho('(NetrwBrowseChgDir:tree-list) ....searched for treedir<'.treedir.'/> : not found') endif endif @@ -3703,16 +4489,16 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) if !haskey && treedir =~ '/$' let treedir= substitute(treedir,'/$','','') if has_key(w:netrw_treedict,treedir) -" call Decho('(NetrwBrowseChgDir) ....searched.for treedir<'.treedir.'> found it!') +" call Decho('(NetrwBrowseChgDir:tree-list) ....searched.for treedir<'.treedir.'> found it!') let haskey = 1 else -" call Decho('(NetrwBrowseChgDir) ....searched for treedir<'.treedir.'> : not found') +" call Decho('(NetrwBrowseChgDir:tree-list) ....searched for treedir<'.treedir.'> : not found') endif endif if haskey " close tree listing for selected subdirectory -" call Decho("(NetrwBrowseChgDir) closing selected subdirectory<".dirname.">") +" call Decho("(NetrwBrowseChgDir:tree-list) closing selected subdirectory<".dirname.">") call remove(w:netrw_treedict,treedir) " call Decho("(NetrwBrowseChgDir) removed entry<".treedir."> from treedict") " call Decho("(NetrwBrowseChgDir) yielding treedict<".string(w:netrw_treedict).">") @@ -3720,7 +4506,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) else " go down one directory let dirname= substitute(treedir,'/*$','/','') -" call Decho("(NetrwBrowseChgDir) go down one dir: treedir<".treedir.">") +" call Decho("(NetrwBrowseChgDir:tree-list) go down one dir: treedir<".treedir.">") endif keepj call s:SetRexDir(a:islocal,dirname) let s:treeforceredraw = 1 @@ -3730,7 +4516,7 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) " NetrwBrowseChgDir: Go down one directory {{{3 " ---------------------------------------- let dirname = s:ComposePath(dirname,newdir) -" call Decho("(NetrwBrowseChgDir) go down one dir: dirname<".dirname."> newdir<".newdir.">") +" call Decho("(NetrwBrowseChgDir:go-down) go down one dir: dirname<".dirname."> newdir<".newdir.">") keepj call s:SetRexDir(a:islocal,dirname) endif @@ -3739,17 +4525,17 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...) " -------------------------------------- keepj call s:NetrwOptionRestore("s:") if dolockout -" call Decho("(NetrwBrowseChgDir) filewritable(dirname<".dirname.">)=".filewritable(dirname)) +" call Decho("(NetrwBrowseChgDir:restore) filewritable(dirname<".dirname.">)=".filewritable(dirname)) if filewritable(dirname) -" call Decho("(NetrwBrowseChgDir) doing modification lockout settings: ma nomod noro") -" call Decho("(NetrwBrowseChgDir) setl ma nomod noro") +" call Decho("(NetrwBrowseChgDir:restore) doing modification lockout settings: ma nomod noro") +" call Decho("(NetrwBrowseChgDir:restore) setl ma nomod noro") setl ma nomod noro -" call Decho("(NetrwBrowseChgDir) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") +" call Decho("(NetrwBrowseChgDir:restore) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") else -" call Decho("(NetrwBrowseChgDir) doing modification lockout settings: ma nomod ro") -" call Decho("(NetrwBrowseChgDir) setl ma nomod noro") +" call Decho("(NetrwBrowseChgDir:restore) doing modification lockout settings: ma nomod ro") +" call Decho("(NetrwBrowseChgDir:restore) setl ma nomod noro") setl ma nomod ro -" call Decho("(NetrwBrowseChgDir) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") +" call Decho("(NetrwBrowseChgDir:restore) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") endif endif let @@= ykeep @@ -3775,7 +4561,7 @@ fun! netrw#NetrwBrowseX(fname,remote) " g:Netrw_corehandler is a function reference (see :help Funcref) " call Decho("g:Netrw_corehandler is a funcref") call g:Netrw_corehandler(a:fname) - elseif type(g:Netrw_corehandler) == 3) + elseif type(g:Netrw_corehandler) == 3 " g:Netrw_corehandler is a List of function references (see :help Funcref) " call Decho("g:Netrw_corehandler is a List") for Fncref in g:Netrw_corehandler @@ -3817,7 +4603,7 @@ fun! netrw#NetrwBrowseX(fname,remote) if a:remote == 1 " create a local copy " call Decho("(remote) a:remote=".a:remote.": create a local copy of <".a:fname.">") - setlocal bh=delete + setl bh=delete call netrw#NetRead(3,a:fname) " attempt to rename tempfile let basename= substitute(a:fname,'^\(.*\)/\(.*\)\.\([^.]*\)$','\2','') @@ -3963,9 +4749,9 @@ fun! netrw#NetrwBrowseX(fname,remote) " endif if a:remote == 1 - setlocal bh=delete bt=nofile + setl bh=delete bt=nofile if g:netrw_use_noswf - setlocal noswf + setl noswf endif exe "sil! keepj norm! \<c-o>" " redraw! @@ -4019,453 +4805,6 @@ fun! s:NetrwClearExplore() endfun " --------------------------------------------------------------------- -" netrw#Explore: launch the local browser in the directory of the current file {{{2 -" indx: == -1: Nexplore -" == -2: Pexplore -" == +: this is overloaded: -" * If Nexplore/Pexplore is in use, then this refers to the -" indx'th item in the w:netrw_explore_list[] of items which -" matched the */pattern **/pattern *//pattern **//pattern -" * If Hexplore or Vexplore, then this will override -" g:netrw_winsize to specify the qty of rows or columns the -" newly split window should have. -" dosplit==0: the window will be split iff the current file has been modified -" dosplit==1: the window will be split before running the local browser -" style == 0: Explore style == 1: Explore! -" == 2: Hexplore style == 3: Hexplore! -" == 4: Vexplore style == 5: Vexplore! -" == 6: Texplore -fun! netrw#Explore(indx,dosplit,style,...) -" call Dfunc("netrw#Explore(indx=".a:indx." dosplit=".a:dosplit." style=".a:style.",a:1<".a:1.">) &modified=".&modified." modifiable=".&modifiable." a:0=".a:0." win#".winnr()." buf#".bufnr("%")) - if !exists("b:netrw_curdir") - let b:netrw_curdir= getcwd() -" call Decho("set b:netrw_curdir<".b:netrw_curdir."> (used getcwd)") - endif - let curdir = simplify(b:netrw_curdir) - let curfiledir = substitute(expand("%:p"),'^\(.*[/\\]\)[^/\\]*$','\1','e') -" call Decho("curdir<".curdir."> curfiledir<".curfiledir.">") - - " save registers - sil! let keepregstar = @* - sil! let keepregplus = @+ - sil! let keepregslash= @/ - - " if dosplit or file has been modified - 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 winsz= g:netrw_winsize - if a:indx > 0 - let winsz= a:indx - endif - - if a:style == 0 " Explore, Sexplore -" call Decho("style=0: Explore or Sexplore") - let winsz= (winsz > 0)? (winsz*winheight(0))/100 : -winsz - exe winsz."wincmd s" - - elseif a:style == 1 "Explore!, Sexplore! -" call Decho("style=1: Explore! or Sexplore!") - let winsz= (winsz > 0)? (winsz*winwidth(0))/100 : -winsz - exe winsz."wincmd v" - - elseif a:style == 2 " Hexplore -" call Decho("style=2: Hexplore") - let winsz= (winsz > 0)? (winsz*winheight(0))/100 : -winsz - exe "bel ".winsz."wincmd s" - - elseif a:style == 3 " Hexplore! -" call Decho("style=3: Hexplore!") - let winsz= (winsz > 0)? (winsz*winheight(0))/100 : -winsz - exe "abo ".winsz."wincmd s" - - elseif a:style == 4 " Vexplore -" call Decho("style=4: Vexplore") - let winsz= (winsz > 0)? (winsz*winwidth(0))/100 : -winsz - exe "lefta ".winsz."wincmd v" - - elseif a:style == 5 " Vexplore! -" call Decho("style=5: Vexplore!") - let winsz= (winsz > 0)? (winsz*winwidth(0))/100 : -winsz - exe "rightb ".winsz."wincmd v" - - elseif a:style == 6 " Texplore - call s:SaveBufVars() -" call Decho("style = 6: Texplore") - exe "tabnew ".fnameescape(curdir) - call s:RestoreBufVars() - endif - call s:RestoreWinVars() -" else " Decho -" call Decho("case a:dosplit=".a:dosplit." AND modified=".&modified." AND a:style=".a:style." is not 6") - endif - keepj norm! 0 - - if a:0 > 0 -" call Decho("case [a:0=".a:0."] > 0") - if a:1 =~ '^\~' && (has("unix") || (exists("g:netrw_cygwin") && g:netrw_cygwin)) -" call Decho("..case a:1<".a:1.">: starts with ~ and unix or cygwin") - let dirname= simplify(substitute(a:1,'\~',expand("$HOME"),'')) -" call Decho("..using dirname<".dirname."> (case: ~ && unix||cygwin)") - elseif a:1 == '.' -" call Decho("..case a:1<".a:1.">: matches .") - let dirname= simplify(exists("b:netrw_curdir")? b:netrw_curdir : getcwd()) - if dirname !~ '/$' - let dirname= dirname."/" - endif -" call Decho("..using dirname<".dirname."> (case: ".(exists("b:netrw_curdir")? "b:netrw_curdir" : "getcwd()").")") - elseif a:1 =~ '\$' -" call Decho("..case a:1<".a:1.">: matches ending $") - let dirname= simplify(expand(a:1)) -" call Decho("..using user-specified dirname<".dirname."> with $env-var") - elseif a:1 !~ '^\*\{1,2}/' -" call Decho("..case a:1<".a:1.">: other, not pattern or filepattern") - let dirname= simplify(a:1) -" call Decho("..using user-specified dirname<".dirname.">") - else -" call Decho("..case a:1: pattern or filepattern") - let dirname= a:1 - endif - else - " clear explore -" call Decho("case a:0=".a:0.": clearing Explore list") - call s:NetrwClearExplore() -" call Dret("netrw#Explore : cleared list") - return - endif - -" call Decho("dirname<".dirname.">") - if dirname =~ '\.\./\=$' - let dirname= simplify(fnamemodify(dirname,':p:h')) - elseif dirname =~ '\.\.' || dirname == '.' - let dirname= simplify(fnamemodify(dirname,':p')) - endif -" call Decho("dirname<".dirname."> (after simplify)") - - if dirname =~ '^\*//' - " starpat=1: Explore *//pattern (current directory only search for files containing pattern) -" call Decho("case Explore *//pattern") - let pattern= substitute(dirname,'^\*//\(.*\)$','\1','') - let starpat= 1 -" call Decho("..Explore *//pat: (starpat=".starpat.") dirname<".dirname."> -> pattern<".pattern.">") - if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif - - elseif dirname =~ '^\*\*//' - " starpat=2: Explore **//pattern (recursive descent search for files containing pattern) -" call Decho("case Explore **//pattern") - let pattern= substitute(dirname,'^\*\*//','','') - let starpat= 2 -" call Decho("..Explore **//pat: (starpat=".starpat.") dirname<".dirname."> -> pattern<".pattern.">") - - elseif dirname =~ '/\*\*/' - " handle .../**/.../filepat -" call Decho("case Explore .../**/.../filepat") - let prefixdir= substitute(dirname,'^\(.\{-}\)\*\*.*$','\1','') - if prefixdir =~ '^/' || (prefixdir =~ '^\a:/' && (has("win32") || has("win95") || has("win64") || has("win16"))) - let b:netrw_curdir = prefixdir - else - let b:netrw_curdir= getcwd().'/'.prefixdir - endif - let dirname= substitute(dirname,'^.\{-}\(\*\*/.*\)$','\1','') - let starpat= 4; -" call Decho("..pwd<".getcwd()."> dirname<".dirname.">") -" call Decho("..case Explore ../**/../filepat (starpat=".starpat.")") - - elseif dirname =~ '^\*/' - " starpat=3: Explore */filepat (search in current directory for filenames matching filepat) - let starpat= 3 -" call Decho("case Explore */filepat (starpat=".starpat.")") - - elseif dirname=~ '^\*\*/' - " starpat=4: Explore **/filepat (recursive descent search for filenames matching filepat) - let starpat= 4 -" call Decho("case Explore **/filepat (starpat=".starpat.")") - - else - let starpat= 0 -" call Decho("default case: starpat=".starpat) - endif - - if starpat == 0 && a:indx >= 0 - " [Explore Hexplore Vexplore Sexplore] [dirname] -" call Decho("case starpat==0 && a:indx=".a:indx.": dirname<".dirname."> Explore Hexplore Vexplore Sexplore") - if dirname == "" - let dirname= curfiledir -" call Decho("..empty dirname, using current file's directory<".dirname.">") - endif - if dirname =~ '^scp:' || dirname =~ '^ftp:' -" call Decho("..calling NetrwBrowse(0,dirname<".dirname.">)") - call s:NetrwBrowse(0,dirname) - else - if dirname == ""|let dirname= getcwd()|endif -" call Decho("..calling LocalBrowseCheck(dirname<".dirname.">)") - call netrw#LocalBrowseCheck(dirname) -" call Decho("win#".winnr()." buf#".bufnr("%")." modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) - endif - -" call Decho("curdir<".curdir.">") - if has("win32") || has("win95") || has("win64") || has("win16") - keepj call search('\<'.substitute(curdir,'^.*[/\\]','','e').'\>','cW') - else - keepj call search('\<'.substitute(curdir,'^.*/','','e').'\>','cW') - endif - - " starpat=1: Explore *//pattern (current directory only search for files containing pattern) - " starpat=2: Explore **//pattern (recursive descent search for files containing pattern) - " starpat=3: Explore */filepat (search in current directory for filenames matching filepat) - " starpat=4: Explore **/filepat (recursive descent search for filenames matching filepat) - elseif a:indx <= 0 - " Nexplore, Pexplore, Explore: handle starpat -" call Decho("case a:indx<=0: Nexplore, Pexplore, <s-down>, <s-up> starpat=".starpat." a:indx=".a:indx) - if !mapcheck("<s-up>","n") && !mapcheck("<s-down>","n") && exists("b:netrw_curdir") -" call Decho("..set up <s-up> and <s-down> maps") - let s:didstarstar= 1 - nnoremap <buffer> <silent> <s-up> :Pexplore<cr> - nnoremap <buffer> <silent> <s-down> :Nexplore<cr> - endif - - if has("path_extra") -" call Decho("..starpat=".starpat.": has +path_extra") - if !exists("w:netrw_explore_indx") - let w:netrw_explore_indx= 0 - endif - - let indx = a:indx -" call Decho("..starpat=".starpat.": set indx= [a:indx=".indx."]") - - if indx == -1 - " Nexplore -" call Decho("..case Nexplore with starpat=".starpat.": (indx=".indx.")") - if !exists("w:netrw_explore_list") " sanity check - keepj call netrw#ErrorMsg(s:WARNING,"using Nexplore or <s-down> improperly; see help for netrw-starstar",40) - sil! let @* = keepregstar - sil! let @+ = keepregstar - sil! let @/ = keepregslash -" call Dret("netrw#Explore") - return - endif - let indx= w:netrw_explore_indx - if indx < 0 | let indx= 0 | endif - if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif - let curfile= w:netrw_explore_list[indx] -" call Decho("....indx=".indx." curfile<".curfile.">") - while indx < w:netrw_explore_listlen && curfile == w:netrw_explore_list[indx] - let indx= indx + 1 -" call Decho("....indx=".indx." (Nexplore while loop)") - endwhile - if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif -" call Decho("....Nexplore: indx= [w:netrw_explore_indx=".w:netrw_explore_indx."]=".indx) - - elseif indx == -2 - " Pexplore -" call Decho("case Pexplore with starpat=".starpat.": (indx=".indx.")") - if !exists("w:netrw_explore_list") " sanity check - keepj call netrw#ErrorMsg(s:WARNING,"using Pexplore or <s-up> improperly; see help for netrw-starstar",41) - sil! let @* = keepregstar - sil! let @+ = keepregstar - sil! let @/ = keepregslash -" call Dret("netrw#Explore") - return - endif - let indx= w:netrw_explore_indx - if indx < 0 | let indx= 0 | endif - if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif - let curfile= w:netrw_explore_list[indx] -" call Decho("....indx=".indx." curfile<".curfile.">") - while indx >= 0 && curfile == w:netrw_explore_list[indx] - let indx= indx - 1 -" call Decho("....indx=".indx." (Pexplore while loop)") - endwhile - if indx < 0 | let indx= 0 | endif -" call Decho("....Pexplore: indx= [w:netrw_explore_indx=".w:netrw_explore_indx."]=".indx) - - else - " Explore -- initialize - " build list of files to Explore with Nexplore/Pexplore -" call Decho("..starpat=".starpat.": case Explore: initialize (indx=".indx.")") - keepj call s:NetrwClearExplore() - let w:netrw_explore_indx= 0 - if !exists("b:netrw_curdir") - let b:netrw_curdir= getcwd() - endif -" call Decho("....starpat=".starpat.": b:netrw_curdir<".b:netrw_curdir.">") - - " switch on starpat to build the w:netrw_explore_list of files - if starpat == 1 - " starpat=1: Explore *//pattern (current directory only search for files containing pattern) -" call Decho("..case starpat=".starpat.": build *//pattern list (curdir-only srch for files containing pattern) &hls=".&hls) -" call Decho("....pattern<".pattern.">") - try - exe "keepj noautocmd vimgrep /".pattern."/gj ".fnameescape(b:netrw_curdir)."/*" - catch /^Vim\%((\a\+)\)\=:E480/ - call netrw#ErrorMsg(s:WARNING,"no match with pattern<".pattern.">",76) -" call Dret("netrw#Explore : unable to find pattern<".pattern.">") - return - endtry - let w:netrw_explore_list = s:NetrwExploreListUniq(map(getqflist(),'bufname(v:val.bufnr)')) - if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif - - elseif starpat == 2 - " starpat=2: Explore **//pattern (recursive descent search for files containing pattern) -" call Decho("..case starpat=".starpat.": build **//pattern list (recursive descent files containing pattern)") -" call Decho("....pattern<".pattern.">") - try - exe "sil keepj noautocmd vimgrep /".pattern."/gj "."**/*" - catch /^Vim\%((\a\+)\)\=:E480/ - call netrw#ErrorMsg(s:WARNING,'no files matched pattern<'.pattern.'>',45) - if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif - sil! let @* = keepregstar - sil! let @+ = keepregstar - sil! let @/ = keepregslash -" call Dret("netrw#Explore : no files matched pattern") - return - endtry - let s:netrw_curdir = b:netrw_curdir - let w:netrw_explore_list = getqflist() - let w:netrw_explore_list = s:NetrwExploreListUniq(map(w:netrw_explore_list,'s:netrw_curdir."/".bufname(v:val.bufnr)')) - if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif - - elseif starpat == 3 - " starpat=3: Explore */filepat (search in current directory for filenames matching filepat) -" call Decho("..case starpat=".starpat.": build */filepat list (curdir-only srch filenames matching filepat) &hls=".&hls) - let filepat= substitute(dirname,'^\*/','','') - let filepat= substitute(filepat,'^[%#<]','\\&','') -" call Decho("....b:netrw_curdir<".b:netrw_curdir.">") -" call Decho("....filepat<".filepat.">") - let w:netrw_explore_list= s:NetrwExploreListUniq(split(expand(b:netrw_curdir."/".filepat),'\n')) - if &hls | let keepregslash= s:ExplorePatHls(filepat) | endif - - elseif starpat == 4 - " starpat=4: Explore **/filepat (recursive descent search for filenames matching filepat) -" call Decho("..case starpat=".starpat.": build **/filepat list (recursive descent srch filenames matching filepat) &hls=".&hls) - let w:netrw_explore_list= s:NetrwExploreListUniq(split(expand(b:netrw_curdir."/".dirname),'\n')) - if &hls | let keepregslash= s:ExplorePatHls(dirname) | endif - endif " switch on starpat to build w:netrw_explore_list - - let w:netrw_explore_listlen = len(w:netrw_explore_list) -" call Decho("....w:netrw_explore_list<".string(w:netrw_explore_list).">") -" call Decho("....w:netrw_explore_listlen=".w:netrw_explore_listlen) - - if w:netrw_explore_listlen == 0 || (w:netrw_explore_listlen == 1 && w:netrw_explore_list[0] =~ '\*\*\/') - keepj call netrw#ErrorMsg(s:WARNING,"no files matched",42) - sil! let @* = keepregstar - sil! let @+ = keepregstar - sil! let @/ = keepregslash -" call Dret("netrw#Explore : no files matched") - return - endif - endif " if indx ... endif - - " NetrwStatusLine support - for exploring support - let w:netrw_explore_indx= indx -" call Decho("....w:netrw_explore_list<".join(w:netrw_explore_list,',')."> len=".w:netrw_explore_listlen) - - " wrap the indx around, but issue a note - if indx >= w:netrw_explore_listlen || indx < 0 -" call Decho("....wrap indx (indx=".indx." listlen=".w:netrw_explore_listlen.")") - let indx = (indx < 0)? ( w:netrw_explore_listlen - 1 ) : 0 - let w:netrw_explore_indx= indx - keepj call netrw#ErrorMsg(s:NOTE,"no more files match Explore pattern",43) - endif - - exe "let dirfile= w:netrw_explore_list[".indx."]" -" call Decho("....dirfile=w:netrw_explore_list[indx=".indx."]= <".dirfile.">") - let newdir= substitute(dirfile,'/[^/]*$','','e') -" call Decho("....newdir<".newdir.">") - -" call Decho("....calling LocalBrowseCheck(newdir<".newdir.">)") - call netrw#LocalBrowseCheck(newdir) - if !exists("w:netrw_liststyle") - let w:netrw_liststyle= g:netrw_liststyle - endif - if w:netrw_liststyle == s:THINLIST || w:netrw_liststyle == s:LONGLIST - keepj call search('^'.substitute(dirfile,"^.*/","","").'\>',"W") - else - keepj 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(".") - keepj 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 -" call Decho("..your vim does not have +path_extra") - if !exists("g:netrw_quiet") - keepj call netrw#ErrorMsg(s:WARNING,"your vim needs the +path_extra feature for Exploring with **!",44) - endif - sil! let @* = keepregstar - sil! let @+ = keepregstar - sil! let @/ = keepregslash -" call Dret("netrw#Explore : missing +path_extra") - return - endif - - else -" call Decho("..default case: Explore newdir<".dirname.">") - if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && dirname =~ '/' - sil! unlet w:netrw_treedict - sil! unlet w:netrw_treetop - endif - let newdir= dirname - if !exists("b:netrw_curdir") - keepj call netrw#LocalBrowseCheck(getcwd()) - else - keepj call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,newdir)) - endif - endif - - " visual display of **/ **// */ Exploration files -" call Decho("w:netrw_explore_indx=".(exists("w:netrw_explore_indx")? w:netrw_explore_indx : "doesn't exist")) -" call Decho("b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "n/a").">") - if exists("w:netrw_explore_indx") && exists("b:netrw_curdir") -" call Decho("s:explore_prvdir<".(exists("s:explore_prvdir")? s:explore_prvdir : "-doesn't exist-")) - if !exists("s:explore_prvdir") || s:explore_prvdir != b:netrw_curdir - " only update match list if current directory isn't the same as before -" call Decho("only update match list if current directory not the same as before") - let s:explore_prvdir = b:netrw_curdir - let s:explore_match = "" - let dirlen = s:Strlen(b:netrw_curdir) - if b:netrw_curdir !~ '/$' - let dirlen= dirlen + 1 - endif - let prvfname= "" - for fname in w:netrw_explore_list -" call Decho("fname<".fname.">") - if fname =~ '^'.b:netrw_curdir - if s:explore_match == "" - let s:explore_match= '\<'.escape(strpart(fname,dirlen),g:netrw_markfileesc).'\>' - else - let s:explore_match= s:explore_match.'\|\<'.escape(strpart(fname,dirlen),g:netrw_markfileesc).'\>' - endif - elseif fname !~ '^/' && fname != prvfname - if s:explore_match == "" - let s:explore_match= '\<'.escape(fname,g:netrw_markfileesc).'\>' - else - let s:explore_match= s:explore_match.'\|\<'.escape(fname,g:netrw_markfileesc).'\>' - endif - endif - let prvfname= fname - endfor -" call Decho("explore_match<".s:explore_match.">") - exe "2match netrwMarkFile /".s:explore_match."/" - endif - echo "<s-up>==Pexplore <s-down>==Nexplore" - else - 2match none - if exists("s:explore_match") | unlet s:explore_match | endif - if exists("s:explore_prvdir") | unlet s:explore_prvdir | endif - echo " " -" call Decho("cleared explore match list") - endif - - sil! let @* = keepregstar - sil! let @+ = keepregstar - sil! let @/ = keepregslash -" call Dret("netrw#Explore : @/<".@/.">") -endfun - -" --------------------------------------------------------------------- " s:NetrwExploreListUniq: {{{2 fun! s:NetrwExploreListUniq(explist) " call Dfunc("s:NetrwExploreListUniq(explist<".string(a:explist).">)") @@ -4511,13 +4850,17 @@ endfun " --------------------------------------------------------------------- " s:NetrwForceFile: (gf support) Force treatment as a file {{{2 fun! s:NetrwForceFile(islocal,newfile) -" " call Dfunc("s:NetrwForceFile(islocal=".a:islocal." newdir<".a:newdir.">)") +" call Dfunc("s:NetrwForceFile(islocal=".a:islocal." newdir<".a:newfile.">)") if a:newfile =~ '[/@*=|\\]$' let newfile= substitute(a:newfile,'.$','','') else let newfile= a:newfile endif - call s:NetrwBrowseChgDir(a:islocal,newfile) + if a:islocal + call s:NetrwBrowseChgDir(a:islocal,newfile) + else + call s:NetrwBrowse(a:islocal,s:NetrwBrowseChgDir(a:islocal,newfile)) + endif " call Dret("s:NetrwForceFile") endfun @@ -4539,7 +4882,7 @@ fun! s:NetrwHide(islocal) " hide the files in the markfile list for fname in s:netrwmarkfilelist_{bufnr("%")} -" call Decho("match(g:netrw_list_hide<".g:netrw_list_hide.'> fname<\<'.fname.'\>>)='.match(g:netrw_list_hide,'\<'.fname.'\>')." isk=".&isk) +" call Decho("match(g:netrw_list_hide<".g:netrw_list_hide.'> fname<\<'.fname.'\>>)='.match(g:netrw_list_hide,'\<'.fname.'\>')." l:isk=".&l:isk) if match(g:netrw_list_hide,'\<'.fname.'\>') != -1 " remove fname from hiding list let g:netrw_list_hide= substitute(g:netrw_list_hide,'..\<'.escape(fname,g:netrw_fname_escape).'\>..','','') @@ -4626,7 +4969,7 @@ fun! s:NetrwHome() endif endif " insure that the home directory exists - if !isdirectory(home) + if g:netrw_dirhistmax > 0 && !isdirectory(home) if exists("g:netrw_mkdir") call system(g:netrw_mkdir." ".shellescape(home)) else @@ -4640,6 +4983,9 @@ endfun " --------------------------------------------------------------------- " s:NetrwLeftmouse: handles the <leftmouse> when in a netrw browsing window {{{2 fun! s:NetrwLeftmouse(islocal) + if exists("s:netrwdrag") + return + endif " call Dfunc("s:NetrwLeftmouse(islocal=".a:islocal.")") let ykeep= @@ @@ -4680,6 +5026,47 @@ fun! s:NetrwLeftmouse(islocal) endfun " --------------------------------------------------------------------- +" s:NetrwRightdrag: {{{2 +"DechoTabOn +fun! s:NetrwRightdrag(islocal) +" call Dfunc("s:NetrwRightdrag(islocal=".a:islocal.")") + if !exists("s:netrwdrag") + let s:netrwdrag = winnr() + call s:NetrwMarkFile(a:islocal,s:NetrwGetWord()) + if a:islocal + nno <silent> <s-rightrelease> <leftmouse>:<c-u>call <SID>NetrwRightrelease(1)<cr> + else + nno <silent> <s-rightrelease> <leftmouse>:<c-u>call <SID>NetrwRightrelease(0)<cr> + endif + endif +" call Dret("s:NetrwRightdrag : s:netrwdrag=".s:netrwdrag." buf#".bufnr("%")) +endfun + +" --------------------------------------------------------------------- +" s:NetrwRightrelease: {{{2 +fun! s:NetrwRightrelease(islocal) +" call Dfunc("s:NetrwRightrelease(islocal=".a:islocal.") s:netrwdrag=".s:netrwdrag." buf#".bufnr("%")) + if exists("s:netrwdrag") + nunmap <s-rightrelease> + let tgt = s:NetrwGetWord() +" call Decho("target#1: ".tgt) + if tgt =~ '/$' && tgt !~ '^\./$' + let tgt = b:netrw_curdir."/".tgt + else + let tgt= b:netrw_curdir + endif +" call Decho("target#2: ".tgt) + call netrw#NetrwMakeTgt(tgt) + let curwin= winnr() + exe s:netrwdrag."wincmd w" + call s:NetrwMarkFileMove(a:islocal) + exe curwin."wincmd w" + unlet s:netrwdrag + endif +" call Dret("s:NetrwRightrelease") +endfun + +" --------------------------------------------------------------------- " s:NetrwListHide: uses [range]g~...~d to delete files that match comma {{{2 " separated patterns given in g:netrw_list_hide fun! s:NetrwListHide() @@ -4900,6 +5287,13 @@ endfun " b:netrw_islocal fun! s:NetrwMarkFile(islocal,fname) " call Dfunc("s:NetrwMarkFile(islocal=".a:islocal." fname<".a:fname.">)") + + " sanity check + if empty(a:fname) +" call Dret("s:NetrwMarkFile : emtpy fname") + return + endif + let ykeep = @@ let curbufnr= bufnr("%") let curdir = b:netrw_curdir @@ -5010,34 +5404,44 @@ fun! s:NetrwMarkFileCompress(islocal) let curdir = b:netrw_curdir let curbufnr = bufnr("%") + " sanity check + if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr}) + keepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) +" call Dret("s:NetrwMarkFileCompress") + return + endif +" call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr})) + if exists("s:netrwmarkfilelist_{curbufnr}") && exists("g:netrw_compress") && exists("g:netrw_decompress") + + " for every filename in the marked list for fname in s:netrwmarkfilelist_{curbufnr} - " for every filename in the marked list - for sfx in sort(keys(g:netrw_decompress)) - if fname =~ '\'.sfx.'$' - " fname has a suffix indicating that its compressed; apply associated decompression routine - let exe= netrw#WinPath(g:netrw_decompress[sfx]) -" call Decho("fname<".fname."> is compressed so decompress with <".exe.">") - if a:islocal - if g:netrw_keepdir - let fname= shellescape(s:ComposePath(curdir,fname)) - endif - else - let fname= shellescape(b:netrw_curdir.fname,1) + let sfx= substitute(fname,'^.\{-}\(\.\a\+\)$','\1','') +" call Decho("extracted sfx<".sfx.">") + if exists("g:netrw_decompress['".sfx."']") + " fname has a suffix indicating that its compressed; apply associated decompression routine + let exe= g:netrw_decompress[sfx] +" call Decho("fname<".fname."> is compressed so decompress with <".exe.">") + let exe= netrw#WinPath(exe) + if a:islocal + if g:netrw_keepdir + let fname= shellescape(s:ComposePath(curdir,fname)) endif - if executable(exe) - if a:islocal - call system(exe." ".fname) - else - keepj call s:RemoteSystem(exe." ".fname) - endif + else + let fname= shellescape(b:netrw_curdir.fname,1) + endif + if executable(exe) + if a:islocal + call system(exe." ".fname) else - keepj call netrw#ErrorMsg(s:WARNING,"unable to apply<".exe."> to file<".fname.">",50) + keepj call s:RemoteSystem(exe." ".fname) endif - break + else + keepj call netrw#ErrorMsg(s:WARNING,"unable to apply<".exe."> to file<".fname.">",50) endif - unlet sfx - endfor + endif + unlet sfx + if exists("exe") unlet exe elseif a:islocal @@ -5047,7 +5451,8 @@ fun! s:NetrwMarkFileCompress(islocal) " fname not a compressed file, so compress it keepj call s:RemoteSystem(netrw#WinPath(g:netrw_compress)." ".shellescape(fname)) endif - endfor + endfor " for every file in the marked list + call s:NetrwUnmarkList(curbufnr,curdir) keepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) keepj call netrw#NetrwRestorePosn(svpos) @@ -5064,36 +5469,52 @@ endfun " 0=failure fun! s:NetrwMarkFileCopy(islocal) " call Dfunc("s:NetrwMarkFileCopy(islocal=".a:islocal.") target<".(exists("s:netrwmftgt")? s:netrwmftgt : '---').">") + let curdir = b:netrw_curdir + let curbufnr = bufnr("%") - " sanity checks - if !exists("s:netrwmarkfilelist_{bufnr('%')}") || empty(s:netrwmarkfilelist_{bufnr('%')}) - 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 + " sanity check + if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr}) + keepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) +" call Dret("s:NetrwMarkFileCopy") + return endif -" call Decho("sanity chk passed: s:netrwmarkfilelist_".bufnr('%')."<".string(s:netrwmarkfilelist_{bufnr('%')})) +" call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr})) + if !exists("s:netrwmftgt") keepj call netrw#ErrorMsg(s:ERROR,"your marked file target is empty! (:help netrw-mt)",67) " call Dret("s:NetrwMarkFileCopy 0") return 0 endif " call Decho("sanity chk passed: s:netrwmftgt<".s:netrwmftgt.">") - let curdir = b:netrw_curdir - let curbufnr = bufnr("%") if a:islocal && s:netrwmftgt_islocal " Copy marked files, local directory to local directory " call Decho("copy from local to local") - if !executable(g:netrw_localcopycmd) && g:netrw_localcopycmd !~ '^cmd ' + if !executable(g:netrw_localcopycmd) && g:netrw_localcopycmd !~ '\<cmd\s' call netrw#ErrorMsg(s:ERROR,"g:netrw_localcopycmd<".g:netrw_localcopycmd."> not executable on your system, aborting",91) " call Dfunc("s:NetrwMarkFileMove : g:netrw_localcopycmd<".g:netrw_localcopycmd."> n/a!") return endif let args= join(map(deepcopy(s:netrwmarkfilelist_{bufnr('%')}),"shellescape(b:netrw_curdir.\"/\".v:val)")) -" call Decho("system(".g:netrw_localcopycmd." ".args." ".shellescape(s:netrwmftgt).")") - call system(netrw#WinPath(g:netrw_localcopycmd)." ".args." ".shellescape(s:netrwmftgt)) + let tgt = shellescape(s:netrwmftgt) + if !g:netrw_cygwin && (has("win32") || has("win95") || has("win64") || has("win16")) + let args= substitute(args,'/','\\','g') + let tgt = substitute(tgt, '/','\\','g') + endif + if g:netrw_localcopycmd =~ '\s' + let copycmd = substitute(g:netrw_localcopycmd,'\s.*$','','') + let copycmdargs = substitute(g:netrw_localcopycmd,'^.\{-}\(\s.*\)$','\1','') + let copycmd = netrw#WinPath(copycmd).copycmdargs + else + let copycmd = netrw#WinPath(g:netrw_localcopycmd) + endif +" call Decho("args <".args.">") +" call Decho("tgt <".tgt.">") +" call Decho("copycmd<".copycmd.">") +" call Decho("system(".copycmd." ".args." ".tgt.")") + call system(copycmd." ".args." ".tgt) 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#ErrorMsg(s:ERROR,"tried using g:netrw_localcopycmd<".g:netrw_localcopycmd.">; it doesn't work!",80) " call Dret("s:NetrwMarkFileCopy 0 : failed: system(".g:netrw_localcopycmd." ".args." ".shellescape(s:netrwmftgt)) return 0 endif @@ -5178,7 +5599,15 @@ fun! s:NetrwMarkFileDiff(islocal) " call Dfunc("s:NetrwMarkFileDiff(islocal=".a:islocal.") b:netrw_curdir<".b:netrw_curdir.">") let curbufnr= bufnr("%") - if exists("s:netrwmarkfilelist_{curbufnr}") + " sanity check + if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr}) + keepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) +" call Dret("s:NetrwMarkFileDiff") + return + endif +" call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr})) + + if exists("s:netrwmarkfilelist_{."curbufnr}") let cnt = 0 let curdir = b:netrw_curdir for fname in s:netrwmarkfilelist @@ -5211,6 +5640,15 @@ fun! s:NetrwMarkFileEdit(islocal) let curdir = b:netrw_curdir let curbufnr = bufnr("%") + + " sanity check + if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr}) + keepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) +" call Dret("s:NetrwMarkFileEdit") + return + endif +" call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr})) + if exists("s:netrwmarkfilelist_{curbufnr}") call s:SetRexDir(a:islocal,curdir) let flist= join(map(deepcopy(s:netrwmarkfilelist), "fnameescape(v:val)")) @@ -5220,11 +5658,43 @@ fun! s:NetrwMarkFileEdit(islocal) " call Decho("exe sil args ".flist) exe "sil args ".flist endif + echo "(use :bn, :bp to navigate files; :Rex to return)" " call Dret("s:NetrwMarkFileEdit") endfun " --------------------------------------------------------------------- +" s:NetrwMarkFileQFEL: convert a quickfix-error list into a marked file list {{{2 +fun! s:NetrwMarkFileQFEL(islocal,qfel) +" call Dfunc("s:NetrwMarkFileQFEL(islocal=".a:islocal.",qfel)") + call s:NetrwUnmarkAll() + let curbufnr= bufnr("%") + + if !empty(a:qfel) + for entry in a:qfel + let bufnmbr= entry["bufnr"] +" call Decho("bufname(".bufnmbr.")<".bufname(bufnmbr)."> line#".entry["lnum"]." text=".entry["text"]) + if !exists("s:netrwmarkfilelist_{curbufnr}") +" call Decho("case: no marked file list") + call s:NetrwMarkFile(a:islocal,bufname(bufnmbr)) + elseif index(s:netrwmarkfilelist_{curbufnr},bufname(bufnmbr)) == -1 + " s:NetrwMarkFile will remove duplicate entries from the marked file list. + " So, this test lets two or more hits on the same pattern to be ignored. +" call Decho("case: ".bufname(bufnmbr)." not currently in marked file list") + call s:NetrwMarkFile(a:islocal,bufname(bufnmbr)) + else +" call Decho("case: ".bufname(bufnmbr)." already in marked file list") + endif + endfor + echo "(use me to edit marked files)" + else + call netrw#ErrorMsg(s:WARNING,"can't convert quickfix error list; its empty!",92) + endif + +" call Dret("s:NetrwMarkFileQFEL") +endfun + +" --------------------------------------------------------------------- " s:NetrwMarkFileExe: (invoked by mx) execute arbitrary system command on marked files, one at a time {{{2 " Uses the local marked-file list. fun! s:NetrwMarkFileExe(islocal) @@ -5233,6 +5703,14 @@ fun! s:NetrwMarkFileExe(islocal) let curdir = b:netrw_curdir let curbufnr = bufnr("%") + " sanity check + if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr}) + keepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) +" call Dret("s:NetrwMarkFileExe") + return + endif +" call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr})) + if exists("s:netrwmarkfilelist_{curbufnr}") " get the command call inputsave() @@ -5353,6 +5831,14 @@ fun! s:NetrwMarkFileVimCmd(islocal) let curdir = b:netrw_curdir let curbufnr = bufnr("%") + " sanity check + if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr}) + keepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) +" call Dret("s:NetrwMarkFileVimCmd") + return + endif +" call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr})) + if exists("s:netrwmarkfilelist_{curbufnr}") " get the command call inputsave() @@ -5463,30 +5949,47 @@ fun! s:NetrwMarkFileGrep(islocal) " call Decho("s:netrwmarkfilelist".string(s:netrwmarkfilelist).">") let netrwmarkfilelist= join(map(deepcopy(s:netrwmarkfilelist), "fnameescape(v:val)")) call s:NetrwUnmarkAll() + else +" call Decho('no marked files, using "*"') + let netrwmarkfilelist= "*" + endif - " ask user for pattern - call inputsave() - let pat= input("Enter pattern: ","") - call inputrestore() - if pat !~ '^\s' - if pat !~ '^/' - let pat= '/'.pat.'/' - endif - let pat= " ".pat - endif + " ask user for pattern + call inputsave() + let pat= input("Enter pattern: ","") + call inputrestore() + let patbang = "" + if pat =~ '^!' + let patbang = "!" + let pat= strpart(pat,2) + endif + if pat =~ '^\i' + let pat = escape(pat,'/') + let pat = '/'.pat.'/' + else + let nonisi = pat[0] + endif - " use vimgrep for both local and remote -" call Decho("exe vimgrep".pat." ".netrwmarkfilelist) - try - exe "keepj noautocmd vimgrep".pat." ".netrwmarkfilelist - catch /^Vim\%((\a\+)\)\=:E480/ - keepj call netrw#ErrorMsg(s:WARNING,"no match with pattern<".pattern.">",76) -" call Dret("s:NetrwMarkFileGrep : unable to find pattern<".pattern.">") - return - endtry + " use vimgrep for both local and remote +" call Decho("exe vimgrep".patbang." ".pat." ".netrwmarkfilelist) + try + exe "keepj noautocmd vimgrep".patbang." ".pat." ".netrwmarkfilelist + catch /^Vim\%((\a\+)\)\=:E480/ + keepj call netrw#ErrorMsg(s:WARNING,"no match with pattern<".pat.">",76) +" call Dret("s:NetrwMarkFileGrep : unable to find pattern<".pat.">") + return + endtry + echo "(use :cn, :cp to navigate, :Rex to return)" - 2match none - keepj call netrw#NetrwRestorePosn(svpos) + 2match none + keepj call netrw#NetrwRestorePosn(svpos) + + if exists("nonisi") + " original, user-supplied pattern did not begin with a character from isident +" call Decho("looking for trailing nonisi<".nonisi."> followed by a j, gj, or jg") + if pat =~ nonisi.'j$\|'.nonisi.'gj$\|'.nonisi.'jg$' + call s:NetrwMarkFileQFEL(a:islocal,getqflist()) + endif endif " call Dret("s:NetrwMarkFileGrep") @@ -5503,12 +6006,13 @@ fun! s:NetrwMarkFileMove(islocal) let curbufnr = bufnr("%") " sanity check - if !exists("s:netrwmarkfilelist_{bufnr('%')}") || empty(s:netrwmarkfilelist_{bufnr('%')}) + if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr}) keepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) " call Dret("s:NetrwMarkFileMove") return endif -" call Decho("sanity chk passed: s:netrwmarkfilelist_".bufnr('%')."<".string(s:netrwmarkfilelist_{bufnr('%')})) +" call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr})) + if !exists("s:netrwmftgt") keepj call netrw#ErrorMsg(2,"your marked file target is empty! (:help netrw-mt)",67) " call Dret("s:NetrwMarkFileCopy 0") @@ -5520,16 +6024,37 @@ fun! s:NetrwMarkFileMove(islocal) " move: local -> local " call Decho("move from local to local") " call Decho("(s:NetrwMarkFileMove) local to local move") - if !executable(g:netrw_localmovecmd) && g:netrw_localmovecmd !~ '^cmd ' + if !executable(g:netrw_localmovecmd) && g:netrw_localmovecmd !~ '\<cmd\s' call netrw#ErrorMsg(s:ERROR,"g:netrw_localmovecmd<".g:netrw_localmovecmd."> not executable on your system, aborting",90) " call Dfunc("s:NetrwMarkFileMove : g:netrw_localmovecmd<".g:netrw_localmovecmd."> n/a!") return endif + let tgt = shellescape(s:netrwmftgt) +" call Decho("tgt<".tgt.">") + if !g:netrw_cygwin && (has("win32") || has("win95") || has("win64") || has("win16")) + let tgt = substitute(tgt, '/','\\','g') +" call Decho("windows exception: tgt<".tgt.">") + if g:netrw_localmovecmd =~ '\s' + let movecmd = substitute(g:netrw_localmovecmd,'\s.*$','','') + let movecmdargs = substitute(g:netrw_localmovecmd,'^.\{-}\(\s.*\)$','\1','') + let movecmd = netrw#WinPath(movecmd).movecmdargs +" call Decho("windows exception: movecmd<".movecmd."> (#1: had a space)") + else + let movecmd = netrw#WinPath(movecmd) +" call Decho("windows exception: movecmd<".movecmd."> (#2: no space)") + endif + else + let movecmd = netrw#WinPath(g:netrw_localmovecmd) +" call Decho("movecmd<".movecmd."> (#3 linux or cygwin)") + endif for fname in s:netrwmarkfilelist_{bufnr("%")} -" call Decho("system(".g:netrw_localmovecmd." ".shellescape(fname)." ".shellescape(s:netrwmftgt).")") - let ret= system(g:netrw_localmovecmd." ".shellescape(fname)." ".shellescape(s:netrwmftgt)) - if v:shell_error < 0 - call netrw#ErrorMsg(s:ERROR,"command<".g:netrw_localmovecmd."> failed, aborting",54) +" call Decho("system(".movecmd." ".shellescape(fname)." ".tgt.")") + if !g:netrw_cygwin && (has("win32") || has("win95") || has("win64") || has("win16")) + let fname= substitute(fname,'/','\\','g') + endif + let ret= system(g:netrw_localmovecmd." ".shellescape(fname)." ".tgt) + if v:shell_error != 0 + call netrw#ErrorMsg(s:ERROR,"tried using g:netrw_localmovecmd<".g:netrw_localmovecmd.">; it doesn't work!",54) break endif endfor @@ -5605,6 +6130,14 @@ endfun fun! s:NetrwMarkFilePrint(islocal) " call Dfunc("s:NetrwMarkFilePrint(islocal=".a:islocal.")") let curbufnr= bufnr("%") + + " sanity check + if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr}) + keepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) +" call Dret("s:NetrwMarkFilePrint") + return + endif +" call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr})) if exists("s:netrwmarkfilelist_{curbufnr}") let netrwmarkfilelist = s:netrwmarkfilelist_{curbufnr} let curdir = b:netrw_curdir @@ -5633,7 +6166,7 @@ endfun " --------------------------------------------------------------------- " s:NetrwMarkFileRegexp: (invoked by mr) This function is used to mark {{{2 " files when given a regexp (for which a prompt is -" issued). +" issued) (matches to name of files). fun! s:NetrwMarkFileRegexp(islocal) " call Dfunc("s:NetrwMarkFileRegexp(islocal=".a:islocal.")") @@ -5645,8 +6178,8 @@ fun! s:NetrwMarkFileRegexp(islocal) if a:islocal " get the matching list of files using local glob() " call Decho("handle local regexp") - let dirname = escape(b:netrw_curdir,g:netrw_glob_escape) - let files = glob(s:ComposePath(dirname,regexp)) + let dirname = escape(b:netrw_curdir,g:netrw_glob_escape) + let files = glob(s:ComposePath(dirname,regexp)) " call Decho("files<".files.">") let filelist= split(files,"\n") @@ -5699,6 +6232,7 @@ fun! s:NetrwMarkFileRegexp(islocal) let @a = areg let &ei = eikeep endif + echo " (use me to edit marked files)" " call Dret("s:NetrwMarkFileRegexp") endfun @@ -5709,6 +6243,14 @@ endfun fun! s:NetrwMarkFileSource(islocal) " call Dfunc("s:NetrwMarkFileSource(islocal=".a:islocal.")") let curbufnr= bufnr("%") + + " sanity check + if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr}) + keepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) +" call Dret("s:NetrwMarkFileSource") + return + endif +" call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr})) if exists("s:netrwmarkfilelist_{curbufnr}") let netrwmarkfilelist = s:netrwmarkfilelist_{bufnr("%")} let curdir = b:netrw_curdir @@ -5739,6 +6281,14 @@ fun! s:NetrwMarkFileTag(islocal) let curdir = b:netrw_curdir let curbufnr = bufnr("%") + " sanity check + if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr}) + keepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) +" call Dret("s:NetrwMarkFileTag") + return + endif +" call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr})) + if exists("s:netrwmarkfilelist") " call Decho("s:netrwmarkfilelist".string(s:netrwmarkfilelist).">") let netrwmarkfilelist= join(map(deepcopy(s:netrwmarkfilelist), "shellescape(v:val,".!a:islocal.")")) @@ -5774,9 +6324,9 @@ endfun " --------------------------------------------------------------------- " s:NetrwMarkFileTgt: (invoked by mt) This function sets up a marked file target {{{2 " Sets up two variables, -" s:netrwmftgt : holds the target directory +" s:netrwmftgt : holds the target directory " s:netrwmftgt_islocal : 0=target directory is remote -" 1=target directory is local +" 1=target directory is local fun! s:NetrwMarkFileTgt(islocal) " call Dfunc("s:NetrwMarkFileTgt(islocal=".a:islocal.")") let svpos = netrw#NetrwSavePosn() @@ -5788,9 +6338,21 @@ fun! s:NetrwMarkFileTgt(islocal) " set up target if line(".") < w:netrw_bannercnt - " if cursor in banner region, use b:netrw_curdir for the target - let s:netrwmftgt= b:netrw_curdir -" call Decho("inbanner: s:netrwmftgt<".s:netrwmftgt.">") + " if cursor in banner region, use b:netrw_curdir for the target unless its already the target + if exists("s:netrwmftgt") && exists("s:netrwmftgt_islocal") && s:netrwmftgt == b:netrw_curdir +" call Decho("cursor in banner region, and target already is <".b:netrw_curdir.">: removing target") + unlet s:netrwmftgt s:netrwmftgt_islocal + if g:netrw_fastbrowse <= 1 + call s:LocalBrowseShellCmdRefresh() + endif + call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) + call netrw#NetrwRestorePosn(svpos) +" call Dret("s:NetrwMarkFileTgt : removed target") + return + else + let s:netrwmftgt= b:netrw_curdir +" call Decho("inbanner: s:netrwmftgt<".s:netrwmftgt.">") + endif else " get word under cursor. @@ -5866,6 +6428,8 @@ endfun " --------------------------------------------------------------------- " s:NetrwUnmarkList: delete local marked file lists and remove their contents from the global marked-file list {{{2 +" User access provided by the <mu> mapping. (see :help netrw-mu) +" Used by many MarkFile functions. fun! s:NetrwUnmarkList(curbufnr,curdir) " call Dfunc("s:NetrwUnmarkList(curbufnr=".a:curbufnr." curdir<".a:curdir.">)") @@ -5903,7 +6467,7 @@ fun! s:NetrwUnmarkAll() endfun " --------------------------------------------------------------------- -" s:NetrwUnmarkAll2: {{{2 +" s:NetrwUnmarkAll2: unmark all files from all buffers {{{2 fun! s:NetrwUnmarkAll2() " call Dfunc("s:NetrwUnmarkAll2()") redir => netrwmarkfilelist_let @@ -5956,58 +6520,74 @@ fun! s:NetrwMenu(domenu) if !exists("s:netrw_menu_enabled") && a:domenu " call Decho("initialize menu") let s:netrw_menu_enabled= 1 - exe 'sil! menu '.g:NetrwMenuPriority.'.1 '.g:NetrwTopLvlMenu.'Help<tab><F1> <F1>' - exe 'sil! menu '.g:NetrwMenuPriority.'.5 '.g:NetrwTopLvlMenu.'-Sep1- :' - exe 'sil! menu '.g:NetrwMenuPriority.'.6 '.g:NetrwTopLvlMenu.'Go\ Up\ Directory<tab>- -' - exe 'sil! menu '.g:NetrwMenuPriority.'.7 '.g:NetrwTopLvlMenu.'Apply\ Special\ Viewer<tab>x x' - exe 'sil! menu '.g:NetrwMenuPriority.'.8.1 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Bookmark\ Current\ Directory<tab>mb mb' - exe 'sil! menu '.g:NetrwMenuPriority.'.8.4 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Goto\ Prev\ Dir\ (History)<tab>u u' - exe 'sil! menu '.g:NetrwMenuPriority.'.8.5 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Goto\ Next\ Dir\ (History)<tab>U U' - exe 'sil! menu '.g:NetrwMenuPriority.'.8.6 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.List<tab>qb qb' - exe 'sil! menu '.g:NetrwMenuPriority.'.9.1 '.g:NetrwTopLvlMenu.'Browsing\ Control.Edit\ File\ Hiding\ List<tab><ctrl-h>'." \<c-h>'" - exe 'sil! menu '.g:NetrwMenuPriority.'.9.2 '.g:NetrwTopLvlMenu.'Browsing\ Control.Edit\ Sorting\ Sequence<tab>S S' - exe 'sil! menu '.g:NetrwMenuPriority.'.9.3 '.g:NetrwTopLvlMenu.'Browsing\ Control.Quick\ Hide/Unhide\ Dot\ Files<tab>'."gh gh" - exe 'sil! menu '.g:NetrwMenuPriority.'.9.4 '.g:NetrwTopLvlMenu.'Browsing\ Control.Refresh\ Listing<tab>'."<ctrl-l> \<c-l>" - exe 'sil! menu '.g:NetrwMenuPriority.'.9.5 '.g:NetrwTopLvlMenu.'Browsing\ Control.Settings/Options<tab>:NetrwSettings '.":NetrwSettings\<cr>" - exe 'sil! menu '.g:NetrwMenuPriority.'.10 '.g:NetrwTopLvlMenu.'Delete\ File/Directory<tab>D D' - exe 'sil! menu '.g:NetrwMenuPriority.'.11.1 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.Create\ New\ File<tab>% %' - exe 'sil! menu '.g:NetrwMenuPriority.'.11.1 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ Current\ Window<tab><cr> '."\<cr>" - exe 'sil! menu '.g:NetrwMenuPriority.'.11.2 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.Preview\ File/Directory<tab>p p' - exe 'sil! menu '.g:NetrwMenuPriority.'.11.3 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ Previous\ Window<tab>P P' - exe 'sil! menu '.g:NetrwMenuPriority.'.11.4 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ New\ Window<tab>o o' - exe 'sil! menu '.g:NetrwMenuPriority.'.11.5 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ New\ Vertical\ Window<tab>v v' - exe 'sil! menu '.g:NetrwMenuPriority.'.12.1 '.g:NetrwTopLvlMenu.'Explore.Directory\ Name :Explore ' - exe 'sil! menu '.g:NetrwMenuPriority.'.12.2 '.g:NetrwTopLvlMenu.'Explore.Filenames\ Matching\ Pattern\ (curdir\ only)<tab>:Explore\ */ :Explore */' - exe 'sil! menu '.g:NetrwMenuPriority.'.12.2 '.g:NetrwTopLvlMenu.'Explore.Filenames\ Matching\ Pattern\ (+subdirs)<tab>:Explore\ **/ :Explore **/' - exe 'sil! menu '.g:NetrwMenuPriority.'.12.3 '.g:NetrwTopLvlMenu.'Explore.Files\ Containing\ String\ Pattern\ (curdir\ only)<tab>:Explore\ *// :Explore *//' - exe 'sil! menu '.g:NetrwMenuPriority.'.12.4 '.g:NetrwTopLvlMenu.'Explore.Files\ Containing\ String\ Pattern\ (+subdirs)<tab>:Explore\ **// :Explore **//' - exe 'sil! menu '.g:NetrwMenuPriority.'.12.4 '.g:NetrwTopLvlMenu.'Explore.Next\ Match<tab>:Nexplore :Nexplore<cr>' - exe 'sil! menu '.g:NetrwMenuPriority.'.12.4 '.g:NetrwTopLvlMenu.'Explore.Prev\ Match<tab>:Pexplore :Pexplore<cr>' - exe 'sil! menu '.g:NetrwMenuPriority.'.13 '.g:NetrwTopLvlMenu.'Make\ Subdirectory<tab>d d' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.1 '.g:NetrwTopLvlMenu.'Marked\ Files.Mark\ File<tab>mf mf' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.2 '.g:NetrwTopLvlMenu.'Marked\ Files.Mark\ Files\ by\ Regexp<tab>mr mr' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.3 '.g:NetrwTopLvlMenu.'Marked\ Files.Hide-Show-List\ Control<tab>a a' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.4 '.g:NetrwTopLvlMenu.'Marked\ Files.Copy\ To\ Target<tab>mc mc' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.5 '.g:NetrwTopLvlMenu.'Marked\ Files.Delete<tab>D D' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.6 '.g:NetrwTopLvlMenu.'Marked\ Files.Diff<tab>md md' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.7 '.g:NetrwTopLvlMenu.'Marked\ Files.Edit<tab>me me' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.8 '.g:NetrwTopLvlMenu.'Marked\ Files.Exe\ Cmd<tab>mx mx' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.9 '.g:NetrwTopLvlMenu.'Marked\ Files.Move\ To\ Target<tab>mm mm' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.10 '.g:NetrwTopLvlMenu.'Marked\ Files.Obtain<tab>O O' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.11 '.g:NetrwTopLvlMenu.'Marked\ Files.Print<tab>mp mp' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.12 '.g:NetrwTopLvlMenu.'Marked\ Files.Replace<tab>R R' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.13 '.g:NetrwTopLvlMenu.'Marked\ Files.Set\ Target<tab>mt mt' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.14 '.g:NetrwTopLvlMenu.'Marked\ Files.Tag<tab>mT mT' - exe 'sil! menu '.g:NetrwMenuPriority.'.14.15 '.g:NetrwTopLvlMenu.'Marked\ Files.Zip/Unzip/Compress/Uncompress<tab>mz mz' - exe 'sil! menu '.g:NetrwMenuPriority.'.15 '.g:NetrwTopLvlMenu.'Obtain\ File<tab>O O' - exe 'sil! menu '.g:NetrwMenuPriority.'.16.1 '.g:NetrwTopLvlMenu.'Style.Listing\ Style\ (thin-long-wide-tree)<tab>i i' - exe 'sil! menu '.g:NetrwMenuPriority.'.16.2 '.g:NetrwTopLvlMenu.'Style.Normal-Hide-Show<tab>a a' - exe 'sil! menu '.g:NetrwMenuPriority.'.16.3 '.g:NetrwTopLvlMenu.'Style.Reverse\ Sorting\ Order<tab>'."r r" - exe 'sil! menu '.g:NetrwMenuPriority.'.16.4 '.g:NetrwTopLvlMenu.'Style.Sorting\ Method\ (name-time-size)<tab>s s' - exe 'sil! menu '.g:NetrwMenuPriority.'.17 '.g:NetrwTopLvlMenu.'Rename\ File/Directory<tab>R R' - exe 'sil! menu '.g:NetrwMenuPriority.'.18 '.g:NetrwTopLvlMenu.'Set\ Current\ Directory<tab>c c' - call s:NetrwBookmarkMenu() " provide some history! uses priorities 2,3, reserves 4, 8.2.x + exe 'sil! menu '.g:NetrwMenuPriority.'.1 '.g:NetrwTopLvlMenu.'Help<tab><F1> <F1>' + exe 'sil! menu '.g:NetrwMenuPriority.'.5 '.g:NetrwTopLvlMenu.'-Sep1- :' + exe 'sil! menu '.g:NetrwMenuPriority.'.6 '.g:NetrwTopLvlMenu.'Go\ Up\ Directory<tab>- -' + exe 'sil! menu '.g:NetrwMenuPriority.'.7 '.g:NetrwTopLvlMenu.'Apply\ Special\ Viewer<tab>x x' + if g:netrw_dirhistmax > 0 + exe 'sil! menu '.g:NetrwMenuPriority.'.8.1 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Bookmark\ Current\ Directory<tab>mb mb' + exe 'sil! menu '.g:NetrwMenuPriority.'.8.4 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Goto\ Prev\ Dir\ (History)<tab>u u' + exe 'sil! menu '.g:NetrwMenuPriority.'.8.5 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Goto\ Next\ Dir\ (History)<tab>U U' + exe 'sil! menu '.g:NetrwMenuPriority.'.8.6 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.List<tab>qb qb' + else + exe 'sil! menu '.g:NetrwMenuPriority.'.8 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History :echo "(disabled)"'."\<cr>" + endif + exe 'sil! menu '.g:NetrwMenuPriority.'.9.1 '.g:NetrwTopLvlMenu.'Browsing\ Control.Horizontal\ Split<tab>o o' + exe 'sil! menu '.g:NetrwMenuPriority.'.9.2 '.g:NetrwTopLvlMenu.'Browsing\ Control.Vertical\ Split<tab>v v' + exe 'sil! menu '.g:NetrwMenuPriority.'.9.3 '.g:NetrwTopLvlMenu.'Browsing\ Control.New\ Tab<tab>t t' + exe 'sil! menu '.g:NetrwMenuPriority.'.9.4 '.g:NetrwTopLvlMenu.'Browsing\ Control.Preview<tab>p p' + exe 'sil! menu '.g:NetrwMenuPriority.'.9.5 '.g:NetrwTopLvlMenu.'Browsing\ Control.Edit\ File\ Hiding\ List<tab><ctrl-h>'." \<c-h>'" + exe 'sil! menu '.g:NetrwMenuPriority.'.9.6 '.g:NetrwTopLvlMenu.'Browsing\ Control.Edit\ Sorting\ Sequence<tab>S S' + exe 'sil! menu '.g:NetrwMenuPriority.'.9.7 '.g:NetrwTopLvlMenu.'Browsing\ Control.Quick\ Hide/Unhide\ Dot\ Files<tab>'."gh gh" + exe 'sil! menu '.g:NetrwMenuPriority.'.9.8 '.g:NetrwTopLvlMenu.'Browsing\ Control.Refresh\ Listing<tab>'."<ctrl-l> \<c-l>" + exe 'sil! menu '.g:NetrwMenuPriority.'.9.9 '.g:NetrwTopLvlMenu.'Browsing\ Control.Settings/Options<tab>:NetrwSettings '.":NetrwSettings\<cr>" + exe 'sil! menu '.g:NetrwMenuPriority.'.10 '.g:NetrwTopLvlMenu.'Delete\ File/Directory<tab>D D' + exe 'sil! menu '.g:NetrwMenuPriority.'.11.1 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.Create\ New\ File<tab>% %' + exe 'sil! menu '.g:NetrwMenuPriority.'.11.1 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ Current\ Window<tab><cr> '."\<cr>" + exe 'sil! menu '.g:NetrwMenuPriority.'.11.2 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.Preview\ File/Directory<tab>p p' + exe 'sil! menu '.g:NetrwMenuPriority.'.11.3 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ Previous\ Window<tab>P P' + exe 'sil! menu '.g:NetrwMenuPriority.'.11.4 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ New\ Window<tab>o o' + exe 'sil! menu '.g:NetrwMenuPriority.'.11.5 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ New\ Vertical\ Window<tab>v v' + exe 'sil! menu '.g:NetrwMenuPriority.'.12.1 '.g:NetrwTopLvlMenu.'Explore.Directory\ Name :Explore ' + exe 'sil! menu '.g:NetrwMenuPriority.'.12.2 '.g:NetrwTopLvlMenu.'Explore.Filenames\ Matching\ Pattern\ (curdir\ only)<tab>:Explore\ */ :Explore */' + exe 'sil! menu '.g:NetrwMenuPriority.'.12.2 '.g:NetrwTopLvlMenu.'Explore.Filenames\ Matching\ Pattern\ (+subdirs)<tab>:Explore\ **/ :Explore **/' + exe 'sil! menu '.g:NetrwMenuPriority.'.12.3 '.g:NetrwTopLvlMenu.'Explore.Files\ Containing\ String\ Pattern\ (curdir\ only)<tab>:Explore\ *// :Explore *//' + exe 'sil! menu '.g:NetrwMenuPriority.'.12.4 '.g:NetrwTopLvlMenu.'Explore.Files\ Containing\ String\ Pattern\ (+subdirs)<tab>:Explore\ **// :Explore **//' + exe 'sil! menu '.g:NetrwMenuPriority.'.12.4 '.g:NetrwTopLvlMenu.'Explore.Next\ Match<tab>:Nexplore :Nexplore<cr>' + exe 'sil! menu '.g:NetrwMenuPriority.'.12.4 '.g:NetrwTopLvlMenu.'Explore.Prev\ Match<tab>:Pexplore :Pexplore<cr>' + exe 'sil! menu '.g:NetrwMenuPriority.'.13 '.g:NetrwTopLvlMenu.'Make\ Subdirectory<tab>d d' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.1 '.g:NetrwTopLvlMenu.'Marked\ Files.Mark\ File<tab>mf mf' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.2 '.g:NetrwTopLvlMenu.'Marked\ Files.Mark\ Files\ by\ Regexp<tab>mr mr' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.3 '.g:NetrwTopLvlMenu.'Marked\ Files.Hide-Show-List\ Control<tab>a a' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.4 '.g:NetrwTopLvlMenu.'Marked\ Files.Copy\ To\ Target<tab>mc mc' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.5 '.g:NetrwTopLvlMenu.'Marked\ Files.Delete<tab>D D' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.6 '.g:NetrwTopLvlMenu.'Marked\ Files.Diff<tab>md md' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.7 '.g:NetrwTopLvlMenu.'Marked\ Files.Edit<tab>me me' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.8 '.g:NetrwTopLvlMenu.'Marked\ Files.Exe\ Cmd<tab>mx mx' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.9 '.g:NetrwTopLvlMenu.'Marked\ Files.Move\ To\ Target<tab>mm mm' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.10 '.g:NetrwTopLvlMenu.'Marked\ Files.Obtain<tab>O O' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.11 '.g:NetrwTopLvlMenu.'Marked\ Files.Print<tab>mp mp' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.12 '.g:NetrwTopLvlMenu.'Marked\ Files.Replace<tab>R R' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.13 '.g:NetrwTopLvlMenu.'Marked\ Files.Set\ Target<tab>mt mt' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.14 '.g:NetrwTopLvlMenu.'Marked\ Files.Tag<tab>mT mT' + exe 'sil! menu '.g:NetrwMenuPriority.'.14.15 '.g:NetrwTopLvlMenu.'Marked\ Files.Zip/Unzip/Compress/Uncompress<tab>mz mz' + exe 'sil! menu '.g:NetrwMenuPriority.'.15 '.g:NetrwTopLvlMenu.'Obtain\ File<tab>O O' + exe 'sil! menu '.g:NetrwMenuPriority.'.16.1.1 '.g:NetrwTopLvlMenu.'Style.Listing.thin<tab>i :let w:netrw_liststyle=0<cr><c-L>' + exe 'sil! menu '.g:NetrwMenuPriority.'.16.1.1 '.g:NetrwTopLvlMenu.'Style.Listing.long<tab>i :let w:netrw_liststyle=1<cr><c-L>' + exe 'sil! menu '.g:NetrwMenuPriority.'.16.1.1 '.g:NetrwTopLvlMenu.'Style.Listing.wide<tab>i :let w:netrw_liststyle=2<cr><c-L>' + exe 'sil! menu '.g:NetrwMenuPriority.'.16.1.1 '.g:NetrwTopLvlMenu.'Style.Listing.tree<tab>i :let w:netrw_liststyle=3<cr><c-L>' + exe 'sil! menu '.g:NetrwMenuPriority.'.16.2.1 '.g:NetrwTopLvlMenu.'Style.Normal-Hide-Show.Show\ All<tab>a :let g:netrw_hide=0<cr><c-L>' + exe 'sil! menu '.g:NetrwMenuPriority.'.16.2.3 '.g:NetrwTopLvlMenu.'Style.Normal-Hide-Show.Normal<tab>a :let g:netrw_hide=1<cr><c-L>' + exe 'sil! menu '.g:NetrwMenuPriority.'.16.2.2 '.g:NetrwTopLvlMenu.'Style.Normal-Hide-Show.Hidden\ Only<tab>a :let g:netrw_hide=2<cr><c-L>' + exe 'sil! menu '.g:NetrwMenuPriority.'.16.3 '.g:NetrwTopLvlMenu.'Style.Reverse\ Sorting\ Order<tab>'."r r" + exe 'sil! menu '.g:NetrwMenuPriority.'.16.4.1 '.g:NetrwTopLvlMenu.'Style.Sorting\ Method.Name<tab>s :let g:netrw_sort_by="name"<cr><c-L>' + exe 'sil! menu '.g:NetrwMenuPriority.'.16.4.2 '.g:NetrwTopLvlMenu.'Style.Sorting\ Method.Time<tab>s :let g:netrw_sort_by="time"<cr><c-L>' + exe 'sil! menu '.g:NetrwMenuPriority.'.16.4.3 '.g:NetrwTopLvlMenu.'Style.Sorting\ Method.Size<tab>s :let g:netrw_sort_by="size"<cr><c-L>' + exe 'sil! menu '.g:NetrwMenuPriority.'.17 '.g:NetrwTopLvlMenu.'Rename\ File/Directory<tab>R R' + exe 'sil! menu '.g:NetrwMenuPriority.'.18 '.g:NetrwTopLvlMenu.'Set\ Current\ Directory<tab>c c' let s:netrw_menucnt= 28 + call s:NetrwBookmarkMenu() " provide some history! uses priorities 2,3, reserves 4, 8.2.x + call s:NetrwTgtMenu() " let bookmarks and history be easy targets elseif !a:domenu let s:netrwcnt = 0 @@ -6048,222 +6628,6 @@ fun! s:NetrwObtain(islocal) endfun " --------------------------------------------------------------------- -" netrw#NetrwObtain: {{{2 -" netrw#NetrwObtain(islocal,fname[,tgtdirectory]) -" islocal=0 obtain from remote source -" =1 obtain from local source -" fname : a filename or a list of filenames -" tgtdir : optional place where files are to go (not present, uses getcwd()) -fun! netrw#NetrwObtain(islocal,fname,...) -" call Dfunc("netrw#NetrwObtain(islocal=".a:islocal." fname<".((type(a:fname) == 1)? a:fname : string(a:fname)).">) a:0=".a:0) - " NetrwStatusLine support - for obtaining support - - if type(a:fname) == 1 - let fnamelist= [ a:fname ] - 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 Dret("netrw#NetrwObtain") - return - endif -" call Decho("fnamelist<".string(fnamelist).">") - if a:0 > 0 - let tgtdir= a:1 - else - let tgtdir= getcwd() - endif -" call Decho("tgtdir<".tgtdir.">") - - if exists("b:netrw_islocal") && b:netrw_islocal - " obtain a file from local b:netrw_curdir to (local) tgtdir -" call Decho("obtain a file from local ".b:netrw_curdir." to ".tgtdir) - if exists("b:netrw_curdir") && getcwd() != b:netrw_curdir - let topath= s:ComposePath(tgtdir,"") - if (has("win32") || has("win95") || has("win64") || has("win16")) - " transfer files one at time -" call Decho("transfer files one at a time") - for fname in fnamelist -" call Decho("system(".g:netrw_localcopycmd." ".shellescape(fname)." ".shellescape(topath).")") - call system(g:netrw_localcopycmd." ".shellescape(fname)." ".shellescape(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 Dret("s:NetrwObtain 0 : failed: ".g:netrw_localcopycmd." ".shellescape(fname)." ".shellescape(topath)) - return - endfor - else - " transfer files with one command -" call Decho("transfer files with one command") - let filelist= join(map(deepcopy(fnamelist),"shellescape(v:val)")) -" call Decho("system(".g:netrw_localcopycmd." ".filelist." ".shellescape(topath).")") - call system(g:netrw_localcopycmd." ".filelist." ".shellescape(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 Dret("s:NetrwObtain 0 : failed: ".g:netrw_localcopycmd." ".filelist." ".shellescape(topath)) - return - endif - elseif !exists("b:netrw_curdir") - call netrw#ErrorMsg(s:ERROR,"local browsing directory doesn't exist!",36) - else - call netrw#ErrorMsg(s:WARNING,"local browsing directory and current directory are identical",37) - endif - - else - " obtain files from remote b:netrw_curdir to local tgtdir -" call Decho("obtain a file from remote ".b:netrw_curdir." to ".tgtdir) - if type(a:fname) == 1 - call s:SetupNetrwStatusLine('%f %h%m%r%=%9*Obtaining '.a:fname) - endif - call s:NetrwMethod(b:netrw_curdir) - - if b:netrw_method == 4 - " obtain file using scp -" call Decho("obtain via scp (method#4)") - if exists("g:netrw_port") && g:netrw_port != "" - let useport= " ".g:netrw_scpport." ".g:netrw_port - else - let useport= "" - endif - if b:netrw_fname =~ '/' - let path= substitute(b:netrw_fname,'^\(.*/\).\{-}$','\1','') - else - let path= "" - endif - let filelist= join(map(deepcopy(fnamelist),'shellescape(g:netrw_machine.":".path.v:val,1)')) -" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_scp_cmd.shellescape(useport,1)." ".filelist." ".shellescape(tgtdir,1)) - exe s:netrw_silentxfer."!".g:netrw_scp_cmd.shellescape(useport,1)." ".filelist." ".shellescape(tgtdir,1) - - elseif b:netrw_method == 2 - " obtain file using ftp + .netrc -" call Decho("obtain via ftp+.netrc (method #2)") - call s:SaveBufVars()|sil keepjumps new|call s:RestoreBufVars() - let tmpbufnr= bufnr("%") - setlocal ff=unix - if exists("g:netrw_ftpmode") && g:netrw_ftpmode != "" - keepj put =g:netrw_ftpmode -" call Decho("filter input: ".getline('$')) - endif - - if exists("b:netrw_fname") && b:netrw_fname != "" - call setline(line("$")+1,'cd "'.b:netrw_fname.'"') -" call Decho("filter input: ".getline('$')) - endif - - if exists("g:netrw_ftpextracmd") - keepj put =g:netrw_ftpextracmd -" call Decho("filter input: ".getline('$')) - endif - for fname in fnamelist - call setline(line("$")+1,'get "'.fname.'"') -" call Decho("filter input: ".getline('$')) - endfor - if exists("g:netrw_port") && g:netrw_port != "" -" call Decho("executing: %!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1)) - exe s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1) - else -" call Decho("executing: %!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)) - exe s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1) - endif - " 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 ' - let debugkeep= &debug - setlocal debug=msg - call netrw#ErrorMsg(s:ERROR,getline(1),4) - let &debug= debugkeep - endif - - elseif b:netrw_method == 3 - " obtain with ftp + machine, id, passwd, and fname (ie. no .netrc) -" call Decho("obtain via ftp+mipf (method #3)") - call s:SaveBufVars()|sil keepjumps new|call s:RestoreBufVars() - let tmpbufnr= bufnr("%") - setlocal ff=unix - - if exists("g:netrw_port") && g:netrw_port != "" - keepj put ='open '.g:netrw_machine.' '.g:netrw_port -" call Decho("filter input: ".getline('$')) - else - keepj put ='open '.g:netrw_machine -" call Decho("filter input: ".getline('$')) - endif - - if exists("g:netrw_uid") && g:netrw_uid != "" - if exists("g:netrw_ftp") && g:netrw_ftp == 1 - keepj put =g:netrw_uid -" call Decho("filter input: ".getline('$')) - if exists("s:netrw_passwd") && s:netrw_passwd != "" - keepj put ='\"'.s:netrw_passwd.'\"' - endif -" call Decho("filter input: ".getline('$')) - elseif exists("s:netrw_passwd") - keepj put ='user \"'.g:netrw_uid.'\" \"'.s:netrw_passwd.'\"' -" call Decho("filter input: ".getline('$')) - endif - endif - - if exists("g:netrw_ftpmode") && g:netrw_ftpmode != "" - keepj put =g:netrw_ftpmode -" call Decho("filter input: ".getline('$')) - endif - - if exists("b:netrw_fname") && b:netrw_fname != "" - keepj call setline(line("$")+1,'cd "'.b:netrw_fname.'"') -" call Decho("filter input: ".getline('$')) - endif - - if exists("g:netrw_ftpextracmd") - keepj put =g:netrw_ftpextracmd -" call Decho("filter input: ".getline('$')) - endif - - if exists("g:netrw_ftpextracmd") - keepj put =g:netrw_ftpextracmd -" call Decho("filter input: ".getline('$')) - endif - for fname in fnamelist - keepj call setline(line("$")+1,'get "'.fname.'"') - endfor -" 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 - keepj norm! 1Gdd -" call Decho("executing: %!".s:netrw_ftp_cmd." ".g:netrw_ftp_options) - exe 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 getline(1) !~ "^$" -" call Decho("error<".getline(1).">") - if !exists("g:netrw_quiet") - keepj call netrw#ErrorMsg(s:ERROR,getline(1),5) - endif - endif - elseif !exists("b:netrw_method") || b:netrw_method < 0 -" call Dfunc("netrw#NetrwObtain : unsupported method") - return - endif - - " restore status line - if type(a:fname) == 1 && exists("s:netrw_users_stl") - keepj call s:SetupNetrwStatusLine(s:netrw_users_stl) - endif - - endif - - " cleanup - if exists("tmpbufnr") - if bufnr("%") != tmpbufnr - exe tmpbufnr."bw!" - else - q! - endif - endif - -" call Dret("netrw#NetrwObtain") -endfun - -" --------------------------------------------------------------------- " s:NetrwPrevWinOpen: open file/directory in previous window. {{{2 " If there's only one window, then the window will first be split. " Returns: @@ -6487,7 +6851,7 @@ fun! s:NetrwUpload(fname,tgt,...) let netrw_fname= b:netrw_fname keepj call s:SaveBufVars()|sil keepj new|keepj call s:RestoreBufVars() let tmpbufnr= bufnr("%") - setlocal ff=unix + setl ff=unix if exists("g:netrw_port") && g:netrw_port != "" keepj put ='open '.g:netrw_machine.' '.g:netrw_port @@ -6541,7 +6905,7 @@ fun! s:NetrwUpload(fname,tgt,...) call histdel("/",-1) if getline(1) !~ "^$" && !exists("g:netrw_quiet") && getline(1) !~ '^Trying ' let debugkeep= &debug - setlocal debug=msg + setl debug=msg call netrw#ErrorMsg(s:ERROR,getline(1),15) let &debug = debugkeep let mod = 1 @@ -6596,11 +6960,12 @@ fun! s:NetrwRefresh(islocal,dirname) " at the current time (Mar 19, 2007) all calls to NetrwRefresh() call NetrwBrowseChgDir() first. " (defunct) NetrwBrowseChgDir() may clear the display; hence a NetrwSavePosn() may not work if its placed here. " (defunct) Also, NetrwBrowseChgDir() now does a NetrwSavePosn() itself. - setlocal ma noro -" call Decho("setlocal ma noro") + setl ma noro +" call Decho("setl ma noro") " call Decho("clear buffer<".expand("%")."> with :%d") let ykeep = @@ let screenposn = netrw#NetrwSavePosn() +" call Decho("clearing buffer prior to refresh") sil! keepj %d if a:islocal keepj call netrw#LocalBrowseCheck(a:dirname) @@ -6730,6 +7095,37 @@ fun! s:NetrwSetSort() " call Dret("SetSort") endfun +" --------------------------------------------------------------------- +" s:NetrwSetTgt: sets the target to the specified choice index {{{2 +" Implements [count]Tb (bookhist<b>) +" [count]Th (bookhist<h>) +" See :help netrw-qb for how to make the choice. +fun! s:NetrwSetTgt(bookhist,choice) +" call Dfunc("s:NetrwSetTgt(bookhist<".a:bookhist."> choice#".a:choice.")") + + if a:bookhist == 'b' + " supports choosing a bookmark as a target using a qb-generated list + let choice= a:choice - 1 + if exists("g:netrw_bookmarklist[".choice."]") + call netrw#NetrwMakeTgt(g:netrw_bookmarklist[choice]) + else + echomsg "Sorry, bookmark#".a:choice." doesn't exist!" + endif + + elseif a:bookhist == 'h' + " supports choosing a history stack entry as a target using a qb-generated list + let choice= (a:choice % g:netrw_dirhistmax) + 1 + if exists("g:netrw_dirhist_".choice) + let histentry = g:netrw_dirhist_{choice} + call netrw#NetrwMakeTgt(histentry) + else + echomsg "Sorry, history#".a:choice." not available!" + endif + endif + +" call Dret("s:NetrwSetTgt") +endfun + " ===================================================================== " s:NetrwSortStyle: change sorting style (name - time - size) and refresh display {{{2 fun! s:NetrwSortStyle(islocal) @@ -6830,36 +7226,53 @@ fun! s:NetrwSplit(mode) endfun " --------------------------------------------------------------------- -" NetrwStatusLine: {{{2 -fun! NetrwStatusLine() +" s:NetrwTgtMenu: {{{2 +fun! s:NetrwTgtMenu() + if !exists("s:netrw_menucnt") + return + endif +" call Dfunc("s:NetrwTgtMenu()") -" 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 ^^^ + " the following test assures that gvim is running, has menus available, and has menus enabled. + if has("gui") && has("menu") && has("gui_running") && &go =~# 'm' && g:netrw_menu + if exists("g:NetrwTopLvlMenu") +" call Decho("removing ".g:NetrwTopLvlMenu."Bookmarks menu item(s)") + exe 'sil! unmenu '.g:NetrwTopLvlMenu.'Targets' + endif + if !exists("s:netrw_initbookhist") + call s:NetrwBookHistRead() + endif - 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 &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 "" - else - return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen + " target bookmarked places + if exists("g:netrw_bookmarklist") && g:netrw_bookmarklist != [] && g:netrw_dirhistmax > 0 +" call Decho("installing bookmarks as easy targets") + let cnt= 1 + for bmd in g:netrw_bookmarklist + let ebmd= escape(bmd,g:netrw_menu_escape) + " show bookmarks for goto menu +" call Decho("menu: Targets: ".bmd) + exe 'sil! menu <silent> '.g:NetrwMenuPriority.".19.1.".cnt." ".g:NetrwTopLvlMenu.'Targets.'.ebmd." :call netrw#NetrwMakeTgt('".bmd."')\<cr>" + let cnt= cnt + 1 + endfor + endif + + " target directory browsing history + if exists("g:netrw_dirhistmax") && g:netrw_dirhistmax > 0 +" call Decho("installing history as easy targets (histmax=".g:netrw_dirhistmax.")") + let histcnt = 1 + while histcnt <= g:netrw_dirhistmax + let priority = g:netrw_dirhist_cnt + histcnt + if exists("g:netrw_dirhist_{histcnt}") + let histentry = g:netrw_dirhist_{histcnt} + let ehistentry = escape(histentry,g:netrw_menu_escape) +" call Decho("menu: Targets: ".histentry) + exe 'sil! menu <silent> '.g:NetrwMenuPriority.".19.2.".priority." ".g:NetrwTopLvlMenu.'Targets.'.ehistentry." :call netrw#NetrwMakeTgt('".histentry."')\<cr>" + endif + let histcnt = histcnt + 1 + endwhile + endif endif +" call Dret("s:NetrwTgtMenu") endfun " --------------------------------------------------------------------- @@ -6869,12 +7282,12 @@ fun! s:NetrwTreeDir() " call Dfunc("NetrwTreeDir() curline#".line(".")."<".getline('.')."> b:netrw_curdir<".b:netrw_curdir."> tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%").">") let treedir= b:netrw_curdir -" call Decho("set initial treedir<".treedir.">") +" call Decho("(NetrwTreeDir) set initial treedir<".treedir.">") let s:treecurpos= netrw#NetrwSavePosn() if w:netrw_liststyle == s:TREELIST -" call Decho("w:netrrw_liststyle is TREELIST:") -" call Decho("line#".line(".")." getline(.)<".getline('.')."> treecurpos<".string(s:treecurpos).">") +" call Decho("(NetrwTreeDir) w:netrw_liststyle is TREELIST:") +" call Decho("(NetrwTreeDir) line#".line(".")." getline(.)<".getline('.')."> treecurpos<".string(s:treecurpos).">") " extract tree directory if on a line specifying a subdirectory (ie. ends with "/") if getline('.') =~ '/$' @@ -6882,13 +7295,13 @@ fun! s:NetrwTreeDir() else let treedir= "" endif -" call Decho("treedir<".treedir.">") +" call Decho("(NetrwTreeDir) treedir<".treedir.">") " detect user attempting to close treeroot if getline('.') !~ '|' && getline('.') != '..' " call Decho("user attempted to close treeroot") " now force a refresh -" call Decho("clear buffer<".expand("%")."> with :%d") +" call Decho("(NetrwTreeDir) clear buffer<".expand("%")."> with :%d") sil! keepj %d " call Dret("NetrwTreeDir <".treedir."> : (side effect) s:treecurpos<".string(s:treecurpos).">") return b:netrw_curdir @@ -6896,26 +7309,26 @@ fun! s:NetrwTreeDir() " elide all non-depth information let depth = substitute(getline('.'),'^\(\%(| \)*\)[^|].\{-}$','\1','e') -" call Decho("depth<".depth."> 1st subst (non-depth info removed)") +" call Decho("(NetrwTreeDir) depth<".depth."> 1st subst (non-depth info removed)") " elide first depth let depth = substitute(depth,'^| ','','') -" call Decho("depth<".depth."> 2nd subst (first depth removed)") +" call Decho("(NetrwTreeDir) depth<".depth."> 2nd subst (first depth removed)") " construct treedir by searching backwards at correct depth -" call Decho("constructing treedir<".treedir."> depth<".depth.">") +" call Decho("(NetrwTreeDir) constructing treedir<".treedir."> depth<".depth.">") while depth != "" && search('^'.depth.'[^|].\{-}/$','bW') let dirname= substitute(getline('.'),'^\(| \)*','','e') let treedir= dirname.treedir let depth = substitute(depth,'^| ','','') -" call Decho("constructing treedir<".treedir.">: dirname<".dirname."> while depth<".depth.">") +" call Decho("(NetrwTreeDir) constructing treedir<".treedir.">: dirname<".dirname."> while depth<".depth.">") endwhile if w:netrw_treetop =~ '/$' let treedir= w:netrw_treetop.treedir else let treedir= w:netrw_treetop.'/'.treedir endif -" call Decho("bufnr(.)=".bufnr("%")." line($)=".line("$")." line(.)=".line(".")) +" call Decho("(NetrwTreeDir) bufnr(.)=".bufnr("%")." line($)=".line("$")." line(.)=".line(".")) endif let treedir= substitute(treedir,'//$','/','') @@ -6929,7 +7342,7 @@ fun! s:NetrwTreeDisplay(dir,depth) " call Dfunc("NetrwTreeDisplay(dir<".a:dir."> depth<".a:depth.">)") " insure that there are no folds - setlocal nofen + setl nofen " install ../ and shortdir if a:depth == "" @@ -7033,8 +7446,8 @@ fun! s:NetrwWideListing() " cpf: characters per filename " fpl: filenames per line " fpc: filenames per column - setlocal ma noro -" call Decho("setlocal ma noro") + setl ma noro +" call Decho("setl ma noro") let b:netrw_cpf= 0 if line("$") >= w:netrw_bannercnt exe 'sil keepj '.w:netrw_bannercnt.',$g/^./if virtcol("$") > b:netrw_cpf|let b:netrw_cpf= virtcol("$")|endif' @@ -7091,28 +7504,28 @@ fun! s:PerformListing(islocal) " call Dfunc("s:PerformListing(islocal=".a:islocal.") bufnr(%)=".bufnr("%")."<".bufname("%").">") " set up syntax highlighting {{{3 -" call Decho("set up syntax highlighting") +" call Decho("(PerformListing) set up syntax highlighting") if has("syntax") if !exists("g:syntax_on") || !g:syntax_on -" call Decho("but g:syntax_on".(exists("g:syntax_on")? "=".g:syntax_on : "<doesn't exist>")) - setlocal ft= +" call Decho("(PerformListing) but g:syntax_on".(exists("g:syntax_on")? "=".g:syntax_on : "<doesn't exist>")) + setl ft= elseif &ft != "netrw" - setlocal ft=netrw + setl ft=netrw endif endif keepj call s:NetrwSafeOptions() - setlocal noro ma -" call Decho("setlocal noro ma") + set noro ma +" call Decho("(PerformListing) setl noro ma bh=".&bh) " if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1 " Decho -" call Decho("(netrw) Processing your browsing request...") +" call Decho("(PerformListing) (netrw) Processing your browsing request...") " endif " Decho " call Decho('w:netrw_liststyle='.(exists("w:netrw_liststyle")? w:netrw_liststyle : 'n/a')) if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") " force a refresh for tree listings -" call Decho("force refresh for treelisting: clear buffer<".expand("%")."> with :%d") +" call Decho("(PerformListing) force refresh for treelisting: clear buffer<".expand("%")."> with :%d") sil! keepj %d endif @@ -7121,7 +7534,7 @@ fun! s:PerformListing(islocal) " Set up the banner {{{3 if g:netrw_banner -" call Decho("set up banner") +" call Decho("(PerformListing) set up banner") keepj call setline(1,'" ============================================================================') keepj call setline(2,'" Netrw Directory Listing (netrw '.g:loaded_netrw.')') keepj call setline(3,'" '.b:netrw_curdir) @@ -7139,15 +7552,15 @@ fun! s:PerformListing(islocal) " Sorted by... {{{3 if g:netrw_banner -" call Decho("handle specified sorting: g:netrw_sort_by<".g:netrw_sort_by.">") +" call Decho("(PerformListing) handle specified sorting: g:netrw_sort_by<".g:netrw_sort_by.">") if g:netrw_sort_by =~ "^n" -" call Decho("directories will be sorted by name") +" call Decho("(PerformListing) directories will be sorted by name") " sorted by name keepj put ='\" Sorted by '.sortby keepj put ='\" Sort sequence: '.g:netrw_sort_sequence let w:netrw_bannercnt= w:netrw_bannercnt + 2 else -" call Decho("directories will be sorted by size or time") +" call Decho("(PerformListing) directories will be sorted by size or time") " sorted by size or date keepj put ='\" Sorted by '.sortby let w:netrw_bannercnt= w:netrw_bannercnt + 1 @@ -7158,7 +7571,7 @@ fun! s:PerformListing(islocal) " show copy/move target, if any if g:netrw_banner if exists("s:netrwmftgt") && exists("s:netrwmftgt_islocal") -" call Decho("show copy/move target<".s:netrwmftgt.">") +" call Decho("(PerformListing) show copy/move target<".s:netrwmftgt.">") keepj put ='' if s:netrwmftgt_islocal sil! keepj call setline(line("."),'" Copy/Move Tgt: '.s:netrwmftgt.' (local)') @@ -7167,14 +7580,14 @@ fun! s:PerformListing(islocal) endif let w:netrw_bannercnt= w:netrw_bannercnt + 1 else -" call Decho("s:netrwmftgt does not exist, don't make Copy/Move Tgt") +" call Decho("(PerformListing) s:netrwmftgt does not exist, don't make Copy/Move Tgt") endif exe "sil! keepj ".w:netrw_bannercnt endif " Hiding... -or- Showing... {{{3 if g:netrw_banner -" call Decho("handle hiding/showing (g:netrw_hide=".g:netrw_list_hide." g:netrw_list_hide<".g:netrw_list_hide.">)") +" call Decho("(PerformListing) handle hiding/showing (g:netrw_hide=".g:netrw_list_hide." g:netrw_list_hide<".g:netrw_list_hide.">)") if g:netrw_list_hide != "" && g:netrw_hide if g:netrw_hide == 1 keepj put ='\" Hiding: '.g:netrw_list_hide @@ -7193,37 +7606,37 @@ fun! s:PerformListing(islocal) if g:netrw_banner let w:netrw_bannercnt= w:netrw_bannercnt + 1 exe "sil! keepj ".w:netrw_bannercnt -" call Decho("bannercnt=".w:netrw_bannercnt." (should index line just after banner) line($)=".line("$")) +" call Decho("(PerformListing) bannercnt=".w:netrw_bannercnt." (should index line just after banner) line($)=".line("$")) endif " get list of files -" call Decho("Get list of files - islocal=".a:islocal) +" call Decho("(PerformListing) Get list of files - islocal=".a:islocal) if a:islocal keepj call s:LocalListing() else " remote keepj call s:NetrwRemoteListing() endif -" call Decho("g:netrw_banner=".g:netrw_banner." w:netrw_bannercnt=".w:netrw_bannercnt." (banner complete)") +" call Decho("(PerformListing) g:netrw_banner=".g:netrw_banner." w:netrw_bannercnt=".w:netrw_bannercnt." (banner complete)") " manipulate the directory listing (hide, sort) {{{3 if !exists("w:netrw_bannercnt") let w:netrw_bannercnt= 0 endif if !g:netrw_banner || line("$") >= w:netrw_bannercnt -" call Decho("manipulate directory listing (hide)") -" call Decho("g:netrw_hide=".g:netrw_hide." g:netrw_list_hide<".g:netrw_list_hide.">") +" call Decho("(PerformListing) manipulate directory listing (hide)") +" call Decho("(PerformListing) g:netrw_hide=".g:netrw_hide." g:netrw_list_hide<".g:netrw_list_hide.">") if g:netrw_hide && g:netrw_list_hide != "" keepj call s:NetrwListHide() endif if !g:netrw_banner || line("$") >= w:netrw_bannercnt -" call Decho("manipulate directory listing (sort) : g:netrw_sort_by<".g:netrw_sort_by.">") +" call Decho("(PerformListing) manipulate directory listing (sort) : g:netrw_sort_by<".g:netrw_sort_by.">") if g:netrw_sort_by =~ "^n" " sort by name keepj call s:NetrwSetSort() if !g:netrw_banner || w:netrw_bannercnt < line("$") -" call Decho("g:netrw_sort_direction=".g:netrw_sort_direction." (bannercnt=".w:netrw_bannercnt.")") +" call Decho("(PerformListing) g:netrw_sort_direction=".g:netrw_sort_direction." (bannercnt=".w:netrw_bannercnt.")") if g:netrw_sort_direction =~ 'n' " normal direction sorting exe 'sil keepj '.w:netrw_bannercnt.',$sort'.' '.g:netrw_sort_options @@ -7233,13 +7646,13 @@ fun! s:PerformListing(islocal) endif endif " remove priority pattern prefix -" call Decho("remove priority pattern prefix") +" call Decho("(PerformListing) remove priority pattern prefix") exe 'sil! keepj '.w:netrw_bannercnt.',$s/^\d\{3}'.g:netrw_sepchr.'//e' keepj call histdel("/",-1) elseif a:islocal if !g:netrw_banner || w:netrw_bannercnt < line("$") -" call Decho("g:netrw_sort_direction=".g:netrw_sort_direction) +" call Decho("(PerformListing) g:netrw_sort_direction=".g:netrw_sort_direction) if g:netrw_sort_direction =~ 'n' " call Decho('exe sil keepjumps '.w:netrw_bannercnt.',$sort') exe 'sil! keepj '.w:netrw_bannercnt.',$sort'.' '.g:netrw_sort_options @@ -7262,30 +7675,30 @@ fun! s:PerformListing(islocal) endif " convert to wide/tree listing {{{3 -" call Decho("modify display if wide/tree listing style") +" call Decho("(PerformListing) modify display if wide/tree listing style") keepj call s:NetrwWideListing() keepj call s:NetrwTreeListing(b:netrw_curdir) if exists("w:netrw_bannercnt") && (line("$") > w:netrw_bannercnt || !g:netrw_banner) " place cursor on the top-left corner of the file listing -" call Decho("place cursor on top-left corner of file listing") +" call Decho("(PerformListing) place cursor on top-left corner of file listing") exe 'sil! keepj '.w:netrw_bannercnt sil! keepj norm! 0 endif " record previous current directory let w:netrw_prvdir= b:netrw_curdir -" call Decho("record netrw_prvdir<".w:netrw_prvdir.">") +" call Decho("(PerformListing) record netrw_prvdir<".w:netrw_prvdir.">") " save certain window-oriented variables into buffer-oriented variables {{{3 keepj call s:SetBufWinVars() keepj call s:NetrwOptionRestore("w:") " set display to netrw display settings -" call Decho("set display to netrw display settings (noma nomod etc)") +" call Decho("(PerformListing) set display to netrw display settings (".g:netrw_bufsettings.")") exe "setl ".g:netrw_bufsettings if g:netrw_liststyle == s:LONGLIST -" call Decho("(LocalListing) exe setl ts=".(g:netrw_maxfilenamelen+1)) +" call Decho("(PerformListing) exe setl ts=".(g:netrw_maxfilenamelen+1)) exe "setl ts=".(g:netrw_maxfilenamelen+1) endif if exists("s:treecurpos") @@ -7333,7 +7746,7 @@ fun! s:SetupNetrwStatusLine(statline) " insure that windows have a statusline " make sure statusline is displayed let &stl=a:statline - setlocal laststatus=2 + setl laststatus=2 " call Decho("stl=".&stl) redraw @@ -7634,7 +8047,6 @@ fun! s:NetrwRemoteRmFile(path,rmfile,all) endif elseif ok =~ 'q\%[uit]' " call Decho("ok==".ok) - break endif else @@ -7677,7 +8089,7 @@ fun! s:NetrwRemoteRmFile(path,rmfile,all) endif elseif ok =~ 'q\%[uit]' - break +" call Decho("ok==".ok) endif endif @@ -7696,8 +8108,8 @@ fun! s:NetrwRemoteFtpCmd(path,listcmd) " because WinXX ftp uses unix style input let ffkeep= &ff - setlocal ma ff=unix noro -" call Decho("setlocal ma ff=unix noro") + setl ma ff=unix noro +" call Decho("setl ma ff=unix noro") " clear off any older non-banner lines " note that w:netrw_bannercnt indexes the line after the banner @@ -7727,7 +8139,7 @@ fun! s:NetrwRemoteFtpCmd(path,listcmd) "......................................... elseif w:netrw_method == 3 " ftp + machine,id,passwd,filename: Method #3 - setlocal ff=unix + setl ff=unix if exists("g:netrw_port") && g:netrw_port != "" keepj put ='open '.g:netrw_machine.' '.g:netrw_port else @@ -7923,7 +8335,8 @@ fun! netrw#FileUrlRead(fname) " call Decho("plainfname<".plainfname.">") exe "sil doau BufReadPre ".fname2396e exe 'keepj r '.plainfname - exe 'file! '.plainfname + exe 'sil! bdelete '.plainfname + exe 'keepalt file! '.plainfname keepj 1d " call Decho("(FileUrlRead) setl nomod") setl nomod @@ -7942,22 +8355,22 @@ fun! netrw#LocalBrowseCheck(dirname) " The &ft == "netrw" test was installed because the BufEnter event " would hit when re-entering netrw windows, creating unexpected " refreshes (and would do so in the middle of NetrwSaveOptions(), too) -" call Decho("netrw#LocalBrowseCheck: isdir<".a:dirname.">=".isdirectory(a:dirname).((exists("s:treeforceredraw")? " treeforceredraw" : ""))) +" call Decho("(LocalBrowseCheck) isdir<".a:dirname.">=".isdirectory(a:dirname).((exists("s:treeforceredraw")? " treeforceredraw" : ""))) " call Dredir("LocalBrowseCheck","ls!")|redraw!|sleep 3 let ykeep= @@ if isdirectory(a:dirname) -" call Decho(" ft<".&ft."> b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : " doesn't exist")."> dirname<".a:dirname.">"." line($)=".line("$")." ft<".&ft."> g:netrw_fastbrowse=".g:netrw_fastbrowse) +" call Decho("(LocalBrowseCheck) ft<".&ft."> b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : " doesn't exist")."> dirname<".a:dirname.">"." line($)=".line("$")." ft<".&ft."> g:netrw_fastbrowse=".g:netrw_fastbrowse) let svposn= netrw#NetrwSavePosn() if &ft != "netrw" || (exists("b:netrw_curdir") && b:netrw_curdir != a:dirname) || g:netrw_fastbrowse <= 1 - sil! keepj call s:NetrwBrowse(1,a:dirname) - call netrw#NetrwRestorePosn(svposn) + sil! keepj keepalt call s:NetrwBrowse(1,a:dirname) + keepalt call netrw#NetrwRestorePosn(svposn) elseif &ft == "netrw" && line("$") == 1 - sil! keepj call s:NetrwBrowse(1,a:dirname) - call netrw#NetrwRestorePosn(svposn) + sil! keepj keepalt call s:NetrwBrowse(1,a:dirname) + keepalt call netrw#NetrwRestorePosn(svposn) elseif exists("s:treeforceredraw") unlet s:treeforceredraw - sil! keepj call s:NetrwBrowse(1,a:dirname) - call netrw#NetrwRestorePosn(svposn) + sil! keepj keepalt call s:NetrwBrowse(1,a:dirname) + keepalt call netrw#NetrwRestorePosn(svposn) endif endif " following code wipes out currently unused netrw buffers @@ -7968,7 +8381,7 @@ fun! netrw#LocalBrowseCheck(dirname) let buflast = bufnr("$") while ibuf <= buflast if bufwinnr(ibuf) == -1 && isdirectory(bufname(ibuf)) - exe "sil! ".ibuf."bw!" + exe "sil! keepalt ".ibuf."bw!" endif let ibuf= ibuf + 1 endwhile @@ -7984,74 +8397,36 @@ fun! s:LocalListing() " call Decho("(LocalListing) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") " call Decho("(LocalListing) tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) -" if exists("b:netrw_curdir") |call Decho('b:netrw_curdir<'.b:netrw_curdir.">") |else|call Decho("b:netrw_curdir doesn't exist") |endif -" if exists("g:netrw_sort_by")|call Decho('g:netrw_sort_by<'.g:netrw_sort_by.">")|else|call Decho("g:netrw_sort_by doesn't exist")|endif +" if exists("b:netrw_curdir") |call Decho('(LocalListing) b:netrw_curdir<'.b:netrw_curdir.">") |else|call Decho("(LocalListing) b:netrw_curdir doesn't exist") |endif +" if exists("g:netrw_sort_by")|call Decho('(LocalListing) g:netrw_sort_by<'.g:netrw_sort_by.">")|else|call Decho("(LocalListing) g:netrw_sort_by doesn't exist")|endif " 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,"*")) -" call Decho("(LocalListing) glob(dirname<".dirname."/*>)=".filelist) - if filelist != "" - let filelist= filelist."\n" - endif - let filelist= filelist.glob(s:ComposePath(dirname,".*")) -" call Decho("(LocalListing) glob(dirname<".dirname."/.*>)=".filelist) - - " Coding choice: either elide ./ if present - " or include ./ if not present - if filelist =~ '[\\/]\.[\\/]\=\(\n\|$\)' - " elide /path/. from glob() entries if present -" call Decho("(LocalListing) elide /path/. from glob entries if present") - let filelist = substitute(filelist,'\n','\t','g') - let filelist = substitute(filelist,'^[^\t]\+[/\\]\.\t','','') - let filelist = substitute(filelist,'[^\t]\+[/\\]\.$','','') - let filelist = substitute(filelist,'\t\zs[^\t]\+[/\\]\.\t','','') - let filelist = substitute(filelist,'\t','\n','g') - endif -" call Decho("(LocalListing) filelist<".filelist.">") - if filelist !~ '[\\/]\.\.[\\/]\=\(\n\|$\)' + let filelist = glob(s:ComposePath(dirname,"*"),0,1) + let filelist = filelist + glob(s:ComposePath(dirname,".*"),0,1) +" call Decho("(LocalListing) filelist=".filelist) + + if index(filelist,'..') == -1 && b:netrw_curdir != '/' " include ../ in the glob() entry if its missing -" call Decho("(LocalListing) forcibly tacking on ..") - let filelist= filelist."\n".s:ComposePath(b:netrw_curdir,"../") -" call Decho("(LocalListing) filelist<".filelist.">") - endif - if b:netrw_curdir == '/' - " remove .. from filelist when current directory is root directory -" call Decho("(LocalListing) remove .. from filelist") - let filelist= substitute(filelist,'/\.\.\n','','') - endif - " remove multiple contiguous newlines - let filelist= substitute(filelist,'\n\{2,}','\n','ge') - if !g:netrw_cygwin && (has("win32") || has("win95") || has("win64") || has("win16")) - " change all \s to /s -" call Decho('(LocalListing) change all \s to /s') - let filelist= substitute(filelist,'\','/','g') - else - " escape all \s to \\ -" call Decho('(LocalListing) escape all \s to \\') - let filelist= substitute(filelist,'\','\\','g') +" call Decho("(LocalListing) forcibly tacking on \"..\"") + let filelist= filelist+[s:ComposePath(b:netrw_curdir,"../")] +" call Decho("(LocalListing) filelist=".string(filelist)) endif " call Decho("(LocalListing) (before while) dirname<".dirname.">") " call Decho("(LocalListing) (before while) dirnamelen<".dirnamelen.">") -" call Decho("(LocalListing) (before while) filelist<".filelist.">") - +" call Decho("(LocalListing) (before while) filelist=".string(filelist)) if get(g:, 'netrw_dynamic_maxfilenamelen', 0) - let g:netrw_maxfilenamelen = max(map(split(filelist, '\n'), 'len(fnamemodify(v:val, ":t"))')) + 1 + let filelistcopy = map(deepcopy(filelist),'fnamemodify(v:val, ":t")') + let g:netrw_maxfilenamelen = max(map(filelistcopy,'len(v:val)')) + 1 +" call Decho("(LocalListing) dynamic_maxfilenamelen: filenames =".string(filelistcopy)) +" call Decho("(LocalListing) dynamic_maxfilenamelen: g:netrw_maxfilenamelen=".g:netrw_maxfilenamelen) endif - while filelist != "" - if filelist =~ '\n' - let filename = substitute(filelist,'\n.*$','','e') - let filelist = substitute(filelist,'^.\{-}\n\(.*\)$','\1','e') - else - let filename = filelist - let filelist = "" - endif -" call Decho(" ") -" call Decho("(LocalListing) (while) filelist<".filelist.">") + for filename in filelist +" call Decho("(LocalListing) ") " call Decho("(LocalListing) (while) filename<".filename.">") if getftype(filename) == "link" @@ -8117,7 +8492,7 @@ fun! s:LocalListing() if g:netrw_sort_by =~ "^t" " sort by time (handles time up to 1 quintillion seconds, US) -" call Decho("getftime(".filename.")=".getftime(filename)) +" call Decho("(LocalListing) getftime(".filename.")=".getftime(filename)) let t = getftime(filename) let ft = strpart("000000000000000000",1,18-strlen(t)).t " call Decho("(LocalListing) exe keepjumps put ='".ft.'/'.filename."'") @@ -8138,7 +8513,7 @@ fun! s:LocalListing() " call Decho("(LocalListing) exe keepjumps put ='".pfile."'") sil! keepj put=pfile endif - endwhile + endfor " cleanup any windows mess at end-of-line sil! keepj g/^$/d @@ -8182,25 +8557,25 @@ fun! s:LocalBrowseShellCmdRefresh() let itab = itab + 1 tabn endwhile -" call Decho("buftablist".string(buftablist)) -" call Decho("s:netrw_browselist<".(exists("s:netrw_browselist")? string(s:netrw_browselist) : "").">") +" call Decho("(LocalBrowseShellCmdRefresh) buftablist".string(buftablist)) +" call Decho("(LocalBrowseShellCmdRefresh) s:netrw_browselist<".(exists("s:netrw_browselist")? string(s:netrw_browselist) : "").">") " GO through all buffers on netrw_browselist (ie. just local-netrw buffers): " | refresh any netrw window " | wipe out any non-displaying netrw buffer let curwin = winnr() let ibl = 0 for ibuf in s:netrw_browselist -" call Decho("bufwinnr(".ibuf.") index(buftablist,".ibuf.")=".index(buftablist,ibuf)) +" call Decho("(LocalBrowseShellCmdRefresh) bufwinnr(".ibuf.") index(buftablist,".ibuf.")=".index(buftablist,ibuf)) if bufwinnr(ibuf) == -1 && index(buftablist,ibuf) == -1 " wipe out any non-displaying netrw buffer -" call Decho("wiping buf#".ibuf,"<".bufname(ibuf).">") +" call Decho("(LocalBrowseShellCmdRefresh) wiping buf#".ibuf,"<".bufname(ibuf).">") exe "sil! bd ".fnameescape(ibuf) call remove(s:netrw_browselist,ibl) -" call Decho("browselist=".string(s:netrw_browselist)) +" call Decho("(LocalBrowseShellCmdRefresh) browselist=".string(s:netrw_browselist)) continue elseif index(tabpagebuflist(),ibuf) != -1 " refresh any netrw buffer -" call Decho("refresh buf#".ibuf.'-> win#'.bufwinnr(ibuf)) +" call Decho("(LocalBrowseShellCmdRefresh) refresh buf#".ibuf.'-> win#'.bufwinnr(ibuf)) exe bufwinnr(ibuf)."wincmd w" keepj call s:NetrwRefresh(1,s:NetrwBrowseChgDir(1,'./')) endif @@ -8229,15 +8604,15 @@ fun! s:LocalFastBrowser() " initialize browselist, a list of buffer numbers that the local browser has used if !exists("s:netrw_browselist") -" call Decho("initialize s:netrw_browselist") +" call Decho("(LocalFastBrowser) initialize s:netrw_browselist") let s:netrw_browselist= [] endif " append current buffer to fastbrowse list if empty(s:netrw_browselist) || bufnr("%") > s:netrw_browselist[-1] -" call Decho("appendng current buffer to browselist") +" call Decho("(LocalFastBrowser) appendng current buffer to browselist") call add(s:netrw_browselist,bufnr("%")) -" call Decho("browselist=".string(s:netrw_browselist)) +" call Decho("(LocalFastBrowser) browselist=".string(s:netrw_browselist)) endif " enable autocmd events to handle refreshing/removing local browser buffers @@ -8247,16 +8622,16 @@ fun! s:LocalFastBrowser() " =1 : medium speed, re-use directory listing for remote only " =2 : fast speed, always re-use directory listing when possible if !exists("s:netrw_browser_shellcmd") && g:netrw_fastbrowse <= 1 -" call Decho("setting up local-browser shell command refresh") +" call Decho("(LocalFastBrowser) setting up local-browser shell command refresh") let s:netrw_browser_shellcmd= 1 augroup AuNetrwShellCmd au! if (has("win32") || has("win95") || has("win64") || has("win16")) -" call Decho("autocmd: ShellCmdPost * call s:LocalBrowseShellCmdRefresh()") +" call Decho("(LocalFastBrowser) autocmd: ShellCmdPost * call s:LocalBrowseShellCmdRefresh()") au ShellCmdPost * call s:LocalBrowseShellCmdRefresh() else au ShellCmdPost,FocusGained * call s:LocalBrowseShellCmdRefresh() -" call Decho("autocmd: ShellCmdPost,FocusGained * call s:LocalBrowseShellCmdRefresh()") +" call Decho("(LocalFastBrowser) autocmd: ShellCmdPost,FocusGained * call s:LocalBrowseShellCmdRefresh()") endif augroup END endif @@ -8264,7 +8639,7 @@ fun! s:LocalFastBrowser() " user must have changed fastbrowse to its fast setting, so remove " the associated autocmd events if g:netrw_fastbrowse > 1 && exists("s:netrw_browser_shellcmd") -" call Decho("remove AuNetrwShellCmd autcmd group") +" call Decho("(LocalFastBrowser) remove AuNetrwShellCmd autcmd group") unlet s:netrw_browser_shellcmd augroup AuNetrwShellCmd au! @@ -8535,7 +8910,9 @@ fun! netrw#NetrwRestorePosn(...) let eikeep= &ei set ei=all if expand("%") == "NetrwMessage" - exe s:winBeforeErr."wincmd w" + if exists("s:winBeforeErr") + exe s:winBeforeErr."wincmd w" + endif endif if a:0 > 0 @@ -8544,7 +8921,7 @@ fun! netrw#NetrwRestorePosn(...) " restore window if exists("w:netrw_winnr") -" call Decho("restore window: exe sil! ".w:netrw_winnr."wincmd w") +" call Decho("(NetrwRestorePosn) restore window: exe sil! ".w:netrw_winnr."wincmd w") exe "sil! ".w:netrw_winnr."wincmd w" endif if v:shell_error == 0 @@ -8555,29 +8932,29 @@ fun! netrw#NetrwRestorePosn(...) " restore top-of-screen line if exists("w:netrw_hline") -" call Decho("restore topofscreen: exe keepj norm! ".w:netrw_hline."G0z") +" call Decho("(NetrwRestorePosn) restore topofscreen: exe keepj norm! ".w:netrw_hline."G0z") exe "keepj norm! ".w:netrw_hline."G0z\<CR>" endif " restore position if exists("w:netrw_line") && exists("w:netrw_col") -" call Decho("restore posn: exe keepj norm! ".w:netrw_line."G0".w:netrw_col."|") +" call Decho("(NetrwRestorePosn) restore posn: exe keepj norm! ".w:netrw_line."G0".w:netrw_col."|") exe "keepj norm! ".w:netrw_line."G0".w:netrw_col."\<bar>" endif let &ei= eikeep -" call Dret("netrw#NetrwRestorePosn") +" call Dret("netrw#NetrwRestorePosn : line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol()) endfun " --------------------------------------------------------------------- " netrw#NetrwSavePosn: saves position of cursor on screen {{{2 fun! netrw#NetrwSavePosn() -" call Dfunc("netrw#NetrwSavePosn()") +" call Dfunc("netrw#NetrwSavePosn() line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol()) " Save current line and column let w:netrw_winnr= winnr() let w:netrw_line = line(".") let w:netrw_col = virtcol(".") -" call Decho("currently, win#".w:netrw_winnr." line#".w:netrw_line." col#".w:netrw_col) +" call Decho("(NetrwSavePosn) currently, win#".w:netrw_winnr." line#".w:netrw_line." col#".w:netrw_col) " Save top-of-screen line keepj norm! H0 @@ -8805,11 +9182,11 @@ fun! s:NetrwCursor() " thin-long-tree: cursorline, user's cursorcolumn " wide : cursorline, cursorcolumn if w:netrw_liststyle == s:WIDELIST -" call Decho("case g:netrw_cursor==3 and wide: setlocal cul cuc") +" call Decho("case g:netrw_cursor==3 and wide: setl cul cuc") setl cursorline setl cursorcolumn else -" call Decho("case g:netrw_cursor==3 and not wide: setlocal cul (use user's cuc)") +" call Decho("case g:netrw_cursor==3 and not wide: setl cul (use user's cuc)") setl cursorline let &l:cursorcolumn = s:netrw_usercuc endif @@ -8817,7 +9194,7 @@ fun! s:NetrwCursor() elseif g:netrw_cursor == 2 " thin-long-tree: cursorline, user's cursorcolumn " wide : cursorline, user's cursorcolumn -" call Decho("case g:netrw_cursor==2: setlocal cuc (use user's cul)") +" call Decho("case g:netrw_cursor==2: setl cuc (use user's cul)") let &l:cursorcolumn = s:netrw_usercuc setl cursorline @@ -8826,7 +9203,7 @@ fun! s:NetrwCursor() " wide : cursorline, user's cursorcolumn let &l:cursorcolumn = s:netrw_usercuc if w:netrw_liststyle == s:WIDELIST -" call Decho("case g:netrw_cursor==2 and wide: setlocal cul (use user's cuc)") +" call Decho("case g:netrw_cursor==2 and wide: setl cul (use user's cuc)") set cursorline else " call Decho("case g:netrw_cursor==2 and not wide: (use user's cul,cuc)") @@ -8868,7 +9245,7 @@ fun! s:NetrwDelete(path) if !g:netrw_cygwin && (has("win32") || has("win95") || has("win64") || has("win16")) if exists("+shellslash") let sskeep= &shellslash - setlocal noshellslash + setl noshellslash let result = delete(path) let &shellslash = sskeep else @@ -8948,7 +9325,7 @@ fun! s:NetrwEnew(...) if b:netrw_curdir =~ '/$' if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST file NetrwTreeListing - set bt=nowrite noswf + set bt=nowrite noswf bh=hide nno <silent> <buffer> [ :sil call <SID>TreeListMove('[')<cr> nno <silent> <buffer> ] :sil call <SID>TreeListMove(']')<cr> else @@ -8957,7 +9334,7 @@ fun! s:NetrwEnew(...) endif endif -" call Dret("s:NetrwEnew : buf#".bufnr("%")."<".bufname("%")."> expand(%)<".expand("%")."> expand(#)<".expand("#").">") +" call Dret("s:NetrwEnew : buf#".bufnr("%")."<".bufname("%")."> expand(%)<".expand("%")."> expand(#)<".expand("#")."> bh=".&bh) endfun " --------------------------------------------------------------------- @@ -8977,7 +9354,7 @@ fun! s:NetrwInsureWinVars() endif let iwin= iwin + 1 endwhile - exe curwin."wincmd w" + exe "keepalt ".curwin."wincmd w" if exists("winvars") " call Decho("copying w#".iwin." window variables to w#".curwin) for k in keys(winvars) @@ -9105,6 +9482,9 @@ endfun " " s:nbcd_curpos_{bufnr('%')} is set up by s:NetrwBrowseChgDir() fun! s:NetrwRexplore(islocal,dirname) + if exists("s:netrwdrag") + return + endif " call Dfunc("s:NetrwRexplore() w:netrw_rexlocal=".w:netrw_rexlocal." w:netrw_rexdir<".w:netrw_rexdir.">") if !exists("w:netrw_rexlocal") " " call Dret("s:NetrwRexplore() w:netrw_rexlocal doesn't exist") @@ -9204,7 +9584,7 @@ endfun " --------------------------------------------------------------------- " s:Strlen: this function returns the length of a string, even if its {{{2 -" using two-byte etc characters. +" using multiple-byte characters. " Solution from Nicolai Weibull, vim docs (:help strlen()), Tony Mechelynck, " and a bit from me. " if g:netrw_xstrlen is zero (default), then the builtin strlen() function is used. @@ -9231,6 +9611,7 @@ fun! s:Strlen(x) call setline(line("."),a:x) let ret= virtcol("$") - 1 keepj d + keepj norm! k let &mod= modkeep else diff --git a/runtime/autoload/netrwFileHandlers.vim b/runtime/autoload/netrwFileHandlers.vim index b11e3cfbf..84f70c4f8 100644 --- a/runtime/autoload/netrwFileHandlers.vim +++ b/runtime/autoload/netrwFileHandlers.vim @@ -1,9 +1,9 @@ " netrwFileHandlers: contains various extension-based file handlers for " netrw's browsers' x command ("eXecute launcher") -" Author: Charles E. Campbell, Jr. +" Author: Charles E. Campbell " Date: Mar 14, 2012 " Version: 11a -" Copyright: Copyright (C) 1999-2012 Charles E. Campbell, Jr. {{{1 +" Copyright: Copyright (C) 1999-2012 Charles E. Campbell {{{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, diff --git a/runtime/autoload/netrwSettings.vim b/runtime/autoload/netrwSettings.vim index ef361dc21..68348d8d0 100644 --- a/runtime/autoload/netrwSettings.vim +++ b/runtime/autoload/netrwSettings.vim @@ -1,8 +1,8 @@ " netrwSettings.vim: makes netrw settings simpler " Date: Sep 03, 2008 -" Maintainer: Charles E Campbell, Jr <drchipNOSPAM at campbellfamily dot biz> +" Maintainer: Charles E Campbell <drchipNOSPAM at campbellfamily dot biz> " Version: 13 -" Copyright: Copyright (C) 1999-2007 Charles E. Campbell, Jr. {{{1 +" Copyright: Copyright (C) 1999-2007 Charles E. Campbell {{{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, @@ -63,7 +63,7 @@ fun! netrwSettings#NetrwSettings() endif put ='+ ---------------------------------------------' - put ='+ NetrwSettings: by Charles E. Campbell, Jr.' + put ='+ NetrwSettings: by Charles E. Campbell' put ='+ Press <F1> with cursor atop any line for help' put ='+ ---------------------------------------------' let s:netrw_settings_stop= line(".") diff --git a/runtime/autoload/tar.vim b/runtime/autoload/tar.vim index d67212934..5e76870cc 100644 --- a/runtime/autoload/tar.vim +++ b/runtime/autoload/tar.vim @@ -1,13 +1,13 @@ " tar.vim: Handles browsing tarfiles " AUTOLOAD PORTION -" Date: Jan 17, 2012 -" Version: 28 -" Maintainer: Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM> +" Date: Apr 17, 2013 +" Version: 29 +" Maintainer: Charles E Campbell <NdrOchip@ScampbellPfamily.AbizM-NOSPAM> " License: Vim License (see vim's :help license) " " Contains many ideas from Michael Toren's <tar.vim> " -" Copyright: Copyright (C) 2005-2011 Charles E. Campbell, Jr. {{{1 +" Copyright: Copyright (C) 2005-2011 Charles E. Campbell {{{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, @@ -22,7 +22,7 @@ if &cp || exists("g:loaded_tar") finish endif -let g:loaded_tar= "v28" +let g:loaded_tar= "v29" if v:version < 702 echohl WarningMsg echo "***warning*** this version of tar needs vim 7.2" @@ -31,6 +31,7 @@ if v:version < 702 endif let s:keepcpo= &cpo set cpo&vim +"DechoTabOn "call Decho("loading autoload/tar.vim") " --------------------------------------------------------------------- @@ -80,7 +81,7 @@ endif " set up shell quoting character if !exists("g:tar_shq") - if exists("&shq") && &shq != "" + if exists("+shq") && exists("&shq") && &shq != "" let g:tar_shq= &shq elseif has("win32") || has("win95") || has("win64") || has("win16") if exists("g:netrw_cygwin") && g:netrw_cygwin @@ -147,7 +148,7 @@ fun! tar#Browse(tarfile) keepj $ let tarfile= a:tarfile - if has("win32") && executable("cygpath") + if has("win32unix") && executable("cygpath") " assuming cygwin let tarfile=substitute(system("cygpath -u ".shellescape(tarfile,0)),'\n$','','e') endif @@ -227,7 +228,7 @@ fun! s:TarBrowseSelect() " about to make a new window, need to use b:tarfile let tarfile= b:tarfile let curfile= expand("%") - if has("win32") && executable("cygpath") + if has("win32unix") && executable("cygpath") " assuming cygwin let tarfile=substitute(system("cygpath -u ".shellescape(tarfile,0)),'\n$','','e') endif @@ -239,6 +240,8 @@ fun! s:TarBrowseSelect() let s:tblfile_{winnr()}= curfile call tar#Read("tarfile:".tarfile.'::'.fname,1) filetype detect + set nomod + exe 'com! -buffer -nargs=? -complete=file TarDiff :call tar#Diff(<q-args>,"'.fnameescape(fname).'")' let &report= repkeep " call Dret("TarBrowseSelect : s:tblfile_".winnr()."<".s:tblfile_{winnr()}.">") @@ -252,7 +255,7 @@ fun! tar#Read(fname,mode) set report=10 let tarfile = substitute(a:fname,'tarfile:\(.\{-}\)::.*$','\1','') let fname = substitute(a:fname,'tarfile:.\{-}::\(.*\)$','\1','') - if has("win32") && executable("cygpath") + if has("win32unix") && executable("cygpath") " assuming cygwin let tarfile=substitute(system("cygpath -u ".shellescape(tarfile,0)),'\n$','','e') endif @@ -425,7 +428,7 @@ fun! tar#Write(fname) if fname =~ '/' let dirpath = substitute(fname,'/[^/]\+$','','e') - if executable("cygpath") + if has("win32unix") && executable("cygpath") let dirpath = substitute(system("cygpath ".shellescape(dirpath, 0)),'\n','','e') endif call mkdir(dirpath,"p") @@ -445,7 +448,7 @@ fun! tar#Write(fname) let tar_secure= " " endif exe "w! ".fnameescape(fname) - if executable("cygpath") + if has("win32unix") && executable("cygpath") let tarfile = substitute(system("cygpath ".shellescape(tarfile,0)),'\n','','e') endif @@ -501,6 +504,30 @@ fun! tar#Write(fname) endfun " --------------------------------------------------------------------- +" tar#Diff: {{{2 +fun! tar#Diff(userfname,fname) +" call Dfunc("tar#Diff(userfname<".a:userfname."> fname<".a:fname.")") + let fname= a:fname + if a:userfname != "" + let fname= a:userfname + endif + if filereadable(fname) + " sets current file (from tarball) for diff'ing + " splits window vertically + " opens original file, sets it for diff'ing + " sets up b:tardiff_otherbuf variables so each buffer knows about the other (for closing purposes) + diffthis + wincmd v + exe "e ".fnameescape(fname) + diffthis + else + redraw! + echo "***warning*** unable to read file<".fname.">" + endif +" call Dret("tar#Diff") +endfun + +" --------------------------------------------------------------------- " s:Rmdir: {{{2 fun! s:Rmdir(fname) " call Dfunc("Rmdir(fname<".a:fname.">)") diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim index ad5cce2ed..b7a5bffbf 100644 --- a/runtime/autoload/zip.vim +++ b/runtime/autoload/zip.vim @@ -1,10 +1,10 @@ " zip.vim: Handles browsing zipfiles " AUTOLOAD PORTION -" Date: Jan 17, 2012 -" Version: 25 -" Maintainer: Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM> +" Date: Apr 17, 2013 +" Version: 26 +" Maintainer: Charles E Campbell <NdrOchip@ScampbellPfamily.AbizM-NOSPAM> " License: Vim License (see vim's :help license) -" Copyright: Copyright (C) 2005-2012 Charles E. Campbell, Jr. {{{1 +" Copyright: Copyright (C) 2005-2012 Charles E. Campbell {{{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, @@ -19,7 +19,7 @@ if &cp || exists("g:loaded_zip") finish endif -let g:loaded_zip= "v25" +let g:loaded_zip= "v26" if v:version < 702 echohl WarningMsg echo "***warning*** this version of zip needs vim 7.2" @@ -188,13 +188,23 @@ fun! zip#Read(fname,mode) else let zipfile = substitute(a:fname,'^.\{-}zipfile:\(.\{-}\)::[^\\].*$','\1','') let fname = substitute(a:fname,'^.\{-}zipfile:.\{-}::\([^\\].*\)$','\1','') - let fname = substitute(fname, '[', '[[]', 'g') + let fname = substitute(fname, '[', '[[]', 'g') endif " call Decho("zipfile<".zipfile.">") " call Decho("fname <".fname.">") -" call Decho("exe r! ".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fnameescape(fname),1)) - exe "keepj sil! r! ".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fnameescape(fname),1) + " the following code does much the same thing as + " exe "keepj sil! r! ".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fnameescape(fname),1) + " but allows zipfile:... entries in quickfix lists + let temp = tempname() + let fn = expand('%:p') + exe "sil! !".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fnameescape(fname),1).' > '.temp +" call Decho("exe sil! !".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fnameescape(fname),1).' > '.temp) + sil exe 'keepalt file '.temp + sil keepj e! + sil exe 'keepalt file '.fnameescape(fn) + call delete(temp) + filetype detect " cleanup @@ -267,7 +277,7 @@ fun! zip#Write(fname) if fname =~ '/' let dirpath = substitute(fname,'/[^/]\+$','','e') - if executable("cygpath") + if has("win32unix") && executable("cygpath") let dirpath = substitute(system("cygpath ".s:Escape(dirpath,0)),'\n','','e') endif " call Decho("mkdir(dirpath<".dirpath.">,p)") @@ -279,7 +289,7 @@ fun! zip#Write(fname) " call Decho("zipfile<".zipfile."> fname<".fname.">") exe "w! ".fnameescape(fname) - if executable("cygpath") + if has("win32unix") && executable("cygpath") let zipfile = substitute(system("cygpath ".s:Escape(zipfile,0)),'\n','','e') endif |