Mercurial > vim
comparison runtime/autoload/netrw.vim @ 5618:350272cbf1fd
Updated runtime files.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Thu, 23 Jan 2014 14:24:41 +0100 |
parents | 605c9ce57ec3 |
children | 657ade71d395 |
comparison
equal
deleted
inserted
replaced
5617:a42040fed96c | 5618:350272cbf1fd |
---|---|
1 " netrw.vim: Handles file transfer and remote directory listing across | 1 " netrw.vim: Handles file transfer and remote directory listing across |
2 " AUTOLOAD SECTION | 2 " AUTOLOAD SECTION |
3 " Date: May 18, 2013 | 3 " Date: Jan 21, 2014 |
4 " Version: 149 | 4 " Version: 150 |
5 " Maintainer: Charles E Campbell <NdrOchip@ScampbellPfamily.AbizM-NOSPAM> | 5 " Maintainer: Charles E Campbell <NdrOchip@ScampbellPfamily.AbizM-NOSPAM> |
6 " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim | 6 " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim |
7 " Copyright: Copyright (C) 1999-2012 Charles E. Campbell {{{1 | 7 " Copyright: Copyright (C) 1999-2013 Charles E. Campbell {{{1 |
8 " Permission is hereby granted to use and distribute this code, | 8 " Permission is hereby granted to use and distribute this code, |
9 " with or without modifications, provided that this copyright | 9 " with or without modifications, provided that this copyright |
10 " notice is copied with it. Like anything else that's free, | 10 " notice is copied with it. Like anything else that's free, |
11 " netrw.vim, netrwPlugin.vim, and netrwSettings.vim are provided | 11 " netrw.vim, netrwPlugin.vim, and netrwSettings.vim are provided |
12 " *as is* and come with no warranty of any kind, either | 12 " *as is* and come with no warranty of any kind, either |
20 " =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | 20 " =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- |
21 " Load Once: {{{1 | 21 " Load Once: {{{1 |
22 if &cp || exists("g:loaded_netrw") | 22 if &cp || exists("g:loaded_netrw") |
23 finish | 23 finish |
24 endif | 24 endif |
25 let g:loaded_netrw = "v149" | 25 let g:loaded_netrw = "v150" |
26 if v:version < 703 || (v:version == 703 && !has("patch465")) | |
27 echohl WarningMsg | |
28 echo "***warning*** this version of netrw needs vim 7.3.465 or later" | |
29 echohl Normal | |
30 finish | |
31 endif | |
32 if !exists("s:NOTE") | 26 if !exists("s:NOTE") |
33 let s:NOTE = 0 | 27 let s:NOTE = 0 |
34 let s:WARNING = 1 | 28 let s:WARNING = 1 |
35 let s:ERROR = 2 | 29 let s:ERROR = 2 |
36 endif | 30 endif |
37 | 31 |
38 let s:keepcpo= &cpo | 32 let s:keepcpo= &cpo |
39 set cpo&vim | 33 set cpo&vim |
40 "DechoTabOn | 34 "DechoRemOn |
41 "call Decho("doing autoload/netrw.vim version ".g:loaded_netrw) | 35 "call Decho("doing autoload/netrw.vim version ".g:loaded_netrw) |
42 | 36 |
43 " ====================== | 37 " ====================== |
44 " Netrw Variables: {{{1 | 38 " Netrw Variables: {{{1 |
45 " ====================== | 39 " ====================== |
47 " --------------------------------------------------------------------- | 41 " --------------------------------------------------------------------- |
48 " netrw#ErrorMsg: {{{2 | 42 " netrw#ErrorMsg: {{{2 |
49 " 0=note = s:NOTE | 43 " 0=note = s:NOTE |
50 " 1=warning = s:WARNING | 44 " 1=warning = s:WARNING |
51 " 2=error = s:ERROR | 45 " 2=error = s:ERROR |
52 " May 01, 2013 : max errnum currently is 93 | 46 " Jan 03, 2014 : max errnum currently is 95 |
53 fun! netrw#ErrorMsg(level,msg,errnum) | 47 fun! netrw#ErrorMsg(level,msg,errnum) |
54 " call Dfunc("netrw#ErrorMsg(level=".a:level." msg<".a:msg."> errnum=".a:errnum.") g:netrw_use_errorwindow=".g:netrw_use_errorwindow) | 48 " call Dfunc("netrw#ErrorMsg(level=".a:level." msg<".a:msg."> errnum=".a:errnum.") g:netrw_use_errorwindow=".g:netrw_use_errorwindow) |
55 | 49 |
56 if a:level < g:netrw_errorlvl | 50 if a:level < g:netrw_errorlvl |
57 " call Dret("netrw#ErrorMsg : suppressing level=".a:level." since g:netrw_errorlvl=".g:netrw_errorlvl) | 51 " call Dret("netrw#ErrorMsg : suppressing level=".a:level." since g:netrw_errorlvl=".g:netrw_errorlvl) |
198 call s:NetrwInit("g:netrw_http_xcmd","-o") | 192 call s:NetrwInit("g:netrw_http_xcmd","-o") |
199 else | 193 else |
200 let g:netrw_http_cmd = "" | 194 let g:netrw_http_cmd = "" |
201 endif | 195 endif |
202 endif | 196 endif |
197 call s:NetrwInit("g:netrw_http_put_cmd","curl -T") | |
203 call s:NetrwInit("g:netrw_rcp_cmd" , "rcp") | 198 call s:NetrwInit("g:netrw_rcp_cmd" , "rcp") |
204 call s:NetrwInit("g:netrw_rsync_cmd", "rsync") | 199 call s:NetrwInit("g:netrw_rsync_cmd", "rsync") |
205 if !exists("g:netrw_scp_cmd") | 200 if !exists("g:netrw_scp_cmd") |
206 if executable("scp") | 201 if executable("scp") |
207 call s:NetrwInit("g:netrw_scp_cmd" , "scp -q") | 202 call s:NetrwInit("g:netrw_scp_cmd" , "scp -q") |
258 let g:netrw_cursor= g:netrw_cursorline | 253 let g:netrw_cursor= g:netrw_cursorline |
259 endif | 254 endif |
260 call s:NetrwInit("g:netrw_cursor" , 2) | 255 call s:NetrwInit("g:netrw_cursor" , 2) |
261 let s:netrw_usercul = &cursorline | 256 let s:netrw_usercul = &cursorline |
262 let s:netrw_usercuc = &cursorcolumn | 257 let s:netrw_usercuc = &cursorcolumn |
258 call s:NetrwInit("g:netrw_cygdrive","/cygdrive") | |
263 " Default values - d-g ---------- {{{3 | 259 " Default values - d-g ---------- {{{3 |
264 call s:NetrwInit("s:didstarstar",0) | 260 call s:NetrwInit("s:didstarstar",0) |
265 call s:NetrwInit("g:netrw_dirhist_cnt" , 0) | 261 call s:NetrwInit("g:netrw_dirhist_cnt" , 0) |
266 call s:NetrwInit("g:netrw_decompress" , '{ ".gz" : "gunzip", ".bz2" : "bunzip2", ".zip" : "unzip", ".tar" : "tar -xf", ".xz" : "unxz" }') | 262 call s:NetrwInit("g:netrw_decompress" , '{ ".gz" : "gunzip", ".bz2" : "bunzip2", ".zip" : "unzip", ".tar" : "tar -xf", ".xz" : "unxz" }') |
267 call s:NetrwInit("g:netrw_dirhistmax" , 10) | 263 call s:NetrwInit("g:netrw_dirhistmax" , 10) |
289 let g:netrw_ignorenetrc= 0 | 285 let g:netrw_ignorenetrc= 0 |
290 endif | 286 endif |
291 endif | 287 endif |
292 call s:NetrwInit("g:netrw_keepdir",1) | 288 call s:NetrwInit("g:netrw_keepdir",1) |
293 if !exists("g:netrw_list_cmd") | 289 if !exists("g:netrw_list_cmd") |
294 | |
295 if g:netrw_scp_cmd =~ '^pscp' && executable("pscp") | 290 if g:netrw_scp_cmd =~ '^pscp' && executable("pscp") |
296 if (has("win32") || has("win95") || has("win64") || has("win16")) && filereadable("c:\\private.ppk") | 291 if (has("win32") || has("win95") || has("win64") || has("win16")) && filereadable("c:\\private.ppk") |
297 " provide a pscp-based listing command | 292 " provide a pscp-based listing command |
298 let g:netrw_scp_cmd ="pscp -i C:\\private.ppk" | 293 let g:netrw_scp_cmd ="pscp -i C:\\private.ppk" |
299 endif | 294 endif |
300 let g:netrw_list_cmd= g:netrw_scp_cmd." -ls USEPORT HOSTNAME:" | 295 let g:netrw_list_cmd= g:netrw_scp_cmd." -ls USEPORT HOSTNAME:" |
301 | |
302 elseif executable(g:netrw_ssh_cmd) | 296 elseif executable(g:netrw_ssh_cmd) |
303 " provide a scp-based default listing command | 297 " provide a scp-based default listing command |
304 let g:netrw_list_cmd= g:netrw_ssh_cmd." USEPORT HOSTNAME ls -FLa" | 298 let g:netrw_list_cmd= g:netrw_ssh_cmd." USEPORT HOSTNAME ls -FLa" |
305 | |
306 else | 299 else |
307 " call Decho(g:netrw_ssh_cmd." is not executable") | 300 " call Decho(g:netrw_ssh_cmd." is not executable") |
308 let g:netrw_list_cmd= "" | 301 let g:netrw_list_cmd= "" |
309 endif | 302 endif |
310 | |
311 endif | 303 endif |
312 call s:NetrwInit("g:netrw_list_hide","") | 304 call s:NetrwInit("g:netrw_list_hide","") |
313 " Default values - lh-lz ---------- {{{3 | 305 " Default values - lh-lz ---------- {{{3 |
314 if exists("g:netrw_local_copycmd") | 306 if exists("g:netrw_local_copycmd") |
315 let g:netrw_localcopycmd= g:netrw_local_copycmd | 307 let g:netrw_localcopycmd= g:netrw_local_copycmd |
432 call s:NetrwInit("g:netrw_glob_escape",'*[]?`{~$\') | 424 call s:NetrwInit("g:netrw_glob_escape",'*[]?`{~$\') |
433 endif | 425 endif |
434 call s:NetrwInit("g:netrw_menu_escape",'.&? \') | 426 call s:NetrwInit("g:netrw_menu_escape",'.&? \') |
435 call s:NetrwInit("g:netrw_tmpfile_escape",' &;') | 427 call s:NetrwInit("g:netrw_tmpfile_escape",' &;') |
436 call s:NetrwInit("s:netrw_map_escape","<|\n\r\\\<C-V>\"") | 428 call s:NetrwInit("s:netrw_map_escape","<|\n\r\\\<C-V>\"") |
429 if &enc == 'utf-8' || &enc == 'utf-16' || &enc == 'ucs-4' | |
430 let s:treedepthstring= "│ " | |
431 else | |
432 let s:treedepthstring= "| " | |
433 endif | |
437 | 434 |
438 " BufEnter event ignored by decho when following variable is true | 435 " BufEnter event ignored by decho when following variable is true |
439 " Has a side effect that doau BufReadPost doesn't work, so | 436 " Has a side effect that doau BufReadPost doesn't work, so |
440 " files read by network transfer aren't appropriately highlighted. | 437 " files read by network transfer aren't appropriately highlighted. |
441 "let g:decho_bufenter = 1 "Decho | 438 "let g:decho_bufenter = 1 "Decho |
442 | 439 |
443 " ====================== | 440 " ====================== |
444 " Netrw Initialization: {{{1 | 441 " Netrw Initialization: {{{1 |
445 " ====================== | 442 " ====================== |
446 if v:version >= 700 && has("balloon_eval") && !exists("s:initbeval") && !exists("g:netrw_nobeval") && has("syntax") && exists("g:syntax_on") | 443 if v:version >= 700 && has("balloon_eval") && !exists("s:initbeval") && !exists("g:netrw_nobeval") && has("syntax") && exists("g:syntax_on") |
447 let s:initbeval = &beval | 444 " call Decho("installed beval events") |
448 " let s:initbexpr = &l:bexpr | 445 let &l:bexpr = "netrw#NetrwBalloonHelp()" |
449 let &l:bexpr = "netrw#NetrwBalloonHelp()" | 446 au FileType netrw set beval |
450 set beval | 447 au WinLeave * if &ft == "netrw" && exists("s:initbeval")|let &beval= s:initbeval|endif |
451 au BufWinEnter,WinEnter * if &ft == "netrw"|set beval|else|let &beval= s:initbeval|endif | 448 au VimEnter * let s:initbeval= &beval |
449 "else " Decho | |
450 " if v:version < 700 | call Decho("did not install beval events: v:version=".v:version." < 700") | endif | |
451 " if !has("balloon_eval") | call Decho("did not install beval events: does not have balloon_eval") | endif | |
452 " if exists("s:initbeval") | call Decho("did not install beval events: s:initbeval exists") | endif | |
453 " if exists("g:netrw_nobeval") | call Decho("did not install beval events: g:netrw_nobeval exists") | endif | |
454 " if !has("syntax") | call Decho("did not install beval events: does not have syntax highlighting") | endif | |
455 " if exists("g:syntax_on") | call Decho("did not install beval events: g:syntax_on exists") | endif | |
452 endif | 456 endif |
453 au WinEnter * if &ft == "netrw"|call s:NetrwInsureWinVars()|endif | 457 au WinEnter * if &ft == "netrw"|call s:NetrwInsureWinVars()|endif |
454 | 458 |
455 " ============================== | 459 " ============================== |
456 " Netrw Utility Functions: {{{1 | 460 " Netrw Utility Functions: {{{1 |
457 " ============================== | 461 " ============================== |
458 | 462 |
459 " --------------------------------------------------------------------- | 463 " --------------------------------------------------------------------- |
460 " netrw#NetrwBalloonHelp: {{{2 | 464 " netrw#NetrwBalloonHelp: {{{2 |
461 if v:version >= 700 && has("balloon_eval") && &beval == 1 && has("syntax") && exists("g:syntax_on") | 465 if v:version >= 700 && has("balloon_eval") && has("syntax") && exists("g:syntax_on") && !exists("g:netrw_nobeval") |
462 fun! netrw#NetrwBalloonHelp() | 466 " call Decho("loading netrw#BalloonHelp()") |
463 if !exists("w:netrw_bannercnt") || v:beval_lnum >= w:netrw_bannercnt || (exists("g:netrw_nobeval") && g:netrw_nobeval) | 467 fun! netrw#NetrwBalloonHelp() |
464 let mesg= "" | 468 if &ft != "netrw" |
465 elseif v:beval_text == "Netrw" || v:beval_text == "Directory" || v:beval_text == "Listing" | 469 return "" |
466 let mesg = "i: thin-long-wide-tree gh: quick hide/unhide of dot-files qf: quick file info %:open new file" | 470 endif |
467 elseif getline(v:beval_lnum) =~ '^"\s*/' | 471 if !exists("w:netrw_bannercnt") || v:beval_lnum >= w:netrw_bannercnt || (exists("g:netrw_nobeval") && g:netrw_nobeval) |
468 let mesg = "<cr>: edit/enter o: edit/enter in horiz window t: edit/enter in new tab v:edit/enter in vert window" | 472 let mesg= "" |
469 elseif v:beval_text == "Sorted" || v:beval_text == "by" | 473 elseif v:beval_text == "Netrw" || v:beval_text == "Directory" || v:beval_text == "Listing" |
470 let mesg = 's: sort by name, time, or file size r: reverse sorting order mt: mark target' | 474 let mesg = "i: thin-long-wide-tree gh: quick hide/unhide of dot-files qf: quick file info %:open new file" |
471 elseif v:beval_text == "Sort" || v:beval_text == "sequence" | 475 elseif getline(v:beval_lnum) =~ '^"\s*/' |
472 let mesg = "S: edit sorting sequence" | 476 let mesg = "<cr>: edit/enter o: edit/enter in horiz window t: edit/enter in new tab v:edit/enter in vert window" |
473 elseif v:beval_text == "Hiding" || v:beval_text == "Showing" | 477 elseif v:beval_text == "Sorted" || v:beval_text == "by" |
474 let mesg = "a: hiding-showing-all ctrl-h: editing hiding list mh: hide/show by suffix" | 478 let mesg = 's: sort by name, time, or file size r: reverse sorting order mt: mark target' |
475 elseif v:beval_text == "Quick" || v:beval_text == "Help" | 479 elseif v:beval_text == "Sort" || v:beval_text == "sequence" |
476 let mesg = "Help: press <F1>" | 480 let mesg = "S: edit sorting sequence" |
477 elseif v:beval_text == "Copy/Move" || v:beval_text == "Tgt" | 481 elseif v:beval_text == "Hiding" || v:beval_text == "Showing" |
478 let mesg = "mt: mark target mc: copy marked file to target mm: move marked file to target" | 482 let mesg = "a: hiding-showing-all ctrl-h: editing hiding list mh: hide/show by suffix" |
479 else | 483 elseif v:beval_text == "Quick" || v:beval_text == "Help" |
480 let mesg= "" | 484 let mesg = "Help: press <F1>" |
481 endif | 485 elseif v:beval_text == "Copy/Move" || v:beval_text == "Tgt" |
482 return mesg | 486 let mesg = "mt: mark target mc: copy marked file to target mm: move marked file to target" |
483 endfun | 487 else |
488 let mesg= "" | |
489 endif | |
490 return mesg | |
491 endfun | |
492 "else " Decho | |
493 " if v:version < 700 |call Decho("did not load netrw#BalloonHelp(): vim version ".v:version." < 700 -")|endif | |
494 " if !has("balloon_eval") |call Decho("did not load netrw#BalloonHelp(): does not have balloon eval") |endif | |
495 " if !has("syntax") |call Decho("did not load netrw#BalloonHelp(): syntax disabled") |endif | |
496 " if !exists("g:syntax_on") |call Decho("did not load netrw#BalloonHelp(): g:syntax_on=".g:syntax_on) |endif | |
497 " if exists("g:netrw_nobeval") |call Decho("did not load netrw#BalloonHelp(): g:netrw_nobeval exists") |endif | |
484 endif | 498 endif |
485 | 499 |
486 " ------------------------------------------------------------------------ | 500 " ------------------------------------------------------------------------ |
487 " s:NetrwOptionSave: save options prior to setting to "netrw-buffer-standard" form {{{2 | 501 " s:NetrwOptionSave: save options prior to setting to "netrw-buffer-standard" form {{{2 |
502 " Options get restored by s:NetrwOptionRestore() | |
488 " 06/08/07 : removed call to NetrwSafeOptions(), either placed | 503 " 06/08/07 : removed call to NetrwSafeOptions(), either placed |
489 " immediately after NetrwOptionSave() calls in NetRead | 504 " immediately after NetrwOptionSave() calls in NetRead |
490 " and NetWrite, or after the s:NetrwEnew() call in | 505 " and NetWrite, or after the s:NetrwEnew() call in |
491 " NetrwBrowse. | 506 " NetrwBrowse. |
492 " vt: normally its "w:" or "s:" (a variable type) | 507 " vt: normally its "w:" or "s:" (a variable type) |
493 fun! s:NetrwOptionSave(vt) | 508 fun! s:NetrwOptionSave(vt) |
494 " call Dfunc("s:NetrwOptionSave(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")."<".bufname(bufnr("%")).">"." winnr($)=".winnr("$")." mod=".&mod." ma=".&ma) | 509 " call Dfunc("s:NetrwOptionSave(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")."<".bufname(bufnr("%")).">"." winnr($)=".winnr("$")." mod=".&mod." ma=".&ma) |
495 " call Decho(a:vt."netrw_optionsave".(exists("{a:vt}netrw_optionsave")? ("=".{a:vt}netrw_optionsave) : " doesn't exist")) | 510 " call Decho(a:vt."netrw_optionsave".(exists("{a:vt}netrw_optionsave")? ("=".{a:vt}netrw_optionsave) : " doesn't exist")) |
511 " call Decho("(s:NetrwOptionSave) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt) | |
496 | 512 |
497 if !exists("{a:vt}netrw_optionsave") | 513 if !exists("{a:vt}netrw_optionsave") |
498 let {a:vt}netrw_optionsave= 1 | 514 let {a:vt}netrw_optionsave= 1 |
499 else | 515 else |
500 " call Dret("s:NetrwOptionSave : options already saved") | 516 " call Dret("s:NetrwOptionSave : options already saved") |
501 return | 517 return |
502 endif | 518 endif |
503 " call Decho("fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist")." diff=".&l:diff) | 519 " call Decho("(s:NetrwOptionSave) prior to save: fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist")." diff=".&l:diff) |
504 | 520 |
505 " Save current settings and current directory | 521 " Save current settings and current directory |
506 " call Decho("saving current settings and current directory") | 522 " call Decho("saving current settings and current directory") |
507 let s:yykeep = @@ | 523 let s:yykeep = @@ |
508 if exists("&l:acd")|let {a:vt}netrw_acdkeep = &l:acd|endif | 524 if exists("&l:acd")|let {a:vt}netrw_acdkeep = &l:acd|endif |
533 let {a:vt}netrw_nukeep = &l:nu | 549 let {a:vt}netrw_nukeep = &l:nu |
534 let {a:vt}netrw_repkeep = &l:report | 550 let {a:vt}netrw_repkeep = &l:report |
535 let {a:vt}netrw_rokeep = &l:ro | 551 let {a:vt}netrw_rokeep = &l:ro |
536 let {a:vt}netrw_selkeep = &l:sel | 552 let {a:vt}netrw_selkeep = &l:sel |
537 let {a:vt}netrw_spellkeep = &l:spell | 553 let {a:vt}netrw_spellkeep = &l:spell |
554 let {a:vt}netrw_starkeep = @* | |
538 let {a:vt}netrw_tskeep = &l:ts | 555 let {a:vt}netrw_tskeep = &l:ts |
539 let {a:vt}netrw_twkeep = &l:tw " textwidth | 556 let {a:vt}netrw_twkeep = &l:tw " textwidth |
540 let {a:vt}netrw_wigkeep = &l:wig " wildignore | 557 let {a:vt}netrw_wigkeep = &l:wig " wildignore |
541 let {a:vt}netrw_wrapkeep = &l:wrap | 558 let {a:vt}netrw_wrapkeep = &l:wrap |
542 let {a:vt}netrw_writekeep = &l:write | 559 let {a:vt}netrw_writekeep = &l:write |
553 let {a:vt}netrw_swfkeep = &l:swf " swapfile | 570 let {a:vt}netrw_swfkeep = &l:swf " swapfile |
554 endif | 571 endif |
555 if &go =~# 'a' | sil! let {a:vt}netrw_regstar = @* | endif | 572 if &go =~# 'a' | sil! let {a:vt}netrw_regstar = @* | endif |
556 sil! let {a:vt}netrw_regslash= @/ | 573 sil! let {a:vt}netrw_regslash= @/ |
557 | 574 |
558 " call Dret("s:NetrwOptionSave : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")." modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) | 575 " call Decho("(s:NetrwOptionSave) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt) |
576 " call Dret("s:NetrwOptionSave : tab#".tabpagenr()." win#".winnr()) | |
559 endfun | 577 endfun |
560 | 578 |
561 " ------------------------------------------------------------------------ | 579 " ------------------------------------------------------------------------ |
562 " s:NetrwOptionRestore: restore options {{{2 | 580 " s:NetrwOptionRestore: restore options (based on prior s:NetrwOptionSave) {{{2 |
563 fun! s:NetrwOptionRestore(vt) | 581 fun! s:NetrwOptionRestore(vt) |
564 " call Dfunc("s:NetrwOptionRestore(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> winnr($)=".winnr("$")) | 582 " call Dfunc("s:NetrwOptionRestore(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> winnr($)=".winnr("$")) |
583 " call Decho("(NetrwOptionRestore) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt) | |
565 if !exists("{a:vt}netrw_optionsave") | 584 if !exists("{a:vt}netrw_optionsave") |
566 if exists("s:nbcd_curpos_{bufnr('%')}") | 585 if exists("s:nbcd_curpos_{bufnr('%')}") |
567 " call Decho("(NetrwOptionRestore) restoring previous position (s:nbcd_curpos_".bufnr('%')." exists)") | 586 " call Decho("(NetrwOptionRestore) restoring previous position (s:nbcd_curpos_".bufnr('%')." exists)") |
568 keepj call netrw#NetrwRestorePosn(s:nbcd_curpos_{bufnr('%')}) | 587 keepj call netrw#NetrwRestorePosn(s:nbcd_curpos_{bufnr('%')}) |
569 " call Decho("(NetrwOptionRestore) win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> winnr($)=".winnr("$")) | 588 " call Decho("(NetrwOptionRestore) win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> winnr($)=".winnr("$")) |
570 " call Decho("(NetrwOptionRestore) unlet s:nbcd_curpos_".bufnr('%')) | 589 " call Decho("(NetrwOptionRestore) unlet s:nbcd_curpos_".bufnr('%')) |
571 unlet s:nbcd_curpos_{bufnr('%')} | 590 unlet s:nbcd_curpos_{bufnr('%')} |
572 else | 591 else |
573 " call Decho("(NetrwOptionRestore) no previous position") | 592 " call Decho("(NetrwOptionRestore) no previous position") |
574 endif | 593 endif |
594 " call Decho("(NetrwOptionRestore) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt) | |
575 " call Decho("(NetrwOptionRestore) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") | 595 " call Decho("(NetrwOptionRestore) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") |
576 " call Dret("s:NetrwOptionRestore : ".a:vt."netrw_optionsave doesn't exist") | 596 " call Dret("s:NetrwOptionRestore : ".a:vt."netrw_optionsave doesn't exist") |
577 return | 597 return |
578 endif | 598 endif |
579 unlet {a:vt}netrw_optionsave | 599 unlet {a:vt}netrw_optionsave |
625 if exists("{a:vt}netrw_nukeep") |let &l:nu = {a:vt}netrw_nukeep |unlet {a:vt}netrw_nukeep |endif | 645 if exists("{a:vt}netrw_nukeep") |let &l:nu = {a:vt}netrw_nukeep |unlet {a:vt}netrw_nukeep |endif |
626 if exists("{a:vt}netrw_repkeep") |let &l:report = {a:vt}netrw_repkeep |unlet {a:vt}netrw_repkeep |endif | 646 if exists("{a:vt}netrw_repkeep") |let &l:report = {a:vt}netrw_repkeep |unlet {a:vt}netrw_repkeep |endif |
627 if exists("{a:vt}netrw_rokeep") |let &l:ro = {a:vt}netrw_rokeep |unlet {a:vt}netrw_rokeep |endif | 647 if exists("{a:vt}netrw_rokeep") |let &l:ro = {a:vt}netrw_rokeep |unlet {a:vt}netrw_rokeep |endif |
628 if exists("{a:vt}netrw_selkeep") |let &l:sel = {a:vt}netrw_selkeep |unlet {a:vt}netrw_selkeep |endif | 648 if exists("{a:vt}netrw_selkeep") |let &l:sel = {a:vt}netrw_selkeep |unlet {a:vt}netrw_selkeep |endif |
629 if exists("{a:vt}netrw_spellkeep")|let &l:spell = {a:vt}netrw_spellkeep |unlet {a:vt}netrw_spellkeep|endif | 649 if exists("{a:vt}netrw_spellkeep")|let &l:spell = {a:vt}netrw_spellkeep |unlet {a:vt}netrw_spellkeep|endif |
650 if exists("{a:vt}netrw_starkeep") |let @* = {a:vt}netrw_starkeep |unlet {a:vt}netrw_starkeep |endif | |
630 " Problem: start with liststyle=0; press <i> : result, following line resets l:ts. | 651 " Problem: start with liststyle=0; press <i> : result, following line resets l:ts. |
631 " if exists("{a:vt}netrw_tskeep") |let &l:ts = {a:vt}netrw_tskeep |unlet {a:vt}netrw_tskeep |endif | 652 " if exists("{a:vt}netrw_tskeep") |let &l:ts = {a:vt}netrw_tskeep |unlet {a:vt}netrw_tskeep |endif |
632 if exists("{a:vt}netrw_twkeep") |let &l:tw = {a:vt}netrw_twkeep |unlet {a:vt}netrw_twkeep |endif | 653 if exists("{a:vt}netrw_twkeep") |let &l:tw = {a:vt}netrw_twkeep |unlet {a:vt}netrw_twkeep |endif |
633 if exists("{a:vt}netrw_wigkeep") |let &l:wig = {a:vt}netrw_wigkeep |unlet {a:vt}netrw_wigkeep |endif | 654 if exists("{a:vt}netrw_wigkeep") |let &l:wig = {a:vt}netrw_wigkeep |unlet {a:vt}netrw_wigkeep |endif |
634 if exists("{a:vt}netrw_wrapkeep") |let &l:wrap = {a:vt}netrw_wrapkeep |unlet {a:vt}netrw_wrapkeep |endif | 655 if exists("{a:vt}netrw_wrapkeep") |let &l:wrap = {a:vt}netrw_wrapkeep |unlet {a:vt}netrw_wrapkeep |endif |
637 if exists("{a:vt}netrw_swfkeep") | 658 if exists("{a:vt}netrw_swfkeep") |
638 if &directory == "" | 659 if &directory == "" |
639 " user hasn't specified a swapfile directory; | 660 " user hasn't specified a swapfile directory; |
640 " netrw will temporarily set the swapfile directory | 661 " netrw will temporarily set the swapfile directory |
641 " to the current directory as returned by getcwd(). | 662 " to the current directory as returned by getcwd(). |
642 let &l:directory = getcwd() | 663 let &l:directory= getcwd() |
643 sil! let &l:swf = {a:vt}netrw_swfkeep | 664 sil! let &l:swf = {a:vt}netrw_swfkeep |
644 setl directory= | 665 setl directory= |
645 unlet {a:vt}netrw_swfkeep | 666 unlet {a:vt}netrw_swfkeep |
646 elseif &l:swf != {a:vt}netrw_swfkeep | 667 elseif &l:swf != {a:vt}netrw_swfkeep |
647 " following line causes a Press ENTER in windows -- can't seem to work around it!!! | 668 " following line causes a Press ENTER in windows -- can't seem to work around it!!! |
657 if exists("{a:vt}netrw_regslash")|sil! let @/= {a:vt}netrw_regslash|unlet {a:vt}netrw_regslash|endif | 678 if exists("{a:vt}netrw_regslash")|sil! let @/= {a:vt}netrw_regslash|unlet {a:vt}netrw_regslash|endif |
658 if exists("s:nbcd_curpos_{bufnr('%')}") | 679 if exists("s:nbcd_curpos_{bufnr('%')}") |
659 " call Decho("(NetrwOptionRestore) restoring previous position (s:nbcd_curpos_".bufnr('%')." exists)") | 680 " call Decho("(NetrwOptionRestore) restoring previous position (s:nbcd_curpos_".bufnr('%')." exists)") |
660 keepj call netrw#NetrwRestorePosn(s:nbcd_curpos_{bufnr('%')}) | 681 keepj call netrw#NetrwRestorePosn(s:nbcd_curpos_{bufnr('%')}) |
661 " call Decho("(NetrwOptionRestore) unlet s:nbcd_curpos_".bufnr('%')) | 682 " call Decho("(NetrwOptionRestore) unlet s:nbcd_curpos_".bufnr('%')) |
662 unlet s:nbcd_curpos_{bufnr('%')} | 683 if exists("s:nbcd_curpos_".bufnr('%')) |
684 unlet s:nbcd_curpos_{bufnr('%')} | |
685 endif | |
663 else | 686 else |
664 " call Decho("no previous position") | 687 " call Decho("no previous position") |
665 endif | 688 endif |
666 | 689 |
667 " call Decho("(NetrwOptionRestore) g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd) | 690 " call Decho("(NetrwOptionRestore) g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd) |
674 " NetrwOptionRestore. | 697 " NetrwOptionRestore. |
675 if &ft != "netrw" | 698 if &ft != "netrw" |
676 " call Decho("(NetrwOptionRestore) filetype detect (ft=".&ft.")") | 699 " call Decho("(NetrwOptionRestore) filetype detect (ft=".&ft.")") |
677 filetype detect | 700 filetype detect |
678 endif | 701 endif |
702 " call Decho("(s:NetrwOptionRestore) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt) | |
679 " call Dret("s:NetrwOptionRestore : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) | 703 " call Dret("s:NetrwOptionRestore : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) |
680 endfun | 704 endfun |
681 | 705 |
682 " --------------------------------------------------------------------- | 706 " --------------------------------------------------------------------- |
683 " s:NetrwSafeOptions: sets options to help netrw do its job {{{2 | 707 " s:NetrwSafeOptions: sets options to help netrw do its job {{{2 |
684 " Use s:NetrwSaveOptions() to save user settings | 708 " Use s:NetrwSaveOptions() to save user settings |
685 " Use s:NetrwOptionRestore() to restore user settings | 709 " Use s:NetrwOptionRestore() to restore user settings |
686 fun! s:NetrwSafeOptions() | 710 fun! s:NetrwSafeOptions() |
687 " call Dfunc("s:NetrwSafeOptions() win#".winnr()." buf#".bufnr("%")."<".bufname(bufnr("%"))."> winnr($)=".winnr("$")) | 711 " call Dfunc("s:NetrwSafeOptions() win#".winnr()." buf#".bufnr("%")."<".bufname(bufnr("%"))."> winnr($)=".winnr("$")) |
688 " call Decho("win#".winnr()."'s ft=".&ft) | 712 " call Decho("(s:NetrwSafeOptions) win#".winnr()."'s ft=".&ft) |
713 " call Decho("(s:NetrwSafeOptions) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) | |
689 if exists("+acd") | setl noacd | endif | 714 if exists("+acd") | setl noacd | endif |
690 setl noai | 715 setl noai |
691 setl noaw | 716 setl noaw |
717 setl nobl | |
692 setl nobomb | 718 setl nobomb |
693 setl noci | 719 setl noci |
694 setl nocin | 720 setl nocin |
695 if g:netrw_liststyle == s:TREELIST | 721 if g:netrw_liststyle == s:TREELIST |
696 setl bh=hide | 722 setl bh=hide |
698 setl cino= | 724 setl cino= |
699 setl com= | 725 setl com= |
700 setl cpo-=a | 726 setl cpo-=a |
701 setl cpo-=A | 727 setl cpo-=A |
702 setl fo=nroql2 | 728 setl fo=nroql2 |
703 setl nohid | 729 setl nohid |
704 setl noim | 730 setl noim |
705 setl isk+=@ isk+=* isk+=/ | 731 setl isk+=@ isk+=* isk+=/ |
706 setl magic | 732 setl magic |
707 setl report=10000 | 733 setl report=10000 |
708 setl sel=inclusive | 734 setl sel=inclusive |
714 setl noswf | 740 setl noswf |
715 endif | 741 endif |
716 call s:NetrwCursor() | 742 call s:NetrwCursor() |
717 | 743 |
718 " allow the user to override safe options | 744 " allow the user to override safe options |
719 " call Decho("ft<".&ft."> ei=".&ei) | 745 " call Decho("(s:NetrwSafeOptions) ft<".&ft."> ei=".&ei) |
720 if &ft == "netrw" | 746 if &ft == "netrw" |
721 " call Decho("do any netrw FileType autocmds (doau FileType netrw)") | 747 " call Decho("(s:NetrwSafeOptions) do any netrw FileType autocmds (doau FileType netrw)") |
722 sil! keepalt keepj doau FileType netrw | 748 sil! keepalt keepj doau FileType netrw |
723 endif | 749 endif |
724 | 750 |
725 " call Decho("fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist")." bh=".&l:bh) | 751 " call Decho("(s:NetrwSafeOptions) fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist")." bh=".&l:bh) |
752 " call Decho("(s:NetrwSafeOptions) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) | |
726 " call Dret("s:NetrwSafeOptions") | 753 " call Dret("s:NetrwSafeOptions") |
727 endfun | 754 endfun |
728 | 755 |
729 " --------------------------------------------------------------------- | 756 " --------------------------------------------------------------------- |
730 " netrw#Explore: launch the local browser in the directory of the current file {{{2 | 757 " netrw#Explore: launch the local browser in the directory of the current file {{{2 |
735 " indx'th item in the w:netrw_explore_list[] of items which | 762 " indx'th item in the w:netrw_explore_list[] of items which |
736 " matched the */pattern **/pattern *//pattern **//pattern | 763 " matched the */pattern **/pattern *//pattern **//pattern |
737 " * If Hexplore or Vexplore, then this will override | 764 " * If Hexplore or Vexplore, then this will override |
738 " g:netrw_winsize to specify the qty of rows or columns the | 765 " g:netrw_winsize to specify the qty of rows or columns the |
739 " newly split window should have. | 766 " newly split window should have. |
740 " dosplit==0: the window will be split iff the current file has been modified | 767 " dosplit==0: the window will be split iff the current file has been modified and hidden not set |
741 " dosplit==1: the window will be split before running the local browser | 768 " dosplit==1: the window will be split before running the local browser |
742 " style == 0: Explore style == 1: Explore! | 769 " style == 0: Explore style == 1: Explore! |
743 " == 2: Hexplore style == 3: Hexplore! | 770 " == 2: Hexplore style == 3: Hexplore! |
744 " == 4: Vexplore style == 5: Vexplore! | 771 " == 4: Vexplore style == 5: Vexplore! |
745 " == 6: Texplore | 772 " == 6: Texplore |
746 fun! netrw#Explore(indx,dosplit,style,...) | 773 fun! netrw#Explore(indx,dosplit,style,...) |
747 " 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("%")) | 774 " 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("%")) |
748 if !exists("b:netrw_curdir") | 775 if !exists("b:netrw_curdir") |
749 let b:netrw_curdir= getcwd() | 776 let b:netrw_curdir= getcwd() |
750 if !g:netrw_cygwin && (has("win32") || has("win95") || has("win64") || has("win16")) | |
751 let b:netrw_curdir= substitute(b:netrw_curdir,'\','/','g') | |
752 endif | |
753 " call Decho("(Explore) set b:netrw_curdir<".b:netrw_curdir."> (used getcwd)") | 777 " call Decho("(Explore) set b:netrw_curdir<".b:netrw_curdir."> (used getcwd)") |
754 endif | 778 endif |
755 let curdir = simplify(b:netrw_curdir) | 779 let curdir = simplify(b:netrw_curdir) |
756 let curfiledir = substitute(expand("%:p"),'^\(.*[/\\]\)[^/\\]*$','\1','e') | 780 let curfiledir = substitute(expand("%:p"),'^\(.*[/\\]\)[^/\\]*$','\1','e') |
757 if !exists("g:netrw_cygwin") && (has("win32") || has("win95") || has("win64") || has("win16")) | 781 if !exists("g:netrw_cygwin") && (has("win32") || has("win95") || has("win64") || has("win16")) |
762 " save registers | 786 " save registers |
763 sil! let keepregstar = @* | 787 sil! let keepregstar = @* |
764 sil! let keepregplus = @+ | 788 sil! let keepregplus = @+ |
765 sil! let keepregslash= @/ | 789 sil! let keepregslash= @/ |
766 | 790 |
767 " if dosplit or file has been modified | 791 " if dosplit |
768 if a:dosplit || &modified || a:style == 6 | 792 " -or- file has been modified AND file not hidden when abandoned |
793 " -or- Texplore used | |
794 if a:dosplit || (&modified && &hidden == 0 && &bufhidden != "hide") || a:style == 6 | |
769 " call Decho("(Explore) case dosplit=".a:dosplit." modified=".&modified." a:style=".a:style.": dosplit or file has been modified") | 795 " call Decho("(Explore) case dosplit=".a:dosplit." modified=".&modified." a:style=".a:style.": dosplit or file has been modified") |
770 call s:SaveWinVars() | 796 call s:SaveWinVars() |
771 let winsz= g:netrw_winsize | 797 let winsz= g:netrw_winsize |
772 if a:indx > 0 | 798 if a:indx > 0 |
773 let winsz= a:indx | 799 let winsz= a:indx |
1149 " call Decho("(Explore) w:netrw_explore_indx=".(exists("w:netrw_explore_indx")? w:netrw_explore_indx : "doesn't exist")) | 1175 " call Decho("(Explore) w:netrw_explore_indx=".(exists("w:netrw_explore_indx")? w:netrw_explore_indx : "doesn't exist")) |
1150 " call Decho("(Explore) b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "n/a").">") | 1176 " call Decho("(Explore) b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "n/a").">") |
1151 if exists("w:netrw_explore_indx") && exists("b:netrw_curdir") | 1177 if exists("w:netrw_explore_indx") && exists("b:netrw_curdir") |
1152 " call Decho("(Explore) s:explore_prvdir<".(exists("s:explore_prvdir")? s:explore_prvdir : "-doesn't exist-")) | 1178 " call Decho("(Explore) s:explore_prvdir<".(exists("s:explore_prvdir")? s:explore_prvdir : "-doesn't exist-")) |
1153 if !exists("s:explore_prvdir") || s:explore_prvdir != b:netrw_curdir | 1179 if !exists("s:explore_prvdir") || s:explore_prvdir != b:netrw_curdir |
1154 " only update match list if current directory isn't the same as before | 1180 " only update match list when current directory isn't the same as before |
1155 " call Decho("(Explore) only update match list if current directory not the same as before") | 1181 " call Decho("(Explore) only update match list when current directory not the same as before") |
1156 let s:explore_prvdir = b:netrw_curdir | 1182 let s:explore_prvdir = b:netrw_curdir |
1157 let s:explore_match = "" | 1183 let s:explore_match = "" |
1158 let dirlen = s:Strlen(b:netrw_curdir) | 1184 let dirlen = strlen(b:netrw_curdir) |
1159 if b:netrw_curdir !~ '/$' | 1185 if b:netrw_curdir !~ '/$' |
1160 let dirlen= dirlen + 1 | 1186 let dirlen= dirlen + 1 |
1161 endif | 1187 endif |
1162 let prvfname= "" | 1188 let prvfname= "" |
1163 for fname in w:netrw_explore_list | 1189 for fname in w:netrw_explore_list |
1191 | 1217 |
1192 sil! let @* = keepregstar | 1218 sil! let @* = keepregstar |
1193 sil! let @+ = keepregstar | 1219 sil! let @+ = keepregstar |
1194 sil! let @/ = keepregslash | 1220 sil! let @/ = keepregslash |
1195 " call Dret("netrw#Explore : @/<".@/.">") | 1221 " call Dret("netrw#Explore : @/<".@/.">") |
1222 endfun | |
1223 | |
1224 " --------------------------------------------------------------------- | |
1225 " netrw#Lexplore: toggle Explorer window, keeping it on the left of the current tab {{{2 | |
1226 fun! netrw#Lexplore(...) | |
1227 " call Dfunc("netrw#Lexplore() a:0=".a:0) | |
1228 if exists("t:netrw_lexbufnr") | |
1229 " close down netrw explorer window | |
1230 let lexwinnr = bufwinnr(t:netrw_lexbufnr) | |
1231 if lexwinnr != -1 | |
1232 let curwin = winnr() | |
1233 exe lexwinnr."wincmd w" | |
1234 close | |
1235 exe curwin."wincmd w" | |
1236 endif | |
1237 unlet t:netrw_lexbufnr | |
1238 | |
1239 else | |
1240 " open netrw explorer window | |
1241 exe "1wincmd w" | |
1242 let keep_altv = g:netrw_altv | |
1243 let g:netrw_altv = 0 | |
1244 if a:0 > 0 && a:1 != "" | |
1245 Vexplore a:1 | |
1246 else | |
1247 Vexplore . | |
1248 endif | |
1249 let g:netrw_altv = keep_altv | |
1250 let t:netrw_lexbufnr = bufnr("%") | |
1251 endif | |
1252 " call Dret("netrw#Lexplore") | |
1196 endfun | 1253 endfun |
1197 | 1254 |
1198 " --------------------------------------------------------------------- | 1255 " --------------------------------------------------------------------- |
1199 " netrw#NetrwMakeTgt: make a target out of the directory name provided {{{2 | 1256 " netrw#NetrwMakeTgt: make a target out of the directory name provided {{{2 |
1200 fun! netrw#NetrwMakeTgt(dname) | 1257 fun! netrw#NetrwMakeTgt(dname) |
1635 " call Dfunc("netrw#NetRead : unsupported method") | 1692 " call Dfunc("netrw#NetRead : unsupported method") |
1636 return | 1693 return |
1637 endif | 1694 endif |
1638 let tmpfile= s:GetTempfile(b:netrw_fname) " apply correct suffix | 1695 let tmpfile= s:GetTempfile(b:netrw_fname) " apply correct suffix |
1639 | 1696 |
1640 " Check if NetrwBrowse() should be handling this request | 1697 " Check whether or not NetrwBrowse() should be handling this request |
1641 " call Decho("checking if NetrwBrowse() should handle choice<".choice."> with netrw_list_cmd<".g:netrw_list_cmd.">") | 1698 " call Decho("checking if NetrwBrowse() should handle choice<".choice."> with netrw_list_cmd<".g:netrw_list_cmd.">") |
1642 if choice =~ "^.*[\/]$" && b:netrw_method != 5 && choice !~ '^https\=://' | 1699 if choice =~ "^.*[\/]$" && b:netrw_method != 5 && choice !~ '^https\=://' |
1643 " call Decho("yes, choice matches '^.*[\/]$'") | 1700 " call Decho("yes, choice matches '^.*[\/]$'") |
1644 keepj call s:NetrwBrowse(0,choice) | 1701 keepj call s:NetrwBrowse(0,choice) |
1645 " call Dret("netrw#NetRead :3 getcwd<".getcwd().">") | 1702 " call Dret("netrw#NetRead :3 getcwd<".getcwd().">") |
1657 " NetRead: (rcp) NetRead Method #1 {{{3 | 1714 " NetRead: (rcp) NetRead Method #1 {{{3 |
1658 if b:netrw_method == 1 " read with rcp | 1715 if b:netrw_method == 1 " read with rcp |
1659 " call Decho("read via rcp (method #1)") | 1716 " call Decho("read via rcp (method #1)") |
1660 " ER: nothing done with g:netrw_uid yet? | 1717 " ER: nothing done with g:netrw_uid yet? |
1661 " ER: on Win2K" rcp machine[.user]:file tmpfile | 1718 " ER: on Win2K" rcp machine[.user]:file tmpfile |
1662 " ER: if machine contains '.' adding .user is required (use $USERNAME) | 1719 " ER: when machine contains '.' adding .user is required (use $USERNAME) |
1663 " ER: the tmpfile is full path: rcp sees C:\... as host C | 1720 " ER: the tmpfile is full path: rcp sees C:\... as host C |
1664 if s:netrw_has_nt_rcp == 1 | 1721 if s:netrw_has_nt_rcp == 1 |
1665 if exists("g:netrw_uid") && ( g:netrw_uid != "" ) | 1722 if exists("g:netrw_uid") && ( g:netrw_uid != "" ) |
1666 let uid_machine = g:netrw_machine .'.'. g:netrw_uid | 1723 let uid_machine = g:netrw_machine .'.'. g:netrw_uid |
1667 else | 1724 else |
1976 " Also supports the writing of tar and zip files. | 2033 " Also supports the writing of tar and zip files. |
1977 " call Decho("(write entire file) sil exe w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile)) | 2034 " call Decho("(write entire file) sil exe w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile)) |
1978 exe "sil keepj w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile) | 2035 exe "sil keepj w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile) |
1979 elseif g:netrw_cygwin | 2036 elseif g:netrw_cygwin |
1980 " write (selected portion of) file to temporary | 2037 " write (selected portion of) file to temporary |
1981 let cygtmpfile= substitute(tmpfile,'/cygdrive/\(.\)','\1:','') | 2038 let cygtmpfile= substitute(tmpfile,g:netrw_cygdrive.'/\(.\)','\1:','') |
1982 " call Decho("(write selected portion) sil exe ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(cygtmpfile)) | 2039 " call Decho("(write selected portion) sil exe ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(cygtmpfile)) |
1983 exe "sil keepj ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(cygtmpfile) | 2040 exe "sil keepj ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(cygtmpfile) |
1984 else | 2041 else |
1985 " write (selected portion of) file to temporary | 2042 " write (selected portion of) file to temporary |
1986 " call Decho("(write selected portion) sil exe ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile)) | 2043 " call Decho("(write selected portion) sil exe ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile)) |
1987 exe "sil keepj ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile) | 2044 exe "sil keepj ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile) |
1988 endif | 2045 endif |
1989 | 2046 |
1990 if curbufname == "" | 2047 if curbufname == "" |
1991 " if the file is [No Name], and one attempts to Nwrite it, the buffer takes | 2048 " when the file is [No Name], and one attempts to Nwrite it, the buffer takes |
1992 " on the temporary file's name. Deletion of the temporary file during | 2049 " on the temporary file's name. Deletion of the temporary file during |
1993 " cleanup then causes an error message. | 2050 " cleanup then causes an error message. |
1994 0file! | 2051 0file! |
1995 endif | 2052 endif |
1996 | 2053 |
2004 let choice = b:netrw_lastfile | 2061 let choice = b:netrw_lastfile |
2005 let ichoice= ichoice + 1 | 2062 let ichoice= ichoice + 1 |
2006 else | 2063 else |
2007 exe "let choice= a:" . ichoice | 2064 exe "let choice= a:" . ichoice |
2008 | 2065 |
2009 " Reconstruct Choice if choice starts with '"' | 2066 " Reconstruct Choice when choice starts with '"' |
2010 if match(choice,"?") == 0 | 2067 if match(choice,"?") == 0 |
2011 echomsg 'NetWrite Usage:"' | 2068 echomsg 'NetWrite Usage:"' |
2012 echomsg ':Nwrite machine:path uses rcp' | 2069 echomsg ':Nwrite machine:path uses rcp' |
2013 echomsg ':Nwrite "machine path" uses ftp with <.netrc>' | 2070 echomsg ':Nwrite "machine path" uses ftp with <.netrc>' |
2014 echomsg ':Nwrite "machine id password path" uses ftp' | 2071 echomsg ':Nwrite "machine id password path" uses ftp' |
2213 | 2270 |
2214 "......................................... | 2271 "......................................... |
2215 " NetWrite: (http) NetWrite Method #5 {{{3 | 2272 " NetWrite: (http) NetWrite Method #5 {{{3 |
2216 elseif b:netrw_method == 5 | 2273 elseif b:netrw_method == 5 |
2217 " call Decho("write via http (method #5)") | 2274 " call Decho("write via http (method #5)") |
2218 if !exists("g:netrw_quiet") | 2275 let curl= substitute(g:netrw_http_put_cmd,'\s\+.*$',"","") |
2219 call netrw#ErrorMsg(s:ERROR,"currently <netrw.vim> does not support writing using http:",16) | 2276 if executable(curl) |
2277 let url= g:netrw_choice | |
2278 " call Decho("exe ".s:netrw_silentxfer."!".g:netrw_http_put_cmd." ".shellescape(tmpfile,1)." ".shellescape(url,1) ) | |
2279 exe s:netrw_silentxfer."!".g:netrw_http_put_cmd." ".shellescape(tmpfile,1)." ".shellescape(url,1) | |
2280 elseif !exists("g:netrw_quiet") | |
2281 call netrw#ErrorMsg(s:ERROR,"can't write to http using <".g:netrw_http_put_cmd".">".",16) | |
2220 endif | 2282 endif |
2221 | 2283 |
2222 "......................................... | 2284 "......................................... |
2223 " NetWrite: (dav) NetWrite Method #6 (cadaver) {{{3 | 2285 " NetWrite: (dav) NetWrite Method #6 (cadaver) {{{3 |
2224 elseif b:netrw_method == 6 | 2286 elseif b:netrw_method == 6 |
2361 endwhile | 2423 endwhile |
2362 endif | 2424 endif |
2363 " call Dret("netrw#NetSource") | 2425 " call Dret("netrw#NetSource") |
2364 endfun | 2426 endfun |
2365 | 2427 |
2428 " --------------------------------------------------------------------- | |
2429 " netrw#NetrwSetTreetop: resets the tree top to the current directory/specified directory {{{2 | |
2430 fun! netrw#NetrwSetTreetop(...) | |
2431 " call Dfunc("netrw#NetrwSetTreetop(".((a:0 > 0)? a:1 : "").") a:0=".a:0) | |
2432 " clear out the current tree | |
2433 if exists("w:netrw_treetop") | |
2434 let inittreetop= w:netrw_treetop | |
2435 unlet w:netrw_treetop | |
2436 endif | |
2437 if exists("w:netrw_treedict") | |
2438 unlet w:netrw_treedict | |
2439 endif | |
2440 if a:1 == "" | |
2441 let treedir= s:NetrwTreePath(inittreetop) | |
2442 else | |
2443 if isdirectory(a:1) | |
2444 let treedir= a:1 | |
2445 elseif exists("b:netrw_curdir") && isdirectory(b:netrw_curdir."/".a:1) | |
2446 let treedir= b:netrw_curdir."/".a:1 | |
2447 else | |
2448 call netrw#ErrorMsg(s:ERROR,"sorry, ".a:1." doesn't seem to be a directory!",95) | |
2449 " call Dret("netrw#NetrwSetTreetop") | |
2450 return | |
2451 endif | |
2452 endif | |
2453 " call Decho("treedir<".treedir.">") | |
2454 sil! call netrw#LocalBrowseCheck(treedir) | |
2455 " call Dret("netrw#NetrwSetTreetop") | |
2456 endfun | |
2457 | |
2366 " =========================================== | 2458 " =========================================== |
2367 " s:NetrwGetFile: Function to read temporary file "tfile" with command "readcmd". {{{2 | 2459 " s:NetrwGetFile: Function to read temporary file "tfile" with command "readcmd". {{{2 |
2368 " readcmd == %r : replace buffer with newly read file | 2460 " readcmd == %r : replace buffer with newly read file |
2369 " == 0r : read file at top of buffer | 2461 " == 0r : read file at top of buffer |
2370 " == r : read file after current line | 2462 " == r : read file after current line |
2392 " get file into buffer | 2484 " get file into buffer |
2393 " call Decho("get file into buffer") | 2485 " call Decho("get file into buffer") |
2394 | 2486 |
2395 " rename the current buffer to the temp file (ie. tfile) | 2487 " rename the current buffer to the temp file (ie. tfile) |
2396 if g:netrw_cygwin | 2488 if g:netrw_cygwin |
2397 let tfile= substitute(a:tfile,'/cygdrive/\(.\)','\1:','') | 2489 let tfile= substitute(a:tfile,g:netrw_cygdrive.'/\(.\)','\1:','') |
2398 else | 2490 else |
2399 let tfile= a:tfile | 2491 let tfile= a:tfile |
2400 endif | 2492 endif |
2401 " call Decho("exe sil! keepalt file ".fnameescape(tfile)) | 2493 " call Decho("exe sil! keepalt file ".fnameescape(tfile)) |
2402 exe "sil! keepalt file ".fnameescape(tfile) | 2494 exe "sil! keepalt file ".fnameescape(tfile) |
2433 " Note that isk must not include a "/" for scripts.vim | 2525 " Note that isk must not include a "/" for scripts.vim |
2434 " to process this detection correctly. | 2526 " to process this detection correctly. |
2435 " call Decho("detect filetype of local version of remote file") | 2527 " call Decho("detect filetype of local version of remote file") |
2436 let iskkeep= &l:isk | 2528 let iskkeep= &l:isk |
2437 setl isk-=/ | 2529 setl isk-=/ |
2530 " filetype detect " COMBAK - trying filetype detect in NetrwOptionRestore Jan 24, 2013 | |
2438 let &l:isk= iskkeep | 2531 let &l:isk= iskkeep |
2439 " call Dredir("renamed buffer back to remote filename<".rfile."> : expand(%)<".expand("%").">","ls!") | 2532 " call Dredir("renamed buffer back to remote filename<".rfile."> : expand(%)<".expand("%").">","ls!") |
2440 let line1 = 1 | 2533 let line1 = 1 |
2441 let line2 = line("$") | 2534 let line2 = line("$") |
2535 | |
2536 elseif !&ma | |
2537 " attempting to read a file after the current line in the file, but the buffer is not modifiable | |
2538 keepj call netrw#ErrorMsg(s:WARNING,"attempt to read<".a:tfile."> into a non-modifiable buffer!",94) | |
2539 " call Dret("NetrwGetFile : attempt to read<".a:tfile."> into a non-modifiable buffer!") | |
2540 return | |
2442 | 2541 |
2443 elseif s:FileReadable(a:tfile) | 2542 elseif s:FileReadable(a:tfile) |
2444 " read file after current line | 2543 " read file after current line |
2445 " call Decho("read file<".a:tfile."> after current line") | 2544 " call Decho("read file<".a:tfile."> after current line") |
2446 let curline = line(".") | 2545 let curline = line(".") |
2910 if a:islocal | 3009 if a:islocal |
2911 " call Decho("(NetrwMaps) make local maps") | 3010 " call Decho("(NetrwMaps) make local maps") |
2912 " local normal-mode maps | 3011 " local normal-mode maps |
2913 nnoremap <buffer> <silent> a :call <SID>NetrwHide(1)<cr> | 3012 nnoremap <buffer> <silent> a :call <SID>NetrwHide(1)<cr> |
2914 nnoremap <buffer> <silent> % :call <SID>NetrwOpenFile(1)<cr> | 3013 nnoremap <buffer> <silent> % :call <SID>NetrwOpenFile(1)<cr> |
2915 nnoremap <buffer> <silent> c :exe "keepjumps lcd ".fnameescape(b:netrw_curdir)<cr> | 3014 nnoremap <buffer> <silent> c :exe "keepj lcd ".fnameescape(b:netrw_curdir)<cr> |
2916 nnoremap <buffer> <silent> C :let g:netrw_chgwin= winnr()<cr> | 3015 nnoremap <buffer> <silent> C :let g:netrw_chgwin= winnr()<cr> |
2917 nnoremap <buffer> <silent> <cr> :call netrw#LocalBrowseCheck(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord()))<cr> | 3016 nnoremap <buffer> <silent> <cr> :call netrw#LocalBrowseCheck(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord()))<cr> |
2918 nnoremap <buffer> <silent> d :call <SID>NetrwMakeDir("")<cr> | 3017 nnoremap <buffer> <silent> d :call <SID>NetrwMakeDir("")<cr> |
2919 nnoremap <buffer> <silent> - :exe "norm! 0"<bar>call netrw#LocalBrowseCheck(<SID>NetrwBrowseChgDir(1,'../'))<cr> | 3018 nnoremap <buffer> <silent> - :exe "norm! 0"<bar>call netrw#LocalBrowseCheck(<SID>NetrwBrowseChgDir(1,'../'))<cr> |
2920 nnoremap <buffer> <silent> gb :<c-u>call <SID>NetrwBookHistHandler(1,b:netrw_curdir)<cr> | 3019 nnoremap <buffer> <silent> gb :<c-u>call <SID>NetrwBookHistHandler(1,b:netrw_curdir)<cr> |
3027 nnoremap <buffer> <silent> <s-up> :Pexplore<cr> | 3126 nnoremap <buffer> <silent> <s-up> :Pexplore<cr> |
3028 inoremap <buffer> <silent> <s-up> :Pexplore<cr> | 3127 inoremap <buffer> <silent> <s-up> :Pexplore<cr> |
3029 endif | 3128 endif |
3030 let mapsafecurdir = escape(b:netrw_curdir, s:netrw_map_escape) | 3129 let mapsafecurdir = escape(b:netrw_curdir, s:netrw_map_escape) |
3031 if g:netrw_mousemaps == 1 | 3130 if g:netrw_mousemaps == 1 |
3032 nmap <buffer> <leftmouse> <Plug>NetrwLeftmouse | 3131 nmap <buffer> <leftmouse> <Plug>NetrwLeftmouse |
3033 nno <buffer> <silent> <Plug>NetrwLeftmouse <leftmouse>:call <SID>NetrwLeftmouse(1)<cr> | 3132 nno <buffer> <silent> <Plug>NetrwLeftmouse <leftmouse>:call <SID>NetrwLeftmouse(1)<cr> |
3034 nmap <buffer> <s-rightdrag> <Plug>NetrwRightdrag | 3133 nmap <buffer> <middlemouse> <Plug>NetrwMiddlemouse |
3035 nno <buffer> <silent> <Plug>NetrwRightdrag <leftmouse>:call <SID>NetrwRightdrag(1)<cr> | 3134 nno <buffer> <silent> <Plug>NetrwMiddlemouse <leftmouse>:call <SID>NetrwPrevWinOpen(1)<cr> |
3036 nmap <buffer> <middlemouse> <Plug>NetrwMiddlemouse | 3135 nmap <buffer> <s-leftmouse> <Plug>NetrwSLeftmouse |
3037 nno <buffer> <silent> <Plug>NetrwMiddlemouse <leftmouse>:call <SID>NetrwPrevWinOpen(1)<cr> | 3136 nno <buffer> <silent> <Plug>NetrwSLeftmouse <leftmouse>:call <SID>NetrwSLeftmouse(1)<cr> |
3038 nmap <buffer> <s-leftmouse> <Plug>NetrwSLeftmouse | 3137 nmap <buffer> <s-leftdrag> <Plug>NetrwSLeftdrag |
3039 nno <buffer> <silent> <Plug>NetrwSLeftmouse <leftmouse>:call <SID>NetrwMarkFile(1,<SID>NetrwGetWord())<cr> | 3138 nno <buffer> <silent> <Plug>NetrwSLeftdrag <leftmouse>:call <SID>NetrwSLeftdrag(1)<cr> |
3040 nmap <buffer> <2-leftmouse> <Plug>Netrw2Leftmouse | 3139 nmap <buffer> <2-leftmouse> <Plug>Netrw2Leftmouse |
3041 nmap <buffer> <silent> <Plug>Netrw2Leftmouse - | 3140 nmap <buffer> <silent> <Plug>Netrw2Leftmouse - |
3042 imap <buffer> <leftmouse> <Plug>ILeftmouse | 3141 imap <buffer> <leftmouse> <Plug>ILeftmouse |
3043 ino <buffer> <silent> <Plug>ILeftmouse <c-o><leftmouse><c-o>:call <SID>NetrwLeftmouse(1)<cr> | 3142 ino <buffer> <silent> <Plug>ILeftmouse <c-o><leftmouse><c-o>:call <SID>NetrwLeftmouse(1)<cr> |
3044 imap <buffer> <middlemouse> <Plug>IMiddlemouse | 3143 imap <buffer> <middlemouse> <Plug>IMiddlemouse |
3045 ino <buffer> <silent> <Plug>IMiddlemouse <c-o><leftmouse><c-o>:call <SID>NetrwPrevWinOpen(1)<cr> | 3144 ino <buffer> <silent> <Plug>IMiddlemouse <c-o><leftmouse><c-o>:call <SID>NetrwPrevWinOpen(1)<cr> |
3046 imap <buffer> <s-leftmouse> <Plug>ISLeftmouse | 3145 imap <buffer> <s-leftmouse> <Plug>ISLeftmouse |
3047 ino <buffer> <silent> <Plug>ISLeftmouse <c-o><leftmouse><c-o>:call <SID>NetrwMarkFile(1,<SID>NetrwGetWord())<cr> | 3146 ino <buffer> <silent> <Plug>ISLeftmouse <c-o><leftmouse><c-o>:call <SID>NetrwMarkFile(1,<SID>NetrwGetWord())<cr> |
3048 exe 'nnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' | 3147 exe 'nnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' |
3049 exe 'vnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' | 3148 exe 'vnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' |
3050 exe 'inoremap <buffer> <silent> <rightmouse> <c-o><leftmouse><c-o>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' | 3149 exe 'inoremap <buffer> <silent> <rightmouse> <c-o><leftmouse><c-o>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' |
3051 endif | 3150 endif |
3052 exe 'nnoremap <buffer> <silent> <del> :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' | 3151 exe 'nnoremap <buffer> <silent> <del> :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' |
3053 exe 'nnoremap <buffer> <silent> D :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' | 3152 exe 'nnoremap <buffer> <silent> D :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' |
3054 exe 'nnoremap <buffer> <silent> R :call <SID>NetrwLocalRename("'.mapsafecurdir.'")<cr>' | 3153 exe 'nnoremap <buffer> <silent> R :call <SID>NetrwLocalRename("'.mapsafecurdir.'")<cr>' |
3055 exe 'nnoremap <buffer> <silent> <Leader>m :call <SID>NetrwMakeDir("")<cr>' | 3154 exe 'nnoremap <buffer> <silent> d :call <SID>NetrwMakeDir("")<cr>' |
3056 exe 'vnoremap <buffer> <silent> <del> :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' | 3155 exe 'vnoremap <buffer> <silent> <del> :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' |
3057 exe 'vnoremap <buffer> <silent> D :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' | 3156 exe 'vnoremap <buffer> <silent> D :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' |
3058 exe 'vnoremap <buffer> <silent> R :call <SID>NetrwLocalRename("'.mapsafecurdir.'")<cr>' | 3157 exe 'vnoremap <buffer> <silent> R :call <SID>NetrwLocalRename("'.mapsafecurdir.'")<cr>' |
3059 exe 'inoremap <buffer> <silent> <del> <c-o>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' | 3158 exe 'inoremap <buffer> <silent> <del> <c-o>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' |
3060 exe 'inoremap <buffer> <silent> D <c-o>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' | 3159 exe 'inoremap <buffer> <silent> D <c-o>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' |
3061 exe 'inoremap <buffer> <silent> R <c-o>:call <SID>NetrwLocalRename("'.mapsafecurdir.'")<cr>' | 3160 exe 'inoremap <buffer> <silent> R <c-o>:call <SID>NetrwLocalRename("'.mapsafecurdir.'")<cr>' |
3062 exe 'inoremap <buffer> <silent> <Leader>m <c-o>:call <SID>NetrwMakeDir("")<cr>' | 3161 exe 'inoremap <buffer> <silent> d <c-o>:call <SID>NetrwMakeDir("")<cr>' |
3063 nnoremap <buffer> <F1> :he netrw-quickhelp<cr> | 3162 nnoremap <buffer> <F1> :he netrw-quickhelp<cr> |
3064 | 3163 |
3065 else " remote | 3164 else " remote |
3066 " call Decho("(NetrwMaps) make remote maps") | 3165 " call Decho("(NetrwMaps) make remote maps") |
3067 call s:RemotePathAnalysis(b:netrw_curdir) | 3166 call s:RemotePathAnalysis(b:netrw_curdir) |
3068 " remote normal-mode maps | 3167 " remote normal-mode maps |
3179 if g:netrw_mousemaps == 1 | 3278 if g:netrw_mousemaps == 1 |
3180 nmap <leftmouse> <Plug>NetrwLeftmouse | 3279 nmap <leftmouse> <Plug>NetrwLeftmouse |
3181 nno <buffer> <silent> <Plug>NetrwLeftmouse <leftmouse>:call <SID>NetrwLeftmouse(0)<cr> | 3280 nno <buffer> <silent> <Plug>NetrwLeftmouse <leftmouse>:call <SID>NetrwLeftmouse(0)<cr> |
3182 nmap <buffer> <leftdrag> <Plug>NetrwLeftdrag | 3281 nmap <buffer> <leftdrag> <Plug>NetrwLeftdrag |
3183 nno <buffer> <silent> <Plug>NetrwLeftdrag :call <SID>NetrwLeftdrag(0)<cr> | 3282 nno <buffer> <silent> <Plug>NetrwLeftdrag :call <SID>NetrwLeftdrag(0)<cr> |
3283 nmap <buffer> <s-leftmouse> <Plug>NetrwSLeftmouse | |
3284 nno <buffer> <silent> <Plug>NetrwSLeftmouse <leftmouse>:call <SID>NetrwSLeftmouse(0)<cr> | |
3285 nmap <buffer> <s-leftdrag> <Plug>NetrwSLeftdrag | |
3286 nno <buffer> <silent> <Plug>NetrwSLeftdrag <leftmouse>:call <SID>NetrwSLeftdrag(0)<cr> | |
3184 nmap <middlemouse> <Plug>NetrwMiddlemouse | 3287 nmap <middlemouse> <Plug>NetrwMiddlemouse |
3185 nno <buffer> <silent> <middlemouse> <Plug>NetrwMiddlemouse <leftmouse>:call <SID>NetrwPrevWinOpen(0)<cr> | 3288 nno <buffer> <silent> <middlemouse> <Plug>NetrwMiddlemouse <leftmouse>:call <SID>NetrwPrevWinOpen(0)<cr> |
3186 nmap <buffer> <s-leftmouse> <Plug>NetrwSLeftmouse | |
3187 nno <buffer> <silent> <Plug>NetrwSLeftmouse <leftmouse>:call <SID>NetrwMarkFile(0,<SID>NetrwGetWord())<cr> | |
3188 nmap <buffer> <2-leftmouse> <Plug>Netrw2Leftmouse | 3289 nmap <buffer> <2-leftmouse> <Plug>Netrw2Leftmouse |
3189 nmap <buffer> <silent> <Plug>Netrw2Leftmouse - | 3290 nmap <buffer> <silent> <Plug>Netrw2Leftmouse - |
3190 imap <buffer> <leftmouse> <Plug>ILeftmouse | 3291 imap <buffer> <leftmouse> <Plug>ILeftmouse |
3191 ino <buffer> <silent> <Plug>ILeftmouse <c-o><leftmouse><c-o>:call <SID>NetrwLeftmouse(0)<cr> | 3292 ino <buffer> <silent> <Plug>ILeftmouse <c-o><leftmouse><c-o>:call <SID>NetrwLeftmouse(0)<cr> |
3192 imap <buffer> <middlemouse> <Plug>IMiddlemouse | 3293 imap <buffer> <middlemouse> <Plug>IMiddlemouse |
3342 sil! keepj %d | 3443 sil! keepj %d |
3343 setl nomod | 3444 setl nomod |
3344 " call Decho("(NetrwBookHistHandler) setl nomod") | 3445 " call Decho("(NetrwBookHistHandler) setl nomod") |
3345 " call Decho("(NetrwBookHistHandler) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") | 3446 " call Decho("(NetrwBookHistHandler) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") |
3346 endif | 3447 endif |
3347 " " call Decho("exe e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt})) | 3448 " call Decho("exe e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt})) |
3348 exe "keepj e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt}) | 3449 exe "keepj e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt}) |
3349 else | 3450 else |
3350 if g:netrw_dirhistmax > 0 | 3451 if g:netrw_dirhistmax > 0 |
3351 let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt + v:count1 ) % g:netrw_dirhistmax | 3452 let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt + v:count1 ) % g:netrw_dirhistmax |
3352 else | 3453 else |
3504 " with the requested remote hostname first. | 3605 " with the requested remote hostname first. |
3505 fun! s:NetrwBrowse(islocal,dirname) | 3606 fun! s:NetrwBrowse(islocal,dirname) |
3506 if !exists("w:netrw_liststyle")|let w:netrw_liststyle= g:netrw_liststyle|endif | 3607 if !exists("w:netrw_liststyle")|let w:netrw_liststyle= g:netrw_liststyle|endif |
3507 " call Dfunc("s:NetrwBrowse(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".w:netrw_liststyle." ".g:loaded_netrw." buf#".bufnr("%")."<".bufname("%")."> win#".winnr()) | 3608 " call Dfunc("s:NetrwBrowse(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".w:netrw_liststyle." ".g:loaded_netrw." buf#".bufnr("%")."<".bufname("%")."> win#".winnr()) |
3508 " call Decho("(NetrwBrowse) tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")." modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) | 3609 " call Decho("(NetrwBrowse) tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")." modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) |
3610 " call Dredir("ls!") | |
3509 " s:NetrwBrowse: initialize history {{{3 | 3611 " s:NetrwBrowse: initialize history {{{3 |
3510 if !exists("s:netrw_initbookhist") | 3612 if !exists("s:netrw_initbookhist") |
3511 keepj call s:NetrwBookHistRead() | 3613 keepj call s:NetrwBookHistRead() |
3512 endif | 3614 endif |
3513 | 3615 |
3623 " call Dret("s:NetrwBrowse : re-using buffer") | 3725 " call Dret("s:NetrwBrowse : re-using buffer") |
3624 return | 3726 return |
3625 endif | 3727 endif |
3626 | 3728 |
3627 " set b:netrw_curdir to the new directory name {{{3 | 3729 " set b:netrw_curdir to the new directory name {{{3 |
3628 " call Decho("(NetrwBrowse) set b:netrw_curdir to the new directory name: (buf#".bufnr("%").")") | 3730 " call Decho("(NetrwBrowse) set b:netrw_curdir to the new directory name<".dirname."> (buf#".bufnr("%").")") |
3629 let b:netrw_curdir= dirname | 3731 let b:netrw_curdir= dirname |
3630 if b:netrw_curdir =~ '[/\\]$' | 3732 if b:netrw_curdir =~ '[/\\]$' |
3631 let b:netrw_curdir= substitute(b:netrw_curdir,'[/\\]$','','e') | 3733 let b:netrw_curdir= substitute(b:netrw_curdir,'[/\\]$','','e') |
3734 endif | |
3735 if b:netrw_curdir =~ '\a:$' && (has("win32") || has("win95") || has("win64") || has("win16")) | |
3736 let b:netrw_curdir= b:netrw_curdir."/" | |
3632 endif | 3737 endif |
3633 if b:netrw_curdir == '' | 3738 if b:netrw_curdir == '' |
3634 if has("amiga") | 3739 if has("amiga") |
3635 " On the Amiga, the empty string connotes the current directory | 3740 " On the Amiga, the empty string connotes the current directory |
3636 let b:netrw_curdir= getcwd() | 3741 let b:netrw_curdir= getcwd() |
3657 " handle g:netrw_keepdir: set vim's current directory to netrw's notion of the current directory {{{3 | 3762 " handle g:netrw_keepdir: set vim's current directory to netrw's notion of the current directory {{{3 |
3658 if !g:netrw_keepdir | 3763 if !g:netrw_keepdir |
3659 " call Decho("(NetrwBrowse) handle g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd) | 3764 " call Decho("(NetrwBrowse) handle g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd) |
3660 " call Decho("(NetrwBrowse) l:acd".(exists("&l:acd")? "=".&l:acd : " doesn't exist")) | 3765 " call Decho("(NetrwBrowse) l:acd".(exists("&l:acd")? "=".&l:acd : " doesn't exist")) |
3661 if !exists("&l:acd") || !&l:acd | 3766 if !exists("&l:acd") || !&l:acd |
3662 " call Decho('exe keepjumps lcd '.fnameescape(b:netrw_curdir)) | 3767 " call Decho('(NetrwBrowse) exe keepj lcd '.fnameescape(b:netrw_curdir)) |
3663 try | 3768 try |
3664 exe 'keepj lcd '.fnameescape(b:netrw_curdir) | 3769 exe 'keepj lcd '.fnameescape(b:netrw_curdir) |
3665 catch /^Vim\%((\a\+)\)\=:E472/ | 3770 catch /^Vim\%((\a\+)\)\=:E472/ |
3666 call netrw#ErrorMsg(s:ERROR,"unable to change directory to <".b:netrw_curdir."> (permissions?)",61) | 3771 call netrw#ErrorMsg(s:ERROR,"unable to change directory to <".b:netrw_curdir."> (permissions?)",61) |
3667 if exists("w:netrw_prvdir") | 3772 if exists("w:netrw_prvdir") |
3744 endfun | 3849 endfun |
3745 | 3850 |
3746 " --------------------------------------------------------------------- | 3851 " --------------------------------------------------------------------- |
3747 " s:NetrwFileInfo: supports qf (query for file information) {{{2 | 3852 " s:NetrwFileInfo: supports qf (query for file information) {{{2 |
3748 fun! s:NetrwFileInfo(islocal,fname) | 3853 fun! s:NetrwFileInfo(islocal,fname) |
3749 " call Dfunc("s:NetrwFileInfo(islocal=".a:islocal." fname<".a:fname.">)") | 3854 " call Dfunc("s:NetrwFileInfo(islocal=".a:islocal." fname<".a:fname.">) b:netrw_curdir<".b:netrw_curdir.">") |
3750 let ykeep= @@ | 3855 let ykeep= @@ |
3751 if a:islocal | 3856 if a:islocal |
3752 if (has("unix") || has("macunix")) && executable("/bin/ls") | 3857 if (has("unix") || has("macunix")) && executable("/bin/ls") |
3753 if exists("b:netrw_curdir") | 3858 |
3754 " call Decho('using ls with b:netrw_curdir<'.b:netrw_curdir.'>') | 3859 if getline(".") == "../" |
3860 echo system("/bin/ls -lsad ".shellescape("..")) | |
3861 " call Decho("#1: echo system(/bin/ls -lsad ".shellescape(..).")") | |
3862 | |
3863 elseif getline(".") !~ '^'.s:treedepthstring | |
3864 echo system("/bin/ls -lsad ".shellescape(b:netrw_curdir)) | |
3865 " call Decho("#2: echo system(/bin/ls -lsad ".shellescape(b:netrw_curdir).")") | |
3866 | |
3867 elseif exists("b:netrw_curdir") | |
3755 if b:netrw_curdir =~ '/$' | 3868 if b:netrw_curdir =~ '/$' |
3756 echo system("/bin/ls -lsad ".shellescape(b:netrw_curdir.a:fname)) | 3869 echo system("/bin/ls -lsad ".shellescape(b:netrw_curdir.a:fname)) |
3870 " call Decho("#3: echo system(/bin/ls -lsad ".shellescape(b:netrw_curdir.a:fname).")") | |
3871 | |
3757 else | 3872 else |
3758 echo system("/bin/ls -lsad ".shellescape(b:netrw_curdir."/".a:fname)) | 3873 echo system("/bin/ls -lsad ".shellescape(b:netrw_curdir."/".a:fname)) |
3874 " call Decho("#4: echo system(/bin/ls -lsad ".shellescape(b:netrw_curdir."/".a:fname).")") | |
3759 endif | 3875 endif |
3876 | |
3760 else | 3877 else |
3761 " call Decho('using ls '.a:fname." using cwd<".getcwd().">") | 3878 " call Decho('using ls '.a:fname." using cwd<".getcwd().">") |
3762 echo system("/bin/ls -lsad ".shellescape(a:fname)) | 3879 echo system("/bin/ls -lsad ".shellescape(a:fname)) |
3880 " call Decho("#5: echo system(/bin/ls -lsad ".shellescape(a:fname).")") | |
3763 endif | 3881 endif |
3764 else | 3882 else |
3765 " use vim functions to return information about file below cursor | 3883 " use vim functions to return information about file below cursor |
3766 " call Decho("using vim functions to query for file info") | 3884 " call Decho("using vim functions to query for file info") |
3767 if !isdirectory(a:fname) && !filereadable(a:fname) && a:fname =~ '[*@/]' | 3885 if !isdirectory(a:fname) && !filereadable(a:fname) && a:fname =~ '[*@/]' |
3785 " s:NetrwGetBuffer: {{{2 | 3903 " s:NetrwGetBuffer: {{{2 |
3786 " returns 0=cleared buffer | 3904 " returns 0=cleared buffer |
3787 " 1=re-used buffer | 3905 " 1=re-used buffer |
3788 fun! s:NetrwGetBuffer(islocal,dirname) | 3906 fun! s:NetrwGetBuffer(islocal,dirname) |
3789 " call Dfunc("s:NetrwGetBuffer(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".g:netrw_liststyle) | 3907 " call Dfunc("s:NetrwGetBuffer(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".g:netrw_liststyle) |
3790 " call Decho("(NetrwGetBuffer) modiable=".&mod." modifiable=".&ma." readonly=".&ro) | 3908 " call Decho("(NetrwGetBuffer) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) |
3791 let dirname= a:dirname | 3909 let dirname= a:dirname |
3792 | 3910 |
3793 " re-use buffer if possible {{{3 | 3911 " re-use buffer if possible {{{3 |
3794 " call Decho("(NetrwGetBuffer) --re-use a buffer if possible--") | 3912 " call Decho("(NetrwGetBuffer) --re-use a buffer if possible--") |
3795 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST | 3913 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST |
3796 " find NetrwTreeList buffer if there is one | 3914 " find NetrwTreeList buffer if there is one |
3797 " call Decho("(NetrwGetBuffer) case liststyle=treelist: find NetrwTreeList buffer if there is one") | 3915 " call Decho("(NetrwGetBuffer) case liststyle=treelist: find NetrwTreeList buffer if there is one") |
3798 if exists("w:netrw_treebufnr") && w:netrw_treebufnr > 0 | 3916 if exists("w:netrw_treebufnr") && w:netrw_treebufnr > 0 |
3799 " call Decho("(NetrwGetBuffer) re-using w:netrw_treebufnr=".w:netrw_treebufnr) | 3917 " call Decho("(NetrwGetBuffer) re-using w:netrw_treebufnr=".w:netrw_treebufnr) |
3800 setl mod | |
3801 sil! keepj %d | |
3802 let eikeep= &ei | 3918 let eikeep= &ei |
3803 set ei=all | 3919 set ei=all |
3804 exe "sil! keepalt b ".w:netrw_treebufnr | 3920 exe "sil! keepalt b ".w:netrw_treebufnr |
3805 let &ei= eikeep | 3921 let &ei= eikeep |
3922 setl ma | |
3923 sil! keepj %d | |
3924 " call Decho("(NetrwGetBuffer) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) | |
3806 " call Dret("s:NetrwGetBuffer 0<buffer cleared> : bufnum#".w:netrw_treebufnr."<NetrwTreeListing>") | 3925 " call Dret("s:NetrwGetBuffer 0<buffer cleared> : bufnum#".w:netrw_treebufnr."<NetrwTreeListing>") |
3807 return 0 | 3926 return 0 |
3808 endif | 3927 endif |
3809 let bufnum= -1 | 3928 let bufnum= -1 |
3810 " call Decho("(NetrwGetBuffer) liststyle=TREE but w:netrw_treebufnr doesn't exist") | 3929 " call Decho("(NetrwGetBuffer) liststyle=TREE but w:netrw_treebufnr doesn't exist") |
3811 | 3930 |
3812 else | 3931 else |
3813 " find buffer number of buffer named precisely the same as dirname {{{3 | 3932 " find buffer number of buffer named precisely the same as dirname {{{3 |
3814 " call Decho("(NetrwGetBuffer) case listtyle not treelist: find buffer numnber of buffer named precisely the same as dirname--") | 3933 " call Decho("(NetrwGetBuffer) case listtyle not treelist: find buffer numnber of buffer named precisely the same as dirname--") |
3934 " call Dredir("(NetrwGetBuffer) ls!","ls!") | |
3815 | 3935 |
3816 " get dirname and associated buffer number | 3936 " get dirname and associated buffer number |
3817 let bufnum = bufnr(escape(dirname,'\')) | 3937 let bufnum = bufnr(escape(dirname,'\')) |
3818 " call Decho("(NetrwGetBuffer) find buffer<".dirname.">'s number ") | 3938 " call Decho("(NetrwGetBuffer) find buffer<".dirname.">'s number ") |
3819 " call Decho("(NetrwGetBuffer) bufnr(dirname<".escape(dirname,'\').">)=".bufnum) | 3939 " call Decho("(NetrwGetBuffer) bufnr(dirname<".escape(dirname,'\').">)=".bufnum) |
3931 exe "sil! keepalt file ".fnameescape(getcwd()) | 4051 exe "sil! keepalt file ".fnameescape(getcwd()) |
3932 endif | 4052 endif |
3933 let &ei= eikeep | 4053 let &ei= eikeep |
3934 if line("$") <= 1 | 4054 if line("$") <= 1 |
3935 keepj call s:NetrwListSettings(a:islocal) | 4055 keepj call s:NetrwListSettings(a:islocal) |
4056 " call Decho("(NetrwGetBuffer) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) | |
3936 " call Dret("s:NetrwGetBuffer 0<buffer empty> : re-using buffer#".bufnr("%").", but its empty, so refresh it") | 4057 " call Dret("s:NetrwGetBuffer 0<buffer empty> : re-using buffer#".bufnr("%").", but its empty, so refresh it") |
3937 return 0 | 4058 return 0 |
3938 elseif g:netrw_fastbrowse == 0 || (a:islocal && g:netrw_fastbrowse == 1) | 4059 elseif g:netrw_fastbrowse == 0 || (a:islocal && g:netrw_fastbrowse == 1) |
3939 keepj call s:NetrwListSettings(a:islocal) | 4060 keepj call s:NetrwListSettings(a:islocal) |
3940 sil keepj %d | 4061 sil keepj %d |
4062 " call Decho("(NetrwGetBuffer) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) | |
3941 " call Dret("s:NetrwGetBuffer 0<cleared buffer> : re-using buffer#".bufnr("%").", but refreshing due to g:netrw_fastbrowse=".g:netrw_fastbrowse) | 4063 " call Dret("s:NetrwGetBuffer 0<cleared buffer> : re-using buffer#".bufnr("%").", but refreshing due to g:netrw_fastbrowse=".g:netrw_fastbrowse) |
3942 return 0 | 4064 return 0 |
3943 elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST | 4065 elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST |
3944 " call Decho("(NetrwGetBuffer) --re-use tree listing--") | 4066 " call Decho("(NetrwGetBuffer) --re-use tree listing--") |
3945 " call Decho("(NetrwGetBuffer) clear buffer<".expand("%")."> with :%d") | 4067 " call Decho("(NetrwGetBuffer) clear buffer<".expand("%")."> with :%d") |
3946 sil keepj %d | 4068 sil keepj %d |
3947 keepj call s:NetrwListSettings(a:islocal) | 4069 keepj call s:NetrwListSettings(a:islocal) |
4070 " call Decho("(NetrwGetBuffer) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) | |
3948 " call Dret("s:NetrwGetBuffer 0<cleared buffer> : re-using buffer#".bufnr("%").", but treelist mode always needs a refresh") | 4071 " call Dret("s:NetrwGetBuffer 0<cleared buffer> : re-using buffer#".bufnr("%").", but treelist mode always needs a refresh") |
3949 return 0 | 4072 return 0 |
3950 else | 4073 else |
4074 " call Decho("(NetrwGetBuffer) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) | |
3951 " call Dret("s:NetrwGetBuffer 1<buffer not cleared> : buf#".bufnr("%")) | 4075 " call Dret("s:NetrwGetBuffer 1<buffer not cleared> : buf#".bufnr("%")) |
3952 return 1 | 4076 return 1 |
3953 endif | 4077 endif |
3954 endif | 4078 endif |
3955 | 4079 |
3967 " delete all lines from buffer {{{3 | 4091 " delete all lines from buffer {{{3 |
3968 " call Decho("(NetrwGetBuffer) --delete all lines from buffer--") | 4092 " call Decho("(NetrwGetBuffer) --delete all lines from buffer--") |
3969 " call Decho("(NetrwGetBuffer) clear buffer<".expand("%")."> with :%d") | 4093 " call Decho("(NetrwGetBuffer) clear buffer<".expand("%")."> with :%d") |
3970 sil! keepalt keepj %d | 4094 sil! keepalt keepj %d |
3971 | 4095 |
3972 " call Dret("s:NetrwGetBuffer 0<cleared buffer> : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) | 4096 " call Decho("(NetrwGetBuffer) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) |
4097 " call Dret("s:NetrwGetBuffer 0<cleared buffer> : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")) | |
3973 return 0 | 4098 return 0 |
3974 endfun | 4099 endfun |
3975 | 4100 |
3976 " --------------------------------------------------------------------- | 4101 " --------------------------------------------------------------------- |
3977 " s:NetrwGetcwd: get the current directory. {{{2 | 4102 " s:NetrwGetcwd: get the current directory. {{{2 |
4046 keepj norm! 0 | 4171 keepj norm! 0 |
4047 let dirname= substitute(getline('.'),'^\(\%(\S\+ \)*\S\+\).\{-}$','\1','e') | 4172 let dirname= substitute(getline('.'),'^\(\%(\S\+ \)*\S\+\).\{-}$','\1','e') |
4048 | 4173 |
4049 elseif w:netrw_liststyle == s:TREELIST | 4174 elseif w:netrw_liststyle == s:TREELIST |
4050 " call Decho("treelist handling") | 4175 " call Decho("treelist handling") |
4051 let dirname= substitute(getline('.'),'^\(| \)*','','e') | 4176 let dirname= substitute(getline('.'),'^\('.s:treedepthstring.'\)*','','e') |
4052 | 4177 |
4053 else | 4178 else |
4054 " call Decho("obtain word from wide listing") | 4179 " call Decho("obtain word from wide listing") |
4055 let dirname= getline('.') | 4180 let dirname= getline('.') |
4056 | 4181 |
4098 | 4223 |
4099 " --------------------------------------------------------------------- | 4224 " --------------------------------------------------------------------- |
4100 " s:NetrwListSettings: make standard settings for a netrw listing {{{2 | 4225 " s:NetrwListSettings: make standard settings for a netrw listing {{{2 |
4101 fun! s:NetrwListSettings(islocal) | 4226 fun! s:NetrwListSettings(islocal) |
4102 " call Dfunc("s:NetrwListSettings(islocal=".a:islocal.")") | 4227 " call Dfunc("s:NetrwListSettings(islocal=".a:islocal.")") |
4228 " call Decho("(s:NetrwListSettings) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) | |
4103 let fname= bufname("%") | 4229 let fname= bufname("%") |
4104 " call Decho("(NetrwListSettings) setl bt=nofile nobl ma nonu nowrap noro") | 4230 " call Decho("(NetrwListSettings) setl bt=nofile nobl ma nonu nowrap noro") |
4105 setl bt=nofile nobl ma nonu nowrap noro | 4231 setl bt=nofile nobl ma nonu nowrap noro |
4106 " call Decho("(NetrwListSettings) exe sil! keepalt file ".fnameescape(fname)) | 4232 " call Decho("(NetrwListSettings) exe sil! keepalt file ".fnameescape(fname)) |
4107 exe "sil! keepalt file ".fnameescape(fname) | 4233 exe "sil! keepalt file ".fnameescape(fname) |
4108 if g:netrw_use_noswf | 4234 if g:netrw_use_noswf |
4109 setl noswf | 4235 setl noswf |
4110 endif | 4236 endif |
4237 " call Dredir("ls!") | |
4111 " call Decho("(NetrwListSettings) exe setl ts=".(g:netrw_maxfilenamelen+1)) | 4238 " call Decho("(NetrwListSettings) exe setl ts=".(g:netrw_maxfilenamelen+1)) |
4112 exe "setl ts=".(g:netrw_maxfilenamelen+1) | 4239 exe "setl ts=".(g:netrw_maxfilenamelen+1) |
4113 setl isk+=.,~,- | 4240 setl isk+=.,~,- |
4114 if g:netrw_fastbrowse > a:islocal | 4241 if g:netrw_fastbrowse > a:islocal |
4115 setl bh=hide | 4242 setl bh=hide |
4116 else | 4243 else |
4117 setl bh=delete | 4244 setl bh=delete |
4118 endif | 4245 endif |
4246 " call Decho("(s:NetrwListSettings) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) | |
4119 " call Dret("s:NetrwListSettings") | 4247 " call Dret("s:NetrwListSettings") |
4120 endfun | 4248 endfun |
4121 | 4249 |
4122 " --------------------------------------------------------------------- | 4250 " --------------------------------------------------------------------- |
4123 " s:NetrwListStyle: {{{2 | 4251 " s:NetrwListStyle: {{{2 |
4237 | 4365 |
4238 " show bookmarked places | 4366 " show bookmarked places |
4239 if exists("g:netrw_bookmarklist") && g:netrw_bookmarklist != [] && g:netrw_dirhistmax > 0 | 4367 if exists("g:netrw_bookmarklist") && g:netrw_bookmarklist != [] && g:netrw_dirhistmax > 0 |
4240 let cnt= 1 | 4368 let cnt= 1 |
4241 for bmd in g:netrw_bookmarklist | 4369 for bmd in g:netrw_bookmarklist |
4242 let ebmd= escape(bmd,g:netrw_menu_escape) | 4370 " call Decho('sil! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmark.'.bmd.' :e '.bmd) |
4243 " call Decho('sil! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmark.'.ebmd.' :e '.bmd) | 4371 let bmd= escape(bmd,g:netrw_menu_escape) |
4244 | 4372 |
4245 " show bookmarks for goto menu | 4373 " show bookmarks for goto menu |
4246 exe 'sil! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmarks.'.ebmd.' :e '.bmd."\<cr>" | 4374 exe 'sil! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmarks.'.bmd.' :e '.bmd."\<cr>" |
4247 | 4375 |
4248 " show bookmarks for deletion menu | 4376 " show bookmarks for deletion menu |
4249 exe 'sil! menu '.g:NetrwMenuPriority.".8.2.".cnt." ".g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Bookmark\ Delete.'.ebmd.' '.cnt."mB" | 4377 exe 'sil! menu '.g:NetrwMenuPriority.".8.2.".cnt." ".g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Bookmark\ Delete.'.bmd.' '.cnt."mB" |
4250 let cnt= cnt + 1 | 4378 let cnt= cnt + 1 |
4251 endfor | 4379 endfor |
4252 | 4380 |
4253 endif | 4381 endif |
4254 | 4382 |
4290 " Don't try to change-directory: this can happen, for example, when netrw#ErrorMsg has been called | 4418 " Don't try to change-directory: this can happen, for example, when netrw#ErrorMsg has been called |
4291 " and the current window is the NetrwMessage window. | 4419 " and the current window is the NetrwMessage window. |
4292 let @@= ykeep | 4420 let @@= ykeep |
4293 " call Decho("(NetrwBrowseChgDir) b:netrw_curdir doesn't exist!") | 4421 " call Decho("(NetrwBrowseChgDir) b:netrw_curdir doesn't exist!") |
4294 " call Decho("(NetrwBrowseChgDir) getcwd<".getcwd().">") | 4422 " call Decho("(NetrwBrowseChgDir) getcwd<".getcwd().">") |
4423 " call Dredir("ls!") | |
4295 " call Dret("s:NetrwBrowseChgDir") | 4424 " call Dret("s:NetrwBrowseChgDir") |
4296 return | 4425 return |
4297 endif | 4426 endif |
4298 | 4427 |
4299 " NetrwBrowseChgDir: save options and initialize {{{3 | 4428 " NetrwBrowseChgDir: save options and initialize {{{3 |
4429 " call Decho("(NetrwBrowseChgDir) saving options") | |
4300 keepj call s:NetrwOptionSave("s:") | 4430 keepj call s:NetrwOptionSave("s:") |
4301 keepj call s:NetrwSafeOptions() | 4431 keepj call s:NetrwSafeOptions() |
4302 let nbcd_curpos = netrw#NetrwSavePosn() | 4432 let nbcd_curpos = netrw#NetrwSavePosn() |
4303 let s:nbcd_curpos_{bufnr('%')} = nbcd_curpos | 4433 let s:nbcd_curpos_{bufnr('%')} = nbcd_curpos |
4304 " call Decho("(NetrwBrowseChgDir) setting s:nbcd_curpos_".bufnr('%')." to SavePosn") | 4434 " call Decho("(NetrwBrowseChgDir) setting s:nbcd_curpos_".bufnr('%')." to SavePosn") |
4309 endif | 4439 endif |
4310 let newdir = a:newdir | 4440 let newdir = a:newdir |
4311 let dolockout = 0 | 4441 let dolockout = 0 |
4312 | 4442 |
4313 " set up o/s-dependent directory recognition pattern | 4443 " set up o/s-dependent directory recognition pattern |
4444 " call Decho("(NetrwBrowseChgDir) set up o/s-dependent directory recognition pattern") | |
4314 if has("amiga") | 4445 if has("amiga") |
4315 let dirpat= '[\/:]$' | 4446 let dirpat= '[\/:]$' |
4316 else | 4447 else |
4317 let dirpat= '[\/]$' | 4448 let dirpat= '[\/]$' |
4318 endif | 4449 endif |
4333 | 4464 |
4334 " save position for benefit of Rexplore | 4465 " save position for benefit of Rexplore |
4335 let s:rexposn_{bufnr("%")}= netrw#NetrwSavePosn() | 4466 let s:rexposn_{bufnr("%")}= netrw#NetrwSavePosn() |
4336 | 4467 |
4337 " call Decho("(NetrwBrowseChgDir:edit-a-file) setting s:rexposn_".bufnr("%")." to SavePosn") | 4468 " call Decho("(NetrwBrowseChgDir:edit-a-file) setting s:rexposn_".bufnr("%")." to SavePosn") |
4469 " call Decho("(NetrwBrowseChgDir:edit-a-file) win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> ft=".&ft) | |
4338 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") && newdir !~ '^\(/\|\a:\)' | 4470 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") && newdir !~ '^\(/\|\a:\)' |
4471 " call Decho("(NetrwBrowseChgDir:edit-a-file) handle tree listing: w:netrw_treedict<".(exists("w:netrw_treedict")? string(w:netrw_treedict) : 'n/a').">") | |
4339 let dirname= s:NetrwTreeDir() | 4472 let dirname= s:NetrwTreeDir() |
4340 if dirname =~ '/$' | 4473 if dirname =~ '/$' |
4341 let dirname= dirname.newdir | 4474 let dirname= dirname.newdir |
4342 else | 4475 else |
4343 let dirname= s:NetrwTreeDir()."/".newdir | 4476 let dirname= dirname."/".newdir |
4344 endif | 4477 endif |
4345 " call Decho("(NetrwBrowseChgDir:edit-a-file) dirname<".dirname.">") | 4478 " call Decho("(NetrwBrowseChgDir:edit-a-file) dirname<".dirname.">") |
4346 " call Decho("(NetrwBrowseChgDir:edit-a-file) tree listing") | 4479 " call Decho("(NetrwBrowseChgDir:edit-a-file) tree listing") |
4347 elseif newdir =~ '^\(/\|\a:\)' | 4480 elseif newdir =~ '^\(/\|\a:\)' |
4348 let dirname= newdir | 4481 let dirname= newdir |
4389 endif | 4522 endif |
4390 endif | 4523 endif |
4391 | 4524 |
4392 " the point where netrw actually edits the (local) file | 4525 " the point where netrw actually edits the (local) file |
4393 " if its local only: LocalBrowseCheck() doesn't edit a file, but NetrwBrowse() will | 4526 " if its local only: LocalBrowseCheck() doesn't edit a file, but NetrwBrowse() will |
4527 " no keepalt to support :e # to return to a directory listing | |
4394 if a:islocal | 4528 if a:islocal |
4395 " call Decho("(NetrwBrowseChgDir:edit-a-file) edit local file: exe e! ".fnameescape(dirname)) | 4529 " call Decho("(NetrwBrowseChgDir:edit-a-file) edit local file: exe e! ".fnameescape(dirname)) |
4396 exe "keepj keepalt e! ".fnameescape(dirname) | 4530 " some like c-^ to return to the last edited file |
4531 " others like c-^ to return to the netrw buffer | |
4532 if exists("g:netrw_altfile") && g:netrw_altfile | |
4533 exe "keepj keepalt e! ".fnameescape(dirname) | |
4534 else | |
4535 exe "keepj e! ".fnameescape(dirname) | |
4536 endif | |
4397 call s:NetrwCursor() | 4537 call s:NetrwCursor() |
4398 else | 4538 else |
4399 " call Decho("(NetrwBrowseChgDir:edit-a-file) remote file: NetrwBrowse will edit it") | 4539 " call Decho("(NetrwBrowseChgDir:edit-a-file) remote file: NetrwBrowse will edit it") |
4400 endif | 4540 endif |
4401 let dolockout= 1 | 4541 let dolockout= 1 |
4458 let dirname= substitute(dirname,'/$','','') | 4598 let dirname= substitute(dirname,'/$','','') |
4459 else | 4599 else |
4460 let dirname= substitute(dirname,'^\(.*[/:]\)\([^/]\+/$\)','\1','') | 4600 let dirname= substitute(dirname,'^\(.*[/:]\)\([^/]\+/$\)','\1','') |
4461 endif | 4601 endif |
4462 " call Decho("(NetrwBrowseChgDir:go-up) amiga: dirname<".dirname."> (go up one dir)") | 4602 " call Decho("(NetrwBrowseChgDir:go-up) amiga: dirname<".dirname."> (go up one dir)") |
4603 | |
4604 elseif !g:netrw_cygwin && (has("win32") || has("win95") || has("win64") || has("win16")) | |
4605 " windows | |
4606 if a:islocal | |
4607 let dirname= substitute(dirname,'^\(.*\)/\([^/]\+\)/$','\1','') | |
4608 if dirname == "" | |
4609 let dirname= '/' | |
4610 endif | |
4611 else | |
4612 let dirname= substitute(dirname,'^\(\a\+://.\{-}/\{1,2}\)\(.\{-}\)\([^/]\+\)/$','\1\2','') | |
4613 endif | |
4614 if dirname =~ '^\a:$' | |
4615 let dirname= dirname.'/' | |
4616 endif | |
4617 " call Decho("(NetrwBrowseChgDir:go-up) windows: dirname<".dirname."> (go up one dir)") | |
4463 | 4618 |
4464 else | 4619 else |
4465 " unix or cygwin | 4620 " unix or cygwin |
4466 " call Decho('(NetrwBrowseChgDir:go-up) case "go up one directory": newdir == "../" and unix or cygwin') | 4621 " call Decho('(NetrwBrowseChgDir:go-up) case "go up one directory": newdir == "../" and unix or cygwin') |
4467 if a:islocal | 4622 if a:islocal |
5031 " appears to be a status bar leftmouse click | 5186 " appears to be a status bar leftmouse click |
5032 let @@= ykeep | 5187 let @@= ykeep |
5033 " call Dret("s:NetrwLeftmouse : detected a status bar leftmouse click") | 5188 " call Dret("s:NetrwLeftmouse : detected a status bar leftmouse click") |
5034 return | 5189 return |
5035 endif | 5190 endif |
5036 if v:mouse_col != col('.') | 5191 " NOTE: following test is preventing leftmouse selection/deselection of directories and files in treelist mode (Dec 04, 2013) |
5037 let @@= ykeep | 5192 " Windows are separated by vertical separator bars - but the mouse seems to be doing what it should when dragging that bar |
5193 " without this test. | |
5194 " if v:mouse_col != col('.') | |
5195 " let @@= ykeep | |
5038 " call Dret("s:NetrwLeftmouse : detected a vertical separator bar leftmouse click") | 5196 " call Dret("s:NetrwLeftmouse : detected a vertical separator bar leftmouse click") |
5039 return | 5197 " return |
5040 endif | 5198 " endif |
5041 | 5199 |
5042 if a:islocal | 5200 if a:islocal |
5043 if exists("b:netrw_curdir") | 5201 if exists("b:netrw_curdir") |
5044 keepj call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,s:NetrwGetWord())) | 5202 keepj call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,s:NetrwGetWord())) |
5045 endif | 5203 endif |
5051 let @@= ykeep | 5209 let @@= ykeep |
5052 " call Dret("s:NetrwLeftmouse") | 5210 " call Dret("s:NetrwLeftmouse") |
5053 endfun | 5211 endfun |
5054 | 5212 |
5055 " --------------------------------------------------------------------- | 5213 " --------------------------------------------------------------------- |
5056 " s:NetrwRightdrag: {{{2 | 5214 " s:NetrwSLeftmouse: marks the file under the cursor. May be dragged to select additional files {{{2 |
5057 "DechoTabOn | 5215 fun! s:NetrwSLeftmouse(islocal) |
5058 fun! s:NetrwRightdrag(islocal) | 5216 " call Dfunc("s:NetrwSLeftmouse(islocal=".a:islocal.")") |
5059 " call Dfunc("s:NetrwRightdrag(islocal=".a:islocal.")") | 5217 |
5218 let s:ngw= s:NetrwGetWord() | |
5219 call s:NetrwMarkFile(a:islocal,s:ngw) | |
5220 | |
5221 " call Dret("s:NetrwSLeftmouse") | |
5222 endfun | |
5223 | |
5224 " --------------------------------------------------------------------- | |
5225 " s:NetrwSLeftdrag: invoked via a shift-leftmouse and dragging {{{2 | |
5226 " Used to mark multiple files. | |
5227 fun! s:NetrwSLeftdrag(islocal) | |
5228 " call Dfunc("s:NetrwSLeftdrag(islocal=".a:islocal.")") | |
5060 if !exists("s:netrwdrag") | 5229 if !exists("s:netrwdrag") |
5061 let s:netrwdrag = winnr() | 5230 let s:netrwdrag = winnr() |
5062 call s:NetrwMarkFile(a:islocal,s:NetrwGetWord()) | |
5063 if a:islocal | 5231 if a:islocal |
5064 nno <silent> <s-rightrelease> <leftmouse>:<c-u>call <SID>NetrwRightrelease(1)<cr> | 5232 nno <silent> <s-leftrelease> <leftmouse>:<c-u>call <SID>NetrwSLeftrelease(1)<cr> |
5065 else | 5233 else |
5066 nno <silent> <s-rightrelease> <leftmouse>:<c-u>call <SID>NetrwRightrelease(0)<cr> | 5234 nno <silent> <s-leftrelease> <leftmouse>:<c-u>call <SID>NetrwSLeftrelease(0)<cr> |
5067 endif | 5235 endif |
5068 endif | 5236 endif |
5069 " call Dret("s:NetrwRightdrag : s:netrwdrag=".s:netrwdrag." buf#".bufnr("%")) | 5237 let ngw = s:NetrwGetWord() |
5070 endfun | 5238 if !exists("s:ngw") || s:ngw != ngw |
5071 | 5239 call s:NetrwMarkFile(a:islocal,ngw) |
5072 " --------------------------------------------------------------------- | 5240 endif |
5073 " s:NetrwRightrelease: {{{2 | 5241 let s:ngw= ngw |
5074 fun! s:NetrwRightrelease(islocal) | 5242 " call Dret("s:NetrwSLeftdrag : s:netrwdrag=".s:netrwdrag." buf#".bufnr("%")) |
5075 " call Dfunc("s:NetrwRightrelease(islocal=".a:islocal.") s:netrwdrag=".s:netrwdrag." buf#".bufnr("%")) | 5243 endfun |
5244 | |
5245 " --------------------------------------------------------------------- | |
5246 " s:NetrwSLeftrelease: terminates shift-leftmouse dragging {{{2 | |
5247 fun! s:NetrwSLeftrelease(islocal) | |
5248 " call Dfunc("s:NetrwSLeftrelease(islocal=".a:islocal.") s:netrwdrag=".s:netrwdrag." buf#".bufnr("%")) | |
5076 if exists("s:netrwdrag") | 5249 if exists("s:netrwdrag") |
5077 nunmap <s-rightrelease> | 5250 nunmap <s-leftrelease> |
5078 let tgt = s:NetrwGetWord() | 5251 let ngw = s:NetrwGetWord() |
5079 " call Decho("target#1: ".tgt) | 5252 if !exists("s:ngw") || s:ngw != ngw |
5080 if tgt =~ '/$' && tgt !~ '^\./$' | 5253 call s:NetrwMarkFile(a:islocal,ngw) |
5081 let tgt = b:netrw_curdir."/".tgt | 5254 endif |
5082 else | 5255 if exists("s:ngw") |
5083 let tgt= b:netrw_curdir | 5256 unlet s:ngw |
5084 endif | 5257 endif |
5085 " call Decho("target#2: ".tgt) | |
5086 call netrw#NetrwMakeTgt(tgt) | |
5087 let curwin= winnr() | |
5088 exe s:netrwdrag."wincmd w" | |
5089 call s:NetrwMarkFileMove(a:islocal) | |
5090 exe curwin."wincmd w" | |
5091 unlet s:netrwdrag | 5258 unlet s:netrwdrag |
5092 endif | 5259 endif |
5093 " call Dret("s:NetrwRightrelease") | 5260 " call Dret("s:NetrwSLeftrelease") |
5094 endfun | 5261 endfun |
5095 | 5262 |
5096 " --------------------------------------------------------------------- | 5263 " --------------------------------------------------------------------- |
5097 " s:NetrwListHide: uses [range]g~...~d to delete files that match comma {{{2 | 5264 " s:NetrwListHide: uses [range]g~...~d to delete files that match comma {{{2 |
5098 " separated patterns given in g:netrw_list_hide | 5265 " separated patterns given in g:netrw_list_hide |
5230 endif | 5397 endif |
5231 | 5398 |
5232 " requested new local directory is neither a pre-existing file or | 5399 " requested new local directory is neither a pre-existing file or |
5233 " directory, so make it! | 5400 " directory, so make it! |
5234 if exists("*mkdir") | 5401 if exists("*mkdir") |
5235 call mkdir(fullnewdir,"p") | 5402 if has("unix") |
5403 call mkdir(fullnewdir,"p",xor(0777, system("umask"))) | |
5404 else | |
5405 call mkdir(fullnewdir,"p") | |
5406 endif | |
5236 else | 5407 else |
5237 let netrw_origdir= s:NetrwGetcwd(1) | 5408 let netrw_origdir= s:NetrwGetcwd(1) |
5238 exe 'keepj lcd '.fnameescape(b:netrw_curdir) | 5409 exe 'keepj lcd '.fnameescape(b:netrw_curdir) |
5239 " call Decho("netrw_origdir<".netrw_origdir.">: lcd b:netrw_curdir<".fnameescape(b:netrw_curdir).">") | 5410 " call Decho("netrw_origdir<".netrw_origdir.">: lcd b:netrw_curdir<".fnameescape(b:netrw_curdir).">") |
5240 " call Decho("exe sil! !".g:netrw_localmkdir.' '.shellescape(newdirname,1)) | 5411 " call Decho("exe sil! !".g:netrw_localmkdir.' '.shellescape(newdirname,1)) |
5931 exe "sil! keepalt e ".fnameescape(fname) | 6102 exe "sil! keepalt e ".fnameescape(fname) |
5932 " call Decho("local<".fname.">: exe ".cmd) | 6103 " call Decho("local<".fname.">: exe ".cmd) |
5933 exe cmd | 6104 exe cmd |
5934 exe "sil! keepalt wq!" | 6105 exe "sil! keepalt wq!" |
5935 else | 6106 else |
6107 " COMBAK -- not supported yet | |
5936 " call Decho("remote<".fname.">: exe ".cmd." : NOT SUPPORTED YET") | 6108 " call Decho("remote<".fname.">: exe ".cmd." : NOT SUPPORTED YET") |
5937 echo "sorry, \"mX\" not supported yet for remote files" | 6109 echo "sorry, \"mX\" not supported yet for remote files" |
5938 endif | 6110 endif |
5939 endfor | 6111 endfor |
5940 | 6112 |
6282 call histdel("/",-1) | 6454 call histdel("/",-1) |
6283 elseif g:netrw_liststyle == s:WIDELIST | 6455 elseif g:netrw_liststyle == s:WIDELIST |
6284 sil keepj %s/\s\{2,}/\r/ge | 6456 sil keepj %s/\s\{2,}/\r/ge |
6285 call histdel("/",-1) | 6457 call histdel("/",-1) |
6286 elseif g:netrw_liststyle == s:TREELIST | 6458 elseif g:netrw_liststyle == s:TREELIST |
6287 sil keepj %s/^| //e | 6459 exe 'sil keepj %s/^'.s:treedepthstring.' //e' |
6288 sil! keepj g/^ .*$/d | 6460 sil! keepj g/^ .*$/d |
6289 call histdel("/",-1) | 6461 call histdel("/",-1) |
6290 call histdel("/",-1) | 6462 call histdel("/",-1) |
6291 endif | 6463 endif |
6292 " convert regexp into the more usual glob-style format | 6464 " convert regexp into the more usual glob-style format |
6705 " choice = 0 : didn't have to choose | 6877 " choice = 0 : didn't have to choose |
6706 " choice = 1 : saved modified file in window first | 6878 " choice = 1 : saved modified file in window first |
6707 " choice = 2 : didn't save modified file, opened window | 6879 " choice = 2 : didn't save modified file, opened window |
6708 " choice = 3 : cancel open | 6880 " choice = 3 : cancel open |
6709 fun! s:NetrwPrevWinOpen(islocal) | 6881 fun! s:NetrwPrevWinOpen(islocal) |
6710 " call Dfunc("NetrwPrevWinOpen(islocal=".a:islocal.")") | 6882 " call Dfunc("s:NetrwPrevWinOpen(islocal=".a:islocal.")") |
6711 | 6883 |
6712 let ykeep= @@ | 6884 let ykeep= @@ |
6713 " grab a copy of the b:netrw_curdir to pass it along to newly split windows | 6885 " grab a copy of the b:netrw_curdir to pass it along to newly split windows |
6714 let curdir = b:netrw_curdir | 6886 let curdir = b:netrw_curdir |
6715 | 6887 |
6716 " get last window number and the word currently under the cursor | 6888 " get last window number and the word currently under the cursor |
6889 let origwin = winnr() | |
6717 let lastwinnr = winnr("$") | 6890 let lastwinnr = winnr("$") |
6718 let curword = s:NetrwGetWord() | 6891 let curword = s:NetrwGetWord() |
6719 let choice = 0 | 6892 let choice = 0 |
6720 " call Decho("lastwinnr=".lastwinnr." curword<".curword.">") | 6893 let s:treedir = s:NetrwTreeDir() |
6721 | 6894 " call Decho("(s:NetrwPrevWinOpen) winnr($)#".lastwinnr." curword<".curword.">") |
6722 let didsplit = 0 | 6895 |
6896 let didsplit = 0 | |
6723 if lastwinnr == 1 | 6897 if lastwinnr == 1 |
6724 " if only one window, open a new one first | 6898 " if only one window, open a new one first |
6725 " call Decho("only one window, so open a new one (g:netrw_alto=".g:netrw_alto.")") | 6899 " call Decho("(s:NetrwPrevWinOpen) only one window, so open a new one (g:netrw_alto=".g:netrw_alto.")") |
6726 if g:netrw_preview | 6900 if g:netrw_preview |
6727 let winsz= (g:netrw_winsize > 0)? (g:netrw_winsize*winheight(0))/100 : -g:netrw_winsize | 6901 let winsz= (g:netrw_winsize > 0)? (g:netrw_winsize*winheight(0))/100 : -g:netrw_winsize |
6728 " call Decho("exe ".(g:netrw_alto? "top " : "bot ")."vert ".winsz."wincmd s") | 6902 " call Decho("(s:NetrwPrevWinOpen) exe ".(g:netrw_alto? "top " : "bot ")."vert ".winsz."wincmd s") |
6729 exe (g:netrw_alto? "top " : "bot ")."vert ".winsz."wincmd s" | 6903 exe (g:netrw_alto? "top " : "bot ")."vert ".winsz."wincmd s" |
6730 else | 6904 else |
6731 let winsz= (g:netrw_winsize > 0)? (g:netrw_winsize*winwidth(0))/100 : -g:netrw_winsize | 6905 let winsz= (g:netrw_winsize > 0)? (g:netrw_winsize*winwidth(0))/100 : -g:netrw_winsize |
6732 " call Decho("exe ".(g:netrw_alto? "bel " : "abo ").winsz."wincmd s") | 6906 " call Decho("(s:NetrwPrevWinOpen) exe ".(g:netrw_alto? "bel " : "abo ").winsz."wincmd s") |
6733 exe (g:netrw_alto? "bel " : "abo ").winsz."wincmd s" | 6907 exe (g:netrw_alto? "bel " : "abo ").winsz."wincmd s" |
6734 endif | 6908 endif |
6735 let didsplit = 1 | 6909 let didsplit = 1 |
6910 " call Decho("(s:NetrwPrevWinOpen) did split") | |
6736 | 6911 |
6737 else | 6912 else |
6738 keepj call s:SaveBufVars() | 6913 keepj call s:SaveBufVars() |
6739 " call Decho("wincmd p") | 6914 let eikeep= &ei |
6915 set ei=all | |
6740 wincmd p | 6916 wincmd p |
6917 " call Decho("(s:NetrwPrevWinOpen) wincmd p (now in win#".winnr().")") | |
6918 | |
6919 " prevwinnr: the window number of the "prev" window | |
6920 " prevbufnr: the buffer number of the buffer in the "prev" window | |
6921 " bnrcnt : the qty of windows open on the "prev" buffer | |
6922 let prevwinnr = winnr() | |
6923 let prevbufnr = bufnr("%") | |
6924 let prevbufname = bufname("%") | |
6925 let prevmod = &mod | |
6926 let bnrcnt = 0 | |
6741 keepj call s:RestoreBufVars() | 6927 keepj call s:RestoreBufVars() |
6742 " if the previous window's buffer has been changed (is modified), | 6928 " call Decho("(s:NetrwPrevWinOpen) after wincmd p: win#".winnr()." win($)#".winnr("$")." origwin#".origwin." &mod=".&mod." bufname(%)<".bufname("%")."> prevbufnr=".prevbufnr) |
6929 | |
6930 " if the previous window's buffer has been changed (ie. its modified flag is set), | |
6743 " and it doesn't appear in any other extant window, then ask the | 6931 " and it doesn't appear in any other extant window, then ask the |
6744 " user if s/he wants to abandon modifications therein. | 6932 " user if s/he wants to abandon modifications therein. |
6745 let bnr = winbufnr(0) | 6933 if prevmod |
6746 let bnrcnt = 0 | 6934 " call Decho("(s:NetrwPrevWinOpen) detected that prev window's buffer has been modified: prevbufnr=".prevbufnr." winnr()#".winnr()) |
6747 if &mod | 6935 windo if winbufnr(0) == prevbufnr | let bnrcnt=bnrcnt+1 | endif |
6748 " call Decho("detected: prev window's buffer has been modified: bnr=".bnr." winnr#".winnr()) | 6936 " call Decho("(s:NetrwPrevWinOpen) prevbufnr=".prevbufnr." bnrcnt=".bnrcnt." buftype=".&bt." winnr()=".winnr()." prevwinnr#".prevwinnr) |
6749 let eikeep= &ei | 6937 exe prevwinnr."wincmd w" |
6750 set ei=all | 6938 |
6751 windo if winbufnr(0) == bnr | let bnrcnt=bnrcnt+1 | endif | 6939 if bnrcnt == 1 && &hidden == 0 |
6752 exe bnr."wincmd p" | 6940 " only one copy of the modified buffer in a window, and |
6753 let &ei= eikeep | 6941 " hidden not set, so overwriting will lose the modified file. Ask first... |
6754 " call Decho("bnr=".bnr." bnrcnt=".bnrcnt." buftype=".&bt." winnr#".winnr()) | 6942 let choice = confirm("Save modified buffer<".prevbufname."> first?","&Yes\n&No\n&Cancel") |
6755 if bnrcnt == 1 | 6943 " call Decho("(NetrwPrevWinOpen) prevbufname<".prevbufname."> choice=".choice." current-winnr#".winnr()) |
6756 let bufname = bufname(winbufnr(winnr())) | 6944 let &ei= eikeep |
6757 let choice = confirm("Save modified file<".bufname.">?","&Yes\n&No\n&Cancel") | |
6758 " call Decho("bufname<".bufname."> choice=".choice." winnr#".winnr()) | |
6759 | 6945 |
6760 if choice == 1 | 6946 if choice == 1 |
6761 " Yes -- write file & then browse | 6947 " Yes -- write file & then browse |
6762 let v:errmsg= "" | 6948 let v:errmsg= "" |
6763 sil w | 6949 sil w |
6764 if v:errmsg != "" | 6950 if v:errmsg != "" |
6765 call netrw#ErrorMsg(s:ERROR,"unable to write <".bufname.">!",30) | 6951 call netrw#ErrorMsg(s:ERROR,"unable to write <".prevbufname.">!",30) |
6766 if didsplit | 6952 exe origwin."wincmd w" |
6767 q | 6953 let &ei = eikeep |
6768 else | 6954 let @@ = ykeep |
6769 wincmd p | 6955 " call Dret("s:NetrwPrevWinOpen ".choice." : unable to write <".prevbufname.">") |
6770 endif | |
6771 let @@= ykeep | |
6772 " call Dret("NetrwPrevWinOpen ".choice." : unable to write <".bufname.">") | |
6773 return choice | 6956 return choice |
6774 endif | 6957 endif |
6775 | 6958 |
6776 elseif choice == 2 | 6959 elseif choice == 2 |
6777 " No -- don't worry about changed file, just browse anyway | 6960 " No -- don't worry about changed file, just browse anyway |
6778 " call Decho("(NetrwPrevWinOpen) setl nomod") | 6961 " call Decho("(s:NetrwPrevWinOpen) don't worry about chgd file, just browse anyway (winnr($)#".winnr("$").")") |
6779 setl nomod | 6962 echomsg "**note** changes to ".prevbufname." abandoned" |
6780 " call Decho("(NetrwPrevWinOpen) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") | |
6781 keepj call netrw#ErrorMsg(s:WARNING,bufname." changes to ".bufname." abandoned",31) | |
6782 wincmd p | |
6783 | 6963 |
6784 else | 6964 else |
6785 " Cancel -- don't do this | 6965 " Cancel -- don't do this |
6786 if didsplit | 6966 " call Decho("(s:NetrwPrevWinOpen) cancel, don't browse, switch to win#".origwin) |
6787 q | 6967 exe origwin."wincmd w" |
6788 else | 6968 let &ei= eikeep |
6789 wincmd p | 6969 let @@ = ykeep |
6790 endif | 6970 " call Dret("s:NetrwPrevWinOpen ".choice." : cancelled") |
6791 let @@= ykeep | |
6792 " call Dret("NetrwPrevWinOpen ".choice." : cancelled") | |
6793 return choice | 6971 return choice |
6794 endif | 6972 endif |
6795 endif | 6973 endif |
6796 endif | 6974 endif |
6975 let &ei= eikeep | |
6797 endif | 6976 endif |
6798 | 6977 |
6799 " restore b:netrw_curdir (window split/enew may have lost it) | 6978 " restore b:netrw_curdir (window split/enew may have lost it) |
6800 let b:netrw_curdir= curdir | 6979 let b:netrw_curdir= curdir |
6801 if a:islocal < 2 | 6980 if a:islocal < 2 |
6804 else | 6983 else |
6805 call s:NetrwBrowse(a:islocal,s:NetrwBrowseChgDir(a:islocal,curword)) | 6984 call s:NetrwBrowse(a:islocal,s:NetrwBrowseChgDir(a:islocal,curword)) |
6806 endif | 6985 endif |
6807 endif | 6986 endif |
6808 let @@= ykeep | 6987 let @@= ykeep |
6809 " call Dret("NetrwPrevWinOpen ".choice) | 6988 " call Dret("s:NetrwPrevWinOpen ".choice) |
6810 return choice | 6989 return choice |
6811 endfun | 6990 endfun |
6812 | 6991 |
6813 " --------------------------------------------------------------------- | 6992 " --------------------------------------------------------------------- |
6814 " s:NetrwUpload: load fname to tgt (used by NetrwMarkFileCopy()) {{{2 | 6993 " s:NetrwUpload: load fname to tgt (used by NetrwMarkFileCopy()) {{{2 |
7267 unlet s:didsplit | 7446 unlet s:didsplit |
7268 | 7447 |
7269 elseif a:mode == 4 | 7448 elseif a:mode == 4 |
7270 " local and t | 7449 " local and t |
7271 let cursorword = s:NetrwGetWord() | 7450 let cursorword = s:NetrwGetWord() |
7451 let eikeep = &ei | |
7452 let netrw_winnr = winnr() | |
7453 let netrw_line = line(".") | |
7454 let netrw_col = virtcol(".") | |
7455 keepj norm! H0 | |
7456 let netrw_hline = line(".") | |
7457 set ei=all | |
7458 exe "keepj norm! ".netrw_hline."G0z\<CR>" | |
7459 exe "keepj norm! ".netrw_line."G0".netrw_col."\<bar>" | |
7460 let &ei= eikeep | |
7272 let netrw_curdir= s:NetrwTreeDir() | 7461 let netrw_curdir= s:NetrwTreeDir() |
7273 " call Decho("tabnew") | 7462 " call Decho("tabnew") |
7274 tabnew | 7463 tabnew |
7275 let b:netrw_curdir= netrw_curdir | 7464 let b:netrw_curdir = netrw_curdir |
7276 let s:didsplit= 1 | 7465 let s:didsplit = 1 |
7277 keepj call s:RestoreWinVars() | 7466 keepj call s:RestoreWinVars() |
7278 keepj call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,cursorword)) | 7467 keepj call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,cursorword)) |
7468 if &ft == "netrw" | |
7469 set ei=all | |
7470 exe "keepj norm! ".netrw_hline."G0z\<CR>" | |
7471 exe "keepj norm! ".netrw_line."G0".netrw_col."\<bar>" | |
7472 let &ei= eikeep | |
7473 endif | |
7279 unlet s:didsplit | 7474 unlet s:didsplit |
7280 | 7475 |
7281 elseif a:mode == 5 | 7476 elseif a:mode == 5 |
7282 " local and v | 7477 " local and v |
7283 let winsz= (g:netrw_winsize > 0)? (g:netrw_winsize*winwidth(0))/100 : -g:netrw_winsize | 7478 let winsz= (g:netrw_winsize > 0)? (g:netrw_winsize*winwidth(0))/100 : -g:netrw_winsize |
7348 | 7543 |
7349 " --------------------------------------------------------------------- | 7544 " --------------------------------------------------------------------- |
7350 " s:NetrwTreeDir: determine tree directory given current cursor position {{{2 | 7545 " s:NetrwTreeDir: determine tree directory given current cursor position {{{2 |
7351 " (full path directory with trailing slash returned) | 7546 " (full path directory with trailing slash returned) |
7352 fun! s:NetrwTreeDir() | 7547 fun! s:NetrwTreeDir() |
7353 " call Dfunc("NetrwTreeDir() curline#".line(".")."<".getline('.')."> b:netrw_curdir<".b:netrw_curdir."> tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%").">") | 7548 " call Dfunc("s:NetrwTreeDir() getline(".line(".").")"."<".getline('.')."> b:netrw_curdir<".b:netrw_curdir."> tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> ft=".&ft) |
7354 | 7549 |
7355 let treedir= b:netrw_curdir | 7550 if exists("s:treedir") |
7356 " call Decho("(NetrwTreeDir) set initial treedir<".treedir.">") | 7551 " s:NetrwPrevWinOpen opens a "previous" window -- and thus needs to and does call s:NetrwTreeDir early |
7552 let treedir= s:treedir | |
7553 unlet s:treedir | |
7554 " call Dret("s:NetrwTreeDir ".treedir) | |
7555 return treedir | |
7556 endif | |
7557 if !exists("b:netrw_curdir") || b:netrw_curdir == "" | |
7558 let b:netrw_curdir= getcwd() | |
7559 endif | |
7560 let treedir = b:netrw_curdir | |
7561 " call Decho("(s:NetrwTreeDir) set initial treedir<".treedir.">") | |
7357 let s:treecurpos= netrw#NetrwSavePosn() | 7562 let s:treecurpos= netrw#NetrwSavePosn() |
7358 | 7563 |
7359 if w:netrw_liststyle == s:TREELIST | 7564 if w:netrw_liststyle == s:TREELIST |
7360 " call Decho("(NetrwTreeDir) w:netrw_liststyle is TREELIST:") | 7565 " call Decho("(s:NetrwTreeDir) w:netrw_liststyle is TREELIST:") |
7361 " call Decho("(NetrwTreeDir) line#".line(".")." getline(.)<".getline('.')."> treecurpos<".string(s:treecurpos).">") | 7566 " call Decho("(s:NetrwTreeDir) line#".line(".")." getline(.)<".getline('.')."> treecurpos<".string(s:treecurpos).">") |
7362 | 7567 |
7363 " extract tree directory if on a line specifying a subdirectory (ie. ends with "/") | 7568 " extract tree directory if on a line specifying a subdirectory (ie. ends with "/") |
7364 if getline('.') =~ '/$' | 7569 if getline('.') =~ '/$' |
7365 let treedir= substitute(getline('.'),'^\%(| \)*\([^|].\{-}\)$','\1','e') | 7570 " call Decho("extract tree subdirectory from current line") |
7571 let treedir= substitute(getline('.'),'^\%('.s:treedepthstring.'\)*\([^'.s:treedepthstring.'].\{-}\)$','\1','e') | |
7572 " call Decho("(s:NetrwTreeDir) treedir<".treedir.">") | |
7366 else | 7573 else |
7574 " call Decho("(s:NetrwTreeDir) do not extract tree subdirectory from current line and set treedir to empty") | |
7367 let treedir= "" | 7575 let treedir= "" |
7368 endif | 7576 endif |
7369 " call Decho("(NetrwTreeDir) treedir<".treedir.">") | |
7370 | 7577 |
7371 " detect user attempting to close treeroot | 7578 " detect user attempting to close treeroot |
7372 if getline('.') !~ '|' && getline('.') != '..' | 7579 " call Decho("(s:NetrwTreeDir) win#".winnr()." buf#".bufnr("%")."<".bufname("%").">") |
7373 " call Decho("user attempted to close treeroot") | 7580 " call Decho("(s:NetrwTreeDir) getline(".line(".").")<".getline('.').'> '.((getline('.') =~ '^'.s:treedepthstring)? '=~' : '!~').' ^'.s:treedepthstring) |
7581 if getline('.') !~ '^'.s:treedepthstring && getline('.') != '..' | |
7582 " call Decho("user may have attempted to close treeroot") | |
7374 " now force a refresh | 7583 " now force a refresh |
7375 " call Decho("(NetrwTreeDir) clear buffer<".expand("%")."> with :%d") | 7584 " call Decho("(s:NetrwTreeDir) clear buffer<".expand("%")."> with :%d") |
7376 sil! keepj %d | 7585 sil! keepj %d |
7377 " call Dret("NetrwTreeDir <".treedir."> : (side effect) s:treecurpos<".string(s:treecurpos).">") | 7586 " call Dret("s:NetrwTreeDir <".treedir."> : (side effect) s:treecurpos<".string(s:treecurpos).">") |
7378 return b:netrw_curdir | 7587 return b:netrw_curdir |
7379 endif | 7588 " else " Decho |
7380 | 7589 " call Decho("user did not attempt to close treeroot") |
7381 " elide all non-depth information | 7590 endif |
7382 let depth = substitute(getline('.'),'^\(\%(| \)*\)[^|].\{-}$','\1','e') | 7591 |
7383 " call Decho("(NetrwTreeDir) depth<".depth."> 1st subst (non-depth info removed)") | 7592 let treedir= s:NetrwTreePath(w:netrw_treetop) |
7384 | 7593 endif |
7385 " elide first depth | 7594 |
7386 let depth = substitute(depth,'^| ','','') | 7595 " sanity maintenance: keep those //s away... |
7387 " call Decho("(NetrwTreeDir) depth<".depth."> 2nd subst (first depth removed)") | |
7388 | |
7389 " construct treedir by searching backwards at correct depth | |
7390 " call Decho("(NetrwTreeDir) constructing treedir<".treedir."> depth<".depth.">") | |
7391 while depth != "" && search('^'.depth.'[^|].\{-}/$','bW') | |
7392 let dirname= substitute(getline('.'),'^\(| \)*','','e') | |
7393 let treedir= dirname.treedir | |
7394 let depth = substitute(depth,'^| ','','') | |
7395 " call Decho("(NetrwTreeDir) constructing treedir<".treedir.">: dirname<".dirname."> while depth<".depth.">") | |
7396 endwhile | |
7397 if w:netrw_treetop =~ '/$' | |
7398 let treedir= w:netrw_treetop.treedir | |
7399 else | |
7400 let treedir= w:netrw_treetop.'/'.treedir | |
7401 endif | |
7402 " call Decho("(NetrwTreeDir) bufnr(.)=".bufnr("%")." line($)=".line("$")." line(.)=".line(".")) | |
7403 endif | |
7404 let treedir= substitute(treedir,'//$','/','') | 7596 let treedir= substitute(treedir,'//$','/','') |
7405 | 7597 |
7406 " call Dret("NetrwTreeDir <".treedir."> : (side effect) s:treecurpos<".string(s:treecurpos).">") | 7598 " call Dret("s:NetrwTreeDir <".treedir."> : (side effect) s:treecurpos<".string(s:treecurpos).">") |
7407 return treedir | 7599 return treedir |
7408 endfun | 7600 endfun |
7409 | 7601 |
7410 " --------------------------------------------------------------------- | 7602 " --------------------------------------------------------------------- |
7411 " s:NetrwTreeDisplay: recursive tree display {{{2 | 7603 " s:NetrwTreeDisplay: recursive tree display {{{2 |
7438 if dir !~ '/$' | 7630 if dir !~ '/$' |
7439 let dir= dir.'/' | 7631 let dir= dir.'/' |
7440 endif | 7632 endif |
7441 | 7633 |
7442 " display subtrees (if any) | 7634 " display subtrees (if any) |
7443 let depth= "| ".a:depth | 7635 let depth= s:treedepthstring.a:depth |
7444 | 7636 |
7445 " call Decho("display subtrees with depth<".depth."> and current leaves") | 7637 " call Decho("display subtrees with depth<".depth."> and current leaves") |
7446 for entry in w:netrw_treedict[a:dir] | 7638 for entry in w:netrw_treedict[a:dir] |
7447 let direntry= substitute(dir.entry,'/$','','e') | 7639 let direntry= substitute(dir.entry,'/$','','e') |
7448 " call Decho("dir<".dir."> entry<".entry."> direntry<".direntry.">") | 7640 " call Decho("dir<".dir."> entry<".entry."> direntry<".direntry.">") |
7455 else | 7647 else |
7456 " call Decho("<".entry."> is not a key in treedict (no subtree)") | 7648 " call Decho("<".entry."> is not a key in treedict (no subtree)") |
7457 sil! keepj call setline(line("$")+1,depth.entry) | 7649 sil! keepj call setline(line("$")+1,depth.entry) |
7458 endif | 7650 endif |
7459 endfor | 7651 endfor |
7652 | |
7460 " call Dret("NetrwTreeDisplay") | 7653 " call Dret("NetrwTreeDisplay") |
7461 endfun | 7654 endfun |
7462 | 7655 |
7463 " --------------------------------------------------------------------- | 7656 " --------------------------------------------------------------------- |
7464 " s:NetrwTreeListing: displays tree listing from treetop on down, using NetrwTreeDisplay() {{{2 | 7657 " s:NetrwTreeListing: displays tree listing from treetop on down, using NetrwTreeDisplay() {{{2 |
7465 fun! s:NetrwTreeListing(dirname) | 7658 fun! s:NetrwTreeListing(dirname) |
7466 if w:netrw_liststyle == s:TREELIST | 7659 if w:netrw_liststyle == s:TREELIST |
7467 " call Dfunc("NetrwTreeListing() bufname<".expand("%").">") | 7660 " call Dfunc("NetrwTreeListing() bufname<".expand("%").">") |
7468 " call Decho("curdir<".a:dirname.">") | 7661 " call Decho("(s:NetrwTreeListing) curdir<".a:dirname.">") |
7469 " call Decho("win#".winnr().": w:netrw_treetop ".(exists("w:netrw_treetop")? "exists" : "doesn't exit")." w:netrw_treedict ".(exists("w:netrw_treedict")? "exists" : "doesn't exit")) | 7662 " call Decho("(s:NetrwTreeListing) win#".winnr().": w:netrw_treetop ".(exists("w:netrw_treetop")? "exists" : "doesn't exist")." w:netrw_treedict ".(exists("w:netrw_treedict")? "exists" : "doesn't exit")) |
7663 " call Decho("(s:NetrwTreeListing) g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")") | |
7470 | 7664 |
7471 " update the treetop | 7665 " update the treetop |
7472 " call Decho("update the treetop") | 7666 " call Decho("(s:NetrwTreeListing) update the treetop") |
7473 if !exists("w:netrw_treetop") | 7667 if !exists("w:netrw_treetop") |
7474 let w:netrw_treetop= a:dirname | 7668 let w:netrw_treetop= a:dirname |
7475 " call Decho("w:netrw_treetop<".w:netrw_treetop."> (reusing)") | 7669 " call Decho("(s:NetrwTreeListing) w:netrw_treetop<".w:netrw_treetop."> (reusing)") |
7476 elseif (w:netrw_treetop =~ ('^'.a:dirname) && s:Strlen(a:dirname) < s:Strlen(w:netrw_treetop)) || a:dirname !~ ('^'.w:netrw_treetop) | 7670 elseif (w:netrw_treetop =~ ('^'.a:dirname) && s:Strlen(a:dirname) < s:Strlen(w:netrw_treetop)) || a:dirname !~ ('^'.w:netrw_treetop) |
7477 let w:netrw_treetop= a:dirname | 7671 let w:netrw_treetop= a:dirname |
7478 " call Decho("w:netrw_treetop<".w:netrw_treetop."> (went up)") | 7672 " call Decho("(s:NetrwTreeListing) w:netrw_treetop<".w:netrw_treetop."> (went up)") |
7479 endif | 7673 endif |
7480 | 7674 |
7481 " insure that we have at least an empty treedict | 7675 " insure that we have at least an empty treedict |
7482 if !exists("w:netrw_treedict") | 7676 if !exists("w:netrw_treedict") |
7483 let w:netrw_treedict= {} | 7677 let w:netrw_treedict= {} |
7484 endif | 7678 endif |
7485 | 7679 |
7486 " update the directory listing for the current directory | 7680 " update the directory listing for the current directory |
7487 " call Decho("updating dictionary with ".a:dirname.":[..directory listing..]") | 7681 " call Decho("(s:NetrwTreeListing) updating dictionary with ".a:dirname.":[..directory listing..]") |
7488 " call Decho("bannercnt=".w:netrw_bannercnt." line($)=".line("$")) | 7682 " call Decho("(s:NetrwTreeListing) w:netrw_bannercnt=".w:netrw_bannercnt." line($)=".line("$")) |
7489 exe "sil! keepj ".w:netrw_bannercnt.',$g@^\.\.\=/$@d' | 7683 exe "sil! keepj ".w:netrw_bannercnt.',$g@^\.\.\=/$@d' |
7490 let w:netrw_treedict[a:dirname]= getline(w:netrw_bannercnt,line("$")) | 7684 let w:netrw_treedict[a:dirname]= getline(w:netrw_bannercnt,line("$")) |
7491 " call Decho("w:treedict[".a:dirname."]= ".string(w:netrw_treedict[a:dirname])) | 7685 " call Decho("(s:NetrwTreeListing) w:treedict[".a:dirname."]= ".string(w:netrw_treedict[a:dirname])) |
7492 exe "sil! keepj ".w:netrw_bannercnt.",$d" | 7686 exe "sil! keepj ".w:netrw_bannercnt.",$d" |
7493 | 7687 |
7494 " if past banner, record word | 7688 " if past banner, record word |
7495 if exists("w:netrw_bannercnt") && line(".") > w:netrw_bannercnt | 7689 if exists("w:netrw_bannercnt") && line(".") > w:netrw_bannercnt |
7496 let fname= expand("<cword>") | 7690 let fname= expand("<cword>") |
7497 else | 7691 else |
7498 let fname= "" | 7692 let fname= "" |
7499 endif | 7693 endif |
7500 " call Decho("fname<".fname.">") | 7694 " call Decho("(s:NetrwTreeListing) fname<".fname.">") |
7695 " call Decho("(s:NetrwTreeListing) g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")") | |
7501 | 7696 |
7502 " display from treetop on down | 7697 " display from treetop on down |
7503 keepj call s:NetrwTreeDisplay(w:netrw_treetop,"") | 7698 keepj call s:NetrwTreeDisplay(w:netrw_treetop,"") |
7699 " call Decho("s:NetrwTreeDisplay) setl noma nomod ro") | |
7700 | |
7701 " remove any blank line remaining as line#1 (happens in treelisting mode with banner suppressed) | |
7702 while getline(1) =~ '^\s*$' && byte2line(1) > 0 | |
7703 " call Decho("(s:PerformListing) deleting blank line") | |
7704 1d | |
7705 endwhile | |
7706 | |
7707 setl noma nomod ro | |
7504 | 7708 |
7505 " call Dret("NetrwTreeListing : bufname<".expand("%").">") | 7709 " call Dret("NetrwTreeListing : bufname<".expand("%").">") |
7506 return | 7710 return |
7507 endif | 7711 endif |
7508 endfun | 7712 endfun |
7577 endif | 7781 endif |
7578 | 7782 |
7579 endfun | 7783 endfun |
7580 | 7784 |
7581 " --------------------------------------------------------------------- | 7785 " --------------------------------------------------------------------- |
7786 " s:NetrwTreePath: returns path to current file in tree listing {{{2 | |
7787 " Normally, treetop is w:netrw_treetop, but a | |
7788 " user of this function ( netrw#NetrwSetTreetop() ) | |
7789 " wipes that out prior to calling this function | |
7790 fun! s:NetrwTreePath(treetop) | |
7791 " call Dfunc("s:NetrwTreePath()") | |
7792 let depth = substitute(getline('.'),'^\(\%('.s:treedepthstring.'\)*\)[^'.s:treedepthstring.'].\{-}$','\1','e') | |
7793 let depth = substitute(depth,'^'.s:treedepthstring,'','') | |
7794 " call Decho("(s:NetrwTreePath) depth<".depth."> 2nd subst (first depth removed)") | |
7795 if getline('.') =~ '/$' | |
7796 " call Decho("extract tree directory from current line") | |
7797 let treedir= substitute(getline('.'),'^\%('.s:treedepthstring.'\)*\([^'.s:treedepthstring.'].\{-}\)$','\1','e') | |
7798 " call Decho("(s:NetrwTreePath) treedir<".treedir.">") | |
7799 else | |
7800 " call Decho("(s:NetrwTreePath) do not extract tree directory from current line and set treedir to empty") | |
7801 let treedir= "" | |
7802 endif | |
7803 " construct treedir by searching backwards at correct depth | |
7804 " call Decho("(s:NetrwTreePath) initial treedir<".treedir."> depth<".depth.">") | |
7805 while depth != "" && search('^'.depth.'[^'.s:treedepthstring.'].\{-}/$','bW') | |
7806 let dirname= substitute(getline('.'),'^\('.s:treedepthstring.'\)*','','e') | |
7807 let treedir= dirname.treedir | |
7808 let depth = substitute(depth,'^'.s:treedepthstring,'','') | |
7809 " call Decho("(s:NetrwTreePath) constructing treedir<".treedir.">: dirname<".dirname."> while depth<".depth.">") | |
7810 endwhile | |
7811 if a:treetop =~ '/$' | |
7812 let treedir= a:treetop.treedir | |
7813 else | |
7814 let treedir= a:treetop.'/'.treedir | |
7815 endif | |
7816 let treedir= substitute(treedir,'//$','/','') | |
7817 " call Dret("s:NetrwTreePath <".treedir.">") | |
7818 return treedir | |
7819 endfun | |
7820 | |
7821 " --------------------------------------------------------------------- | |
7582 " s:PerformListing: {{{2 | 7822 " s:PerformListing: {{{2 |
7583 fun! s:PerformListing(islocal) | 7823 fun! s:PerformListing(islocal) |
7584 " call Dfunc("s:PerformListing(islocal=".a:islocal.") bufnr(%)=".bufnr("%")."<".bufname("%").">") | 7824 " call Dfunc("s:PerformListing(islocal=".a:islocal.") bufnr(%)=".bufnr("%")."<".bufname("%").">") |
7825 " call Decho("(s:PerformListing) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (enter)") | |
7585 | 7826 |
7586 " set up syntax highlighting {{{3 | 7827 " set up syntax highlighting {{{3 |
7587 " call Decho("(PerformListing) set up syntax highlighting") | 7828 " call Decho("(s:PerformListing) set up syntax highlighting") |
7588 if has("syntax") | 7829 if has("syntax") |
7589 if !exists("g:syntax_on") || !g:syntax_on | 7830 if !exists("g:syntax_on") || !g:syntax_on |
7590 " call Decho("(PerformListing) but g:syntax_on".(exists("g:syntax_on")? "=".g:syntax_on : "<doesn't exist>")) | 7831 " call Decho("(s:PerformListing) but g:syntax_on".(exists("g:syntax_on")? "=".g:syntax_on : "<doesn't exist>")) |
7591 setl ft= | 7832 setl ft= |
7592 elseif &ft != "netrw" | 7833 elseif &ft != "netrw" |
7593 setl ft=netrw | 7834 setl ft=netrw |
7594 endif | 7835 endif |
7595 endif | 7836 endif |
7596 | 7837 |
7597 keepj call s:NetrwSafeOptions() | 7838 keepj call s:NetrwSafeOptions() |
7598 set noro ma | 7839 set noro ma |
7599 " call Decho("(PerformListing) setl noro ma bh=".&bh) | 7840 " call Decho("(s:PerformListing) setl noro ma bh=".&bh) |
7600 | 7841 |
7601 " if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1 " Decho | 7842 " if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1 " Decho |
7602 " call Decho("(PerformListing) (netrw) Processing your browsing request...") | 7843 " call Decho("(s:PerformListing) (netrw) Processing your browsing request...") |
7603 " endif " Decho | 7844 " endif " Decho |
7604 | 7845 |
7605 " call Decho('w:netrw_liststyle='.(exists("w:netrw_liststyle")? w:netrw_liststyle : 'n/a')) | 7846 " call Decho('w:netrw_liststyle='.(exists("w:netrw_liststyle")? w:netrw_liststyle : 'n/a')) |
7606 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") | 7847 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") |
7607 " force a refresh for tree listings | 7848 " force a refresh for tree listings |
7608 " call Decho("(PerformListing) force refresh for treelisting: clear buffer<".expand("%")."> with :%d") | 7849 " call Decho("(s:PerformListing) force refresh for treelisting: clear buffer<".expand("%")."> with :%d") |
7609 sil! keepj %d | 7850 sil! keepj %d |
7610 endif | 7851 endif |
7611 | 7852 |
7612 " save current directory on directory history list | 7853 " save current directory on directory history list |
7613 keepj call s:NetrwBookHistHandler(3,b:netrw_curdir) | 7854 keepj call s:NetrwBookHistHandler(3,b:netrw_curdir) |
7614 | 7855 |
7615 " Set up the banner {{{3 | 7856 " Set up the banner {{{3 |
7616 if g:netrw_banner | 7857 if g:netrw_banner |
7617 " call Decho("(PerformListing) set up banner") | 7858 " call Decho("(s:PerformListing) set up banner") |
7618 keepj call setline(1,'" ============================================================================') | 7859 keepj call setline(1,'" ============================================================================') |
7619 keepj call setline(2,'" Netrw Directory Listing (netrw '.g:loaded_netrw.')') | 7860 keepj call setline(2,'" Netrw Directory Listing (netrw '.g:loaded_netrw.')') |
7620 if exists("g:netrw_bannerbackslash") && g:netrw_bannerbackslash | 7861 if exists("g:netrw_bannerbackslash") && g:netrw_bannerbackslash |
7621 keepj call setline(3,'" '.substitute(b:netrw_curdir,'/','\\','g')) | 7862 keepj call setline(3,'" '.substitute(b:netrw_curdir,'/','\\','g')) |
7622 else | 7863 else |
7634 let sortby= sortby." reversed" | 7875 let sortby= sortby." reversed" |
7635 endif | 7876 endif |
7636 | 7877 |
7637 " Sorted by... {{{3 | 7878 " Sorted by... {{{3 |
7638 if g:netrw_banner | 7879 if g:netrw_banner |
7639 " call Decho("(PerformListing) handle specified sorting: g:netrw_sort_by<".g:netrw_sort_by.">") | 7880 " call Decho("(s:PerformListing) handle specified sorting: g:netrw_sort_by<".g:netrw_sort_by.">") |
7640 if g:netrw_sort_by =~ "^n" | 7881 if g:netrw_sort_by =~ "^n" |
7641 " call Decho("(PerformListing) directories will be sorted by name") | 7882 " call Decho("(s:PerformListing) directories will be sorted by name") |
7642 " sorted by name | 7883 " sorted by name |
7643 keepj put ='\" Sorted by '.sortby | 7884 keepj put ='\" Sorted by '.sortby |
7644 keepj put ='\" Sort sequence: '.g:netrw_sort_sequence | 7885 keepj put ='\" Sort sequence: '.g:netrw_sort_sequence |
7645 let w:netrw_bannercnt= w:netrw_bannercnt + 2 | 7886 let w:netrw_bannercnt= w:netrw_bannercnt + 2 |
7646 else | 7887 else |
7647 " call Decho("(PerformListing) directories will be sorted by size or time") | 7888 " call Decho("(s:PerformListing) directories will be sorted by size or time") |
7648 " sorted by size or date | 7889 " sorted by size or date |
7649 keepj put ='\" Sorted by '.sortby | 7890 keepj put ='\" Sorted by '.sortby |
7650 let w:netrw_bannercnt= w:netrw_bannercnt + 1 | 7891 let w:netrw_bannercnt= w:netrw_bannercnt + 1 |
7651 endif | 7892 endif |
7652 exe "sil! keepj ".w:netrw_bannercnt | 7893 exe "sil! keepj ".w:netrw_bannercnt |
7894 " else " Decho | |
7895 " call Decho("(s:PerformListing) g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")") | |
7653 endif | 7896 endif |
7654 | 7897 |
7655 " show copy/move target, if any | 7898 " show copy/move target, if any |
7656 if g:netrw_banner | 7899 if g:netrw_banner |
7657 if exists("s:netrwmftgt") && exists("s:netrwmftgt_islocal") | 7900 if exists("s:netrwmftgt") && exists("s:netrwmftgt_islocal") |
7658 " call Decho("(PerformListing) show copy/move target<".s:netrwmftgt.">") | 7901 " call Decho("(s:PerformListing) show copy/move target<".s:netrwmftgt.">") |
7659 keepj put ='' | 7902 keepj put ='' |
7660 if s:netrwmftgt_islocal | 7903 if s:netrwmftgt_islocal |
7661 sil! keepj call setline(line("."),'" Copy/Move Tgt: '.s:netrwmftgt.' (local)') | 7904 sil! keepj call setline(line("."),'" Copy/Move Tgt: '.s:netrwmftgt.' (local)') |
7662 else | 7905 else |
7663 sil! keepj call setline(line("."),'" Copy/Move Tgt: '.s:netrwmftgt.' (remote)') | 7906 sil! keepj call setline(line("."),'" Copy/Move Tgt: '.s:netrwmftgt.' (remote)') |
7664 endif | 7907 endif |
7665 let w:netrw_bannercnt= w:netrw_bannercnt + 1 | 7908 let w:netrw_bannercnt= w:netrw_bannercnt + 1 |
7666 else | 7909 else |
7667 " call Decho("(PerformListing) s:netrwmftgt does not exist, don't make Copy/Move Tgt") | 7910 " call Decho("(s:PerformListing) s:netrwmftgt does not exist, don't make Copy/Move Tgt") |
7668 endif | 7911 endif |
7669 exe "sil! keepj ".w:netrw_bannercnt | 7912 exe "sil! keepj ".w:netrw_bannercnt |
7670 endif | 7913 endif |
7671 | 7914 |
7672 " Hiding... -or- Showing... {{{3 | 7915 " Hiding... -or- Showing... {{{3 |
7673 if g:netrw_banner | 7916 if g:netrw_banner |
7674 " call Decho("(PerformListing) handle hiding/showing (g:netrw_hide=".g:netrw_list_hide." g:netrw_list_hide<".g:netrw_list_hide.">)") | 7917 " call Decho("(s:PerformListing) handle hiding/showing (g:netrw_hide=".g:netrw_list_hide." g:netrw_list_hide<".g:netrw_list_hide.">)") |
7675 if g:netrw_list_hide != "" && g:netrw_hide | 7918 if g:netrw_list_hide != "" && g:netrw_hide |
7676 if g:netrw_hide == 1 | 7919 if g:netrw_hide == 1 |
7677 keepj put ='\" Hiding: '.g:netrw_list_hide | 7920 keepj put ='\" Hiding: '.g:netrw_list_hide |
7678 else | 7921 else |
7679 keepj put ='\" Showing: '.g:netrw_list_hide | 7922 keepj put ='\" Showing: '.g:netrw_list_hide |
7682 endif | 7925 endif |
7683 exe "keepjumps ".w:netrw_bannercnt | 7926 exe "keepjumps ".w:netrw_bannercnt |
7684 keepj put ='\" Quick Help: <F1>:help -:go up dir D:delete R:rename s:sort-by x:exec' | 7927 keepj put ='\" Quick Help: <F1>:help -:go up dir D:delete R:rename s:sort-by x:exec' |
7685 keepj put ='\" ============================================================================' | 7928 keepj put ='\" ============================================================================' |
7686 let w:netrw_bannercnt= w:netrw_bannercnt + 2 | 7929 let w:netrw_bannercnt= w:netrw_bannercnt + 2 |
7930 " else " Decho | |
7931 " call Decho("(s:PerformListing) g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")") | |
7687 endif | 7932 endif |
7688 | 7933 |
7689 " bannercnt should index the line just after the banner | 7934 " bannercnt should index the line just after the banner |
7690 if g:netrw_banner | 7935 if g:netrw_banner |
7691 let w:netrw_bannercnt= w:netrw_bannercnt + 1 | 7936 let w:netrw_bannercnt= w:netrw_bannercnt + 1 |
7692 exe "sil! keepj ".w:netrw_bannercnt | 7937 exe "sil! keepj ".w:netrw_bannercnt |
7693 " call Decho("(PerformListing) w:netrw_bannercnt=".w:netrw_bannercnt." (should index line just after banner) line($)=".line("$")) | 7938 " call Decho("(s:PerformListing) w:netrw_bannercnt=".w:netrw_bannercnt." (should index line just after banner) line($)=".line("$")) |
7939 " else " Decho | |
7940 " call Decho("(s:PerformListing) g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")") | |
7694 endif | 7941 endif |
7695 | 7942 |
7696 " get list of files | 7943 " get list of files |
7697 " call Decho("(PerformListing) Get list of files - islocal=".a:islocal) | 7944 " call Decho("(s:PerformListing) Get list of files - islocal=".a:islocal) |
7698 if a:islocal | 7945 if a:islocal |
7699 keepj call s:LocalListing() | 7946 keepj call s:LocalListing() |
7700 else " remote | 7947 else " remote |
7701 keepj call s:NetrwRemoteListing() | 7948 keepj call s:NetrwRemoteListing() |
7702 endif | 7949 endif |
7950 " call Decho("(s:PerformListing) g:netrw_banner=".g:netrw_banner." w:netrw_bannercnt=".w:netrw_bannercnt." (banner complete)") | |
7951 " call Decho("(s:PerformListing) g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")") | |
7703 | 7952 |
7704 " manipulate the directory listing (hide, sort) {{{3 | 7953 " manipulate the directory listing (hide, sort) {{{3 |
7705 if !exists("w:netrw_bannercnt") | 7954 if !exists("w:netrw_bannercnt") |
7706 let w:netrw_bannercnt= 0 | 7955 let w:netrw_bannercnt= 0 |
7707 endif | 7956 endif |
7708 " call Decho("(PerformListing) g:netrw_banner=".g:netrw_banner." w:netrw_bannercnt=".w:netrw_bannercnt." (banner complete)") | |
7709 | |
7710 if !g:netrw_banner || line("$") >= w:netrw_bannercnt | 7957 if !g:netrw_banner || line("$") >= w:netrw_bannercnt |
7711 " call Decho("(PerformListing) manipulate directory listing (hide)") | 7958 " call Decho("(s:PerformListing) manipulate directory listing (hide)") |
7712 " call Decho("(PerformListing) g:netrw_hide=".g:netrw_hide." g:netrw_list_hide<".g:netrw_list_hide.">") | 7959 " call Decho("(s:PerformListing) g:netrw_hide=".g:netrw_hide." g:netrw_list_hide<".g:netrw_list_hide.">") |
7713 if g:netrw_hide && g:netrw_list_hide != "" | 7960 if g:netrw_hide && g:netrw_list_hide != "" |
7714 keepj call s:NetrwListHide() | 7961 keepj call s:NetrwListHide() |
7715 endif | 7962 endif |
7716 if !g:netrw_banner || line("$") >= w:netrw_bannercnt | 7963 if !g:netrw_banner || line("$") >= w:netrw_bannercnt |
7717 " call Decho("(PerformListing) manipulate directory listing (sort) : g:netrw_sort_by<".g:netrw_sort_by.">") | 7964 " call Decho("(s:PerformListing) manipulate directory listing (sort) : g:netrw_sort_by<".g:netrw_sort_by.">") |
7718 | 7965 |
7719 if g:netrw_sort_by =~ "^n" | 7966 if g:netrw_sort_by =~ "^n" |
7720 " sort by name | 7967 " sort by name |
7721 keepj call s:NetrwSetSort() | 7968 keepj call s:NetrwSetSort() |
7722 | 7969 |
7723 if !g:netrw_banner || w:netrw_bannercnt < line("$") | 7970 if !g:netrw_banner || w:netrw_bannercnt < line("$") |
7724 " call Decho("(PerformListing) g:netrw_sort_direction=".g:netrw_sort_direction." (bannercnt=".w:netrw_bannercnt.")") | 7971 " call Decho("(s:PerformListing) g:netrw_sort_direction=".g:netrw_sort_direction." (bannercnt=".w:netrw_bannercnt.")") |
7725 if g:netrw_sort_direction =~ 'n' | 7972 if g:netrw_sort_direction =~ 'n' |
7726 " normal direction sorting | 7973 " normal direction sorting |
7727 exe 'sil keepj '.w:netrw_bannercnt.',$sort'.' '.g:netrw_sort_options | 7974 exe 'sil keepj '.w:netrw_bannercnt.',$sort'.' '.g:netrw_sort_options |
7728 else | 7975 else |
7729 " reverse direction sorting | 7976 " reverse direction sorting |
7730 exe 'sil keepj '.w:netrw_bannercnt.',$sort!'.' '.g:netrw_sort_options | 7977 exe 'sil keepj '.w:netrw_bannercnt.',$sort!'.' '.g:netrw_sort_options |
7731 endif | 7978 endif |
7732 endif | 7979 endif |
7733 " remove priority pattern prefix | 7980 " remove priority pattern prefix |
7734 " call Decho("(PerformListing) remove priority pattern prefix") | 7981 " call Decho("(s:PerformListing) remove priority pattern prefix") |
7735 exe 'sil! keepj '.w:netrw_bannercnt.',$s/^\d\{3}'.g:netrw_sepchr.'//e' | 7982 exe 'sil! keepj '.w:netrw_bannercnt.',$s/^\d\{3}'.g:netrw_sepchr.'//e' |
7736 keepj call histdel("/",-1) | 7983 keepj call histdel("/",-1) |
7737 | 7984 |
7738 elseif a:islocal | 7985 elseif a:islocal |
7739 if !g:netrw_banner || w:netrw_bannercnt < line("$") | 7986 if !g:netrw_banner || w:netrw_bannercnt < line("$") |
7740 " call Decho("(PerformListing) g:netrw_sort_direction=".g:netrw_sort_direction) | 7987 " call Decho("(s:PerformListing) g:netrw_sort_direction=".g:netrw_sort_direction) |
7741 if g:netrw_sort_direction =~ 'n' | 7988 if g:netrw_sort_direction =~ 'n' |
7742 " call Decho('exe sil keepjumps '.w:netrw_bannercnt.',$sort') | 7989 " call Decho('exe sil keepjumps '.w:netrw_bannercnt.',$sort') |
7743 exe 'sil! keepj '.w:netrw_bannercnt.',$sort'.' '.g:netrw_sort_options | 7990 exe 'sil! keepj '.w:netrw_bannercnt.',$sort'.' '.g:netrw_sort_options |
7744 else | 7991 else |
7745 " call Decho('exe sil keepjumps '.w:netrw_bannercnt.',$sort!') | 7992 " call Decho('exe sil keepjumps '.w:netrw_bannercnt.',$sort!') |
7749 keepj call histdel("/",-1) | 7996 keepj call histdel("/",-1) |
7750 endif | 7997 endif |
7751 endif | 7998 endif |
7752 | 7999 |
7753 elseif g:netrw_sort_direction =~ 'r' | 8000 elseif g:netrw_sort_direction =~ 'r' |
7754 " call Decho('reverse the sorted listing') | 8001 " call Decho('(s:PerformListing) reverse the sorted listing') |
7755 if !g:netrw_banner || w:netrw_bannercnt < line('$') | 8002 if !g:netrw_banner || w:netrw_bannercnt < line('$') |
7756 exe 'sil! keepj '.w:netrw_bannercnt.',$g/^/m '.w:netrw_bannercnt | 8003 exe 'sil! keepj '.w:netrw_bannercnt.',$g/^/m '.w:netrw_bannercnt |
7757 call histdel("/",-1) | 8004 call histdel("/",-1) |
7758 endif | 8005 endif |
7759 endif | 8006 endif |
7760 endif | 8007 endif |
8008 " call Decho("(s:PerformListing) g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")") | |
7761 | 8009 |
7762 " convert to wide/tree listing {{{3 | 8010 " convert to wide/tree listing {{{3 |
7763 " call Decho("(PerformListing) modify display if wide/tree listing style") | 8011 " call Decho("(s:PerformListing) modify display if wide/tree listing style") |
8012 " call Decho("(s:PerformListing) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#1)") | |
7764 keepj call s:NetrwWideListing() | 8013 keepj call s:NetrwWideListing() |
8014 " call Decho("(s:PerformListing) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#2)") | |
7765 keepj call s:NetrwTreeListing(b:netrw_curdir) | 8015 keepj call s:NetrwTreeListing(b:netrw_curdir) |
8016 " call Decho("(s:PerformListing) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#3)") | |
7766 | 8017 |
7767 if exists("w:netrw_bannercnt") && (line("$") > w:netrw_bannercnt || !g:netrw_banner) | 8018 if exists("w:netrw_bannercnt") && (line("$") > w:netrw_bannercnt || !g:netrw_banner) |
7768 " place cursor on the top-left corner of the file listing | 8019 " place cursor on the top-left corner of the file listing |
7769 " call Decho("(PerformListing) place cursor on top-left corner of file listing") | 8020 " call Decho("(s:PerformListing) place cursor on top-left corner of file listing") |
7770 exe 'sil! keepj '.w:netrw_bannercnt | 8021 exe 'sil! keepj '.w:netrw_bannercnt |
7771 sil! keepj norm! 0 | 8022 sil! keepj norm! 0 |
7772 endif | 8023 endif |
7773 | 8024 |
7774 " record previous current directory | 8025 " record previous current directory |
7775 let w:netrw_prvdir= b:netrw_curdir | 8026 let w:netrw_prvdir= b:netrw_curdir |
7776 " call Decho("(PerformListing) record netrw_prvdir<".w:netrw_prvdir.">") | 8027 " call Decho("(s:PerformListing) record netrw_prvdir<".w:netrw_prvdir.">") |
7777 | 8028 |
7778 " save certain window-oriented variables into buffer-oriented variables {{{3 | 8029 " save certain window-oriented variables into buffer-oriented variables {{{3 |
8030 " call Decho("(s:PerformListing) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#4)") | |
7779 keepj call s:SetBufWinVars() | 8031 keepj call s:SetBufWinVars() |
8032 " call Decho("(s:PerformListing) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#5)") | |
7780 keepj call s:NetrwOptionRestore("w:") | 8033 keepj call s:NetrwOptionRestore("w:") |
8034 " call Decho("(s:PerformListing) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#6)") | |
7781 | 8035 |
7782 " set display to netrw display settings | 8036 " set display to netrw display settings |
7783 " call Decho("(PerformListing) set display to netrw display settings (".g:netrw_bufsettings.")") | 8037 " call Decho("(s:PerformListing) set display to netrw display settings (".g:netrw_bufsettings.")") |
7784 exe "setl ".g:netrw_bufsettings | 8038 exe "setl ".g:netrw_bufsettings |
8039 " call Decho("(s:PerformListing) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#7)") | |
7785 if g:netrw_liststyle == s:LONGLIST | 8040 if g:netrw_liststyle == s:LONGLIST |
7786 " call Decho("(PerformListing) exe setl ts=".(g:netrw_maxfilenamelen+1)) | 8041 " call Decho("(s:PerformListing) exe setl ts=".(g:netrw_maxfilenamelen+1)) |
7787 exe "setl ts=".(g:netrw_maxfilenamelen+1) | 8042 exe "setl ts=".(g:netrw_maxfilenamelen+1) |
7788 endif | 8043 endif |
8044 | |
7789 if exists("s:treecurpos") | 8045 if exists("s:treecurpos") |
7790 | 8046 " call Decho("(s:PerformListing) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#8)") |
7791 keepj call netrw#NetrwRestorePosn(s:treecurpos) | 8047 keepj call netrw#NetrwRestorePosn(s:treecurpos) |
7792 unlet s:treecurpos | 8048 unlet s:treecurpos |
7793 endif | 8049 endif |
7794 | 8050 |
8051 " call Decho("(s:PerformListing) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (return)") | |
7795 " call Dret("s:PerformListing : curpos<".string(getpos(".")).">") | 8052 " call Dret("s:PerformListing : curpos<".string(getpos(".")).">") |
7796 endfun | 8053 endfun |
7797 | 8054 |
7798 " --------------------------------------------------------------------- | 8055 " --------------------------------------------------------------------- |
7799 " s:SetupNetrwStatusLine: {{{2 | 8056 " s:SetupNetrwStatusLine: {{{2 |
7846 " s:NetrwRemoteListing: {{{2 | 8103 " s:NetrwRemoteListing: {{{2 |
7847 fun! s:NetrwRemoteListing() | 8104 fun! s:NetrwRemoteListing() |
7848 " call Dfunc("s:NetrwRemoteListing() b:netrw_curdir<".b:netrw_curdir.">)") | 8105 " call Dfunc("s:NetrwRemoteListing() b:netrw_curdir<".b:netrw_curdir.">)") |
7849 | 8106 |
7850 call s:RemotePathAnalysis(b:netrw_curdir) | 8107 call s:RemotePathAnalysis(b:netrw_curdir) |
7851 " call Decho("b:netrw_method#".(exists("b:netrw_method")? b:netrw_method : 'n/a')) | |
7852 " call Decho("g:netrw_list_cmd<".(exists("g:netrw_list_cmd")? g:netrw_list_cmd : 'n/a').">") | |
7853 " call Decho("ssh is ".(executable("ssh")? "" : "not ")."executable") | |
7854 " call Decho("ftp is ".(executable("ftp")? "" : "not ")."executable") | |
7855 " call Decho("sftp is ".(executable("sftp")? "" : "not ")."executable") | |
7856 | 8108 |
7857 " sanity check: | 8109 " sanity check: |
7858 if exists("b:netrw_method") && b:netrw_method =~ '[235]' | 8110 if exists("b:netrw_method") && b:netrw_method =~ '[235]' |
7859 " b:netrw_method = 2: ftp+.netrc | 8111 " call Decho("b:netrw_method=".b:netrw_method) |
7860 " b:netrw_method = 3: ftp+machine,id,p/w,filename (ie. no .netrc) | |
7861 " b:netrw_method = 5: wget (http) | |
7862 " call Decho("b:netrw_method=".b:netrw_method." (for ".s:method.")") | |
7863 if !executable("ftp") | 8112 if !executable("ftp") |
7864 if !exists("g:netrw_quiet") | 8113 if !exists("g:netrw_quiet") |
7865 call netrw#ErrorMsg(s:ERROR,"this system doesn't support remote directory listing via ftp",18) | 8114 call netrw#ErrorMsg(s:ERROR,"this system doesn't support remote directory listing via ftp",18) |
7866 endif | 8115 endif |
7867 call s:NetrwOptionRestore("w:") | 8116 call s:NetrwOptionRestore("w:") |
7868 " call Dret("s:NetrwRemoteListing") | 8117 " call Dret("s:NetrwRemoteListing") |
7869 return | 8118 return |
7870 endif | 8119 endif |
7871 | 8120 |
7872 elseif s:method == "scp" && (!exists("g:netrw_list_cmd") || g:netrw_list_cmd == '') | 8121 elseif !exists("g:netrw_list_cmd") || g:netrw_list_cmd == '' |
7873 " call Decho("g:netrw_list_cmd<".(exists("g:netrw_list_cmd")? g:netrw_list_cmd : 'n/a').">") | |
7874 if !exists("g:netrw_quiet") | 8122 if !exists("g:netrw_quiet") |
7875 if !exists("g:netrw_list_cmd") || g:netrw_list_cmd == "" | 8123 if g:netrw_list_cmd == "" |
7876 keepj call netrw#ErrorMsg(s:ERROR,"neither ssh nor ftp"." is executable on your system",47) | 8124 keepj call netrw#ErrorMsg(s:ERROR,g:netrw_ssh_cmd." is not executable on your system",47) |
7877 else | 8125 else |
7878 keepj call netrw#ErrorMsg(s:ERROR,"this system doesn't support remote directory listing via ".g:netrw_list_cmd,19) | 8126 keepj call netrw#ErrorMsg(s:ERROR,"this system doesn't support remote directory listing via ".g:netrw_list_cmd,19) |
7879 endif | 8127 endif |
7880 endif | 8128 endif |
7881 | 8129 |
7887 if exists("b:netrw_method") | 8135 if exists("b:netrw_method") |
7888 " call Decho("setting w:netrw_method to b:netrw_method<".b:netrw_method.">") | 8136 " call Decho("setting w:netrw_method to b:netrw_method<".b:netrw_method.">") |
7889 let w:netrw_method= b:netrw_method | 8137 let w:netrw_method= b:netrw_method |
7890 endif | 8138 endif |
7891 | 8139 |
7892 if s:method == "ftp" | 8140 if s:method == "ftp" || s:method == "sftp" |
7893 " use ftp to get remote file listing {{{3 | 8141 " use ftp to get remote file listing {{{3 |
7894 " call Decho("use ftp to get remote file listing") | 8142 " call Decho("use ftp to get remote file listing") |
7895 let s:method = "ftp" | 8143 let s:method = "ftp" |
7896 let listcmd = g:netrw_ftp_list_cmd | 8144 let listcmd = g:netrw_ftp_list_cmd |
7897 if g:netrw_sort_by =~ '^t' | 8145 if g:netrw_sort_by =~ '^t' |
7898 let listcmd= g:netrw_ftp_timelist_cmd | 8146 let listcmd= g:netrw_ftp_timelist_cmd |
7899 elseif g:netrw_sort_by =~ '^s' | 8147 elseif g:netrw_sort_by =~ '^s' |
7900 let listcmd= g:netrw_ftp_sizelist_cmd | 8148 let listcmd= g:netrw_ftp_sizelist_cmd |
7901 endif | 8149 endif |
8195 " and reverse sorts will be requested of the server but not otherwise | 8443 " and reverse sorts will be requested of the server but not otherwise |
8196 " enforced here. | 8444 " enforced here. |
8197 fun! s:NetrwRemoteFtpCmd(path,listcmd) | 8445 fun! s:NetrwRemoteFtpCmd(path,listcmd) |
8198 " call Dfunc("NetrwRemoteFtpCmd(path<".a:path."> listcmd<".a:listcmd.">) w:netrw_method=".(exists("w:netrw_method")? w:netrw_method : (exists("b:netrw_method")? b:netrw_method : "???"))) | 8446 " call Dfunc("NetrwRemoteFtpCmd(path<".a:path."> listcmd<".a:listcmd.">) w:netrw_method=".(exists("w:netrw_method")? w:netrw_method : (exists("b:netrw_method")? b:netrw_method : "???"))) |
8199 " call Decho("line($)=".line("$")." w:netrw_bannercnt=".w:netrw_bannercnt) | 8447 " call Decho("line($)=".line("$")." w:netrw_bannercnt=".w:netrw_bannercnt) |
8448 " sanity check: {{{3 | |
8200 if !exists("w:netrw_method") | 8449 if !exists("w:netrw_method") |
8201 if exists("b:netrw_method") | 8450 if exists("b:netrw_method") |
8202 let w:netrw_method= b:netrw_method | 8451 let w:netrw_method= b:netrw_method |
8203 else | 8452 else |
8204 call netrw#ErrorMsg(2,"(s:NetrwRemoteFtpCmd) internal netrw error",93) | 8453 call netrw#ErrorMsg(2,"(s:NetrwRemoteFtpCmd) internal netrw error",93) |
8205 " call Dret("NetrwRemoteFtpCmd") | 8454 " call Dret("NetrwRemoteFtpCmd") |
8206 return | 8455 return |
8207 endif | 8456 endif |
8208 endif | 8457 endif |
8209 | 8458 |
8210 " because WinXX ftp uses unix style input | 8459 " WinXX ftp uses unix style input, so set ff to unix " {{{3 |
8211 let ffkeep= &ff | 8460 let ffkeep= &ff |
8212 setl ma ff=unix noro | 8461 setl ma ff=unix noro |
8213 " call Decho("setl ma ff=unix noro") | 8462 " call Decho("setl ma ff=unix noro") |
8214 | 8463 |
8215 " clear off any older non-banner lines | 8464 " clear off any older non-banner lines " {{{3 |
8216 " note that w:netrw_bannercnt indexes the line after the banner | 8465 " note that w:netrw_bannercnt indexes the line after the banner |
8217 " call Decho('exe sil! keepjumps '.w:netrw_bannercnt.",$d (clear off old non-banner lines)") | 8466 " call Decho('exe sil! keepjumps '.w:netrw_bannercnt.",$d (clear off old non-banner lines)") |
8218 exe "sil! keepjumps ".w:netrw_bannercnt.",$d" | 8467 exe "sil! keepjumps ".w:netrw_bannercnt.",$d" |
8219 | 8468 |
8220 "......................................... | 8469 "......................................... |
8221 if w:netrw_method == 2 || w:netrw_method == 5 | 8470 if w:netrw_method == 2 || w:netrw_method == 5 " {{{3 |
8222 " ftp + <.netrc>: Method #2 | 8471 " ftp + <.netrc>: Method #2 |
8223 if a:path != "" | 8472 if a:path != "" |
8224 keepj put ='cd \"'.a:path.'\"' | 8473 keepj put ='cd \"'.a:path.'\"' |
8225 endif | 8474 endif |
8226 if exists("g:netrw_ftpextracmd") | 8475 if exists("g:netrw_ftpextracmd") |
8235 else | 8484 else |
8236 " call Decho("exe ".s:netrw_silentxfer.w:netrw_bannercnt.",$!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)) | 8485 " call Decho("exe ".s:netrw_silentxfer.w:netrw_bannercnt.",$!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)) |
8237 exe s:netrw_silentxfer." keepj ".w:netrw_bannercnt.",$!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1) | 8486 exe s:netrw_silentxfer." keepj ".w:netrw_bannercnt.",$!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1) |
8238 endif | 8487 endif |
8239 | 8488 |
8240 "......................................... | 8489 "......................................... |
8241 elseif w:netrw_method == 3 | 8490 elseif w:netrw_method == 3 " {{{3 |
8242 " ftp + machine,id,passwd,filename: Method #3 | 8491 " ftp + machine,id,passwd,filename: Method #3 |
8243 setl ff=unix | 8492 setl ff=unix |
8244 if exists("g:netrw_port") && g:netrw_port != "" | 8493 if exists("g:netrw_port") && g:netrw_port != "" |
8245 keepj put ='open '.g:netrw_machine.' '.g:netrw_port | 8494 keepj put ='open '.g:netrw_machine.' '.g:netrw_port |
8246 else | 8495 else |
8279 " -n win32: quit being obnoxious about password | 8528 " -n win32: quit being obnoxious about password |
8280 " exe w:netrw_bannercnt.',$g/^./call Decho("ftp#".line(".").": ".getline("."))' | 8529 " exe w:netrw_bannercnt.',$g/^./call Decho("ftp#".line(".").": ".getline("."))' |
8281 " call Decho("exe ".s:netrw_silentxfer.w:netrw_bannercnt.",$!".s:netrw_ftp_cmd." ".g:netrw_ftp_options) | 8530 " call Decho("exe ".s:netrw_silentxfer.w:netrw_bannercnt.",$!".s:netrw_ftp_cmd." ".g:netrw_ftp_options) |
8282 exe s:netrw_silentxfer.w:netrw_bannercnt.",$!".s:netrw_ftp_cmd." ".g:netrw_ftp_options | 8531 exe s:netrw_silentxfer.w:netrw_bannercnt.",$!".s:netrw_ftp_cmd." ".g:netrw_ftp_options |
8283 | 8532 |
8284 "......................................... | 8533 "......................................... |
8285 else | 8534 elseif w:netrw_method == 9 " {{{3 |
8286 keepj call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . choice . ">",23) | 8535 " sftp username@machine: Method #9 |
8287 endif | 8536 " s:netrw_sftp_cmd |
8288 | 8537 setl ff=unix |
8289 " cleanup for Windows | 8538 " call Decho("COMBAK: still working on sftp remote listing") |
8539 | |
8540 " restore settings | |
8541 let &ff= ffkeep | |
8542 " call Dret("NetrwRemoteFtpCmd") | |
8543 return | |
8544 | |
8545 "......................................... | |
8546 else " {{{3 | |
8547 keepj call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . bufname("%") . ">",23) | |
8548 endif | |
8549 | |
8550 " cleanup for Windows " {{{3 | |
8290 if has("win32") || has("win95") || has("win64") || has("win16") | 8551 if has("win32") || has("win95") || has("win64") || has("win16") |
8291 sil! keepj %s/\r$//e | 8552 sil! keepj %s/\r$//e |
8292 keepj call histdel("/",-1) | 8553 keepj call histdel("/",-1) |
8293 endif | 8554 endif |
8294 if a:listcmd == "dir" | 8555 if a:listcmd == "dir" |
8301 exe "sil! keepj ".w:netrw_bannercnt.',$s/^\%(\S\+\s\+\)\{8}//e' | 8562 exe "sil! keepj ".w:netrw_bannercnt.',$s/^\%(\S\+\s\+\)\{8}//e' |
8302 keepj call histdel("/",-1) | 8563 keepj call histdel("/",-1) |
8303 endif | 8564 endif |
8304 endif | 8565 endif |
8305 | 8566 |
8306 " ftp's listing doesn't seem to include ./ or ../ | 8567 " ftp's listing doesn't seem to include ./ or ../ " {{{3 |
8307 if !search('^\.\/$\|\s\.\/$','wn') | 8568 if !search('^\.\/$\|\s\.\/$','wn') |
8308 exe 'keepj '.w:netrw_bannercnt | 8569 exe 'keepj '.w:netrw_bannercnt |
8309 keepj put ='./' | 8570 keepj put ='./' |
8310 endif | 8571 endif |
8311 if !search('^\.\.\/$\|\s\.\.\/$','wn') | 8572 if !search('^\.\.\/$\|\s\.\.\/$','wn') |
8312 exe 'keepj '.w:netrw_bannercnt | 8573 exe 'keepj '.w:netrw_bannercnt |
8313 keepj put ='../' | 8574 keepj put ='../' |
8314 endif | 8575 endif |
8315 | 8576 |
8316 " restore settings | 8577 " restore settings " {{{3 |
8317 let &ff= ffkeep | 8578 let &ff= ffkeep |
8318 " call Dret("NetrwRemoteFtpCmd") | 8579 " call Dret("NetrwRemoteFtpCmd") |
8319 endfun | 8580 endfun |
8320 | 8581 |
8321 " --------------------------------------------------------------------- | 8582 " --------------------------------------------------------------------- |
8455 " to write to the DBG buffer are made. | 8716 " to write to the DBG buffer are made. |
8456 " The &ft == "netrw" test was installed because the BufEnter event | 8717 " The &ft == "netrw" test was installed because the BufEnter event |
8457 " would hit when re-entering netrw windows, creating unexpected | 8718 " would hit when re-entering netrw windows, creating unexpected |
8458 " refreshes (and would do so in the middle of NetrwSaveOptions(), too) | 8719 " refreshes (and would do so in the middle of NetrwSaveOptions(), too) |
8459 " call Decho("(LocalBrowseCheck) isdir<".a:dirname.">=".isdirectory(a:dirname).((exists("s:treeforceredraw")? " treeforceredraw" : ""))) | 8720 " call Decho("(LocalBrowseCheck) isdir<".a:dirname.">=".isdirectory(a:dirname).((exists("s:treeforceredraw")? " treeforceredraw" : ""))) |
8460 " call Dredir("LocalBrowseCheck","ls!")|redraw!|sleep 3 | 8721 " call Decho("(LocalBrowseCheck) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) |
8722 " call Dredir("(LocalBrowseCheck) ls!","ls!") | |
8461 let ykeep= @@ | 8723 let ykeep= @@ |
8462 if isdirectory(a:dirname) | 8724 if isdirectory(a:dirname) |
8463 " call Decho("(LocalBrowseCheck) is-directory 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) | 8725 " call Decho("(LocalBrowseCheck) is-directory 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) |
8464 let svposn= netrw#NetrwSavePosn() | 8726 let svposn= netrw#NetrwSavePosn() |
8465 if &ft != "netrw" || (exists("b:netrw_curdir") && b:netrw_curdir != a:dirname) || g:netrw_fastbrowse <= 1 | 8727 if &ft != "netrw" || (exists("b:netrw_curdir") && b:netrw_curdir != a:dirname) || g:netrw_fastbrowse <= 1 |
8728 " call Decho("(LocalBrowseCheck) case 1 (ft!=netrw)") | |
8466 sil! keepj keepalt call s:NetrwBrowse(1,a:dirname) | 8729 sil! keepj keepalt call s:NetrwBrowse(1,a:dirname) |
8467 keepalt call netrw#NetrwRestorePosn(svposn) | 8730 keepalt call netrw#NetrwRestorePosn(svposn) |
8731 | |
8468 elseif &ft == "netrw" && line("$") == 1 | 8732 elseif &ft == "netrw" && line("$") == 1 |
8733 " call Decho("(LocalBrowseCheck) case 2 (ft==netrw)") | |
8469 sil! keepj keepalt call s:NetrwBrowse(1,a:dirname) | 8734 sil! keepj keepalt call s:NetrwBrowse(1,a:dirname) |
8470 keepalt call netrw#NetrwRestorePosn(svposn) | 8735 keepalt call netrw#NetrwRestorePosn(svposn) |
8736 | |
8471 elseif exists("s:treeforceredraw") | 8737 elseif exists("s:treeforceredraw") |
8738 " call Decho("(LocalBrowseCheck) case 3 (treeforceredraw)") | |
8472 unlet s:treeforceredraw | 8739 unlet s:treeforceredraw |
8473 sil! keepj keepalt call s:NetrwBrowse(1,a:dirname) | 8740 sil! keepj keepalt call s:NetrwBrowse(1,a:dirname) |
8474 keepalt call netrw#NetrwRestorePosn(svposn) | 8741 keepalt call netrw#NetrwRestorePosn(svposn) |
8475 endif | 8742 endif |
8476 endif | 8743 |
8744 endif | |
8745 | |
8477 " following code wipes out currently unused netrw buffers | 8746 " following code wipes out currently unused netrw buffers |
8478 " IF g:netrw_fastbrowse is zero (ie. slow browsing selected) | 8747 " IF g:netrw_fastbrowse is zero (ie. slow browsing selected) |
8479 " AND IF the listing style is not a tree listing | 8748 " AND IF the listing style is not a tree listing |
8480 if exists("g:netrw_fastbrowse") && g:netrw_fastbrowse == 0 && g:netrw_liststyle != s:TREELIST | 8749 if exists("g:netrw_fastbrowse") && g:netrw_fastbrowse == 0 && g:netrw_liststyle != s:TREELIST |
8481 let ibuf = 1 | 8750 let ibuf = 1 |
8486 endif | 8755 endif |
8487 let ibuf= ibuf + 1 | 8756 let ibuf= ibuf + 1 |
8488 endwhile | 8757 endwhile |
8489 endif | 8758 endif |
8490 let @@= ykeep | 8759 let @@= ykeep |
8760 " call Decho("(LocalBrowseCheck) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) | |
8491 " not a directory, ignore it | 8761 " not a directory, ignore it |
8492 endfun | 8762 endfun |
8493 | 8763 |
8494 " --------------------------------------------------------------------- | 8764 " --------------------------------------------------------------------- |
8495 " s:LocalListing: does the job of "ls" for local directories {{{2 | 8765 " s:LocalListing: does the job of "ls" for local directories {{{2 |
8498 " call Decho("(LocalListing) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") | 8768 " call Decho("(LocalListing) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") |
8499 " call Decho("(LocalListing) tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) | 8769 " call Decho("(LocalListing) tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) |
8500 | 8770 |
8501 " 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 | 8771 " 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 |
8502 " 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 | 8772 " 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 |
8773 " call Decho("(s:LocalListing) g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")") | |
8503 | 8774 |
8504 " get the list of files contained in the current directory | 8775 " get the list of files contained in the current directory |
8505 let dirname = b:netrw_curdir | 8776 let dirname = b:netrw_curdir |
8506 let dirnamelen = s:Strlen(b:netrw_curdir) | 8777 let dirnamelen = strlen(b:netrw_curdir) |
8507 let filelist = glob(s:ComposePath(dirname,"*"),0,1) | 8778 let filelist = glob(s:ComposePath(dirname,"*"),0,1) |
8508 let filelist = filelist + glob(s:ComposePath(dirname,".*"),0,1) | 8779 let filelist = filelist + glob(s:ComposePath(dirname,".*"),0,1) |
8509 " call Decho("(LocalListing) filelist=".filelist) | 8780 " call Decho("(LocalListing) filelist=".filelist) |
8510 | 8781 |
8511 if g:netrw_cygwin == 0 && (has("win32") || has("win95") || has("win64") || has("win16")) | 8782 if g:netrw_cygwin == 0 && (has("win32") || has("win95") || has("win64") || has("win16")) |
8525 let filelistcopy = map(deepcopy(filelist),'fnamemodify(v:val, ":t")') | 8796 let filelistcopy = map(deepcopy(filelist),'fnamemodify(v:val, ":t")') |
8526 let g:netrw_maxfilenamelen = max(map(filelistcopy,'len(v:val)')) + 1 | 8797 let g:netrw_maxfilenamelen = max(map(filelistcopy,'len(v:val)')) + 1 |
8527 " call Decho("(LocalListing) dynamic_maxfilenamelen: filenames =".string(filelistcopy)) | 8798 " call Decho("(LocalListing) dynamic_maxfilenamelen: filenames =".string(filelistcopy)) |
8528 " call Decho("(LocalListing) dynamic_maxfilenamelen: g:netrw_maxfilenamelen=".g:netrw_maxfilenamelen) | 8799 " call Decho("(LocalListing) dynamic_maxfilenamelen: g:netrw_maxfilenamelen=".g:netrw_maxfilenamelen) |
8529 endif | 8800 endif |
8801 " call Decho("(s:LocalListing) g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")") | |
8530 | 8802 |
8531 for filename in filelist | 8803 for filename in filelist |
8532 " call Decho("(LocalListing) ") | 8804 " call Decho("(LocalListing) ") |
8533 " call Decho("(LocalListing) (while) filename<".filename.">") | 8805 " call Decho("(LocalListing) for filename in filelist: filename<".filename.">") |
8534 | 8806 |
8535 if getftype(filename) == "link" | 8807 if getftype(filename) == "link" |
8536 " indicate a symbolic link | 8808 " indicate a symbolic link |
8537 " call Decho("(LocalListing) indicate <".filename."> is a symbolic link with trailing @") | 8809 " call Decho("(LocalListing) indicate <".filename."> is a symbolic link with trailing @") |
8538 let pfile= filename."@" | 8810 let pfile= filename."@" |
9010 " netrw#WinPath: tries to insure that the path is windows-acceptable, whether cygwin is used or not {{{2 | 9282 " netrw#WinPath: tries to insure that the path is windows-acceptable, whether cygwin is used or not {{{2 |
9011 fun! netrw#WinPath(path) | 9283 fun! netrw#WinPath(path) |
9012 " call Dfunc("netrw#WinPath(path<".a:path.">)") | 9284 " call Dfunc("netrw#WinPath(path<".a:path.">)") |
9013 if (!g:netrw_cygwin || &shell !~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$') && (has("win32") || has("win95") || has("win64") || has("win16")) | 9285 if (!g:netrw_cygwin || &shell !~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$') && (has("win32") || has("win95") || has("win64") || has("win16")) |
9014 " remove cygdrive prefix, if present | 9286 " remove cygdrive prefix, if present |
9015 let path = substitute(a:path,'/cygdrive/\(.\)','\1:','') | 9287 let path = substitute(a:path,g:netrw_cygdrive.'/\(.\)','\1:','') |
9016 " remove trailing slash (Win95) | 9288 " remove trailing slash (Win95) |
9017 let path = substitute(path, '\(\\\|/\)$', '', 'g') | 9289 let path = substitute(path, '\(\\\|/\)$', '', 'g') |
9018 " remove escaped spaces | 9290 " remove escaped spaces |
9019 let path = substitute(path, '\ ', ' ', 'g') | 9291 let path = substitute(path, '\ ', ' ', 'g') |
9020 " convert slashes to backslashes | 9292 " convert slashes to backslashes |
9085 | 9357 |
9086 " set up string holding position parameters | 9358 " set up string holding position parameters |
9087 let ret = "let w:netrw_winnr=".w:netrw_winnr."|let w:netrw_line=".w:netrw_line."|let w:netrw_col=".w:netrw_col."|let w:netrw_hline=".w:netrw_hline | 9359 let ret = "let w:netrw_winnr=".w:netrw_winnr."|let w:netrw_line=".w:netrw_line."|let w:netrw_col=".w:netrw_col."|let w:netrw_hline=".w:netrw_hline |
9088 | 9360 |
9089 keepj call netrw#NetrwRestorePosn() | 9361 keepj call netrw#NetrwRestorePosn() |
9090 " call Dret("netrw#NetrwSavePosn : winnr=".w:netrw_winnr." line=".w:netrw_line." col=".w:netrw_col." hline=".w:netrw_hline) | 9362 " call Dret("netrw#NetrwSavePosn : winnr=".(exists("w:netrw_winnr")? w:netrw_winnr : "n/a")." line=".(exists("w:netrw_line")? w:netrw_line : "n/a")." col=".(exists("w:netrw_col")? w:netrw_col : "n/a")." hline=".(exists("w:netrw_hline")? w:netrw_hline : "n/a")) |
9091 return ret | 9363 return ret |
9092 endfun | 9364 endfun |
9093 | 9365 |
9094 " --------------------------------------------------------------------- | 9366 " --------------------------------------------------------------------- |
9095 " netrw#NetrwAccess: intended to provide access to variable values for netrw's test suite {{{2 | 9367 " netrw#NetrwAccess: intended to provide access to variable values for netrw's test suite {{{2 |
9177 " s:FileReadable: o/s independent filereadable {{{2 | 9449 " s:FileReadable: o/s independent filereadable {{{2 |
9178 fun! s:FileReadable(fname) | 9450 fun! s:FileReadable(fname) |
9179 " call Dfunc("s:FileReadable(fname<".a:fname.">)") | 9451 " call Dfunc("s:FileReadable(fname<".a:fname.">)") |
9180 | 9452 |
9181 if g:netrw_cygwin | 9453 if g:netrw_cygwin |
9182 let ret= filereadable(substitute(a:fname,'/cygdrive/\(.\)','\1:/','')) | 9454 let ret= filereadable(substitute(a:fname,g:netrw_cygdrive.'/\(.\)','\1:/','')) |
9183 else | 9455 else |
9184 let ret= filereadable(a:fname) | 9456 let ret= filereadable(a:fname) |
9185 endif | 9457 endif |
9186 | 9458 |
9187 " call Dret("s:FileReadable ".ret) | 9459 " call Dret("s:FileReadable ".ret) |
9215 let s:netrw_tmpfile= tmpfile " used by netrw#NetSource() and netrw#NetrwBrowseX() | 9487 let s:netrw_tmpfile= tmpfile " used by netrw#NetSource() and netrw#NetrwBrowseX() |
9216 " call Decho("tmpfile<".tmpfile."> s:netrw_tmpfile<".s:netrw_tmpfile.">") | 9488 " call Decho("tmpfile<".tmpfile."> s:netrw_tmpfile<".s:netrw_tmpfile.">") |
9217 | 9489 |
9218 " o/s dependencies | 9490 " o/s dependencies |
9219 if g:netrw_cygwin != 0 | 9491 if g:netrw_cygwin != 0 |
9220 let tmpfile = substitute(tmpfile,'^\(\a\):','/cygdrive/\1','e') | 9492 let tmpfile = substitute(tmpfile,'^\(\a\):',g:netrw_cygdrive.'/\1','e') |
9221 elseif has("win32") || has("win95") || has("win64") || has("win16") | 9493 elseif has("win32") || has("win95") || has("win64") || has("win16") |
9222 if !exists("+shellslash") || !&ssl | 9494 if !exists("+shellslash") || !&ssl |
9223 let tmpfile = substitute(tmpfile,'/','\','g') | 9495 let tmpfile = substitute(tmpfile,'/','\','g') |
9224 endif | 9496 endif |
9225 else | 9497 else |
9340 " thin-long-tree: user's cursorline, user's cursorcolumn | 9612 " thin-long-tree: user's cursorline, user's cursorcolumn |
9341 " wide : cursorline, user's cursorcolumn | 9613 " wide : cursorline, user's cursorcolumn |
9342 let &l:cursorcolumn = s:netrw_usercuc | 9614 let &l:cursorcolumn = s:netrw_usercuc |
9343 if w:netrw_liststyle == s:WIDELIST | 9615 if w:netrw_liststyle == s:WIDELIST |
9344 " call Decho("case g:netrw_cursor==2 and wide: setl cul (use user's cuc)") | 9616 " call Decho("case g:netrw_cursor==2 and wide: setl cul (use user's cuc)") |
9345 set cursorline | 9617 setl cursorline |
9346 else | 9618 else |
9347 " call Decho("case g:netrw_cursor==2 and not wide: (use user's cul,cuc)") | 9619 " call Decho("case g:netrw_cursor==2 and not wide: (use user's cul,cuc)") |
9348 let &l:cursorline = s:netrw_usercul | 9620 let &l:cursorline = s:netrw_usercul |
9349 endif | 9621 endif |
9350 | 9622 |
9359 endfun | 9631 endfun |
9360 | 9632 |
9361 " --------------------------------------------------------------------- | 9633 " --------------------------------------------------------------------- |
9362 " s:RestoreCursorline: restores cursorline/cursorcolumn to original user settings {{{2 | 9634 " s:RestoreCursorline: restores cursorline/cursorcolumn to original user settings {{{2 |
9363 fun! s:RestoreCursorline() | 9635 fun! s:RestoreCursorline() |
9364 " call Dfunc("s:RestoreCursorline() currently, cul=".&l:cursorline." cuc=".&l:cursorcolumn." win#".winnr()." buf#".bufnr("%")." mod=".&mod) | 9636 " call Dfunc("s:RestoreCursorline() currently, cul=".&l:cursorline." cuc=".&l:cursorcolumn." win#".winnr()." buf#".bufnr("%")) |
9365 if exists("s:netrw_usercul") | 9637 if exists("s:netrw_usercul") |
9366 let &l:cursorline = s:netrw_usercul | 9638 let &l:cursorline = s:netrw_usercul |
9367 endif | 9639 endif |
9368 if exists("s:netrw_usercuc") | 9640 if exists("s:netrw_usercuc") |
9369 let &l:cursorcolumn = s:netrw_usercuc | 9641 let &l:cursorcolumn = s:netrw_usercuc |
9404 | 9676 |
9405 " --------------------------------------------------------------------- | 9677 " --------------------------------------------------------------------- |
9406 " s:NetrwEnew: opens a new buffer, passes netrw buffer variables through {{{2 | 9678 " s:NetrwEnew: opens a new buffer, passes netrw buffer variables through {{{2 |
9407 fun! s:NetrwEnew(...) | 9679 fun! s:NetrwEnew(...) |
9408 " call Dfunc("s:NetrwEnew() a:0=".a:0." bufnr($)=".bufnr("$")) | 9680 " call Dfunc("s:NetrwEnew() a:0=".a:0." bufnr($)=".bufnr("$")) |
9409 " call Decho("curdir<".((a:0>0)? a:1 : "")."> buf#".bufnr("%")."<".bufname("%").">") | 9681 " call Decho("(s:NetrwEnew) curdir<".((a:0>0)? a:1 : "")."> buf#".bufnr("%")."<".bufname("%").">") |
9410 | 9682 |
9411 " grab a function-local-variable copy of buffer variables | 9683 " grab a function-local-variable copy of buffer variables |
9412 " call Decho("make function-local copy of netrw variables") | 9684 " call Decho("(s:NetrwEnew) make function-local copy of netrw variables") |
9413 if exists("b:netrw_bannercnt") |let netrw_bannercnt = b:netrw_bannercnt |endif | 9685 if exists("b:netrw_bannercnt") |let netrw_bannercnt = b:netrw_bannercnt |endif |
9414 if exists("b:netrw_browser_active") |let netrw_browser_active = b:netrw_browser_active |endif | 9686 if exists("b:netrw_browser_active") |let netrw_browser_active = b:netrw_browser_active |endif |
9415 if exists("b:netrw_cpf") |let netrw_cpf = b:netrw_cpf |endif | 9687 if exists("b:netrw_cpf") |let netrw_cpf = b:netrw_cpf |endif |
9416 if exists("b:netrw_curdir") |let netrw_curdir = b:netrw_curdir |endif | 9688 if exists("b:netrw_curdir") |let netrw_curdir = b:netrw_curdir |endif |
9417 if exists("b:netrw_explore_bufnr") |let netrw_explore_bufnr = b:netrw_explore_bufnr |endif | 9689 if exists("b:netrw_explore_bufnr") |let netrw_explore_bufnr = b:netrw_explore_bufnr |endif |
9426 if exists("b:netrw_method") |let netrw_method = b:netrw_method |endif | 9698 if exists("b:netrw_method") |let netrw_method = b:netrw_method |endif |
9427 if exists("b:netrw_option") |let netrw_option = b:netrw_option |endif | 9699 if exists("b:netrw_option") |let netrw_option = b:netrw_option |endif |
9428 if exists("b:netrw_prvdir") |let netrw_prvdir = b:netrw_prvdir |endif | 9700 if exists("b:netrw_prvdir") |let netrw_prvdir = b:netrw_prvdir |endif |
9429 | 9701 |
9430 keepj call s:NetrwOptionRestore("w:") | 9702 keepj call s:NetrwOptionRestore("w:") |
9431 " call Decho("generate a buffer with keepjumps keepalt enew!") | 9703 " call Decho("(s:NetrwEnew) generate a buffer with keepjumps keepalt enew!") |
9432 let netrw_keepdiff= &l:diff | 9704 let netrw_keepdiff= &l:diff |
9433 keepj keepalt enew! | 9705 keepj keepalt enew! |
9434 let &l:diff= netrw_keepdiff | 9706 let &l:diff= netrw_keepdiff |
9435 " call Decho("bufnr($)=".bufnr("$")) | 9707 " call Decho("(s:NetrwEnew) bufnr($)=".bufnr("$")." winnr($)=".winnr("$")) |
9436 keepj call s:NetrwOptionSave("w:") | 9708 keepj call s:NetrwOptionSave("w:") |
9437 | 9709 |
9438 " copy function-local-variables to buffer variable equivalents | 9710 " copy function-local-variables to buffer variable equivalents |
9439 " call Decho("copy function-local variables back to buffer netrw variables") | 9711 " call Decho("(s:NetrwEnew) copy function-local variables back to buffer netrw variables") |
9440 if exists("netrw_bannercnt") |let b:netrw_bannercnt = netrw_bannercnt |endif | 9712 if exists("netrw_bannercnt") |let b:netrw_bannercnt = netrw_bannercnt |endif |
9441 if exists("netrw_browser_active") |let b:netrw_browser_active = netrw_browser_active |endif | 9713 if exists("netrw_browser_active") |let b:netrw_browser_active = netrw_browser_active |endif |
9442 if exists("netrw_cpf") |let b:netrw_cpf = netrw_cpf |endif | 9714 if exists("netrw_cpf") |let b:netrw_cpf = netrw_cpf |endif |
9443 if exists("netrw_curdir") |let b:netrw_curdir = netrw_curdir |endif | 9715 if exists("netrw_curdir") |let b:netrw_curdir = netrw_curdir |endif |
9444 if exists("netrw_explore_bufnr") |let b:netrw_explore_bufnr = netrw_explore_bufnr |endif | 9716 if exists("netrw_explore_bufnr") |let b:netrw_explore_bufnr = netrw_explore_bufnr |endif |
9466 exe "sil! keepalt file ".fnameescape(b:netrw_curdir) | 9738 exe "sil! keepalt file ".fnameescape(b:netrw_curdir) |
9467 endif | 9739 endif |
9468 endif | 9740 endif |
9469 endif | 9741 endif |
9470 | 9742 |
9471 " call Dret("s:NetrwEnew : buf#".bufnr("%")."<".bufname("%")."> expand(%)<".expand("%")."> expand(#)<".expand("#")."> bh=".&bh) | 9743 " call Dret("s:NetrwEnew : buf#".bufnr("%")."<".bufname("%")."> expand(%)<".expand("%")."> expand(#)<".expand("#")."> bh=".&bh." win#".winnr()." winnr($)#".winnr("$")) |
9472 endfun | 9744 endfun |
9473 | 9745 |
9474 " --------------------------------------------------------------------- | 9746 " --------------------------------------------------------------------- |
9475 " s:NetrwInsureWinVars: insure that a netrw buffer has its w: variables in spite of a wincmd v or s {{{2 | 9747 " s:NetrwInsureWinVars: insure that a netrw buffer has its w: variables in spite of a wincmd v or s {{{2 |
9476 fun! s:NetrwInsureWinVars() | 9748 fun! s:NetrwInsureWinVars() |
9535 " --------------------------------------------------------------------- | 9807 " --------------------------------------------------------------------- |
9536 " s:RemotePathAnalysis: {{{2 | 9808 " s:RemotePathAnalysis: {{{2 |
9537 fun! s:RemotePathAnalysis(dirname) | 9809 fun! s:RemotePathAnalysis(dirname) |
9538 " call Dfunc("s:RemotePathAnalysis(a:dirname<".a:dirname.">)") | 9810 " call Dfunc("s:RemotePathAnalysis(a:dirname<".a:dirname.">)") |
9539 | 9811 |
9540 let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/:#]\+\)\%([:#]\(\d\+\)\)\=/\(.*\)$' | 9812 let dirpat = '^\(\w\{-}\)://\(\(\w\+\)@\)\=\([^/:#]\+\)\%([:#]\(\d\+\)\)\=/\(.*\)$' |
9541 let s:method = substitute(a:dirname,dirpat,'\1','') | 9813 let s:method = substitute(a:dirname,dirpat,'\1','') |
9542 let s:user = substitute(a:dirname,dirpat,'\2','') | 9814 let s:user = substitute(a:dirname,dirpat,'\3','') |
9543 let s:machine = substitute(a:dirname,dirpat,'\3','') | 9815 let s:machine = substitute(a:dirname,dirpat,'\4','') |
9544 let s:port = substitute(a:dirname,dirpat,'\4','') | 9816 let s:port = substitute(a:dirname,dirpat,'\5','') |
9545 let s:path = substitute(a:dirname,dirpat,'\5','') | 9817 let s:path = substitute(a:dirname,dirpat,'\6','') |
9546 let s:fname = substitute(a:dirname,'^.*/\ze.','','') | 9818 let s:fname = substitute(a:dirname,'^.*/\ze.','','') |
9547 | 9819 |
9548 " call Decho("set up s:method <".s:method .">") | 9820 " call Decho("set up s:method <".s:method .">") |
9549 " call Decho("set up s:user <".s:user .">") | 9821 " call Decho("set up s:user <".s:user .">") |
9550 " call Decho("set up s:machine<".s:machine.">") | 9822 " call Decho("set up s:machine<".s:machine.">") |
9619 if exists("s:netrwdrag") | 9891 if exists("s:netrwdrag") |
9620 return | 9892 return |
9621 endif | 9893 endif |
9622 " call Dfunc("s:NetrwRexplore() w:netrw_rexlocal=".w:netrw_rexlocal." w:netrw_rexdir<".w:netrw_rexdir.">") | 9894 " call Dfunc("s:NetrwRexplore() w:netrw_rexlocal=".w:netrw_rexlocal." w:netrw_rexdir<".w:netrw_rexdir.">") |
9623 if !exists("w:netrw_rexlocal") | 9895 if !exists("w:netrw_rexlocal") |
9624 " " call Dret("s:NetrwRexplore() w:netrw_rexlocal doesn't exist") | 9896 " call Dret("s:NetrwRexplore() w:netrw_rexlocal doesn't exist") |
9625 return | 9897 return |
9626 endif | 9898 endif |
9899 " call Decho("(NetrwRexplore) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) | |
9627 if w:netrw_rexlocal | 9900 if w:netrw_rexlocal |
9628 keepj call netrw#LocalBrowseCheck(w:netrw_rexdir) | 9901 keepj call netrw#LocalBrowseCheck(w:netrw_rexdir) |
9629 else | 9902 else |
9630 keepj call s:NetrwBrowse(0,w:netrw_rexdir) | 9903 keepj call s:NetrwBrowse(0,w:netrw_rexdir) |
9631 endif | 9904 endif |
9640 " call Decho("(NetrwRexplore) s:rexposn_".bufnr('%')." doesn't exist") | 9913 " call Decho("(NetrwRexplore) s:rexposn_".bufnr('%')." doesn't exist") |
9641 endif | 9914 endif |
9642 if exists("s:explore_match") | 9915 if exists("s:explore_match") |
9643 exe "2match netrwMarkFile /".s:explore_match."/" | 9916 exe "2match netrwMarkFile /".s:explore_match."/" |
9644 endif | 9917 endif |
9918 " call Decho("(NetrwRexplore) settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo) | |
9645 " call Dret("s:NetrwRexplore") | 9919 " call Dret("s:NetrwRexplore") |
9646 endfun | 9920 endfun |
9647 | 9921 |
9648 " --------------------------------------------------------------------- | 9922 " --------------------------------------------------------------------- |
9649 " s:SaveBufVars: {{{2 | 9923 " s:SaveBufVars: save selected b: variables to s: variables {{{2 |
9924 " use s:RestoreBufVars() to restore b: variables from s: variables | |
9650 fun! s:SaveBufVars() | 9925 fun! s:SaveBufVars() |
9651 " call Dfunc("s:SaveBufVars() buf#".bufnr("%")) | 9926 " call Dfunc("s:SaveBufVars() buf#".bufnr("%")) |
9652 | 9927 |
9653 if exists("b:netrw_curdir") |let s:netrw_curdir = b:netrw_curdir |endif | 9928 if exists("b:netrw_curdir") |let s:netrw_curdir = b:netrw_curdir |endif |
9654 if exists("b:netrw_lastfile") |let s:netrw_lastfile = b:netrw_lastfile |endif | 9929 if exists("b:netrw_lastfile") |let s:netrw_lastfile = b:netrw_lastfile |endif |
9715 let w:netrw_rexlocal = a:islocal | 9990 let w:netrw_rexlocal = a:islocal |
9716 " call Dret("s:SetRexDir : win#".winnr()." ".(a:islocal? "local" : "remote")." dir: ".a:dirname) | 9991 " call Dret("s:SetRexDir : win#".winnr()." ".(a:islocal? "local" : "remote")." dir: ".a:dirname) |
9717 endfun | 9992 endfun |
9718 | 9993 |
9719 " --------------------------------------------------------------------- | 9994 " --------------------------------------------------------------------- |
9720 " s:Strlen: this function returns the length of a string, even if its {{{2 | 9995 " s:Strlen: this function returns the length of a string, even if its using multi-byte characters. {{{2 |
9721 " using multiple-byte characters. | 9996 " Solution from Nicolai Weibull, vim docs (:help strlen()), |
9722 " Solution from Nicolai Weibull, vim docs (:help strlen()), Tony Mechelynck, | 9997 " Tony Mechelynck, and my own invention. |
9723 " and a bit from me. | |
9724 " if g:netrw_xstrlen is zero (default), then the builtin strlen() function is used. | |
9725 fun! s:Strlen(x) | 9998 fun! s:Strlen(x) |
9726 " call Dfunc("s:Strlen(x<".a:x.">") | 9999 " "" call Dfunc("s:Strlen(x<".a:x."> g:Align_xstrlen=".g:Align_xstrlen.")") |
9727 if g:netrw_xstrlen == 1 | 10000 |
10001 if v:version >= 703 && exists("*strdisplaywidth") | |
10002 let ret= strdisplaywidth(a:x) | |
10003 | |
10004 elseif type(g:Align_xstrlen) == 1 | |
10005 " allow user to specify a function to compute the string length (ie. let g:Align_xstrlen="mystrlenfunc") | |
10006 exe "let ret= ".g:Align_xstrlen."('".substitute(a:x,"'","''","g")."')" | |
10007 | |
10008 elseif g:Align_xstrlen == 1 | |
9728 " number of codepoints (Latin a + combining circumflex is two codepoints) | 10009 " number of codepoints (Latin a + combining circumflex is two codepoints) |
9729 " (comment from TM, solution from NW) | 10010 " (comment from TM, solution from NW) |
9730 let ret= strlen(substitute(a:x,'.','c','g')) | 10011 let ret= strlen(substitute(a:x,'.','c','g')) |
9731 | 10012 |
9732 elseif g:netrw_xstrlen == 2 | 10013 elseif g:Align_xstrlen == 2 |
9733 " number of spacing codepoints (Latin a + combining circumflex is one spacing | 10014 " number of spacing codepoints (Latin a + combining circumflex is one spacing |
9734 " codepoint; a hard tab is one; wide and narrow CJK are one each; etc.) | 10015 " codepoint; a hard tab is one; wide and narrow CJK are one each; etc.) |
9735 " (comment from TM, solution from TM) | 10016 " (comment from TM, solution from TM) |
9736 let ret=strlen(substitute(a:x, '.\Z', 'x', 'g')) | 10017 let ret=strlen(substitute(a:x, '.\Z', 'x', 'g')) |
9737 | 10018 |
9738 elseif g:netrw_xstrlen == 3 | 10019 elseif g:Align_xstrlen == 3 |
9739 " virtual length (counting, for instance, tabs as anything between 1 and | 10020 " virtual length (counting, for instance, tabs as anything between 1 and |
9740 " 'tabstop', wide CJK as 2 rather than 1, Arabic alif as zero when immediately | 10021 " 'tabstop', wide CJK as 2 rather than 1, Arabic alif as zero when immediately |
9741 " preceded by lam, one otherwise, etc.) | 10022 " preceded by lam, one otherwise, etc.) |
9742 " (comment from TM, solution from me) | 10023 " (comment from TM, solution from me) |
9743 let modkeep= &mod | 10024 let modkeep= &l:mod |
9744 exe "keepj norm! o\<esc>" | 10025 exe "norm! o\<esc>" |
9745 call setline(line("."),a:x) | 10026 call setline(line("."),a:x) |
9746 let ret= virtcol("$") - 1 | 10027 let ret= virtcol("$") - 1 |
9747 keepj d | 10028 d |
9748 keepj norm! k | 10029 keepj norm! k |
9749 let &mod= modkeep | 10030 let &l:mod= modkeep |
9750 | 10031 |
9751 else | 10032 else |
9752 " at least give a decent default | 10033 " at least give a decent default |
9753 let ret= strlen(a:x) | 10034 let ret= strlen(a:x) |
9754 endif | 10035 endif |
9755 " call Dret("s:Strlen ".ret) | 10036 " "" call Dret("s:Strlen ".ret) |
9756 return ret | 10037 return ret |
9757 endfun | 10038 endfun |
9758 | 10039 |
9759 " --------------------------------------------------------------------- | 10040 " --------------------------------------------------------------------- |
9760 " s:TreeListMove: {{{2 | 10041 " s:TreeListMove: {{{2 |
9762 " call Dfunc("s:TreeListMove(dir<".a:dir.">)") | 10043 " call Dfunc("s:TreeListMove(dir<".a:dir.">)") |
9763 let curline = getline('.') | 10044 let curline = getline('.') |
9764 let prvline = (line(".") > 1)? getline(line(".")-1) : '' | 10045 let prvline = (line(".") > 1)? getline(line(".")-1) : '' |
9765 let nxtline = (line(".") < line("$"))? getline(line(".")+1) : '' | 10046 let nxtline = (line(".") < line("$"))? getline(line(".")+1) : '' |
9766 let curindent= substitute(curline,'^\([| ]*\).\{-}$','\1','') | 10047 let curindent= substitute(curline,'^\([| ]*\).\{-}$','\1','') |
9767 let indentm1 = substitute(curindent,'^| ','','') | 10048 let indentm1 = substitute(curindent,'^'.s:treedepthstring.' ','','') |
9768 " call Decho("prvline <".prvline."> #".line(".")-1) | 10049 " call Decho("prvline <".prvline."> #".line(".")-1) |
9769 " call Decho("curline <".curline."> #".line(".")) | 10050 " call Decho("curline <".curline."> #".line(".")) |
9770 " call Decho("nxtline <".nxtline."> #".line(".")+1) | 10051 " call Decho("nxtline <".nxtline."> #".line(".")+1) |
9771 " call Decho("curindent<".curindent.">") | 10052 " call Decho("curindent<".curindent.">") |
9772 " call Decho("indentm1 <".indentm1.">") | 10053 " call Decho("indentm1 <".indentm1.">") |
9773 | 10054 |
9774 if curline !~ '/$' | 10055 if curline !~ '/$' |
9775 " call Decho('regfile') | 10056 " call Decho('regfile') |
9776 if a:dir == '[' && prvline != '' | 10057 if a:dir == '[' && prvline != '' |
9777 keepj norm! 0 | 10058 keepj norm! 0 |
9778 let nl = search('^'.indentm1.'[^|]','bWe') " search backwards from regular file | 10059 let nl = search('^'.indentm1.'[^'.s:treedepthstring.']','bWe') " search backwards from regular file |
9779 " call Decho("regfile srch back: ".nl) | 10060 " call Decho("regfile srch back: ".nl) |
9780 elseif a:dir == ']' && nxtline != '' | 10061 elseif a:dir == ']' && nxtline != '' |
9781 keepj norm! $ | 10062 keepj norm! $ |
9782 let nl = search('^'.indentm1.'[^|]','We') " search forwards from regular file | 10063 let nl = search('^'.indentm1.'[^'.s:treedepthstring.']','We') " search forwards from regular file |
9783 " call Decho("regfile srch fwd: ".nl) | 10064 " call Decho("regfile srch fwd: ".nl) |
9784 endif | 10065 endif |
9785 | 10066 |
9786 elseif a:dir == '[' && prvline != '' | 10067 elseif a:dir == '[' && prvline != '' |
9787 keepj norm! 0 | 10068 keepj norm! 0 |
9788 let curline= line(".") | 10069 let curline= line(".") |
9789 let nl = search('^'.curindent.'[^|]','bWe') " search backwards From directory, same indentation | 10070 let nl = search('^'.curindent.'[^'.s:treedepthstring.']','bWe') " search backwards From directory, same indentation |
9790 " call Decho("dir srch back ind: ".nl) | 10071 " call Decho("dir srch back ind: ".nl) |
9791 if nl != 0 | 10072 if nl != 0 |
9792 if line(".") == curline-1 | 10073 if line(".") == curline-1 |
9793 let nl= search('^'.indentm1.'[^|]','bWe') " search backwards from directory, indentation - 1 | 10074 let nl= search('^'.indentm1.'[^'.s:treedepthstring.']','bWe') " search backwards from directory, indentation - 1 |
9794 " call Decho("dir srch back ind-1: ".nl) | 10075 " call Decho("dir srch back ind-1: ".nl) |
9795 endif | 10076 endif |
9796 endif | 10077 endif |
9797 | 10078 |
9798 elseif a:dir == ']' && nxtline != '' | 10079 elseif a:dir == ']' && nxtline != '' |
9799 keepj norm! $ | 10080 keepj norm! $ |
9800 let curline = line(".") | 10081 let curline = line(".") |
9801 let nl = search('^'.curindent.'[^|]','We') " search forwards from directory, same indentation | 10082 let nl = search('^'.curindent.'[^'.s:treedepthstring.']','We') " search forwards from directory, same indentation |
9802 " call Decho("dir srch fwd ind: ".nl) | 10083 " call Decho("dir srch fwd ind: ".nl) |
9803 if nl != 0 | 10084 if nl != 0 |
9804 if line(".") == curline+1 | 10085 if line(".") == curline+1 |
9805 let nl= search('^'.indentm1.'[^|]','We') " search forwards from directory, indentation - 1 | 10086 let nl= search('^'.indentm1.'[^'.s:treedepthstring.']','We') " search forwards from directory, indentation - 1 |
9806 " call Decho("dir srch fwd ind-1: ".nl) | 10087 " call Decho("dir srch fwd ind-1: ".nl) |
9807 endif | 10088 endif |
9808 endif | 10089 endif |
9809 | 10090 |
9810 endif | 10091 endif |