comparison runtime/plugin/netrw.vim @ 464:3b705e71c7b0 v7.0124

updated for version 7.0124
author vimboss
date Fri, 05 Aug 2005 21:35:02 +0000
parents f98374445f66
children 7a01bd1ac566
comparison
equal deleted inserted replaced
463:8411e13e6dcb 464:3b705e71c7b0
1 " netrw.vim: Handles file transfer and remote directory listing across a network 1 " netrw.vim: Handles file transfer and remote directory listing across a network
2 " Last Change: Aug 02, 2005 2 " Last Change: Aug 05, 2005
3 " Maintainer: Charles E Campbell, Jr <drchipNOSPAM at campbellfamily dot biz> 3 " Maintainer: Charles E Campbell, Jr <drchipNOSPAM at campbellfamily dot biz>
4 " Version: 58b NOT RELEASED 4 " Version: 58e ASTRO-ONLY
5 " License: Vim License (see vim's :help license) 5 " License: Vim License (see vim's :help license)
6 " Copyright: Copyright (C) 1999-2005 Charles E. Campbell, Jr.
7 " Permission is hereby granted to use and distribute this code,
8 " with or without modifications, provided that this copyright
9 " notice is copied with it. Like anything else that's free,
10 " netrw.vim is provided *as is* and comes with no
11 " warranty of any kind, either expressed or implied. In no
12 " event will the copyright holder be liable for any damages
13 " resulting from the use of this software.
6 " 14 "
7 " But be doers of the Word, and not only hearers, deluding your own selves 15 " But be doers of the Word, and not only hearers, deluding your own selves
8 " (James 1:22 RSV) 16 " (James 1:22 RSV)
9 " =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 17 " =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
10 " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim 18 " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
12 " --------------------------------------------------------------------- 20 " ---------------------------------------------------------------------
13 " Load Once: {{{1 21 " Load Once: {{{1
14 if exists("g:loaded_netrw") || &cp 22 if exists("g:loaded_netrw") || &cp
15 finish 23 finish
16 endif 24 endif
17 let g:loaded_netrw = "v58b" 25 let g:loaded_netrw = "v58e"
18 let loaded_explorer = 1 26 let loaded_explorer = 1
19 let s:keepcpo = &cpo 27 let s:keepcpo = &cpo
20 set cpo&vim 28 set cpo&vim
21 29
22 " --------------------------------------------------------------------- 30 " ---------------------------------------------------------------------
261 269
262 " ------------------------------------------------------------------------ 270 " ------------------------------------------------------------------------
263 " NetRestorePosn: restores the cursor and file position as saved by NetSavePosn() {{{1 271 " NetRestorePosn: restores the cursor and file position as saved by NetSavePosn() {{{1
264 fun! <SID>NetRestorePosn() 272 fun! <SID>NetRestorePosn()
265 " call Dfunc("NetRestorePosn() winnr=".s:netrw_winnr." line=".s:netrw_line." col=".s:netrw_col." hline=".s:netrw_hline) 273 " call Dfunc("NetRestorePosn() winnr=".s:netrw_winnr." line=".s:netrw_line." col=".s:netrw_col." hline=".s:netrw_hline)
274 let eikeep= &ei
275 set ei=all
266 276
267 " restore window 277 " restore window
268 " call Decho("restore window: exe silent! ".s:netrw_winnr."wincmd w") 278 " call Decho("restore window: exe silent! ".s:netrw_winnr."wincmd w")
269 exe "silent! ".s:netrw_winnr."wincmd w" 279 exe "silent! ".s:netrw_winnr."wincmd w"
270 if v:shell_error == 0 280 " if v:shell_error == 0
271 " as suggested by Bram M: redraw on no error 281 " " as suggested by Bram M: redraw on no error
272 " allows protocol error messages to remain visible 282 " " allows protocol error messages to remain visible
273 redraw! 283 " redraw!
274 endif 284 " endif
275 285
276 " restore top-of-screen line 286 " restore top-of-screen line
277 " call Decho("restore topofscreen: exe norm! ".s:netrw_hline."G0z") 287 " call Decho("restore topofscreen: exe norm! ".s:netrw_hline."G0z")
278 exe "norm! ".s:netrw_hline."G0z\<CR>" 288 exe "norm! ".s:netrw_hline."G0z\<CR>"
279 289
280 " restore position 290 " restore position
281 " call Decho("restore posn: exe norm! ".s:netrw_line."G0".s:netrw_col."|") 291 " call Decho("restore posn: exe norm! ".s:netrw_line."G0".s:netrw_col."|")
282 exe "norm! ".s:netrw_line."G0".s:netrw_col."\<bar>" 292 exe "norm! ".s:netrw_line."G0".s:netrw_col."\<bar>"
283 293
294 let &ei= eikeep
284 " call Dret("NetRestorePosn") 295 " call Dret("NetRestorePosn")
285 endfun 296 endfun
286 297
287 " ------------------------------------------------------------------------ 298 " ------------------------------------------------------------------------
288 " NetRead: responsible for reading a file over the net {{{1 299 " NetRead: responsible for reading a file over the net {{{1
352 while match(choice,"\"$") == -1 363 while match(choice,"\"$") == -1
353 let wholechoice = wholechoice . " " . choice 364 let wholechoice = wholechoice . " " . choice
354 let ichoice = ichoice + 1 365 let ichoice = ichoice + 1
355 if ichoice > a:0 366 if ichoice > a:0
356 if !exists("g:netrw_quiet") 367 if !exists("g:netrw_quiet")
357 echoerr "***netrw*** Unbalanced string in filename '". wholechoice ."'" 368 echohl Error | echo "***netrw*** Unbalanced string in filename '". wholechoice ."'" | echohl None
358 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 369 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
359 endif 370 endif
360 " call Dret("NetRead") 371 " call Dret("NetRead")
361 return 372 return
362 endif 373 endif
439 endif 450 endif
440 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) 451 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
441 if getline(1) !~ "^$" && !exists("g:netrw_quiet") && getline(1) !~ '^Trying ' 452 if getline(1) !~ "^$" && !exists("g:netrw_quiet") && getline(1) !~ '^Trying '
442 let debugkeep= &debug 453 let debugkeep= &debug
443 set debug=msg 454 set debug=msg
444 echoerr "***netrw*** ".getline(1) 455 echohl Error | echo "***netrw*** ".getline(1) | echohl None
445 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 456 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
446 let &debug= debugkeep 457 let &debug= debugkeep
447 endif 458 endif
448 bd! 459 bd!
449 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) 460 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
485 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n" 496 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n"
486 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) 497 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
487 if getline(1) !~ "^$" 498 if getline(1) !~ "^$"
488 " call Decho("error<".getline(1).">") 499 " call Decho("error<".getline(1).">")
489 if !exists("g:netrw_quiet") 500 if !exists("g:netrw_quiet")
490 echoerr "***netrw*** ".getline(1) 501 echohl Error | echo "***netrw*** ".getline(1) | echohl None
491 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 502 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
492 endif 503 endif
493 endif 504 endif
494 bd! 505 bd!
495 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) 506 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
518 "......................................... 529 ".........................................
519 elseif b:netrw_method == 5 " read with http (wget) 530 elseif b:netrw_method == 5 " read with http (wget)
520 " call Decho("read via http (method #5)") 531 " call Decho("read via http (method #5)")
521 if g:netrw_http_cmd == "" 532 if g:netrw_http_cmd == ""
522 if !exists("g:netrw_quiet") 533 if !exists("g:netrw_quiet")
523 echoerr "***netrw*** neither wget nor fetch command is available" 534 echohl Error | echo "***netrw*** neither wget nor fetch command is available" | echohl None
524 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 535 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
525 endif 536 endif
526 exit 537 exit
527 endif 538 endif
528 539
596 " fetch: NetRead Method #8 607 " fetch: NetRead Method #8
597 " fetch://[user@]host[:http]/path 608 " fetch://[user@]host[:http]/path
598 elseif b:netrw_method == 8 " read with fetch 609 elseif b:netrw_method == 8 " read with fetch
599 if g:netrw_fetch_cmd == "" 610 if g:netrw_fetch_cmd == ""
600 if !exists("g:netrw_quiet") 611 if !exists("g:netrw_quiet")
601 echoerr "***netrw*** fetch command not available" 612 echohl Error | echo "***netrw*** fetch command not available" | echohl None
602 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 613 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
603 endif 614 endif
604 exit 615 exit
605 endif 616 endif
606 if exists("g:netrw_option") && g:netrw_option == ":http" 617 if exists("g:netrw_option") && g:netrw_option == ":http"
803 while match(choice,"\"$") == -1 814 while match(choice,"\"$") == -1
804 let wholechoice= wholechoice . " " . choice 815 let wholechoice= wholechoice . " " . choice
805 let ichoice = ichoice + 1 816 let ichoice = ichoice + 1
806 if choice > a:0 817 if choice > a:0
807 if !exists("g:netrw_quiet") 818 if !exists("g:netrw_quiet")
808 echoerr "***netrw*** Unbalanced string in filename '". wholechoice ."'" 819 echohl Error | echo "***netrw*** Unbalanced string in filename '". wholechoice ."'" | echohl None
809 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 820 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
810 endif 821 endif
811 " call Dret("NetWrite") 822 " call Dret("NetWrite")
812 return 823 return
813 endif 824 endif
874 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine 885 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine
875 endif 886 endif
876 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) 887 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
877 if getline(1) !~ "^$" 888 if getline(1) !~ "^$"
878 if !exists("g:netrw_quiet") 889 if !exists("g:netrw_quiet")
879 echoerr "***netrw*** ".getline(1) 890 echohl Error | echo "***netrw*** ".getline(1) | echohl None
880 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 891 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
881 endif 892 endif
882 let mod=1 893 let mod=1
883 endif 894 endif
884 bd! 895 bd!
914 " call Decho("executing: %!".g:netrw_ftp_cmd." -i -n") 925 " call Decho("executing: %!".g:netrw_ftp_cmd." -i -n")
915 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n" 926 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n"
916 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) 927 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
917 if getline(1) !~ "^$" 928 if getline(1) !~ "^$"
918 if !exists("g:netrw_quiet") 929 if !exists("g:netrw_quiet")
919 echoerr "***netrw*** ".getline(1) 930 echohl Error | echo "***netrw*** ".getline(1) | echohl None
920 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 931 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
921 endif 932 endif
922 let mod=1 933 let mod=1
923 endif 934 endif
924 bd! 935 bd!
943 954
944 "......................................... 955 ".........................................
945 " http: NetWrite Method #5 956 " http: NetWrite Method #5
946 elseif b:netrw_method == 5 957 elseif b:netrw_method == 5
947 if !exists("g:netrw_quiet") 958 if !exists("g:netrw_quiet")
948 echoerr "***netrw*** currently <netrw.vim> does not support writing using http:" 959 echohl Error | echo "***netrw*** currently <netrw.vim> does not support writing using http:" | echohl None
949 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 960 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
950 endif 961 endif
951 962
952 "......................................... 963 ".........................................
953 " dav: NetWrite Method #6 964 " dav: NetWrite Method #6
1042 " sanity check 1053 " sanity check
1043 if exists("b:netrw_method") && b:netrw_method =~ '[235]' 1054 if exists("b:netrw_method") && b:netrw_method =~ '[235]'
1044 " call Decho("b:netrw_method=".b:netrw_method) 1055 " call Decho("b:netrw_method=".b:netrw_method)
1045 if !executable("ftp") 1056 if !executable("ftp")
1046 if !exists("g:netrw_quiet") 1057 if !exists("g:netrw_quiet")
1047 echoerr "***netrw*** this system doesn't support remote directory listing via ftp" 1058 echohl Error | echo "***netrw*** this system doesn't support remote directory listing via ftp" | echohl None
1048 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 1059 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
1049 endif 1060 endif
1050 " call Dret("NetBrowse") 1061 " call Dret("NetBrowse")
1051 return 1062 return
1052 endif 1063 endif
1053 elseif !exists("g:netrw_list_cmd") || g:netrw_list_cmd == '' 1064 elseif !exists("g:netrw_list_cmd") || g:netrw_list_cmd == ''
1054 if !exists("g:netrw_quiet") 1065 if !exists("g:netrw_quiet")
1055 echoerr "***netrw*** this system doesn't support remote directory listing via ssh" 1066 echohl Error | echo "***netrw*** this system doesn't support remote directory listing via ssh" | echohl None
1056 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 1067 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
1057 endif 1068 endif
1069
1058 " call Dret("NetBrowse") 1070 " call Dret("NetBrowse")
1059 return 1071 return
1060 endif 1072 endif
1061 1073
1062 " make this buffer modifiable 1074 " make this buffer modifiable
1066 let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/]\+\)/\(.*\)$' 1078 let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/]\+\)/\(.*\)$'
1067 let dirname = substitute(a:dirname,'\\','/','ge') 1079 let dirname = substitute(a:dirname,'\\','/','ge')
1068 " call Decho("dirpat<".dirpat.">") 1080 " call Decho("dirpat<".dirpat.">")
1069 if dirname !~ dirpat 1081 if dirname !~ dirpat
1070 if !exists("g:netrw_quiet") 1082 if !exists("g:netrw_quiet")
1071 echoerr "***netrw*** netrw doesn't understand your dirname<".dirname.">" 1083 echohl Error | echo "***netrw*** netrw doesn't understand your dirname<".dirname.">" | echohl None
1072 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 1084 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
1073 endif 1085 endif
1074 " call Dret("NetBrowse : badly formatted dirname<".dirname.">") 1086 " call Dret("NetBrowse : badly formatted dirname<".dirname.">")
1075 return 1087 return
1076 endif 1088 endif
1098 let s:netrw_method= b:netrw_method 1110 let s:netrw_method= b:netrw_method
1099 endif 1111 endif
1100 1112
1101 " optionally sort by time (-t) or by size (-S) 1113 " optionally sort by time (-t) or by size (-S)
1102 if listcmd == "dir" && g:netrw_sort_by =~ "^[ts]" 1114 if listcmd == "dir" && g:netrw_sort_by =~ "^[ts]"
1103 echoerr "***netrw*** windows' ftp doesn't support time/size sorts (get cygwin, set g:netrw_cygwin)" 1115 echohl WarningMsg | echo "***netrw*** windows' ftp doesn't support time/size sorts (get cygwin, set g:netrw_cygwin)" | echohl None
1104 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 1116 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
1105 else 1117 else
1106 if g:netrw_sort_by =~ "^t" 1118 if g:netrw_sort_by =~ "^t"
1107 let listcmd= listcmd."t" 1119 let listcmd= listcmd."t"
1108 elseif g:netrw_sort_by =~ "^s" 1120 elseif g:netrw_sort_by =~ "^s"
1138 exe "file ".method."://".user.machine."/".escape(path,s:netrw_cd_escape) 1150 exe "file ".method."://".user.machine."/".escape(path,s:netrw_cd_escape)
1139 exe "silent doau BufReadPre ".fname 1151 exe "silent doau BufReadPre ".fname
1140 silent call s:NetRead(method."://".user.machine."/".path) 1152 silent call s:NetRead(method."://".user.machine."/".path)
1141 exe "silent doau BufReadPost ".fname 1153 exe "silent doau BufReadPost ".fname
1142 keepjumps 1d 1154 keepjumps 1d
1143 setlocal nomod 1155
1156 setlocal nonu nomod noma
1144 1157
1145 " call Dret("NetBrowse : file<".fname.">") 1158 " call Dret("NetBrowse : file<".fname.">")
1146 return 1159 return
1147 endif 1160 endif
1148 1161
1178 call <SID>NetBookmarkDir(3,expand("%")) 1191 call <SID>NetBookmarkDir(3,expand("%"))
1179 1192
1180 " set up buffer-local mappings 1193 " set up buffer-local mappings
1181 " call Decho("set up buffer-local mappings") 1194 " call Decho("set up buffer-local mappings")
1182 nnoremap <buffer> <silent> <cr> :exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),<SID>NetGetWord()))<cr> 1195 nnoremap <buffer> <silent> <cr> :exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),<SID>NetGetWord()))<cr>
1183 nnoremap <buffer> <silent> <c-l> :exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'./'))<cr> 1196 nnoremap <buffer> <silent> <c-l> :call <SID>NetRefresh(<SID>NetBrowseChgDir(expand("%"),'./'))<cr>
1184 nnoremap <buffer> <silent> - :exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'../'))<cr> 1197 nnoremap <buffer> <silent> - :exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'../'))<cr>
1185 nnoremap <buffer> <silent> a :let g:netrw_hide=(g:netrw_hide+1)%3<bar>exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'./'))<cr> 1198 nnoremap <buffer> <silent> a :let g:netrw_hide=(g:netrw_hide+1)%3<bar>exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'./'))<cr>
1186 nnoremap <buffer> <silent> b :<c-u>call <SID>NetBookmarkDir(0,expand("%"))<cr> 1199 nnoremap <buffer> <silent> b :<c-u>call <SID>NetBookmarkDir(0,expand("%"))<cr>
1187 nnoremap <buffer> <silent> B :<c-u>call <SID>NetBookmarkDir(1,expand("%"))<cr> 1200 nnoremap <buffer> <silent> B :<c-u>call <SID>NetBookmarkDir(1,expand("%"))<cr>
1188 nnoremap <buffer> <silent> <c-h> :call <SID>NetHideEdit(0)<cr> 1201 nnoremap <buffer> <silent> <c-h> :call <SID>NetHideEdit(0)<cr>
1277 1290
1278 else 1291 else
1279 " use ssh to get remote file listing 1292 " use ssh to get remote file listing
1280 " call Decho("use ssh to get remote file listing") 1293 " call Decho("use ssh to get remote file listing")
1281 let shq= &shq? &shq : ( &sxq? &sxq : "'") 1294 let shq= &shq? &shq : ( &sxq? &sxq : "'")
1282 " call Decho("exe silent r! ".listcmd." ".shq.escape(path,s:netrw_cd_escape).shq) 1295 " call Decho("exe silent r! ".listcmd." '".shq.escape(path,s:netrw_cd_escape).shq."'")
1283 exe "silent r! ".listcmd." ".shq.escape(path,s:netrw_cd_escape).shq 1296 exe "silent r! ".listcmd." ".shq.escape(path,s:netrw_cd_escape).shq
1284 if !exists("g:junk")
1285 let g:junk=1
1286 else
1287 put ='testing'
1288 return
1289 endif
1290 keepjumps 1d 1297 keepjumps 1d
1291 " cleanup 1298 " cleanup
1292 if g:netrw_ftp_browse_reject != "" 1299 if g:netrw_ftp_browse_reject != ""
1293 exe "silent! g/".g:netrw_ssh_browse_reject."/keepjumps d" 1300 exe "silent! g/".g:netrw_ssh_browse_reject."/keepjumps d"
1294 endif 1301 endif
1295 endif 1302 endif
1303
1296 1304
1297 " set up syntax highlighting 1305 " set up syntax highlighting
1298 if has("syntax") 1306 if has("syntax")
1299 setlocal ft=netrwlist 1307 setlocal ft=netrwlist
1300 if !has("syntax_items") 1308 if !exists("g:syntax_on") || !g:syntax_on
1301 setlocal ft= 1309 setlocal ft=
1310 " Ugly workaround -- when syntax highlighting is off and laststatus==2,
1311 " sometimes the laststatus highlight bleeds into the entire display.
1312 " Only seems to happen with remote browsing. Weird.
1313 redraw
1302 endif 1314 endif
1303 endif 1315 endif
1304 1316
1305 " manipulate the directory listing (hide, sort) 1317 " manipulate the directory listing (hide, sort)
1306 if line("$") >= s:netrw_bannercnt 1318 if line("$") >= s:netrw_bannercnt
1313 " call Decho("manipulate long listing") 1325 " call Decho("manipulate long listing")
1314 1326
1315 if method == "ftp" 1327 if method == "ftp"
1316 " cleanup 1328 " cleanup
1317 exe "keepjumps ".s:netrw_bannercnt 1329 exe "keepjumps ".s:netrw_bannercnt
1318 while getline(".") =~ '^total\s\+\d\+$' || getline(".") =~ 'Trying\s\+\d\+.*$' 1330 while getline(".") =~ g:netrw_ftp_browse_reject
1319 keepjumps d 1331 keepjumps d
1320 endwhile 1332 endwhile
1321 " if there's no ../ listed, then put ./ and ../ in 1333 " if there's no ../ listed, then put ./ and ../ in
1322 let line1= line(".") 1334 let line1= line(".")
1323 keepjumps 1 1335 keepjumps 1
1353 exe "keepjumps silent ".s:netrw_bannercnt.',$s/\t[-dstrwx]\+/\t/e' 1365 exe "keepjumps silent ".s:netrw_bannercnt.',$s/\t[-dstrwx]\+/\t/e'
1354 endif 1366 endif
1355 endif 1367 endif
1356 endif 1368 endif
1357 exe "keepjumps ".s:netrw_bannercnt 1369 exe "keepjumps ".s:netrw_bannercnt
1358 setlocal nomod 1370
1359 setlocal noma 1371 setlocal nomod noma nonu
1360 setlocal nonu
1361 1372
1362 " call Dret("NetBrowse") 1373 " call Dret("NetBrowse")
1363 return 1374 return
1364 endfun 1375 endfun
1365 1376
1495 " call Decho("2nd attempt to remove dir: system(".netrw_rmf_cmd.")") 1506 " call Decho("2nd attempt to remove dir: system(".netrw_rmf_cmd.")")
1496 let ret= system(netrw_rmf_cmd) 1507 let ret= system(netrw_rmf_cmd)
1497 " call Decho("returned=".ret." errcode=".v:shell_error) 1508 " call Decho("returned=".ret." errcode=".v:shell_error)
1498 1509
1499 if v:shell_error != 0 && !exists("g:netrw_quiet") 1510 if v:shell_error != 0 && !exists("g:netrw_quiet")
1500 echoerr "***netrw*** unable to remove directory<".rmfile."> -- is it empty?" 1511 echohl Error | echo "***netrw*** unable to remove directory<".rmfile."> -- is it empty?" | echohl None
1501 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 1512 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
1502 endif 1513 endif
1503 endif 1514 endif
1504 endif 1515 endif
1505 1516
1559 exe "keepjumps ".curline 1570 exe "keepjumps ".curline
1560 " call Dret("NetBrowseRename") 1571 " call Dret("NetBrowseRename")
1561 endfun 1572 endfun
1562 1573
1563 " --------------------------------------------------------------------- 1574 " ---------------------------------------------------------------------
1575 " NetRefresh: {{{2
1576 fun! <SID>NetRefresh(dirname)
1577 " call Dfunc("NetRefresh(dirname<".a:dirname.">)")
1578 set ma
1579 %d
1580 call <SID>NetBrowse(dirname)
1581 redraw!
1582 " call Dret("NetRefresh")
1583 endfun
1584
1585 " ---------------------------------------------------------------------
1564 " NetBrowseX: allows users to write custom functions to operate on {{{2 1586 " NetBrowseX: allows users to write custom functions to operate on {{{2
1565 " files given their extension. Passes 0=local, 1=remote 1587 " files given their extension. Passes 0=local, 1=remote
1566 fun! <SID>NetBrowseX(fname,remote) 1588 fun! <SID>NetBrowseX(fname,remote)
1567 " call Dfunc("NetBrowseX(".a:fname." remote=".a:remote.")") 1589 " call Dfunc("NetBrowseX(".a:fname." remote=".a:remote.")")
1568 1590
1578 if a:remote == 1 1600 if a:remote == 1
1579 " create a local copy 1601 " create a local copy
1580 let fname= tempname().".".exten 1602 let fname= tempname().".".exten
1581 " call Decho("create a local copy of <".a:fname."> as <".fname.">") 1603 " call Decho("create a local copy of <".a:fname."> as <".fname.">")
1582 exe "keepjumps silent bot 1new ".a:fname 1604 exe "keepjumps silent bot 1new ".a:fname
1583 let eikeep= &ei 1605 set bh=delete
1584 set ei=all bh=delete
1585 exe "w! ".fname 1606 exe "w! ".fname
1586 let &ei= eikeep
1587 q 1607 q
1588 endif 1608 endif
1589 " call Decho("exten<".exten."> "."NetrwFileHandler_".exten."():exists=".exists("*NetrwFileHandler_".exten)) 1609 " call Decho("exten<".exten."> "."NetrwFileHandler_".exten."():exists=".exists("*NetrwFileHandler_".exten))
1590 1610
1591 " set up redirection 1611 " set up redirection
1625 " call Decho("deleting temporary file<".fname.">") 1645 " call Decho("deleting temporary file<".fname.">")
1626 call delete(fname) 1646 call delete(fname)
1627 endif 1647 endif
1628 1648
1629 if a:remote == 1 1649 if a:remote == 1
1630 let eikeep= &ei 1650 set bh=delete bt=nofile noswf
1631 set ei=all bh=delete bt=nofile noswf
1632 exe "norm! \<c-o>" 1651 exe "norm! \<c-o>"
1633 let &ei= eikeep
1634 redraw! 1652 redraw!
1635 endif 1653 endif
1636 1654
1637 " call Dret("NetBrowseX") 1655 " call Dret("NetBrowseX")
1638 endfun 1656 endfun
1762 " refresh the listing 1780 " refresh the listing
1763 let g:netrw_list_hide= newhide 1781 let g:netrw_list_hide= newhide
1764 if a:mode == 0 1782 if a:mode == 0
1765 silent call s:NetBrowse(s:NetBrowseChgDir(expand("%"),'./')) 1783 silent call s:NetBrowse(s:NetBrowseChgDir(expand("%"),'./'))
1766 else 1784 else
1767 silent call s:LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,"./")) 1785 silent call s:LocalRefresh(<SID>LocalBrowseChgDir(b:netrw_curdir,"./"))
1768 endif 1786 endif
1769 1787
1770 " call Dret("NetHideEdit") 1788 " call Dret("NetHideEdit")
1771 endfun 1789 endfun
1772 1790
1807 " call Decho("turn long listing on") 1825 " call Decho("turn long listing on")
1808 let g:netrw_longlist = 1 1826 let g:netrw_longlist = 1
1809 let g:netrw_list_cmd = g:netrw_list_cmd." -l" 1827 let g:netrw_list_cmd = g:netrw_list_cmd." -l"
1810 endif 1828 endif
1811 setlocal ma 1829 setlocal ma
1830
1831 " clear buffer - this will cause NetBrowse/LocalBrowse to do a refresh
1812 %d 1832 %d
1813 1833
1814 " refresh the listing 1834 " refresh the listing
1815 if a:mode == 0 1835 if a:mode == 0
1816 silent call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),"./")) 1836 silent call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),"./"))
1817 else 1837 else
1818 silent call <SID>LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,"./")) 1838 silent call <SID>LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,"./"))
1819 endif 1839 endif
1820 1840
1821 call s:NetRestorePosn() 1841 " call s:NetRestorePosn()
1822 " call Dret("NetLongList : g:netrw_longlist=".g:netrw_longlist) 1842 " call Dret("NetLongList : g:netrw_longlist=".g:netrw_longlist)
1823 endfun 1843 endfun
1824 1844
1825 " --------------------------------------------------------------------- 1845 " ---------------------------------------------------------------------
1826 " NetSaveWordPosn: used by the "s" command in both remote and local {{{2 1846 " NetSaveWordPosn: used by the "s" command in both remote and local {{{2
1864 " sanity checks 1884 " sanity checks
1865 let fullnewdir= b:netrw_curdir.'/'.newdirname 1885 let fullnewdir= b:netrw_curdir.'/'.newdirname
1866 " call Decho("fullnewdir<".fullnewdir.">") 1886 " call Decho("fullnewdir<".fullnewdir.">")
1867 if isdirectory(fullnewdir) 1887 if isdirectory(fullnewdir)
1868 if !exists("g:netrw_quiet") 1888 if !exists("g:netrw_quiet")
1869 echoerr "***netrw*** <".newdirname."> is already a directory!" 1889 echohl WarningMsg | echo "***netrw*** <".newdirname."> is already a directory!" | echohl None
1870 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 1890 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
1871 endif 1891 endif
1872 " call Dret("NetMakeDir : directory<".newdirname."> exists previously") 1892 " call Dret("NetMakeDir : directory<".newdirname."> exists previously")
1873 return 1893 return
1874 endif 1894 endif
1875 if filereadable(fullnewdir) 1895 if filereadable(fullnewdir)
1876 if !exists("g:netrw_quiet") 1896 if !exists("g:netrw_quiet")
1877 echoerr "***netrw*** <".newdirname."> is already a file!" 1897 echohl WarningMsg | echo "***netrw*** <".newdirname."> is already a file!" | echohl None
1878 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 1898 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
1879 endif 1899 endif
1880 " call Dret("NetMakeDir : file<".newdirname."> exists previously") 1900 " call Dret("NetMakeDir : file<".newdirname."> exists previously")
1881 return 1901 return
1882 endif 1902 endif
1898 " refresh listing 1918 " refresh listing
1899 " call Decho("refresh listing") 1919 " call Decho("refresh listing")
1900 let linenum= line(".") 1920 let linenum= line(".")
1901 norm! H0 1921 norm! H0
1902 let hline = line(".") 1922 let hline = line(".")
1923 set ma|norm! 2D
1903 call s:LocalBrowse(s:LocalBrowseChgDir(b:netrw_curdir,'./')) 1924 call s:LocalBrowse(s:LocalBrowseChgDir(b:netrw_curdir,'./'))
1904 exe "norm! ".hline."G0z\<CR>" 1925 exe "norm! ".hline."G0z\<CR>"
1905 exe linenum 1926 exe linenum
1906 elseif !exists("g:netrw_quiet") 1927 elseif !exists("g:netrw_quiet")
1907 echoerr "***netrw*** unable to make directory<".newdirname.">" 1928 echohl Error | echo "***netrw*** unable to make directory<".newdirname.">" | echohl None
1908 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 1929 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
1909 endif 1930 endif
1910 redraw! 1931 redraw!
1911 1932
1912 else 1933 else
1922 let hline = line(".") 1943 let hline = line(".")
1923 call s:NetBrowse(s:NetBrowseChgDir(expand("%"),'./')) 1944 call s:NetBrowse(s:NetBrowseChgDir(expand("%"),'./'))
1924 exe "norm! ".hline."G0z\<CR>" 1945 exe "norm! ".hline."G0z\<CR>"
1925 exe linenum 1946 exe linenum
1926 elseif !exists("g:netrw_quiet") 1947 elseif !exists("g:netrw_quiet")
1927 echoerr "***netrw*** unable to make directory<".newdirname.">" 1948 echohl Error | echo "***netrw*** unable to make directory<".newdirname.">" | echohl None
1928 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 1949 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
1929 endif 1950 endif
1930 redraw! 1951 redraw!
1931 endif 1952 endif
1932 1953
1933 " call Dret("NetMakeDir") 1954 " call Dret("NetMakeDir")
1934 endfun 1955 endfun
1935 1956
1936 " --------------------------------------------------------------------- 1957 " ---------------------------------------------------------------------
1937 " NetBookmarkDir: {{{2 1958 " NetBookmarkDir: {{{2
1938 " 0: bookmark the current directory 1959 " 0: (user: <b>) bookmark current directory
1939 " 1: change to the bookmarked directory 1960 " 1: (user: <B>) change to the bookmarked directory
1961 " 2: (user: <q>) list bookmarks
1962 " 3: (LocalBrowse) record current directory history
1963 " 4: (user: <u>) go up (previous) bookmark
1964 " 5: (user: <U>) go down (next) bookmark
1940 fun! <SID>NetBookmarkDir(chg,curdir) 1965 fun! <SID>NetBookmarkDir(chg,curdir)
1941 " call Dfunc("NetBookmarkDir(chg=".a:chg." curdir<".a:curdir.">) cnt=".v:count) 1966 " call Dfunc("NetBookmarkDir(chg=".a:chg." curdir<".a:curdir.">) cnt=".v:count)
1942 1967
1943 if a:chg == 0 1968 if a:chg == 0
1944 " bookmark the current directory 1969 " bookmark the current directory
1956 else 1981 else
1957 echomsg "Sorry, bookmark#".v:count." doesn't exist!" 1982 echomsg "Sorry, bookmark#".v:count." doesn't exist!"
1958 endif 1983 endif
1959 1984
1960 elseif a:chg == 2 1985 elseif a:chg == 2
1986 " list user's bookmarks
1961 if exists("g:NETRW_BOOKMARKMAX") 1987 if exists("g:NETRW_BOOKMARKMAX")
1962 " list user's bookmarks
1963 " call Decho("list bookmarks [0,".g:NETRW_BOOKMARKMAX."]") 1988 " call Decho("list bookmarks [0,".g:NETRW_BOOKMARKMAX."]")
1964 let cnt= 0 1989 let cnt= 0
1965 while cnt <= g:NETRW_BOOKMARKMAX 1990 while cnt <= g:NETRW_BOOKMARKMAX
1966 if exists("g:NETRW_BOOKMARKDIR_{cnt}") 1991 if exists("g:NETRW_BOOKMARKDIR_{cnt}")
1967 " call Decho("Netrw Bookmark#".cnt.": ".g:NETRW_BOOKMARKDIR_{cnt}) 1992 " call Decho("Netrw Bookmark#".cnt.": ".g:NETRW_BOOKMARKDIR_{cnt})
1988 let cnt= cnt + g:netrw_dirhistmax 2013 let cnt= cnt + g:netrw_dirhistmax
1989 endif 2014 endif
1990 endwhile 2015 endwhile
1991 2016
1992 elseif a:chg == 3 2017 elseif a:chg == 3
1993 " saves most recently visited directories 2018 " saves most recently visited directories (when they differ)
1994 let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT + 1 ) % g:netrw_dirhistmax 2019 if !exists("g:NETRW_DIRHIST_0") || g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT} != a:curdir
1995 let g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}= substitute(a:curdir,'[/\\]$','','e') 2020 let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT + 1 ) % g:netrw_dirhistmax
1996 " call Decho("save dirhist#".g:NETRW_DIRHIST_CNT."<".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}.">") 2021 let g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}= substitute(a:curdir,'[/\\]$','','e')
2022 " call Decho("save dirhist#".g:NETRW_DIRHIST_CNT."<".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}.">")
2023 endif
1997 2024
1998 elseif a:chg == 4 2025 elseif a:chg == 4
1999 " u: change to the previous directory stored on the history list 2026 " u: change to the previous directory stored on the history list
2000 let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT - 1 ) % g:netrw_dirhistmax 2027 let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT - 1 ) % g:netrw_dirhistmax
2001 if g:NETRW_DIRHIST_CNT < 0 2028 if g:NETRW_DIRHIST_CNT < 0
2040 return 2067 return
2041 endif 2068 endif
2042 2069
2043 " unfortunate interaction -- when putting debugging calls 2070 " unfortunate interaction -- when putting debugging calls
2044 " above one can no longer enter the DBG buffer. 2071 " above one can no longer enter the DBG buffer.
2045 " call Dfunc("LocalBrowse(dirname<".a:dirname.">) buf#".bufnr("%")." winnr=".winnr()) 2072 " call Dfunc("LocalBrowse(dirname<".a:dirname.">) buf#".bufnr("%")." winnr=".winnr()." sortby=".g:netrw_sort_by)
2046 " call Dredir("ls!") 2073 " call Dredir("ls!")
2047 2074
2048 if v:version < 603 2075 if v:version < 603
2049 if !exists("g:netrw_quiet") 2076 if !exists("g:netrw_quiet")
2050 echoerr "***netrw*** vim version<".v:version."> too old for browsing with netrw" 2077 echohl Error | echo "***netrw*** vim version<".v:version."> too old for browsing with netrw" | echohl None
2051 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 2078 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
2052 endif 2079 endif
2053 " call Dret("LocalBrowse : vim version<".v:version."> too old") 2080 " call Dret("LocalBrowse : vim version<".v:version."> too old")
2054 return 2081 return
2055 endif 2082 endif
2085 else 2112 else
2086 keepalt enew! 2113 keepalt enew!
2087 endif 2114 endif
2088 " call Decho("enew buffer") 2115 " call Decho("enew buffer")
2089 else 2116 else
2090 let eikeep= &ei
2091 set ei=BufEnter
2092 if v:version < 700 2117 if v:version < 700
2093 exe "b ".bufnum 2118 exe "b ".bufnum
2094 else 2119 else
2095 exe "keepalt b ".bufnum 2120 exe "keepalt b ".bufnum
2096 endif 2121 endif
2097 let &ei= eikeep 2122 if exists("s:last_sort_by") && g:netrw_sort_by == s:last_sort_by
2098 if getline(2) =~ '^" Directory Listing ' 2123 if getline(2) =~ '^" Directory Listing '
2099 " call Dret("LocalBrowse : reusing buffer#".bufnum."<".a:dirname.">") 2124 if !g:netrw_keepdir
2100 return 2125 " call Decho("change directory: cd ".b:netrw_curdir)
2101 endif 2126 exe 'cd '.b:netrw_curdir
2102 endif 2127 endif
2128 " call Dret("LocalBrowse : reusing buffer#".bufnum."<".a:dirname.">")
2129 return
2130 endif
2131 endif
2132 endif
2133 let s:last_sort_by= g:netrw_sort_by
2103 2134
2104 " get the new directory name 2135 " get the new directory name
2105 let b:netrw_curdir= substitute(a:dirname,'\\','/','ge') 2136 let b:netrw_curdir= substitute(a:dirname,'\\','/','ge')
2106 if b:netrw_curdir =~ '[/\\]$' 2137 if b:netrw_curdir =~ '[/\\]$'
2107 let b:netrw_curdir= substitute(b:netrw_curdir,'[/\\]$','','e') 2138 let b:netrw_curdir= substitute(b:netrw_curdir,'[/\\]$','','e')
2117 " change the name of the buffer to reflect the b:netrw_curdir 2148 " change the name of the buffer to reflect the b:netrw_curdir
2118 exe 'silent! file '.escape(b:netrw_curdir,s:netrw_cd_escape) 2149 exe 'silent! file '.escape(b:netrw_curdir,s:netrw_cd_escape)
2119 2150
2120 " make this buffer modifiable and hidden 2151 " make this buffer modifiable and hidden
2121 setlocal ma hidden nonu 2152 setlocal ma hidden nonu
2153 keepalt silent! %d
2122 2154
2123 " --------------------------- 2155 " ---------------------------
2124 " Perform Directory Listing: 2156 " Perform Directory Listing:
2125 2157
2126 " save current directory on directory history list 2158 " save current directory on directory history list
2127 call <SID>NetBookmarkDir(3,b:netrw_curdir) 2159 call <SID>NetBookmarkDir(3,b:netrw_curdir)
2128 2160
2129 " set up all the maps 2161 " set up all the maps
2130 " call Decho("Setting up local browser maps") 2162 " call Decho("Setting up local browser maps")
2131 nnoremap <buffer> <silent> <cr> :exe "norm! 0"<bar>call <SID>LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,<SID>NetGetWord()))<cr> 2163 nnoremap <buffer> <silent> <cr> :exe "norm! 0"<bar>call <SID>LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,<SID>NetGetWord()))<cr>
2132 nnoremap <buffer> <silent> <c-l> :exe "norm! 0"<bar>call <SID>LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,'./'))<cr> 2164 nnoremap <buffer> <silent> <c-l> :set ma<bar>%d<bar>call <SID>LocalRefresh(<SID>LocalBrowseChgDir(b:netrw_curdir,'./'))<bar>redraw!<cr>
2133 nnoremap <buffer> <silent> - :exe "norm! 0"<bar>call <SID>LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,'../'))<cr> 2165 nnoremap <buffer> <silent> - :exe "norm! 0"<bar>call <SID>LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,'../'))<cr>
2134 nnoremap <buffer> <silent> a :let g:netrw_hide=(g:netrw_hide+1)%3<bar>exe "norm! 0"<bar>call <SID>LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,'./'))<cr> 2166 nnoremap <buffer> <silent> a :let g:netrw_hide=(g:netrw_hide+1)%3<bar>exe "norm! 0"<bar>call <SID>LocalRefresh(<SID>LocalBrowseChgDir(b:netrw_curdir,'./'))<cr>
2135 nnoremap <buffer> <silent> b :<c-u>call <SID>NetBookmarkDir(0,b:netrw_curdir)<cr> 2167 nnoremap <buffer> <silent> b :<c-u>call <SID>NetBookmarkDir(0,b:netrw_curdir)<cr>
2136 nnoremap <buffer> <silent> B :<c-u>call <SID>NetBookmarkDir(1,b:netrw_curdir)<cr> 2168 nnoremap <buffer> <silent> B :<c-u>call <SID>NetBookmarkDir(1,b:netrw_curdir)<cr>
2137 nnoremap <buffer> <silent> c :exe "cd ".b:netrw_curdir<cr> 2169 nnoremap <buffer> <silent> c :exe "cd ".b:netrw_curdir<cr>
2138 nnoremap <buffer> <silent> d :call <SID>NetMakeDir("")<cr> 2170 nnoremap <buffer> <silent> d :call <SID>NetMakeDir("")<cr>
2139 nnoremap <buffer> <silent> <c-h> :call <SID>NetHideEdit(1)<cr> 2171 nnoremap <buffer> <silent> <c-h> :call <SID>NetHideEdit(1)<cr>
2146 nnoremap <buffer> <silent> S :call <SID>NetSortSequence(1)<cr> 2178 nnoremap <buffer> <silent> S :call <SID>NetSortSequence(1)<cr>
2147 nnoremap <buffer> <silent> u :<c-u>call <SID>NetBookmarkDir(4,expand("%"))<cr> 2179 nnoremap <buffer> <silent> u :<c-u>call <SID>NetBookmarkDir(4,expand("%"))<cr>
2148 nnoremap <buffer> <silent> U :<c-u>call <SID>NetBookmarkDir(5,expand("%"))<cr> 2180 nnoremap <buffer> <silent> U :<c-u>call <SID>NetBookmarkDir(5,expand("%"))<cr>
2149 nnoremap <buffer> <silent> v :exe (g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v"<bar>exe "norm! 0"<bar>call <SID>LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,<SID>NetGetWord()))<cr> 2181 nnoremap <buffer> <silent> v :exe (g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v"<bar>exe "norm! 0"<bar>call <SID>LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,<SID>NetGetWord()))<cr>
2150 nnoremap <buffer> <silent> x :exe "norm! 0"<bar>call <SID>NetBrowseX(<SID>LocalBrowseChgDir(b:netrw_curdir,<SID>NetGetWord(),0),0)<cr> 2182 nnoremap <buffer> <silent> x :exe "norm! 0"<bar>call <SID>NetBrowseX(<SID>LocalBrowseChgDir(b:netrw_curdir,<SID>NetGetWord(),0),0)<cr>
2151 nnoremap <buffer> <silent> <2-leftmouse> :exe "norm! 0"<bar>call <SID>LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,<SID>NetGetWord()))<cr> 2183 nnoremap <buffer> <silent> <2-leftmouse> :exe "norm! 0"<bar>call <SID>LocalRefresh(<SID>LocalBrowseChgDir(b:netrw_curdir,<SID>NetGetWord()))<cr>
2184 nnoremap <buffer> <silent> <s-up> :Pexplore<cr>
2185 nnoremap <buffer> <silent> <s-down> :Nexplore<cr>
2152 exe 'nnoremap <buffer> <silent> <del> :exe "norm! 0"<bar>call <SID>LocalBrowseRm("'.b:netrw_curdir.'")<cr>' 2186 exe 'nnoremap <buffer> <silent> <del> :exe "norm! 0"<bar>call <SID>LocalBrowseRm("'.b:netrw_curdir.'")<cr>'
2153 exe 'vnoremap <buffer> <silent> <del> :call <SID>LocalBrowseRm("'.b:netrw_curdir.'")<cr>' 2187 exe 'vnoremap <buffer> <silent> <del> :call <SID>LocalBrowseRm("'.b:netrw_curdir.'")<cr>'
2154 exe 'nnoremap <buffer> <silent> D :exe "norm! 0"<bar>call <SID>LocalBrowseRm("'.b:netrw_curdir.'")<cr>' 2188 exe 'nnoremap <buffer> <silent> D :exe "norm! 0"<bar>call <SID>LocalBrowseRm("'.b:netrw_curdir.'")<cr>'
2155 exe 'vnoremap <buffer> <silent> D :call <SID>LocalBrowseRm("'.b:netrw_curdir.'")<cr>' 2189 exe 'vnoremap <buffer> <silent> D :call <SID>LocalBrowseRm("'.b:netrw_curdir.'")<cr>'
2156 exe 'nnoremap <buffer> <silent> R :exe "norm! 0"<bar>call <SID>LocalBrowseRename("'.b:netrw_curdir.'")<cr>' 2190 exe 'nnoremap <buffer> <silent> R :exe "norm! 0"<bar>call <SID>LocalBrowseRename("'.b:netrw_curdir.'")<cr>'
2206 call LocalBrowseList() 2240 call LocalBrowseList()
2207 2241
2208 " set up syntax highlighting 2242 " set up syntax highlighting
2209 if has("syntax") 2243 if has("syntax")
2210 setlocal ft=netrwlist 2244 setlocal ft=netrwlist
2211 if !has("syntax_items") 2245 if !exists("g:syntax_on") || !g:syntax_on
2212 setlocal ft= 2246 setlocal ft=
2213 endif 2247 endif
2214 endif 2248 endif
2215 2249
2216 " manipulate the directory listing (hide, sort) 2250 " manipulate the directory listing (hide, sort)
2303 endif 2337 endif
2304 let pfile= filename 2338 let pfile= filename
2305 if isdirectory(filename) 2339 if isdirectory(filename)
2306 let pfile= filename."/" 2340 let pfile= filename."/"
2307 endif 2341 endif
2308 let pfile= substitute(pfile,'^/','','e')
2309 if pfile =~ '//$' 2342 if pfile =~ '//$'
2310 let pfile= substitute(pfile,'//$','/','e') 2343 let pfile= substitute(pfile,'//$','/','e')
2311 endif 2344 endif
2312 let pfile= strpart(pfile,dirnamelen) 2345 let pfile= strpart(pfile,dirnamelen)
2346 let pfile= substitute(pfile,'^/','','e')
2313 " call Decho(" ") 2347 " call Decho(" ")
2314 " call Decho("filename<".filename.">") 2348 " call Decho("filename<".filename.">")
2315 " call Decho("pfile <".pfile.">") 2349 " call Decho("pfile <".pfile.">")
2316 2350
2317 if g:netrw_longlist 2351 if g:netrw_longlist
2399 " call Dret("LocalBrowseChgDir <".dirname.">") 2433 " call Dret("LocalBrowseChgDir <".dirname.">")
2400 return dirname 2434 return dirname
2401 endfun 2435 endfun
2402 2436
2403 " --------------------------------------------------------------------- 2437 " ---------------------------------------------------------------------
2404 " LocalBrowseRm: 2438 " LocalBrowseRm: {{{2
2405 fun! <SID>LocalBrowseRm(path) range 2439 fun! <SID>LocalBrowseRm(path) range
2406 " call Dfunc("LocalBrowseRm(path<".a:path.">)") 2440 " call Dfunc("LocalBrowseRm(path<".a:path.">)")
2407 " call Decho("firstline=".a:firstline." lastline=".a:lastline) 2441 " call Decho("firstline=".a:firstline." lastline=".a:lastline)
2408 2442
2409 " preparation for removing multiple files/directories 2443 " preparation for removing multiple files/directories
2478 if errcode != 0 2512 if errcode != 0
2479 if has("unix") 2513 if has("unix")
2480 " call Decho("3rd attempt to remove directory<".rmfile.">") 2514 " call Decho("3rd attempt to remove directory<".rmfile.">")
2481 call system("rm ".rmfile) 2515 call system("rm ".rmfile)
2482 if v:shell_error != 0 && !exists("g:netrw_quiet") 2516 if v:shell_error != 0 && !exists("g:netrw_quiet")
2483 echoerr "***netrw*** unable to remove directory<".rmfile."> -- is it empty?" 2517 echohl Error | echo "***netrw*** unable to remove directory<".rmfile."> -- is it empty?" | echohl None
2484 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 2518 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
2485 endif 2519 endif
2486 elseif !exists("g:netrw_quiet") 2520 elseif !exists("g:netrw_quiet")
2487 echoerr "***netrw*** unable to remove directory<".rmfile."> -- is it empty?" 2521 echohl Error | echo "***netrw*** unable to remove directory<".rmfile."> -- is it empty?" | echohl None
2488 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 2522 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
2489 endif 2523 endif
2490 endif 2524 endif
2491 endif 2525 endif
2492 2526
2499 endwhile 2533 endwhile
2500 2534
2501 " refresh the directory 2535 " refresh the directory
2502 let curline= line(".") 2536 let curline= line(".")
2503 " call Decho("refresh the directory") 2537 " call Decho("refresh the directory")
2504 call <SID>LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,'./')) 2538 call s:LocalRefresh(s:LocalBrowseChgDir(b:netrw_curdir,'./'))
2505 exe curline 2539 exe curline
2506 2540
2507 " call Dret("LocalBrowseRm") 2541 " call Dret("LocalBrowseRm")
2508 endfun 2542 endfun
2509 2543
2529 let ctr= ctr + 1 2563 let ctr= ctr + 1
2530 continue 2564 continue
2531 endif 2565 endif
2532 2566
2533 norm! 0 2567 norm! 0
2534 let oldname= a:path.curword 2568 let oldname= a:path."/".curword
2535 " call Decho("oldname<".oldname.">") 2569 " call Decho("oldname<".oldname.">")
2536 2570
2537 call inputsave() 2571 call inputsave()
2538 let newname= input("Moving ".oldname." to : ",substitute(oldname,'/*$','','e')) 2572 let newname= input("Moving ".oldname." to : ",substitute(oldname,'/*$','','e'))
2539 call inputrestore() 2573 call inputrestore()
2545 endwhile 2579 endwhile
2546 2580
2547 " refresh the directory 2581 " refresh the directory
2548 let curline= line(".") 2582 let curline= line(".")
2549 " call Decho("refresh the directory listing") 2583 " call Decho("refresh the directory listing")
2550 call <SID>LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,'./')) 2584 call s:LocalRefresh(s:LocalBrowseChgDir(b:netrw_curdir,'./'))
2551 exe "keepjumps ".curline 2585 exe "keepjumps ".curline
2552 " call Dret("LocalBrowseRename") 2586 " call Dret("LocalBrowseRename")
2553 endfun 2587 endfun
2554 2588
2555 " --------------------------------------------------------------------- 2589 " ---------------------------------------------------------------------
2558 " call Dfunc("LocalPreview(path<".a:path.">)") 2592 " call Dfunc("LocalPreview(path<".a:path.">)")
2559 if has("quickfix") 2593 if has("quickfix")
2560 if !isdirectory(a:path) 2594 if !isdirectory(a:path)
2561 exe "pedit ".a:path 2595 exe "pedit ".a:path
2562 elseif !exists("g:netrw_quiet") 2596 elseif !exists("g:netrw_quiet")
2563 echoerr "***netrw*** sorry, cannot preview a directory such as <".a:path.">" 2597 echohl WarningMsg | echo "***netrw*** sorry, cannot preview a directory such as <".a:path.">" | echohl None
2564 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 2598 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
2565 endif 2599 endif
2566 elseif !exists("g:netrw_quiet") 2600 elseif !exists("g:netrw_quiet")
2567 echoerr "***netrw*** sorry, to preview your vim needs the quickfix feature compiled in" 2601 echohl WarningMsg | echo "***netrw*** sorry, to preview your vim needs the quickfix feature compiled in" | echohl None
2568 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 2602 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
2569 endif 2603 endif
2570 " call Dret("LocalPreview") 2604 " call Dret("LocalPreview")
2605 endfun
2606
2607 " ---------------------------------------------------------------------
2608 " LocalRefresh: {{{2
2609 fun! <SID>LocalRefresh(dirname)
2610 " call Dfunc("LocalRefresh(dirname<".a:dirname.">)")
2611 set ma
2612 %d
2613 call <SID>LocalBrowse(a:dirname)
2614 redraw!
2615 " call Dret("LocalRefresh")
2571 endfun 2616 endfun
2572 2617
2573 " --------------------------------------------------------------------- 2618 " ---------------------------------------------------------------------
2574 " Explore: launch the local browser in the directory of the current file {{{2 2619 " Explore: launch the local browser in the directory of the current file {{{2
2575 " dosplit==0: the window will be split iff the current file has 2620 " dosplit==0: the window will be split iff the current file has
2600 if a:1 == "" && a:indx >= 0 2645 if a:1 == "" && a:indx >= 0
2601 let newdir= substitute(expand("%:p"),'^\(.*\)[/\\][^/\\]*$','\1','e') 2646 let newdir= substitute(expand("%:p"),'^\(.*\)[/\\][^/\\]*$','\1','e')
2602 " call Decho("calling LocalBrowse(newdir<".newdir.">)") 2647 " call Decho("calling LocalBrowse(newdir<".newdir.">)")
2603 call s:LocalBrowse(newdir) 2648 call s:LocalBrowse(newdir)
2604 2649
2605 elseif a:1 =~ '\*\*' || a:indx < 0 2650 elseif a:1 =~ '\*\*/' || a:indx < 0
2606 2651
2607 if has("path_extra") 2652 if has("path_extra")
2608 if !exists("s:indx") 2653 if !exists("s:indx")
2609 let s:indx= 0 2654 let s:indx= 0
2610 endif 2655 endif
2615 let indx= s:indx - 1 2660 let indx= s:indx - 1
2616 else 2661 else
2617 let s:indx = 0 2662 let s:indx = 0
2618 let s:explorelist = split(expand(b:netrw_curdir."/".a:1),'\n') 2663 let s:explorelist = split(expand(b:netrw_curdir."/".a:1),'\n')
2619 let s:listlen = len(s:explorelist) 2664 let s:listlen = len(s:explorelist)
2665 if s:listlen == 1 && s:explorelist[0] =~ '\*\*\/'
2666 echohl WarningMsg | echo "***netrw*** no files matched" | echohl None
2667 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
2668 " call Dret("Explore")
2669 return
2670 endif
2620 endif 2671 endif
2621 let s:indx = indx 2672 let s:indx = indx
2622 " call Decho("explorelist<".join(s:explorelist,',')."> len=".s:listlen) 2673 " call Decho("explorelist<".join(s:explorelist,',')."> len=".s:listlen)
2623 2674
2624 " sanity check 2675 " sanity check
2625 if indx >= s:listlen 2676 if indx >= s:listlen || indx < 0
2626 echoerr "***netrw*** no more directories with matching files" 2677 let indx= (indx < 0)? 0 : ( s:listlen - 1 )
2678 echohl WarningMsg | echo "***netrw*** no more files match Explore pattern" | echohl None
2627 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 2679 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
2628 " call Dret("Explore") 2680 " call Dret("Explore")
2629 return 2681 return
2630 endif 2682 endif
2631 2683
2637 call s:LocalBrowse(newdir) 2689 call s:LocalBrowse(newdir)
2638 call search(substitute(dirfile,"^.*/","",""),"W") 2690 call search(substitute(dirfile,"^.*/","",""),"W")
2639 2691
2640 else 2692 else
2641 if v:version < 700 2693 if v:version < 700
2642 echoerr "***netrw*** you need vim version 7.0 or later for Exploring with **!" 2694 echohl WarningMsg | echo "***netrw*** you need vim version 7.0 or later for Exploring with **!" | echohl None
2643 elseif !exists("g:netrw_quiet") 2695 elseif !exists("g:netrw_quiet")
2644 echoerr "***netrw*** your vim needs the path_extra feature for Exploring with **!" 2696 echohl WarningMsg | echo "***netrw*** your vim needs the +path_extra feature for Exploring with **!" | echohl None | echohl None
2645 endif 2697 endif
2646 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 2698 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
2647 endif 2699 endif
2648 2700
2649 else 2701 else
2845 let b:netrw_method = 3 2897 let b:netrw_method = 3
2846 endif 2898 endif
2847 2899
2848 else 2900 else
2849 if !exists("g:netrw_quiet") 2901 if !exists("g:netrw_quiet")
2850 echoerr "***netrw*** cannot determine method" 2902 echohl Error | echo "***netrw*** cannot determine method" | echohl None
2851 call inputsave()|call input("Press <cr> to continue")|call inputrestore() 2903 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
2852 endif 2904 endif
2853 let b:netrw_method = -1 2905 let b:netrw_method = -1
2854 endif 2906 endif
2855 2907