Changeset f3587132
- Timestamp:
- Jun 1, 2014, 12:49:45 AM (10 years ago)
- Branches:
- clfs-3.0.0-sysvinit, sysvinit
- Children:
- 47ce4dc
- Parents:
- e00ab8d
- git-author:
- William Harrington <kb0iic@…> (06/01/14 00:49:35)
- git-committer:
- William Harrington <kb0iic@…> (06/01/14 00:49:45)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
patches/vim-7.4-branch_update-4.patch
re00ab8d rf3587132 1 1 Submitted By: William Harrington (kb0iic at cross-lfs dot org) 2 Date: 2014-0 4-262 Date: 2014-05-31 3 3 Initial Package Version: 7.4 4 4 Origin: Upstream 5 5 Upstream Status: Applied 6 Description: Contains all upstream patches up to 7.4. 265.6 Description: Contains all upstream patches up to 7.4.316. 7 7 8 8 diff -Naur vim74.orig/.hg_archival.txt vim74/.hg_archival.txt 9 9 --- vim74.orig/.hg_archival.txt 1970-01-01 00:00:00.000000000 +0000 10 +++ vim74/.hg_archival.txt 2014-0 4-27 05:20:57.181745403+000010 +++ vim74/.hg_archival.txt 2014-06-01 00:42:48.067546692 +0000 11 11 @@ -0,0 +1,5 @@ 12 12 +repo: 770908d1cb47c04be0aef5c173b17ab8be6b6476 13 +node: 01f2b7e6b33ca4da4fbe2a5b8e9184ea2749d64e13 +node: bed71c37618c11240596390f277d4f5e60d35ebc 14 14 +branch: default 15 +latesttag: v7-4- 26515 +latesttag: v7-4-316 16 16 +latesttagdistance: 1 17 17 diff -Naur vim74.orig/.hgignore vim74/.hgignore 18 18 --- vim74.orig/.hgignore 1970-01-01 00:00:00.000000000 +0000 19 +++ vim74/.hgignore 2014-0 4-27 05:20:57.188412237+000019 +++ vim74/.hgignore 2014-06-01 00:42:48.107546590 +0000 20 20 @@ -0,0 +1,74 @@ 21 21 +syntax: glob … … 95 95 diff -Naur vim74.orig/.hgtags vim74/.hgtags 96 96 --- vim74.orig/.hgtags 1970-01-01 00:00:00.000000000 +0000 97 +++ vim74/.hgtags 2014-0 4-27 05:20:57.195079070+000098 @@ -0,0 +1, 2990@@97 +++ vim74/.hgtags 2014-06-01 00:42:48.127546539 +0000 98 @@ -0,0 +1,3041 @@ 99 99 +004eb98eb3c30714cb6a24ec3e810275080a8413 v7-1-117 100 100 +006e9c8a6a8ad354a5cb6adcce6ebfceddeb20ee v7-0079 … … 3087 3087 +00acac0af680c2d8c82db5258474b121a5908926 v7-4-264 3088 3088 +8ec9d2196bee0c5108f2d2c196a660a7f4e5f29f v7-4-265 3089 +8f84e906d454a95d3167678a745dde9de442b604 v7-4-266 3090 +75f222d67cea335efbe0274de6340dba174c1e7e v7-4-267 3091 +1a5ed2626b26a982e307a206572121a557adf709 v7-4-268 3092 +81c26975e8f9dc7435353581346542409403f296 v7-4-269 3093 +c519c446c5488bfd48c93a03efae4ae3e0c1f162 v7-4-270 3094 +88b0571de4327ba5127a483493bd7d46e6a9850e v7-4-271 3095 +00228400629e28384f7f52556c3c119ba0d0a44d v7-4-272 3096 +747afb6a6de437131d9674e6b2bcc73d74863a89 v7-4-273 3097 +1ee3fc5b40ae94c2a7fc5a62bca38d4f730f9bb2 v7-4-274 3098 +8a3117a4887c1e12a1165c9719491f96753787d6 v7-4-275 3099 +a6b59ee633a355095e6473ec5e2a7d9088bfb853 v7-4-276 3100 +373204662d82e894b27ee76bc3319bc62c91f6ae v7-4-277 3101 +b4ce0e1fb5a67d7d6b0bca8eaa3edc2e94a085d8 v7-4-278 3102 +8e9db1f27a0063df023cc05a760fce73255dad24 v7-4-279 3103 +daf7e98675cf395e1ef96f8040567affb2782a11 v7-4-280 3104 +24c90f1fec859b54cf2b854b98c4c9e614c46061 v7-4-281 3105 +6d0a1132dd71c7f55f7ed53fe99e97c79bfd05a4 v7-4-282 3106 +aa99d04fa7e288a8580e3a5d4a9d6433a1572b48 v7-4-283 3107 +3c35ca9666e88a8024af6dab585b8e79ab295f83 v7-4-284 3108 +5cb1828fd0056de3c166e71fbafc67a74c57d7b1 v7-4-285 3109 +be19015ef43cc17825929206790696c2e716035d v7-4-286 3110 +66fe4908b649ba18426af6f69e8ccb01b487dcbd v7-4-287 3111 +7965cb6a435ae1ea331c7c2f8740d3d4c3625f3b v7-4-288 3112 +99374096a76b96d1128f5e6aa1fa92b4ba70fee9 v7-4-289 3113 +b871734bf54ea185dbd2cc759d86dbfbe21cde26 v7-4-290 3114 +b5972833add9de714f4651e26fd9ea63ec4a880c v7-4-291 3115 +60cdaa05a6ad31cef55eb6b3dc1f57ecac6fcf79 v7-4-292 3116 +10fc95f48546f438648b8357062e93c9c2c0a377 v7-4-293 3117 +fdea5ea9afd139ea59dee6bdb3f1675b8b882bdf v7-4-294 3118 +662ae48e7e246a63d38c9f3165b15b62252edaee v7-4-295 3119 +53b87d790574b6d19034fb3390987c22fb928c58 v7-4-296 3120 +81f5a056b2a582c8109da10cc538dc16a326a34d v7-4-297 3121 +156f891d520e93eab5d3ce02784660fb13a3b0d3 v7-4-298 3122 +daebf8ce66089c0c179fb436ceba359ef8d593d5 v7-4-299 3123 +1157079ca5f167bcf8746dfc52ea5a85e6c87a30 v7-4-300 3124 +8cb42aa3c4957a543e5dffe307475dbab969612f v7-4-301 3125 +df141c80ea3a1ffcbf82d05c1314675231fcfa75 v7-4-302 3126 +463ef551e9f62b63ac3f85f1f297b668b14bcd09 v7-4-303 3127 +fed2e0967f8133ba9a44b0701f151c8d88c4896a v7-4-304 3128 +63e7cc62402dffb180b40c04c63ceeb5f53957d7 v7-4-305 3129 +05e1d8afcc5e375bf708ccc9810e2fd1a5a8a3cf v7-4-306 3130 +06c10522d321d98874546b2a4d3b0ae145386f2e v7-4-307 3131 +e3d2b8d83bb30c428a051f50791e454fcbc080af v7-4-308 3132 +88a6e9f33822d33b6c32db578750c6c178c63f50 v7-4-309 3133 +ccac0aa34eeaf46dad4b831461a532fc3fe71096 v7-4-310 3134 +f6f7543043246107075f0d3739c471d51b7226da v7-4-311 3135 +66eead134d6800fd4cf2d5d4b135d300c933f09a v7-4-312 3136 +332a5c2b2956d9b18d85268a724d01deea27ec83 v7-4-313 3137 +4d7af1962d6ce61df65fdc5c86544a61951f9517 v7-4-314 3138 +646616b6ff4defcc7bef0b198b540f6d965a8126 v7-4-315 3139 +0fc665889e8f0af532cb4e3be2f0ff0421bf2fbc v7-4-316 3089 3140 diff -Naur vim74.orig/Filelist vim74/Filelist 3090 3141 --- vim74.orig/Filelist 2013-07-13 13:23:38.000000000 +0000 3091 +++ vim74/Filelist 2014-04-27 05:20:57.198412485 +0000 3092 @@ -80,10 +80,14 @@ 3142 +++ vim74/Filelist 2014-06-01 00:42:48.197546361 +0000 3143 @@ -3,6 +3,7 @@ 3144 3145 # source files for all source archives 3146 SRC_ALL = \ 3147 + .hgignore \ 3148 src/README.txt \ 3149 src/arabic.c \ 3150 src/arabic.h \ 3151 @@ -80,10 +81,15 @@ 3093 3152 src/main.aap \ 3094 3153 src/testdir/main.aap \ … … 3102 3161 src/testdir/test83-tags? \ 3103 3162 + src/testdir/test77a.com \ 3163 + src/testdir/test_*.vim \ 3104 3164 src/testdir/python2/*.py \ 3105 3165 src/testdir/python3/*.py \ … … 3107 3167 diff -Naur vim74.orig/runtime/autoload/clojurecomplete.vim vim74/runtime/autoload/clojurecomplete.vim 3108 3168 --- vim74.orig/runtime/autoload/clojurecomplete.vim 2013-02-06 14:35:23.000000000 +0000 3109 +++ vim74/runtime/autoload/clojurecomplete.vim 2014-0 4-27 05:20:57.231746647+00003169 +++ vim74/runtime/autoload/clojurecomplete.vim 2014-06-01 00:42:49.274210286 +0000 3110 3170 @@ -1,20 +1,22 @@ 3111 3171 " Vim completion script … … 3148 3208 diff -Naur vim74.orig/runtime/autoload/getscript.vim vim74/runtime/autoload/getscript.vim 3149 3209 --- vim74.orig/runtime/autoload/getscript.vim 2013-04-17 13:40:44.000000000 +0000 3150 +++ vim74/runtime/autoload/getscript.vim 2014-0 4-27 05:20:57.235080063+00003210 +++ vim74/runtime/autoload/getscript.vim 2014-06-01 00:42:49.320876834 +0000 3151 3211 @@ -1,8 +1,8 @@ 3152 3212 " --------------------------------------------------------------------- … … 3182 3242 diff -Naur vim74.orig/runtime/autoload/netrw.vim vim74/runtime/autoload/netrw.vim 3183 3243 --- vim74.orig/runtime/autoload/netrw.vim 2013-05-19 03:28:33.000000000 +0000 3184 +++ vim74/runtime/autoload/netrw.vim 2014-0 4-27 05:20:57.241746894+00003244 +++ vim74/runtime/autoload/netrw.vim 2014-06-01 00:42:49.417543255 +0000 3185 3245 @@ -1,10 +1,10 @@ 3186 3246 " netrw.vim: Handles file transfer and remote directory listing across … … 3188 3248 -" Date: May 18, 2013 3189 3249 -" Version: 149 3190 +" Date: Ma r 20, 20143191 +" Version: 15 13250 +" Date: May 13, 2014 3251 +" Version: 152 3192 3252 " Maintainer: Charles E Campbell <NdrOchip@ScampbellPfamily.AbizM-NOSPAM> 3193 3253 " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim … … 3197 3257 " with or without modifications, provided that this copyright 3198 3258 " notice is copied with it. Like anything else that's free, 3199 @@ -22,13 +22, 7@@3259 @@ -22,13 +22,14 @@ 3200 3260 if &cp || exists("g:loaded_netrw") 3201 3261 finish … … 3206 3266 - echo "***warning*** this version of netrw needs vim 7.3.465 or later" 3207 3267 - echohl Normal 3208 - finish 3209 -endif 3210 +let g:loaded_netrw = "v151" 3268 +if v:version < 704 || !has("patch213") 3269 + if !exists("s:needpatch213") 3270 + echo "***sorry*** this version of netrw requires vim v7.4 with patch 213" 3271 + endif 3272 + let s:needpatch213= 1 3273 finish 3274 endif 3275 +let g:loaded_netrw = "v152" 3211 3276 if !exists("s:NOTE") 3212 3277 let s:NOTE = 0 3213 3278 let s:WARNING = 1 3214 @@ -36,8 +3 0,9 @@3279 @@ -36,8 +37,9 @@ 3215 3280 endif 3216 3281 … … 3224 3289 3225 3290 " ====================== 3226 @@ -49,7 + 44,7 @@3291 @@ -49,7 +51,7 @@ 3227 3292 " 0=note = s:NOTE 3228 3293 " 1=warning = s:WARNING 3229 3294 " 2=error = s:ERROR 3230 3295 -" May 01, 2013 : max errnum currently is 93 3231 +" Mar 04, 2014 : max errnum currently is 963296 +" Apr 16, 2014 : max errnum currently is 97 3232 3297 fun! netrw#ErrorMsg(level,msg,errnum) 3233 3298 " call Dfunc("netrw#ErrorMsg(level=".a:level." msg<".a:msg."> errnum=".a:errnum.") g:netrw_use_errorwindow=".g:netrw_use_errorwindow) 3234 3299 3235 @@ -104, 7 +99,7@@3300 @@ -104,8 +106,8 @@ 3236 3301 hi link netrwMesgWarning WarningMsg 3237 3302 hi link netrwMesgError Error 3238 3303 endif 3239 3304 -" call Decho("(ErrorMsg) setl noma ro bh=wipe") 3305 - setl noma ro bh=wipe 3240 3306 +" call Decho("setl noma ro bh=wipe") 3241 setl noma robh=wipe3307 + setl ro nomod noma bh=wipe 3242 3308 3243 3309 else 3244 @@ -200,6 +195,7 @@ 3310 " (optional) netrw will show messages using echomsg. Even if the 3311 @@ -200,6 +202,7 @@ 3245 3312 let g:netrw_http_cmd = "" 3246 3313 endif … … 3250 3317 call s:NetrwInit("g:netrw_rsync_cmd", "rsync") 3251 3318 if !exists("g:netrw_scp_cmd") 3252 @@ -260,6 +256,7 @@ 3319 @@ -249,7 +252,7 @@ 3320 call s:NetrwInit("g:netrw_altv" , &spr) 3321 call s:NetrwInit("g:netrw_banner" , 1) 3322 call s:NetrwInit("g:netrw_browse_split", 0) 3323 -call s:NetrwInit("g:netrw_bufsettings" , "noma nomod nonu nobl nowrap ro") 3324 +call s:NetrwInit("g:netrw_bufsettings" , "noma nomod nonu nobl nowrap ro nornu") 3325 call s:NetrwInit("g:netrw_chgwin" , -1) 3326 call s:NetrwInit("g:netrw_compress" , "gzip") 3327 call s:NetrwInit("g:netrw_ctags" , "ctags") 3328 @@ -260,6 +263,7 @@ 3253 3329 call s:NetrwInit("g:netrw_cursor" , 2) 3254 3330 let s:netrw_usercul = &cursorline … … 3258 3334 call s:NetrwInit("s:didstarstar",0) 3259 3335 call s:NetrwInit("g:netrw_dirhist_cnt" , 0) 3260 @@ -291,23 +2 88,19 @@3336 @@ -291,23 +295,19 @@ 3261 3337 endif 3262 3338 call s:NetrwInit("g:netrw_keepdir",1) … … 3283 3359 call s:NetrwInit("g:netrw_list_hide","") 3284 3360 " Default values - lh-lz ---------- {{{3 3285 @@ -387,8 +380,17 @@ 3361 @@ -323,7 +323,7 @@ 3362 if g:netrw_cygwin 3363 let g:netrw_localcopycmd= "cp" 3364 else 3365 - let g:netrw_localcopycmd= "cmd /c copy" 3366 + let g:netrw_localcopycmd= expand("$COMSPEC")." /c copy" 3367 endif 3368 elseif has("unix") || has("macunix") 3369 let g:netrw_localcopycmd= "cp" 3370 @@ -335,7 +335,15 @@ 3371 let g:netrw_localmkdir= g:netrw_local_mkdir 3372 call netrw#ErrorMsg(s:NOTE,"g:netrw_local_mkdir is deprecated in favor of g:netrw_localmkdir",87) 3373 endif 3374 -call s:NetrwInit("g:netrw_localmkdir","mkdir") 3375 +if has("win32") || has("win95") || has("win64") || has("win16") 3376 + if g:netrw_cygwin 3377 + call s:NetrwInit("g:netrw_localmkdir","mkdir") 3378 + else 3379 + let g:netrw_localmkdir= expand("$COMSPEC")." /c mkdir" 3380 + endif 3381 +else 3382 + call s:NetrwInit("g:netrw_localmkdir","mkdir") 3383 +endif 3384 call s:NetrwInit("g:netrw_remote_mkdir","mkdir") 3385 if exists("g:netrw_local_movecmd") 3386 let g:netrw_localmovecmd= g:netrw_local_movecmd 3387 @@ -346,7 +354,7 @@ 3388 if g:netrw_cygwin 3389 let g:netrw_localmovecmd= "mv" 3390 else 3391 - let g:netrw_localmovecmd= "cmd /c move" 3392 + let g:netrw_localmovecmd= expand("$COMSPEC")." /c move" 3393 endif 3394 elseif has("unix") || has("macunix") 3395 let g:netrw_localmovecmd= "mv" 3396 @@ -354,11 +362,19 @@ 3397 let g:netrw_localmovecmd= "" 3398 endif 3399 endif 3400 -call s:NetrwInit("g:netrw_localrmdir", "rmdir") 3401 if exists("g:netrw_local_rmdir") 3402 let g:netrw_localrmdir= g:netrw_local_rmdir 3403 call netrw#ErrorMsg(s:NOTE,"g:netrw_local_rmdir is deprecated in favor of g:netrw_localrmdir",86) 3404 endif 3405 +if has("win32") || has("win95") || has("win64") || has("win16") 3406 + if g:netrw_cygwin 3407 + call s:NetrwInit("g:netrw_localrmdir","rmdir") 3408 + else 3409 + let g:netrw_localrmdir= expand("$COMSPEC")." /c rmdir" 3410 + endif 3411 +else 3412 + call s:NetrwInit("g:netrw_localrmdir","rmdir") 3413 +endif 3414 call s:NetrwInit("g:netrw_liststyle" , s:THINLIST) 3415 " sanity checks 3416 if g:netrw_liststyle < 0 || g:netrw_liststyle >= s:MAXLIST 3417 @@ -387,8 +403,17 @@ 3286 3418 call s:NetrwInit("g:netrw_rename_cmd" , g:netrw_ssh_cmd." USEPORT HOSTNAME mv") 3287 3419 call s:NetrwInit("g:netrw_rm_cmd" , g:netrw_ssh_cmd." USEPORT HOSTNAME rm") … … 3303 3435 call s:NetrwInit("g:netrw_sepchr" , (&enc == "euc-jp")? "\<Char-0x01>" : "\<Char-0xff>") 3304 3436 call s:NetrwInit("s:netrw_silentxfer" , (exists("g:netrw_silent") && g:netrw_silent != 0)? "sil keepj " : "keepj ") 3305 @@ -404,7 +4 06,7 @@3437 @@ -404,7 +429,7 @@ 3306 3438 endif 3307 3439 call s:NetrwInit("g:netrw_special_syntax" , 0) … … 3312 3444 call s:NetrwInit("g:netrw_timefmt","%c") 3313 3445 if !exists("g:netrw_xstrlen") 3314 @@ -434,6 +436,11 @@ 3446 @@ -421,7 +446,6 @@ 3447 call s:NetrwInit("g:NetrwTopLvlMenu","Netrw.") 3448 call s:NetrwInit("g:netrw_win95ftp",1) 3449 call s:NetrwInit("g:netrw_winsize",50) 3450 -if g:netrw_winsize == 0|let g:netrw_winsize= -1|endif 3451 if g:netrw_winsize > 100|let g:netrw_winsize= 100|endif 3452 " --------------------------------------------------------------------- 3453 " Default values for netrw's script variables: {{{2 3454 @@ -434,6 +458,11 @@ 3315 3455 call s:NetrwInit("g:netrw_menu_escape",'.&? \') 3316 3456 call s:NetrwInit("g:netrw_tmpfile_escape",' &;') … … 3324 3464 " BufEnter event ignored by decho when following variable is true 3325 3465 " Has a side effect that doau BufReadPost doesn't work, so 3326 @@ -444,11 +4 51,18 @@3466 @@ -444,11 +473,18 @@ 3327 3467 " Netrw Initialization: {{{1 3328 3468 " ====================== … … 3348 3488 au WinEnter * if &ft == "netrw"|call s:NetrwInsureWinVars()|endif 3349 3489 3350 @@ -457,276 +4 71,43 @@3490 @@ -457,276 +493,43 @@ 3351 3491 " ============================== 3352 3492 … … 3659 3799 " indx: == -1: Nexplore 3660 3800 " == -2: Pexplore 3661 @@ -737,7 +5 18,7 @@3801 @@ -737,7 +540,7 @@ 3662 3802 " * If Hexplore or Vexplore, then this will override 3663 3803 " g:netrw_winsize to specify the qty of rows or columns the … … 3668 3808 " style == 0: Explore style == 1: Explore! 3669 3809 " == 2: Hexplore style == 3: Hexplore! 3670 @@ -747,26 +5 28,52 @@3810 @@ -747,26 +550,52 @@ 3671 3811 " 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("%")) 3672 3812 if !exists("b:netrw_curdir") … … 3731 3871 let winsz= g:netrw_winsize 3732 3872 if a:indx > 0 3733 @@ -774,106 + 581,106@@3873 @@ -774,106 +603,119 @@ 3734 3874 endif 3735 3875 … … 3738 3878 +" call Decho("style=0: Explore or Sexplore") 3739 3879 let winsz= (winsz > 0)? (winsz*winheight(0))/100 : -winsz 3740 exe winsz."wincmd s" 3880 - exe winsz."wincmd s" 3881 + if winsz == 0|let winsz= ""|endif 3882 + exe "noswapfile ".winsz."wincmd s" 3883 +" call Decho("exe noswapfile ".winsz."wincmd s") 3741 3884 3742 3885 elseif a:style == 1 "Explore!, Sexplore! … … 3744 3887 +" call Decho("style=1: Explore! or Sexplore!") 3745 3888 let winsz= (winsz > 0)? (winsz*winwidth(0))/100 : -winsz 3746 exe "keepalt ".winsz."wincmd v" 3889 - exe "keepalt ".winsz."wincmd v" 3890 + if winsz == 0|let winsz= ""|endif 3891 + exe "keepalt noswapfile ".winsz."wincmd v" 3892 +" call Decho("exe keepalt noswapfile ".winsz."wincmd v") 3747 3893 3748 3894 elseif a:style == 2 " Hexplore … … 3750 3896 +" call Decho("style=2: Hexplore") 3751 3897 let winsz= (winsz > 0)? (winsz*winheight(0))/100 : -winsz 3752 exe "keepalt bel ".winsz."wincmd s" 3898 - exe "keepalt bel ".winsz."wincmd s" 3899 + if winsz == 0|let winsz= ""|endif 3900 + exe "keepalt noswapfile bel ".winsz."wincmd s" 3901 +" call Decho("exe keepalt noswapfile bel ".winsz."wincmd s") 3753 3902 3754 3903 elseif a:style == 3 " Hexplore! … … 3756 3905 +" call Decho("style=3: Hexplore!") 3757 3906 let winsz= (winsz > 0)? (winsz*winheight(0))/100 : -winsz 3758 exe "keepalt abo ".winsz."wincmd s" 3907 - exe "keepalt abo ".winsz."wincmd s" 3908 + if winsz == 0|let winsz= ""|endif 3909 + exe "keepalt noswapfile abo ".winsz."wincmd s" 3910 +" call Decho("exe keepalt noswapfile abo ".winsz."wincmd s") 3759 3911 3760 3912 elseif a:style == 4 " Vexplore … … 3762 3914 +" call Decho("style=4: Vexplore") 3763 3915 let winsz= (winsz > 0)? (winsz*winwidth(0))/100 : -winsz 3764 exe "keepalt lefta ".winsz."wincmd v" 3916 - exe "keepalt lefta ".winsz."wincmd v" 3917 + if winsz == 0|let winsz= ""|endif 3918 + exe "keepalt noswapfile lefta ".winsz."wincmd v" 3919 +" call Decho("exe keepalt noswapfile lefta ".winsz."wincmd v") 3765 3920 3766 3921 elseif a:style == 5 " Vexplore! … … 3768 3923 +" call Decho("style=5: Vexplore!") 3769 3924 let winsz= (winsz > 0)? (winsz*winwidth(0))/100 : -winsz 3770 exe "keepalt rightb ".winsz."wincmd v" 3925 - exe "keepalt rightb ".winsz."wincmd v" 3926 + if winsz == 0|let winsz= ""|endif 3927 + exe "keepalt noswapfile rightb ".winsz."wincmd v" 3928 +" call Decho("exe keepalt noswapfile rightb ".winsz."wincmd v") 3771 3929 3772 3930 elseif a:style == 6 " Texplore … … 3775 3933 +" call Decho("style = 6: Texplore") 3776 3934 exe "keepalt tabnew ".fnameescape(curdir) 3935 +" call Decho("exe keepalt tabnew ".fnameescape(curdir)) 3777 3936 call s:RestoreBufVars() 3778 3937 endif … … 3864 4023 if prefixdir =~ '^/' || (prefixdir =~ '^\a:/' && (has("win32") || has("win95") || has("win64") || has("win16"))) 3865 4024 let b:netrw_curdir = prefixdir 3866 @@ -882,30 + 689,30 @@4025 @@ -882,30 +724,30 @@ 3867 4026 endif 3868 4027 let dirname= substitute(dirname,'^.\{-}\(\*\*/.*\)$','\1','') … … 3902 4061 if dirname =~ '^scp://' || dirname =~ '^ftp://' 3903 4062 call netrw#Nread(2,dirname) 3904 @@ -914,15 +7 21,17 @@4063 @@ -914,15 +756,17 @@ 3905 4064 if dirname == "" 3906 4065 let dirname= getcwd() … … 3923 4082 if exists("w:netrw_bannercnt") 3924 4083 " done to handle P08-Ingelrest. :Explore will _Always_ go to the line just after the banner. 3925 @@ -930,7 +7 39,7 @@4084 @@ -930,7 +774,7 @@ 3926 4085 exe w:netrw_bannercnt 3927 4086 endif … … 3932 4091 " Jan 24, 2013: not sure why the following was present. See P08-Ingelrest 3933 4092 " if has("win32") || has("win95") || has("win64") || has("win16") 3934 @@ -946,30 +7 55,32 @@4093 @@ -946,30 +790,32 @@ 3935 4094 " starpat=4: Explore **/filepat (recursive descent search for filenames matching filepat) 3936 4095 elseif a:indx <= 0 … … 3972 4131 " call Dret("netrw#Explore") 3973 4132 return 3974 @@ -978,21 + 789,23 @@4133 @@ -978,21 +824,23 @@ 3975 4134 if indx < 0 | let indx= 0 | endif 3976 4135 if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif … … 4002 4161 " call Dret("netrw#Explore") 4003 4162 return 4004 @@ -1001,30 +8 14,30 @@4163 @@ -1001,30 +849,30 @@ 4005 4164 if indx < 0 | let indx= 0 | endif 4006 4165 if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif … … 4040 4199 exe "keepj noautocmd vimgrep /".pattern."/gj ".fnameescape(b:netrw_curdir)."/*" 4041 4200 catch /^Vim\%((\a\+)\)\=:E480/ 4042 @@ -1037,15 +8 50,17 @@4201 @@ -1037,15 +885,17 @@ 4043 4202 4044 4203 elseif starpat == 2 … … 4062 4221 " call Dret("netrw#Explore : no files matched pattern") 4063 4222 return 4064 @@ -1057, 29 +872,31@@4223 @@ -1057,53 +907,55 @@ 4065 4224 4066 4225 elseif starpat == 3 … … 4095 4254 - sil! let @* = keepregstar 4096 4255 - sil! let @+ = keepregstar 4256 - sil! let @/ = keepregslash 4257 -" call Dret("netrw#Explore : no files matched") 4097 4258 + if has("clipboard") 4098 4259 + sil! let @* = keepregstar 4099 4260 + sil! let @+ = keepregstar 4100 4261 + endif 4101 4102 4262 + sil! let @/ = keepregslash 4263 +" call Dret("netrw#Explore : no files matched") 4103 4264 return 4104 @@ -1088,22 +905,22 @@ 4265 endif 4266 endif " if indx ... endif 4105 4267 4106 4268 " NetrwStatusLine support - for exploring support … … 4130 4292 if !exists("w:netrw_liststyle") 4131 4293 let w:netrw_liststyle= g:netrw_liststyle 4132 @@ -1117,22 +9 34,24 @@4294 @@ -1117,22 +969,24 @@ 4133 4295 let w:netrw_explore_bufnr = bufnr("%") 4134 4296 let w:netrw_explore_line = line(".") … … 4160 4322 sil! unlet w:netrw_treedict 4161 4323 sil! unlet w:netrw_treetop 4162 @@ -1146,22 + 965,22 @@4324 @@ -1146,22 +1000,22 @@ 4163 4325 endif 4164 4326 … … 4190 4352 if s:explore_match == "" 4191 4353 let s:explore_match= '\<'.escape(strpart(fname,dirlen),g:netrw_markfileesc).'\>' 4192 @@ -1177,7 + 996,7 @@4354 @@ -1177,7 +1031,7 @@ 4193 4355 endif 4194 4356 let prvfname= fname … … 4199 4361 endif 4200 4362 echo "<s-up>==Pexplore <s-down>==Nexplore" 4201 @@ -1186,47 +10 05,76 @@4363 @@ -1186,47 +1040,76 @@ 4202 4364 if exists("s:explore_match") | unlet s:explore_match | endif 4203 4365 if exists("s:explore_prvdir") | unlet s:explore_prvdir | endif … … 4301 4463 if a:sys 4302 4464 let choice= confirm("Remove personal and system copies of netrw?","&Yes\n&No") 4303 @@ -1264,28 +11 12,44 @@4465 @@ -1264,28 +1147,44 @@ 4304 4466 endif 4305 4467 echohl None … … 4359 4521 4360 4522 if type(a:fname) == 1 4361 @@ -1294,7 +11 58,7 @@4523 @@ -1294,7 +1193,7 @@ 4362 4524 let fnamelist= a:fname 4363 4525 else … … 4368 4530 endif 4369 4531 " call Decho("fnamelist<".string(fnamelist).">") 4370 @@ -1472,7 +1336,7 @@ 4532 @@ -1471,8 +1370,29 @@ 4533 keepj call netrw#ErrorMsg(s:ERROR,getline(1),5) 4371 4534 endif 4372 4535 endif 4536 + 4537 + elseif b:netrw_method == 9 4538 + " obtain file using sftp 4539 +" call Decho("obtain via sftp (method #9)") 4540 + if a:fname =~ '/' 4541 + let localfile= substitute(a:fname,'^.*/','','') 4542 + else 4543 + let localfile= a:fname 4544 + endif 4545 +" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_sftp_cmd." ".shellescape(g:netrw_machine.":".b:netrw_fname,1).shellescape(localfile)." ".shellescape(tgtdir)) 4546 + exe s:netrw_silentxfer."!".g:netrw_sftp_cmd." ".shellescape(g:netrw_machine.":".b:netrw_fname,1).shellescape(localfile)." ".shellescape(tgtdir) 4547 + 4373 4548 elseif !exists("b:netrw_method") || b:netrw_method < 0 4374 4549 -" call Dfunc("netrw#NetrwObtain : unsupported method") 4375 +" call Dfunc("netrw#Obtain : unsupported method") 4550 + " probably a badly formed url; protocol not recognized 4551 +" call Dret("netrw#Obtain : unsupported method") 4552 + return 4553 + 4554 + else 4555 + " protocol recognized but not supported for Obtain (yet?) 4556 + if !exists("g:netrw_quiet") 4557 + keepj call netrw#ErrorMsg(s:ERROR,"current protocol not supported for obtaining file",97) 4558 + endif 4559 +" call Dret("netrw#Obtain : current protocol not supported for obtaining file") 4376 4560 return 4377 4561 endif 4378 4562 4379 @@ -1492, 553 +1356,407 @@4563 @@ -1492,107 +1412,387 @@ 4380 4564 endif 4381 4565 endif … … 4447 4631 - call s:NetrwSafeOptions() 4448 4632 - call s:RestoreCursorline() 4449 -4450 - " NetRead: interpret mode into a readcmd {{{34451 - if a:mode == 0 " read remote file before current line4452 - let readcmd = "0r"4453 - elseif a:mode == 1 " read file after current line4454 - let readcmd = "r"4455 - elseif a:mode == 2 " replace with remote file4456 - let readcmd = "%r"4457 - elseif a:mode == 3 " skip read of file (leave as temporary)4458 - let readcmd = "t"4459 - else4460 - exe a:mode4461 - let readcmd = "r"4462 - endif4463 - let ichoice = (a:0 == 0)? 0 : 14464 -" call Decho("readcmd<".readcmd."> ichoice=".ichoice)4465 -4466 - " NetRead: get temporary filename {{{34467 - let tmpfile= s:GetTempfile("")4468 - if tmpfile == ""4469 -" call Dret("netrw#NetRead : unable to get a tempfile!")4470 4633 +" s:NetrwOptionRestore: restore options (based on prior s:NetrwOptionSave) {{{2 4471 4634 +fun! s:NetrwOptionRestore(vt) … … 4485 4648 +" call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 4486 4649 +" call Dret("s:NetrwOptionRestore : ".a:vt."netrw_optionsave doesn't exist") 4487 4488 4650 + return 4651 + endif 4489 4652 + unlet {a:vt}netrw_optionsave 4490 4653 4491 - while ichoice <= a:0 4492 - 4493 - " attempt to repeat with previous host-file-etc 4494 - if exists("b:netrw_lastfile") && a:0 == 0 4495 -" call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">") 4496 - let choice = b:netrw_lastfile 4497 - let ichoice= ichoice + 1 4498 - 4499 - else 4500 - exe "let choice= a:" . ichoice 4501 -" call Decho("no lastfile: choice<" . choice . ">") 4502 - 4503 - if match(choice,"?") == 0 4504 - " give help 4505 - echomsg 'NetRead Usage:' 4506 - echomsg ':Nread machine:path uses rcp' 4507 - echomsg ':Nread "machine path" uses ftp with <.netrc>' 4508 - echomsg ':Nread "machine id password path" uses ftp' 4509 - echomsg ':Nread dav://machine[:port]/path uses cadaver' 4510 - echomsg ':Nread fetch://machine/path uses fetch' 4511 - echomsg ':Nread ftp://[user@]machine[:port]/path uses ftp autodetects <.netrc>' 4512 - echomsg ':Nread http://[user@]machine/path uses http wget' 4513 - echomsg ':Nread rcp://[user@]machine/path uses rcp' 4514 - echomsg ':Nread rsync://machine[:port]/path uses rsync' 4515 - echomsg ':Nread scp://[user@]machine[[:#]port]/path uses scp' 4516 - echomsg ':Nread sftp://[user@]machine[[:#]port]/path uses sftp' 4517 - sleep 4 4518 - break 4519 - 4520 - elseif match(choice,'^"') != -1 4521 - " Reconstruct Choice if choice starts with '"' 4522 -" call Decho("reconstructing choice") 4523 - if match(choice,'"$') != -1 4524 - " case "..." 4525 - let choice= strpart(choice,1,strlen(choice)-2) 4526 - else 4527 - " case "... ... ..." 4528 - let choice = strpart(choice,1,strlen(choice)-1) 4529 - let wholechoice = "" 4530 - 4531 - while match(choice,'"$') == -1 4532 - let wholechoice = wholechoice . " " . choice 4533 - let ichoice = ichoice + 1 4534 - if ichoice > a:0 4535 - if !exists("g:netrw_quiet") 4536 - call netrw#ErrorMsg(s:ERROR,"Unbalanced string in filename '". wholechoice ."'",3) 4537 - endif 4538 -" call Dret("netrw#NetRead :2 getcwd<".getcwd().">") 4539 - return 4540 - endif 4541 - let choice= a:{ichoice} 4542 - endwhile 4543 - let choice= strpart(wholechoice,1,strlen(wholechoice)-1) . " " . strpart(choice,0,strlen(choice)-1) 4544 - endif 4654 - " NetRead: interpret mode into a readcmd {{{3 4655 - if a:mode == 0 " read remote file before current line 4656 - let readcmd = "0r" 4657 - elseif a:mode == 1 " read file after current line 4658 - let readcmd = "r" 4659 - elseif a:mode == 2 " replace with remote file 4660 - let readcmd = "%r" 4661 - elseif a:mode == 3 " skip read of file (leave as temporary) 4662 - let readcmd = "t" 4545 4663 + if exists("+acd") 4546 4664 + if exists("{a:vt}netrw_acdkeep") … … 4551 4669 + if &l:acd 4552 4670 + call s:NetrwLcd(curdir) 4553 endif 4554 endif 4555 - 4556 -" call Decho("choice<" . choice . ">") 4557 - let ichoice= ichoice + 1 4558 - 4559 - " NetRead: Determine method of read (ftp, rcp, etc) {{{3 4560 - call s:NetrwMethod(choice) 4561 - if !exists("b:netrw_method") || b:netrw_method < 0 4562 -" call Dfunc("netrw#NetRead : unsupported method") 4563 - return 4671 + endif 4672 + endif 4564 4673 + endif 4565 4674 + if exists("{a:vt}netrw_aikeep") |let &l:ai = {a:vt}netrw_aikeep |unlet {a:vt}netrw_aikeep |endif … … 4590 4699 + if exists("{a:vt}netrw_modkeep") |let &l:mod = {a:vt}netrw_modkeep |unlet {a:vt}netrw_modkeep |endif 4591 4700 + if exists("{a:vt}netrw_nukeep") |let &l:nu = {a:vt}netrw_nukeep |unlet {a:vt}netrw_nukeep |endif 4701 + if exists("{a:vt}netrw_rnukeep") |let &l:rnu = {a:vt}netrw_rnukeep |unlet {a:vt}netrw_rnukeep |endif 4592 4702 + if exists("{a:vt}netrw_repkeep") |let &l:report = {a:vt}netrw_repkeep |unlet {a:vt}netrw_repkeep |endif 4593 4703 + if exists("{a:vt}netrw_rokeep") |let &l:ro = {a:vt}netrw_rokeep |unlet {a:vt}netrw_rokeep |endif … … 4617 4727 + sil! let &l:swf= {a:vt}netrw_swfkeep 4618 4728 + unlet {a:vt}netrw_swfkeep 4619 endif 4620 - let tmpfile= s:GetTempfile(b:netrw_fname) " apply correct suffix 4621 - 4622 - " Check if NetrwBrowse() should be handling this request 4623 -" call Decho("checking if NetrwBrowse() should handle choice<".choice."> with netrw_list_cmd<".g:netrw_list_cmd.">") 4624 - if choice =~ "^.*[\/]$" && b:netrw_method != 5 && choice !~ '^https\=://' 4625 -" call Decho("yes, choice matches '^.*[\/]$'") 4626 - keepj call s:NetrwBrowse(0,choice) 4627 -" call Dret("netrw#NetRead :3 getcwd<".getcwd().">") 4628 - return 4729 + endif 4629 4730 + endif 4630 4731 + if exists("{a:vt}netrw_dirkeep") && isdirectory({a:vt}netrw_dirkeep) && g:netrw_keepdir … … 4645 4746 + if exists("s:nbcd_curpos_".bufnr('%')) 4646 4747 + unlet s:nbcd_curpos_{bufnr('%')} 4647 endif 4648 + else 4748 + endif 4749 else 4750 - exe a:mode 4751 - let readcmd = "r" 4649 4752 +" call Decho("no previous position") 4650 + endif 4651 4652 - " ============ 4653 - " NetRead: Perform Protocol-Based Read {{{3 4654 - " =========================== 4655 - if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1 4656 - echo "(netrw) Processing your read request..." 4657 - endif 4753 endif 4754 - let ichoice = (a:0 == 0)? 0 : 1 4755 -" call Decho("readcmd<".readcmd."> ichoice=".ichoice) 4756 4757 - " NetRead: get temporary filename {{{3 4758 - let tmpfile= s:GetTempfile("") 4759 - if tmpfile == "" 4760 -" call Dret("netrw#NetRead : unable to get a tempfile!") 4761 - return 4658 4762 +" call Decho("g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd) 4659 4763 +" call Decho("fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist")) … … 4667 4771 +" call Decho("filetype detect (ft=".&ft.")") 4668 4772 + filetype detect 4669 +endif4773 endif 4670 4774 +" call Decho("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) 4671 4775 +" call Dret("s:NetrwOptionRestore : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) 4672 4776 +endfun 4673 4777 4674 - "......................................... 4675 - " NetRead: (rcp) NetRead Method #1 {{{3 4676 - if b:netrw_method == 1 " read with rcp 4677 -" call Decho("read via rcp (method #1)") 4678 - " ER: nothing done with g:netrw_uid yet? 4679 - " ER: on Win2K" rcp machine[.user]:file tmpfile 4680 - " ER: if machine contains '.' adding .user is required (use $USERNAME) 4681 - " ER: the tmpfile is full path: rcp sees C:\... as host C 4682 - if s:netrw_has_nt_rcp == 1 4683 - if exists("g:netrw_uid") && ( g:netrw_uid != "" ) 4684 - let uid_machine = g:netrw_machine .'.'. g:netrw_uid 4685 - else 4686 - " Any way needed it machine contains a '.' 4687 - let uid_machine = g:netrw_machine .'.'. $USERNAME 4688 - endif 4689 - else 4690 - if exists("g:netrw_uid") && ( g:netrw_uid != "" ) 4691 - let uid_machine = g:netrw_uid .'@'. g:netrw_machine 4692 - else 4693 - let uid_machine = g:netrw_machine 4694 - endif 4695 - endif 4696 -" call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".shellescape(uid_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1)) 4697 - exe s:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".shellescape(uid_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1) 4698 - let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) 4699 - let b:netrw_lastfile = choice 4778 - while ichoice <= a:0 4779 - 4780 - " attempt to repeat with previous host-file-etc 4781 - if exists("b:netrw_lastfile") && a:0 == 0 4782 -" call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">") 4783 - let choice = b:netrw_lastfile 4784 - let ichoice= ichoice + 1 4700 4785 +" --------------------------------------------------------------------- 4701 4786 +" s:NetrwOptionSave: save options prior to setting to "netrw-buffer-standard" form {{{2 … … 4711 4796 +" call Decho("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) 4712 4797 4713 - "......................................... 4714 - " NetRead: (ftp + <.netrc>) NetRead Method #2 {{{3 4715 - elseif b:netrw_method == 2 " read with ftp + <.netrc> 4716 -" call Decho("read via ftp+.netrc (method #2)") 4717 - let netrw_fname= b:netrw_fname 4718 - keepj call s:SaveBufVars()|new|keepj call s:RestoreBufVars() 4719 - let filtbuf= bufnr("%") 4720 - setl ff=unix 4721 - keepj put =g:netrw_ftpmode 4722 -" call Decho("filter input: ".getline(line("$"))) 4723 - if exists("g:netrw_ftpextracmd") 4724 - keepj put =g:netrw_ftpextracmd 4725 -" call Decho("filter input: ".getline(line("$"))) 4726 - endif 4727 - call setline(line("$")+1,'get "'.netrw_fname.'" '.tmpfile) 4728 -" call Decho("filter input: ".getline(line("$"))) 4729 - if exists("g:netrw_port") && g:netrw_port != "" 4730 -" call Decho("executing: %!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1)) 4731 - exe s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1) 4732 - else 4733 -" call Decho("executing: %!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)) 4734 - exe s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1) 4735 - endif 4736 - " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) 4737 - if getline(1) !~ "^$" && !exists("g:netrw_quiet") && getline(1) !~ '^Trying ' 4738 - let debugkeep = &debug 4739 - setl debug=msg 4740 - keepj call netrw#ErrorMsg(s:ERROR,getline(1),4) 4741 - let &debug = debugkeep 4742 - endif 4743 - call s:SaveBufVars() 4744 - bd! 4745 - if bufname("%") == "" && getline("$") == "" && line('$') == 1 4746 - " needed when one sources a file in a nolbl setting window via ftp 4747 - q! 4748 - endif 4749 - call s:RestoreBufVars() 4750 - let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) 4751 - let b:netrw_lastfile = choice 4798 - else 4799 - exe "let choice= a:" . ichoice 4800 -" call Decho("no lastfile: choice<" . choice . ">") 4752 4801 + if !exists("{a:vt}netrw_optionsave") 4753 4802 + let {a:vt}netrw_optionsave= 1 … … 4758 4807 +" call Decho("prior to save: fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist")." diff=".&l:diff) 4759 4808 4760 - "......................................... 4761 - " NetRead: (ftp + machine,id,passwd,filename) NetRead Method #3 {{{3 4762 - elseif b:netrw_method == 3 " read with ftp + machine, id, passwd, and fname 4763 - " Construct execution string (four lines) which will be passed through filter 4764 -" call Decho("read via ftp+mipf (method #3)") 4765 - let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape) 4766 - keepj call s:SaveBufVars()|new|keepj call s:RestoreBufVars() 4767 - let filtbuf= bufnr("%") 4768 - setl ff=unix 4769 - if exists("g:netrw_port") && g:netrw_port != "" 4770 - keepj put ='open '.g:netrw_machine.' '.g:netrw_port 4771 -" call Decho("filter input: ".getline('.')) 4772 - else 4773 - keepj put ='open '.g:netrw_machine 4774 -" call Decho("filter input: ".getline('.')) 4775 - endif 4809 - if match(choice,"?") == 0 4810 - " give help 4811 - echomsg 'NetRead Usage:' 4812 - echomsg ':Nread machine:path uses rcp' 4813 - echomsg ':Nread "machine path" uses ftp with <.netrc>' 4814 - echomsg ':Nread "machine id password path" uses ftp' 4815 - echomsg ':Nread dav://machine[:port]/path uses cadaver' 4816 - echomsg ':Nread fetch://machine/path uses fetch' 4817 - echomsg ':Nread ftp://[user@]machine[:port]/path uses ftp autodetects <.netrc>' 4818 - echomsg ':Nread http://[user@]machine/path uses http wget' 4819 - echomsg ':Nread rcp://[user@]machine/path uses rcp' 4820 - echomsg ':Nread rsync://machine[:port]/path uses rsync' 4776 4821 + " Save current settings and current directory 4777 4822 +" call Decho("saving current settings and current directory") … … 4782 4827 + let {a:vt}netrw_bhkeep = &l:bh 4783 4828 + let {a:vt}netrw_blkeep = &l:bl 4784 + "let {a:vt}netrw_btkeep = &l:bt4829 + let {a:vt}netrw_btkeep = &l:bt 4785 4830 + let {a:vt}netrw_bombkeep = &l:bomb 4786 4831 + let {a:vt}netrw_cedit = &cedit … … 4792 4837 + let {a:vt}netrw_diffkeep = &l:diff 4793 4838 + let {a:vt}netrw_fenkeep = &l:fen 4794 + let {a:vt}netrw_ffkeep = &l:ff 4839 + if !exists("g:netrw_ffkeep") || g:netrw_ffkeep == 1 4840 + let {a:vt}netrw_ffkeep = &l:ff 4841 + endif 4795 4842 + let {a:vt}netrw_fokeep = &l:fo " formatoptions 4796 4843 + let {a:vt}netrw_gdkeep = &l:gd " gdefault … … 4803 4850 + let {a:vt}netrw_modkeep = &l:mod 4804 4851 + let {a:vt}netrw_nukeep = &l:nu 4852 + let {a:vt}netrw_rnukeep = &l:rnu 4805 4853 + let {a:vt}netrw_repkeep = &l:report 4806 4854 + let {a:vt}netrw_rokeep = &l:ro … … 4818 4866 + let {a:vt}netrw_wrapkeep = &l:wrap 4819 4867 + let {a:vt}netrw_writekeep = &l:write 4820 4821 - if exists("g:netrw_uid") && g:netrw_uid != "" 4822 - if exists("g:netrw_ftp") && g:netrw_ftp == 1 4823 - keepj put =g:netrw_uid 4824 -" call Decho("filter input: ".getline('.')) 4825 - if exists("s:netrw_passwd") 4826 - keepj put ='\"'.s:netrw_passwd.'\"' 4827 - endif 4828 -" call Decho("filter input: ".getline('.')) 4829 - elseif exists("s:netrw_passwd") 4830 - keepj put ='user \"'.g:netrw_uid.'\" \"'.s:netrw_passwd.'\"' 4831 -" call Decho("filter input: ".getline('.')) 4832 - endif 4833 - endif 4868 + 4834 4869 + " save a few selected netrw-related variables 4835 4870 +" call Decho("saving a few selected netrw-related variables") … … 4841 4876 + endif 4842 4877 + sil! let {a:vt}netrw_regslash= @/ 4843 4844 - if exists("g:netrw_ftpmode") && g:netrw_ftpmode != "" 4845 - keepj put =g:netrw_ftpmode 4846 -" call Decho("filter input: ".getline('.')) 4847 - endif 4848 - if exists("g:netrw_ftpextracmd") 4849 - keepj put =g:netrw_ftpextracmd 4850 -" call Decho("filter input: ".getline('.')) 4851 - endif 4852 - keepj put ='get \"'.netrw_fname.'\" '.tmpfile 4853 -" call Decho("filter input: ".getline('.')) 4878 + 4854 4879 +" call Decho("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) 4855 4880 +" call Dret("s:NetrwOptionSave : tab#".tabpagenr()." win#".winnr()) 4856 4881 +endfun 4857 4858 - " perform ftp: 4859 - " -i : turns off interactive prompting from ftp 4860 - " -n unix : DON'T use <.netrc>, even though it exists 4861 - " -n win32: quit being obnoxious about password 4862 - keepj norm! 1Gdd 4863 -" call Decho("executing: %!".s:netrw_ftp_cmd." ".g:netrw_ftp_options) 4864 - exe s:netrw_silentxfer."%!".s:netrw_ftp_cmd." ".g:netrw_ftp_options 4865 - " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) 4866 - if getline(1) !~ "^$" 4867 -" call Decho("error<".getline(1).">") 4868 - if !exists("g:netrw_quiet") 4869 - call netrw#ErrorMsg(s:ERROR,getline(1),5) 4870 - endif 4871 - endif 4872 - call s:SaveBufVars()|bd!|call s:RestoreBufVars() 4873 - let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) 4874 - let b:netrw_lastfile = choice 4882 + 4875 4883 +" ------------------------------------------------------------------------ 4876 4884 +" s:NetrwSafeOptions: sets options to help netrw do its job {{{2 … … 4911 4919 + setl cedit& 4912 4920 + call s:NetrwCursor() 4913 4914 - "......................................... 4915 - " NetRead: (scp) NetRead Method #4 {{{3 4916 - elseif b:netrw_method == 4 " read with scp 4917 -" call Decho("read via scp (method #4)") 4918 - if exists("g:netrw_port") && g:netrw_port != "" 4919 - let useport= " ".g:netrw_scpport." ".g:netrw_port 4920 - else 4921 - let useport= "" 4922 - endif 4923 -" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1)) 4924 - exe s:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1) 4925 - let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) 4926 - let b:netrw_lastfile = choice 4921 + 4927 4922 + " allow the user to override safe options 4928 4923 +" call Decho("ft<".&ft."> ei=".&ei) … … 4931 4926 + sil! keepalt keepj doau FileType netrw 4932 4927 + endif 4933 4934 - "......................................... 4935 - " NetRead: (http) NetRead Method #5 (wget) {{{3 4936 - elseif b:netrw_method == 5 4937 -" call Decho("read via http (method #5)") 4938 - if g:netrw_http_cmd == "" 4939 - if !exists("g:netrw_quiet") 4940 - call netrw#ErrorMsg(s:ERROR,"neither the wget nor the fetch command is available",6) 4941 - endif 4942 -" call Dret("netrw#NetRead :4 getcwd<".getcwd().">") 4943 - return 4944 - endif 4945 - 4946 - if match(b:netrw_fname,"#") == -1 || exists("g:netrw_http_xcmd") 4947 - " using g:netrw_http_cmd (usually elinks, links, curl, wget, or fetch) 4948 -" call Decho('using '.g:netrw_http_cmd.' (# not in b:netrw_fname<'.b:netrw_fname.">)") 4949 - if exists("g:netrw_http_xcmd") 4950 -" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape("http://".g:netrw_machine.b:netrw_fname,1)." ".g:netrw_http_xcmd." ".shellescape(tmpfile,1)) 4951 - exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape("http://".g:netrw_machine.b:netrw_fname,1)." ".g:netrw_http_xcmd." ".shellescape(tmpfile,1) 4952 - else 4953 -" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("http://".g:netrw_machine.b:netrw_fname,1)) 4954 - exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("http://".g:netrw_machine.b:netrw_fname,1) 4955 - endif 4956 - let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) 4957 - 4958 - else 4959 - " wget/curl/fetch plus a jump to an in-page marker (ie. http://abc/def.html#aMarker) 4960 -" call Decho("wget/curl plus jump (# in b:netrw_fname<".b:netrw_fname.">)") 4961 - let netrw_html= substitute(b:netrw_fname,"#.*$","","") 4962 - let netrw_tag = substitute(b:netrw_fname,"^.*#","","") 4963 -" call Decho("netrw_html<".netrw_html.">") 4964 -" call Decho("netrw_tag <".netrw_tag.">") 4965 -" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("http://".g:netrw_machine.netrw_html,1)) 4966 - exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("http://".g:netrw_machine.netrw_html,1) 4967 - let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) 4968 -" call Decho('<\s*a\s*name=\s*"'.netrw_tag.'"/') 4969 - exe 'keepj norm! 1G/<\s*a\s*name=\s*"'.netrw_tag.'"/'."\<CR>" 4970 - endif 4971 - let b:netrw_lastfile = choice 4972 -" call Decho("(NetRead) setl ro") 4973 - setl ro 4974 - 4975 - "......................................... 4976 - " NetRead: (dav) NetRead Method #6 {{{3 4977 - elseif b:netrw_method == 6 4978 -" call Decho("read via cadaver (method #6)") 4979 - 4980 - if !executable(g:netrw_dav_cmd) 4981 - call netrw#ErrorMsg(s:ERROR,g:netrw_dav_cmd." is not executable",73) 4982 -" call Dret("netrw#NetRead : ".g:netrw_dav_cmd." not executable") 4983 - return 4984 - endif 4985 - if g:netrw_dav_cmd =~ "curl" 4986 -" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_dav_cmd." ".shellescape("dav://".g:netrw_machine.b:netrw_fname,1)." ".shellescape(tmpfile,1)) 4987 - exe s:netrw_silentxfer."!".g:netrw_dav_cmd." ".shellescape("dav://".g:netrw_machine.b:netrw_fname,1)." ".shellescape(tmpfile,1) 4988 - else 4989 - " Construct execution string (four lines) which will be passed through filter 4990 - let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape) 4991 - new 4992 - setl ff=unix 4993 - if exists("g:netrw_port") && g:netrw_port != "" 4994 - keepj put ='open '.g:netrw_machine.' '.g:netrw_port 4995 - else 4996 - keepj put ='open '.g:netrw_machine 4997 - endif 4998 - if exists("g:netrw_uid") && exists("s:netrw_passwd") && g:netrw_uid != "" 4999 - keepj put ='user '.g:netrw_uid.' '.s:netrw_passwd 5000 - endif 5001 - keepj put ='get '.netrw_fname.' '.tmpfile 5002 - keepj put ='quit' 5003 - 5004 - " perform cadaver operation: 5005 - keepj norm! 1Gdd 5006 -" call Decho("executing: %!".g:netrw_dav_cmd) 5007 - exe s:netrw_silentxfer."%!".g:netrw_dav_cmd 5008 - bd! 5009 - endif 5010 - let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) 5011 - let b:netrw_lastfile = choice 5012 - 5013 - "......................................... 5014 - " NetRead: (rsync) NetRead Method #7 {{{3 5015 - elseif b:netrw_method == 7 5016 -" call Decho("read via rsync (method #7)") 5017 -" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_rsync_cmd." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1)) 5018 - exe s:netrw_silentxfer."!".g:netrw_rsync_cmd." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1) 5019 - let result = s:NetrwGetFile(readcmd,tmpfile, b:netrw_method) 5020 - let b:netrw_lastfile = choice 5021 - 5022 - "......................................... 5023 - " NetRead: (fetch) NetRead Method #8 {{{3 5024 - " fetch://[user@]host[:http]/path 5025 - elseif b:netrw_method == 8 5026 -" call Decho("read via fetch (method #8)") 5027 - if g:netrw_fetch_cmd == "" 5028 - if !exists("g:netrw_quiet") 5029 - keepj call netrw#ErrorMsg(s:ERROR,"fetch command not available",7) 5030 - endif 5031 -" call Dret("NetRead") 5032 - return 5033 - endif 5034 - if exists("g:netrw_option") && g:netrw_option == ":https\=" 5035 - let netrw_option= "http" 5036 - else 5037 - let netrw_option= "ftp" 5038 - endif 5039 -" call Decho("read via fetch for ".netrw_option) 5040 - 5041 - if exists("g:netrw_uid") && g:netrw_uid != "" && exists("s:netrw_passwd") && s:netrw_passwd != "" 5042 -" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_fetch_cmd." ".shellescape(tmpfile,1)." ".shellescape(netrw_option."://".g:netrw_uid.':'.s:netrw_passwd.'@'.g:netrw_machine."/".b:netrw_fname,1)) 5043 - exe s:netrw_silentxfer."!".g:netrw_fetch_cmd." ".shellescape(tmpfile,1)." ".shellescape(netrw_option."://".g:netrw_uid.':'.s:netrw_passwd.'@'.g:netrw_machine."/".b:netrw_fname,1) 5044 - else 5045 -" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_fetch_cmd." ".shellescape(tmpfile,1)." ".shellescape(netrw_option."://".g:netrw_machine."/".b:netrw_fname,1)) 5046 - exe s:netrw_silentxfer."!".g:netrw_fetch_cmd." ".shellescape(tmpfile,1)." ".shellescape(netrw_option."://".g:netrw_machine."/".b:netrw_fname,1) 5047 - endif 5048 - 5049 - let result = s:NetrwGetFile(readcmd,tmpfile, b:netrw_method) 5050 - let b:netrw_lastfile = choice 5051 -" call Decho("(NetRead) setl ro") 5052 - setl ro 4928 + 5053 4929 +" call Decho("fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist")." bh=".&l:bh) 5054 4930 +" call Decho("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) 5055 4931 +" call Dret("s:NetrwSafeOptions") 5056 4932 +endfun 5057 5058 - "......................................... 5059 - " NetRead: (sftp) NetRead Method #9 {{{3 5060 - elseif b:netrw_method == 9 5061 -" call Decho("read via sftp (method #9)") 5062 -" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_sftp_cmd." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".tmpfile) 5063 - exe s:netrw_silentxfer."!".g:netrw_sftp_cmd." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".tmpfile 5064 - let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) 5065 - let b:netrw_lastfile = choice 4933 + 5066 4934 +" --------------------------------------------------------------------- 5067 4935 +" NetrwStatusLine: {{{2 5068 4936 +fun! NetrwStatusLine() 5069 5070 - "......................................... 5071 - " NetRead: Complain {{{3 5072 - else 5073 - call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . choice . ">",8) 5074 - endif 5075 - endwhile 4937 + 5076 4938 +" vvv NetrwStatusLine() debugging vvv 5077 4939 +" let g:stlmsg="" … … 5090 4952 +" endif 5091 4953 +" ^^^ NetrwStatusLine() debugging ^^^ 5092 5093 - " NetRead: cleanup {{{3 5094 - if exists("b:netrw_method") 5095 -" call Decho("cleanup b:netrw_method and b:netrw_fname") 5096 - unlet b:netrw_method 5097 - unlet b:netrw_fname 5098 - endif 5099 - if s:FileReadable(tmpfile) && tmpfile !~ '.tar.bz2$' && tmpfile !~ '.tar.gz$' && tmpfile !~ '.zip' && tmpfile !~ '.tar' && readcmd != 't' && tmpfile !~ '.tar.xz$' && tmpfile !~ '.txz' 5100 -" call Decho("cleanup by deleting tmpfile<".tmpfile.">") 5101 - keepj call s:NetrwDelete(tmpfile) 4954 + 5102 4955 + if !exists("w:netrw_explore_bufnr") || w:netrw_explore_bufnr != bufnr("%") || !exists("w:netrw_explore_line") || w:netrw_explore_line != line(".") || !exists("w:netrw_explore_list") 5103 4956 + " restore user's status line … … 5109 4962 + else 5110 4963 + return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen 5111 endif 5112 - keepj call s:NetrwOptionRestore("w:") 5113 - 5114 -" call Dret("netrw#NetRead :5 getcwd<".getcwd().">") 5115 endfun 5116 4964 + endif 4965 +endfun 4966 + 5117 4967 +" --------------------------------------------------------------------- 5118 4968 +" Netrw Transfer Functions: {{{1 5119 4969 +" =============================== 5120 4970 + 5121 " ------------------------------------------------------------------------ 5122 -" netrw#NetWrite: responsible for writing a file over the net {{{2 5123 -fun! netrw#NetWrite(...) range 5124 -" call Dfunc("netrw#NetWrite(a:0=".a:0.") ".g:loaded_netrw) 4971 +" ------------------------------------------------------------------------ 5125 4972 +" netrw#NetRead: responsible for reading a file over the net {{{2 5126 4973 +" mode: =0 read remote file and insert before current line … … 5130 4977 +fun! netrw#NetRead(mode,...) 5131 4978 +" call Dfunc("netrw#NetRead(mode=".a:mode.",...) a:0=".a:0." ".g:loaded_netrw.((a:0 > 0)? " a:1<".a:1.">" : "")) 5132 5133 - " NetWrite: option handling {{{3 5134 - let mod= 0 4979 + 5135 4980 + " NetRead: save options {{{3 5136 5137 4981 + call s:NetrwOptionSave("w:") 4982 + call s:NetrwSafeOptions() 5138 4983 + call s:RestoreCursorline() 5139 5140 - " NetWrite: Get Temporary Filename {{{3 5141 - let tmpfile= s:GetTempfile("") 5142 - if tmpfile == "" 5143 -" call Dret("netrw#NetWrite : unable to get a tempfile!") 5144 - return 5145 - endif 5146 - 5147 - if a:0 == 0 5148 - let ichoice = 0 5149 - else 5150 - let ichoice = 1 5151 - endif 5152 - 5153 - let curbufname= expand("%") 5154 -" call Decho("curbufname<".curbufname.">") 5155 - if &binary 5156 - " For binary writes, always write entire file. 5157 - " (line numbers don't really make sense for that). 5158 - " Also supports the writing of tar and zip files. 5159 -" call Decho("(write entire file) sil exe w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile)) 5160 - exe "sil keepj w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile) 5161 - elseif g:netrw_cygwin 5162 - " write (selected portion of) file to temporary 5163 - let cygtmpfile= substitute(tmpfile,'/cygdrive/\(.\)','\1:','') 5164 -" call Decho("(write selected portion) sil exe ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(cygtmpfile)) 5165 - exe "sil keepj ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(cygtmpfile) 4984 + 5166 4985 + " NetRead: interpret mode into a readcmd {{{3 5167 4986 + if a:mode == 0 " read remote file before current line … … 5173 4992 + elseif a:mode == 3 " skip read of file (leave as temporary) 5174 4993 + let readcmd = "t" 5175 else 5176 - " write (selected portion of) file to temporary 5177 -" call Decho("(write selected portion) sil exe ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile)) 5178 - exe "sil keepj ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile) 4994 + else 5179 4995 + exe a:mode 5180 4996 + let readcmd = "r" 5181 4997 + endif 5182 4998 + let ichoice = (a:0 == 0)? 0 : 1 5183 4999 +" call Decho("readcmd<".readcmd."> ichoice=".ichoice) 5184 5185 - if curbufname == "" 5186 - " if the file is [No Name], and one attempts to Nwrite it, the buffer takes 5187 - " on the temporary file's name. Deletion of the temporary file during 5188 - " cleanup then causes an error message. 5189 - 0file! 5000 + 5190 5001 + " NetRead: get temporary filename {{{3 5191 5002 + let tmpfile= s:GetTempfile("") … … 5193 5004 +" call Dret("netrw#NetRead : unable to get a tempfile!") 5194 5005 + return 5195 endif 5196 5197 - " NetWrite: while choice loop: {{{3 5198 while ichoice <= a:0 5199 5200 - " Process arguments: {{{4 5201 " attempt to repeat with previous host-file-etc 5202 if exists("b:netrw_lastfile") && a:0 == 0 5203 " call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">") 5204 let choice = b:netrw_lastfile 5205 let ichoice= ichoice + 1 5206 + 5207 else 5208 exe "let choice= a:" . ichoice 5006 + endif 5007 + 5008 + while ichoice <= a:0 5009 + 5010 + " attempt to repeat with previous host-file-etc 5011 + if exists("b:netrw_lastfile") && a:0 == 0 5012 +" call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">") 5013 + let choice = b:netrw_lastfile 5014 + let ichoice= ichoice + 1 5015 + 5016 + else 5017 + exe "let choice= a:" . ichoice 5209 5018 +" call Decho("no lastfile: choice<" . choice . ">") 5210 5211 - " Reconstruct Choice if choice starts with '"' 5212 if match(choice,"?") == 0 5213 - echomsg 'NetWrite Usage:"' 5214 - echomsg ':Nwrite machine:path uses rcp' 5215 - echomsg ':Nwrite "machine path" uses ftp with <.netrc>' 5216 - echomsg ':Nwrite "machine id password path" uses ftp' 5217 - echomsg ':Nwrite dav://[user@]machine/path uses cadaver' 5218 - echomsg ':Nwrite fetch://[user@]machine/path uses fetch' 5219 - echomsg ':Nwrite ftp://machine[#port]/path uses ftp (autodetects <.netrc>)' 5220 - echomsg ':Nwrite rcp://machine/path uses rcp' 5221 - echomsg ':Nwrite rsync://[user@]machine/path uses rsync' 5222 - echomsg ':Nwrite scp://[user@]machine[[:#]port]/path uses scp' 5223 - echomsg ':Nwrite sftp://[user@]machine/path uses sftp' 5224 - sleep 4 5225 - break 5226 - 5227 - elseif match(choice,"^\"") != -1 5228 - if match(choice,"\"$") != -1 5229 - " case "..." 5230 - let choice=strpart(choice,1,strlen(choice)-2) 5231 - else 5232 - " case "... ... ..." 5233 - let choice = strpart(choice,1,strlen(choice)-1) 5234 - let wholechoice = "" 5019 + 5020 + if match(choice,"?") == 0 5235 5021 + " give help 5236 5022 + echomsg 'NetRead Usage:' … … 5245 5031 + echomsg ':Nread rcp://[user@]machine/path uses rcp' 5246 5032 + echomsg ':Nread rsync://machine[:port]/path uses rsync' 5247 +echomsg ':Nread scp://[user@]machine[[:#]port]/path uses scp'5248 +echomsg ':Nread sftp://[user@]machine[[:#]port]/path uses sftp'5249 +sleep 45250 + break 5251 5252 - while match(choice,"\"$") == -1 5253 - let wholechoice= wholechoice . " " . choice 5254 - let ichoice = ichoice + 15255 - if choice > a:0 5256 + elseif match(choice,'^"') != -1 5257 + " Reconstruct Choice if choice starts with '"'5258 +" call Decho("reconstructing choice")5259 + if match(choice,'"$') != -1 5260 + " case "..." 5261 + let choice= strpart(choice,1,strlen(choice)-2) 5262 + else5263 + " case "... ... ..." 5264 + let choice = strpart(choice,1,strlen(choice)-1)5265 + let wholechoice = "" 5266 + 5267 + while match(choice,'"$') == -1 5268 + let wholechoice = wholechoice . " " . choice 5269 + let ichoice = ichoice + 1 5270 + if ichoice > a:0 5271 if !exists("g:netrw_quiet")5272 - call netrw#ErrorMsg(s:ERROR,"Unbalanced string in filename '". wholechoice ."'",13)5273 + call netrw#ErrorMsg(s:ERROR,"Unbalanced string in filename '". wholechoice ."'",3)5274 endif 5275 -" call Dret("netrw#NetWrite")5276 +" call Dret("netrw#NetRead :2 getcwd<".getcwd().">") 5277 return 5278 endif 5279 let choice= a:{ichoice} 5280 @@ -2047,105 +1765,110 @@ 5033 echomsg ':Nread scp://[user@]machine[[:#]port]/path uses scp' 5034 echomsg ':Nread sftp://[user@]machine[[:#]port]/path uses sftp' 5035 sleep 4 5036 @@ -1637,7 +1837,7 @@ 5037 endif 5038 let tmpfile= s:GetTempfile(b:netrw_fname) " apply correct suffix 5039 5040 - " Check if NetrwBrowse() should be handling this request 5041 + " Check whether or not NetrwBrowse() should be handling this request 5042 " call Decho("checking if NetrwBrowse() should handle choice<".choice."> with netrw_list_cmd<".g:netrw_list_cmd.">") 5043 if choice =~ "^.*[\/]$" && b:netrw_method != 5 && choice !~ '^https\=://' 5044 " call Decho("yes, choice matches '^.*[\/]$'") 5045 @@ -1659,7 +1859,7 @@ 5046 " call Decho("read via rcp (method #1)") 5047 " ER: nothing done with g:netrw_uid yet? 5048 " ER: on Win2K" rcp machine[.user]:file tmpfile 5049 - " ER: if machine contains '.' adding .user is required (use $USERNAME) 5050 + " ER: when machine contains '.' adding .user is required (use $USERNAME) 5051 " ER: the tmpfile is full path: rcp sees C:\... as host C 5052 if s:netrw_has_nt_rcp == 1 5053 if exists("g:netrw_uid") && ( g:netrw_uid != "" ) 5054 @@ -1810,11 +2010,11 @@ 5055 " using g:netrw_http_cmd (usually elinks, links, curl, wget, or fetch) 5056 " call Decho('using '.g:netrw_http_cmd.' (# not in b:netrw_fname<'.b:netrw_fname.">)") 5057 if exists("g:netrw_http_xcmd") 5058 -" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape("http://".g:netrw_machine.b:netrw_fname,1)." ".g:netrw_http_xcmd." ".shellescape(tmpfile,1)) 5059 - exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape("http://".g:netrw_machine.b:netrw_fname,1)." ".g:netrw_http_xcmd." ".shellescape(tmpfile,1) 5060 +" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(b:netrw_http."://".g:netrw_machine.b:netrw_fname,1)." ".g:netrw_http_xcmd." ".shellescape(tmpfile,1)) 5061 + exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(b:netrw_http."://".g:netrw_machine.b:netrw_fname,1)." ".g:netrw_http_xcmd." ".shellescape(tmpfile,1) 5062 else 5063 -" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("http://".g:netrw_machine.b:netrw_fname,1)) 5064 - exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("http://".g:netrw_machine.b:netrw_fname,1) 5065 +" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape(b:netrw_http."://".g:netrw_machine.b:netrw_fname,1)) 5066 + exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape(b:netrw_http."://".g:netrw_machine.b:netrw_fname,1) 5281 5067 endif 5068 let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) 5069 5070 @@ -1825,15 +2025,15 @@ 5071 let netrw_tag = substitute(b:netrw_fname,"^.*#","","") 5072 " call Decho("netrw_html<".netrw_html.">") 5073 " call Decho("netrw_tag <".netrw_tag.">") 5074 -" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("http://".g:netrw_machine.netrw_html,1)) 5075 - exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("http://".g:netrw_machine.netrw_html,1) 5076 +" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape(b:netrw_http."://".g:netrw_machine.netrw_html,1)) 5077 + exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape(b:netrw_http."://".g:netrw_machine.netrw_html,1) 5078 let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) 5079 " call Decho('<\s*a\s*name=\s*"'.netrw_tag.'"/') 5080 exe 'keepj norm! 1G/<\s*a\s*name=\s*"'.netrw_tag.'"/'."\<CR>" 5282 5081 endif 5283 endif 5284 + 5285 +" call Decho("choice<" . choice . ">") 5286 let ichoice= ichoice + 1 5287 -" call Decho("choice<" . choice . "> ichoice=".ichoice) 5288 5289 - " Determine method of write (ftp, rcp, etc) {{{4 5290 - keepj call s:NetrwMethod(choice) 5291 + " NetRead: Determine method of read (ftp, rcp, etc) {{{3 5292 + call s:NetrwMethod(choice) 5293 if !exists("b:netrw_method") || b:netrw_method < 0 5294 -" call Dfunc("netrw#NetWrite : unsupported method") 5295 +" call Dfunc("netrw#NetRead : unsupported method") 5296 + return 5297 + endif 5298 + let tmpfile= s:GetTempfile(b:netrw_fname) " apply correct suffix 5299 + 5300 + " Check whether or not NetrwBrowse() should be handling this request 5301 +" call Decho("checking if NetrwBrowse() should handle choice<".choice."> with netrw_list_cmd<".g:netrw_list_cmd.">") 5302 + if choice =~ "^.*[\/]$" && b:netrw_method != 5 && choice !~ '^https\=://' 5303 +" call Decho("yes, choice matches '^.*[\/]$'") 5304 + keepj call s:NetrwBrowse(0,choice) 5305 +" call Dret("netrw#NetRead :3 getcwd<".getcwd().">") 5306 return 5307 endif 5308 5309 - " ============= 5310 - " NetWrite: Perform Protocol-Based Write {{{3 5311 - " ============================ 5312 + " ============ 5313 + " NetRead: Perform Protocol-Based Read {{{3 5314 + " =========================== 5315 if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1 5316 - echo "(netrw) Processing your write request..." 5317 -" call Decho("(netrw) Processing your write request...") 5318 + echo "(netrw) Processing your read request..." 5319 endif 5082 let b:netrw_lastfile = choice 5083 -" call Decho("(NetRead) setl ro") 5084 - setl ro 5085 +" call Decho("setl ro") 5086 + setl ro nomod 5320 5087 5321 5088 "......................................... 5322 - " NetWrite: (rcp) NetWrite Method #1 {{{3 5323 - if b:netrw_method == 1 5324 -" call Decho("write via rcp (method #1)") 5325 - if s:netrw_has_nt_rcp == 1 5326 - if exists("g:netrw_uid") && ( g:netrw_uid != "" ) 5327 - let uid_machine = g:netrw_machine .'.'. g:netrw_uid 5328 - else 5329 - let uid_machine = g:netrw_machine .'.'. $USERNAME 5330 - endif 5331 + " NetRead: (rcp) NetRead Method #1 {{{3 5332 + if b:netrw_method == 1 " read with rcp 5333 +" call Decho("read via rcp (method #1)") 5334 + " ER: nothing done with g:netrw_uid yet? 5335 + " ER: on Win2K" rcp machine[.user]:file tmpfile 5336 + " ER: when machine contains '.' adding .user is required (use $USERNAME) 5337 + " ER: the tmpfile is full path: rcp sees C:\... as host C 5338 + if s:netrw_has_nt_rcp == 1 5339 + if exists("g:netrw_uid") && ( g:netrw_uid != "" ) 5340 + let uid_machine = g:netrw_machine .'.'. g:netrw_uid 5089 " NetRead: (dav) NetRead Method #6 {{{3 5090 @@ -1894,7 +2094,7 @@ 5091 " call Dret("NetRead") 5092 return 5093 endif 5094 - if exists("g:netrw_option") && g:netrw_option == ":https\=" 5095 + if exists("g:netrw_option") && g:netrw_option =~ ":https\=" 5096 let netrw_option= "http" 5341 5097 else 5342 - if exists("g:netrw_uid") && ( g:netrw_uid != "" ) 5343 - let uid_machine = g:netrw_uid .'@'. g:netrw_machine 5344 - else 5345 - let uid_machine = g:netrw_machine 5346 - endif 5347 - endif 5348 -" call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".shellescape(tmpfile,1)." ".shellescape(uid_machine.":".b:netrw_fname,1)) 5349 - exe s:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".shellescape(tmpfile,1)." ".shellescape(uid_machine.":".b:netrw_fname,1) 5350 - let b:netrw_lastfile = choice 5351 - 5352 - "......................................... 5353 - " NetWrite: (ftp + <.netrc>) NetWrite Method #2 {{{3 5354 - elseif b:netrw_method == 2 5355 -" call Decho("write via ftp+.netrc (method #2)") 5356 - let netrw_fname = b:netrw_fname 5357 - 5358 - " formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead 5359 - let bhkeep = &l:bh 5360 - let curbuf = bufnr("%") 5361 - setl bh=hide 5362 - keepalt enew 5363 - 5364 -" call Decho("filter input window#".winnr()) 5365 - setl ff=unix 5366 - keepj put =g:netrw_ftpmode 5367 -" call Decho("filter input: ".getline('$')) 5368 - if exists("g:netrw_ftpextracmd") 5369 - keepj put =g:netrw_ftpextracmd 5370 -" call Decho("filter input: ".getline("$")) 5371 + " Any way needed it machine contains a '.' 5372 + let uid_machine = g:netrw_machine .'.'. $USERNAME 5373 endif 5374 - keepj call setline(line("$")+1,'put "'.tmpfile.'" "'.netrw_fname.'"') 5375 -" call Decho("filter input: ".getline("$")) 5376 - if exists("g:netrw_port") && g:netrw_port != "" 5377 -" call Decho("executing: %!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1)) 5378 - exe s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1) 5379 + else 5380 + if exists("g:netrw_uid") && ( g:netrw_uid != "" ) 5381 + let uid_machine = g:netrw_uid .'@'. g:netrw_machine 5382 else 5383 -" call Decho("filter input window#".winnr()) 5384 -" call Decho("executing: %!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)) 5385 - exe s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1) 5386 - endif 5387 - " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) 5388 - if getline(1) !~ "^$" 5389 - if !exists("g:netrw_quiet") 5390 - keepj call netrw#ErrorMsg(s:ERROR,getline(1),14) 5391 - endif 5392 - let mod=1 5393 + let uid_machine = g:netrw_machine 5394 endif 5395 + endif 5396 +" call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".shellescape(uid_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1)) 5397 + exe s:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".shellescape(uid_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1) 5398 + let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) 5399 + let b:netrw_lastfile = choice 5400 5401 - " remove enew buffer (quietly) 5402 - let filtbuf= bufnr("%") 5403 - exe curbuf."b!" 5404 - let &l:bh = bhkeep 5405 - exe filtbuf."bw!" 5406 - 5407 - let b:netrw_lastfile = choice 5408 + "......................................... 5409 + " NetRead: (ftp + <.netrc>) NetRead Method #2 {{{3 5410 + elseif b:netrw_method == 2 " read with ftp + <.netrc> 5411 +" call Decho("read via ftp+.netrc (method #2)") 5412 + let netrw_fname= b:netrw_fname 5413 + keepj call s:SaveBufVars()|new|keepj call s:RestoreBufVars() 5414 + let filtbuf= bufnr("%") 5415 + setl ff=unix 5416 + keepj put =g:netrw_ftpmode 5417 +" call Decho("filter input: ".getline(line("$"))) 5418 + if exists("g:netrw_ftpextracmd") 5419 + keepj put =g:netrw_ftpextracmd 5420 +" call Decho("filter input: ".getline(line("$"))) 5421 + endif 5422 + call setline(line("$")+1,'get "'.netrw_fname.'" '.tmpfile) 5423 +" call Decho("filter input: ".getline(line("$"))) 5424 + if exists("g:netrw_port") && g:netrw_port != "" 5425 +" call Decho("executing: %!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1)) 5426 + exe s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1) 5427 + else 5428 +" call Decho("executing: %!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)) 5429 + exe s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1) 5430 + endif 5431 + " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) 5432 + if getline(1) !~ "^$" && !exists("g:netrw_quiet") && getline(1) !~ '^Trying ' 5433 + let debugkeep = &debug 5434 + setl debug=msg 5435 + keepj call netrw#ErrorMsg(s:ERROR,getline(1),4) 5436 + let &debug = debugkeep 5437 + endif 5438 + call s:SaveBufVars() 5439 + bd! 5440 + if bufname("%") == "" && getline("$") == "" && line('$') == 1 5441 + " needed when one sources a file in a nolbl setting window via ftp 5442 + q! 5443 + endif 5444 + call s:RestoreBufVars() 5445 + let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) 5446 + let b:netrw_lastfile = choice 5098 let netrw_option= "ftp" 5099 @@ -1911,8 +2111,8 @@ 5100 5101 let result = s:NetrwGetFile(readcmd,tmpfile, b:netrw_method) 5102 let b:netrw_lastfile = choice 5103 -" call Decho("(NetRead) setl ro") 5104 - setl ro 5105 +" call Decho("setl ro") 5106 + setl ro nomod 5447 5107 5448 5108 "......................................... 5449 - " NetWrite: (ftp + machine, id, passwd, filename) NetWrite Method #3 {{{3 5450 - elseif b:netrw_method == 3 5451 - " Construct execution string (three or more lines) which will be passed through filter 5452 + " NetRead: (ftp + machine,id,passwd,filename) NetRead Method #3 {{{3 5453 + elseif b:netrw_method == 3 " read with ftp + machine, id, passwd, and fname 5454 + " Construct execution string (four lines) which will be passed through filter 5455 " call Decho("read via ftp+mipf (method #3)") 5456 - let netrw_fname = b:netrw_fname 5457 - let bhkeep = &l:bh 5458 - 5459 - " formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead 5460 - let curbuf = bufnr("%") 5461 - setl bh=hide 5462 - keepalt enew 5463 + let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape) 5464 + keepj call s:SaveBufVars()|new|keepj call s:RestoreBufVars() 5465 + let filtbuf= bufnr("%") 5466 setl ff=unix 5467 - 5468 if exists("g:netrw_port") && g:netrw_port != "" 5469 keepj put ='open '.g:netrw_machine.' '.g:netrw_port 5470 " call Decho("filter input: ".getline('.')) 5471 @@ -2153,29 +1876,31 @@ 5472 keepj put ='open '.g:netrw_machine 5473 " call Decho("filter input: ".getline('.')) 5474 endif 5475 + 5476 if exists("g:netrw_uid") && g:netrw_uid != "" 5477 if exists("g:netrw_ftp") && g:netrw_ftp == 1 5478 keepj put =g:netrw_uid 5479 -" call Decho("filter input: ".getline('.')) 5480 - if exists("s:netrw_passwd") && s:netrw_passwd != "" 5481 +" call Decho("filter input: ".getline('.')) 5482 + if exists("s:netrw_passwd") 5483 keepj put ='\"'.s:netrw_passwd.'\"' 5484 endif 5485 " call Decho("filter input: ".getline('.')) 5486 - elseif exists("s:netrw_passwd") && s:netrw_passwd != "" 5487 + elseif exists("s:netrw_passwd") 5488 keepj put ='user \"'.g:netrw_uid.'\" \"'.s:netrw_passwd.'\"' 5489 " call Decho("filter input: ".getline('.')) 5490 endif 5491 endif 5492 - keepj put =g:netrw_ftpmode 5493 -" call Decho("filter input: ".getline('$')) 5494 + 5495 + if exists("g:netrw_ftpmode") && g:netrw_ftpmode != "" 5496 + keepj put =g:netrw_ftpmode 5497 +" call Decho("filter input: ".getline('.')) 5498 + endif 5499 if exists("g:netrw_ftpextracmd") 5500 keepj put =g:netrw_ftpextracmd 5501 -" call Decho("filter input: ".getline("$")) 5502 +" call Decho("filter input: ".getline('.')) 5503 endif 5504 - keepj put ='put \"'.tmpfile.'\" \"'.netrw_fname.'\"' 5505 + keepj put ='get \"'.netrw_fname.'\" '.tmpfile 5506 " call Decho("filter input: ".getline('.')) 5507 - " save choice/id/password for future use 5508 - let b:netrw_lastfile = choice 5509 5510 " perform ftp: 5511 " -i : turns off interactive prompting from ftp 5512 @@ -2186,3113 +1911,3829 @@ 5513 exe s:netrw_silentxfer."%!".s:netrw_ftp_cmd." ".g:netrw_ftp_options 5514 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) 5515 if getline(1) !~ "^$" 5516 - if !exists("g:netrw_quiet") 5517 - call netrw#ErrorMsg(s:ERROR,getline(1),15) 5518 +" call Decho("error<".getline(1).">") 5519 + if !exists("g:netrw_quiet") 5520 + call netrw#ErrorMsg(s:ERROR,getline(1),5) 5521 endif 5522 - let mod=1 5523 endif 5524 - 5525 - " remove enew buffer (quietly) 5526 - let filtbuf= bufnr("%") 5527 - exe curbuf."b!" 5528 - let &l:bh= bhkeep 5529 - exe filtbuf."bw!" 5530 + call s:SaveBufVars()|bd!|call s:RestoreBufVars() 5531 + let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) 5532 + let b:netrw_lastfile = choice 5533 5534 "......................................... 5535 - " NetWrite: (scp) NetWrite Method #4 {{{3 5536 - elseif b:netrw_method == 4 5537 -" call Decho("write via scp (method #4)") 5538 + " NetRead: (scp) NetRead Method #4 {{{3 5539 + elseif b:netrw_method == 4 " read with scp 5540 +" call Decho("read via scp (method #4)") 5541 if exists("g:netrw_port") && g:netrw_port != "" 5542 - let useport= " ".g:netrw_scpport." ".fnameescape(g:netrw_port) 5543 + let useport= " ".g:netrw_scpport." ".g:netrw_port 5544 else 5545 let useport= "" 5546 endif 5547 -" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".shellescape(tmpfile,1)." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)) 5548 - exe s:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".shellescape(tmpfile,1)." ".shellescape(g:netrw_machine.":".b:netrw_fname,1) 5549 +" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1)) 5550 + exe s:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1) 5551 + let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) 5552 let b:netrw_lastfile = choice 5553 5554 "......................................... 5555 - " NetWrite: (http) NetWrite Method #5 {{{3 5556 - elseif b:netrw_method == 5 5557 -" call Decho("write via http (method #5)") 5109 " NetRead: (sftp) NetRead Method #9 {{{3 5110 @@ -1978,7 +2178,7 @@ 5111 exe "sil keepj w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile) 5112 elseif g:netrw_cygwin 5113 " write (selected portion of) file to temporary 5114 - let cygtmpfile= substitute(tmpfile,'/cygdrive/\(.\)','\1:','') 5115 + let cygtmpfile= substitute(tmpfile,g:netrw_cygdrive.'/\(.\)','\1:','') 5116 " call Decho("(write selected portion) sil exe ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(cygtmpfile)) 5117 exe "sil keepj ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(cygtmpfile) 5118 else 5119 @@ -1988,7 +2188,7 @@ 5120 endif 5121 5122 if curbufname == "" 5123 - " if the file is [No Name], and one attempts to Nwrite it, the buffer takes 5124 + " when the file is [No Name], and one attempts to Nwrite it, the buffer takes 5125 " on the temporary file's name. Deletion of the temporary file during 5126 " cleanup then causes an error message. 5127 0file! 5128 @@ -2006,7 +2206,7 @@ 5129 else 5130 exe "let choice= a:" . ichoice 5131 5132 - " Reconstruct Choice if choice starts with '"' 5133 + " Reconstruct Choice when choice starts with '"' 5134 if match(choice,"?") == 0 5135 echomsg 'NetWrite Usage:"' 5136 echomsg ':Nwrite machine:path uses rcp' 5137 @@ -2215,8 +2415,13 @@ 5138 " NetWrite: (http) NetWrite Method #5 {{{3 5139 elseif b:netrw_method == 5 5140 " call Decho("write via http (method #5)") 5558 5141 - if !exists("g:netrw_quiet") 5559 5142 - call netrw#ErrorMsg(s:ERROR,"currently <netrw.vim> does not support writing using http:",16) 5560 - endif5561 -5562 - ".........................................5563 - " NetWrite: (dav) NetWrite Method #6 (cadaver) {{{35564 - elseif b:netrw_method == 65565 -" call Decho("write via cadaver (method #6)")5566 -5567 - " Construct execution string (four lines) which will be passed through filter5568 - let netrw_fname = escape(b:netrw_fname,g:netrw_fname_escape)5569 - let bhkeep = &l:bh5570 + " NetRead: (http) NetRead Method #5 (wget) {{{35571 + elseif b:netrw_method == 55572 +" call Decho("read via http (method #5)")5573 + if g:netrw_http_cmd == ""5574 + if !exists("g:netrw_quiet")5575 + call netrw#ErrorMsg(s:ERROR,"neither the wget nor the fetch command is available",6)5576 + endif5577 +" call Dret("netrw#NetRead :4 getcwd<".getcwd().">")5578 + return5579 + endif5580 5581 - " formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead5582 - let curbuf = bufnr("%")5583 - setl bh=hide5584 - keepalt enew5585 + if match(b:netrw_fname,"#") == -1 || exists("g:netrw_http_xcmd")5586 + " using g:netrw_http_cmd (usually elinks, links, curl, wget, or fetch)5587 +" call Decho('using '.g:netrw_http_cmd.' (# not in b:netrw_fname<'.b:netrw_fname.">)")5588 + if exists("g:netrw_http_xcmd")5589 +" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(b:netrw_http."://".g:netrw_machine.b:netrw_fname,1)." ".g:netrw_http_xcmd." ".shellescape(tmpfile,1))5590 + exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(b:netrw_http."://".g:netrw_machine.b:netrw_fname,1)." ".g:netrw_http_xcmd." ".shellescape(tmpfile,1)5591 + else5592 +" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape(b:netrw_http."://".g:netrw_machine.b:netrw_fname,1))5593 + exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape(b:netrw_http."://".g:netrw_machine.b:netrw_fname,1)5594 + endif5595 + let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)5596 5597 - setl ff=unix5598 - if exists("g:netrw_port") && g:netrw_port != ""5599 - keepj put ='open '.g:netrw_machine.' '.g:netrw_port5600 else5601 - keepj put ='open '.g:netrw_machine5602 - endif5603 - if exists("g:netrw_uid") && exists("s:netrw_passwd") && g:netrw_uid != ""5604 - keepj put ='user '.g:netrw_uid.' '.s:netrw_passwd5605 + " wget/curl/fetch plus a jump to an in-page marker (ie. http://abc/def.html#aMarker)5606 +" call Decho("wget/curl plus jump (# in b:netrw_fname<".b:netrw_fname.">)")5607 + let netrw_html= substitute(b:netrw_fname,"#.*$","","")5608 + let netrw_tag = substitute(b:netrw_fname,"^.*#","","")5609 +" call Decho("netrw_html<".netrw_html.">")5610 +" call Decho("netrw_tag <".netrw_tag.">")5611 +" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape(b:netrw_http."://".g:netrw_machine.netrw_html,1))5612 + exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape(b:netrw_http."://".g:netrw_machine.netrw_html,1)5613 + let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)5614 +" call Decho('<\s*a\s*name=\s*"'.netrw_tag.'"/')5615 + exe 'keepj norm! 1G/<\s*a\s*name=\s*"'.netrw_tag.'"/'."\<CR>"5616 endif5617 - keepj put ='put '.tmpfile.' '.netrw_fname5618 + let b:netrw_lastfile = choice5619 +" call Decho("setl ro")5620 + setl ro5621 5622 - " perform cadaver operation:5623 - keepj norm! 1Gdd5624 -" call Decho("executing: %!".g:netrw_dav_cmd)5625 - exe s:netrw_silentxfer."%!".g:netrw_dav_cmd5626 + ".........................................5627 + " NetRead: (dav) NetRead Method #6 {{{35628 + elseif b:netrw_method == 65629 +" call Decho("read via cadaver (method #6)")5630 5631 - " remove enew buffer (quietly)5632 - let filtbuf= bufnr("%")5633 - exe curbuf."b!"5634 - let &l:bh = bhkeep5635 - exe filtbuf."bw!"5636 + if !executable(g:netrw_dav_cmd)5637 + call netrw#ErrorMsg(s:ERROR,g:netrw_dav_cmd." is not executable",73)5638 +" call Dret("netrw#NetRead : ".g:netrw_dav_cmd." not executable")5639 + return5640 + endif5641 + if g:netrw_dav_cmd =~ "curl"5642 +" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_dav_cmd." ".shellescape("dav://".g:netrw_machine.b:netrw_fname,1)." ".shellescape(tmpfile,1))5643 + exe s:netrw_silentxfer."!".g:netrw_dav_cmd." ".shellescape("dav://".g:netrw_machine.b:netrw_fname,1)." ".shellescape(tmpfile,1)5644 + else5645 + " Construct execution string (four lines) which will be passed through filter5646 + let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)5647 + new5648 + setl ff=unix5649 + if exists("g:netrw_port") && g:netrw_port != ""5650 + keepj put ='open '.g:netrw_machine.' '.g:netrw_port5651 + else5652 + keepj put ='open '.g:netrw_machine5653 + endif5654 + if exists("g:netrw_uid") && exists("s:netrw_passwd") && g:netrw_uid != ""5655 + keepj put ='user '.g:netrw_uid.' '.s:netrw_passwd5656 + endif5657 + keepj put ='get '.netrw_fname.' '.tmpfile5658 + keepj put ='quit'5659 5660 + " perform cadaver operation:5661 + keepj norm! 1Gdd5662 +" call Decho("executing: %!".g:netrw_dav_cmd)5663 + exe s:netrw_silentxfer."%!".g:netrw_dav_cmd5664 + bd!5665 + endif5666 + let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)5667 let b:netrw_lastfile = choice5668 5669 ".........................................5670 - " NetWrite: (rsync) NetWrite Method #7 {{{35671 - elseif b:netrw_method == 75672 -" call Decho("write via rsync (method #7)")5673 -" call Decho("executing: !".g:netrw_rsync_cmd." ".shellescape(tmpfile,1)." ".shellescape(g:netrw_machine.":".b:netrw_fname,1))5674 - exe s:netrw_silentxfer."!".g:netrw_rsync_cmd." ".shellescape(tmpfile,1)." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)5675 + " NetRead: (rsync) NetRead Method #7 {{{35676 + elseif b:netrw_method == 75677 +" call Decho("read via rsync (method #7)")5678 +" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_rsync_cmd." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1))5679 + exe s:netrw_silentxfer."!".g:netrw_rsync_cmd." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1)5680 + let result = s:NetrwGetFile(readcmd,tmpfile, b:netrw_method)5681 let b:netrw_lastfile = choice5682 5683 ".........................................5684 - " NetWrite: (sftp) NetWrite Method #9 {{{35685 - elseif b:netrw_method == 95686 -" call Decho("write via sftp (method #9)")5687 - let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)5688 - if exists("g:netrw_uid") && ( g:netrw_uid != "" )5689 - let uid_machine = g:netrw_uid .'@'. g:netrw_machine5690 + " NetRead: (fetch) NetRead Method #8 {{{35691 + " fetch://[user@]host[:http]/path5692 + elseif b:netrw_method == 85693 +" call Decho("read via fetch (method #8)")5694 + if g:netrw_fetch_cmd == ""5695 + if !exists("g:netrw_quiet")5696 + keepj call netrw#ErrorMsg(s:ERROR,"fetch command not available",7)5697 + endif5698 +" call Dret("NetRead")5699 + return5700 + endif5701 + if exists("g:netrw_option") && g:netrw_option =~ ":https\="5702 + let netrw_option= "http"5703 else5704 - let uid_machine = g:netrw_machine5705 + let netrw_option= "ftp"5706 endif5707 +" call Decho("read via fetch for ".netrw_option)5708 5709 - " formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead5710 - let bhkeep = &l:bh5711 - let curbuf = bufnr("%")5712 - setl bh=hide5713 - keepalt enew5714 + if exists("g:netrw_uid") && g:netrw_uid != "" && exists("s:netrw_passwd") && s:netrw_passwd != ""5715 +" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_fetch_cmd." ".shellescape(tmpfile,1)." ".shellescape(netrw_option."://".g:netrw_uid.':'.s:netrw_passwd.'@'.g:netrw_machine."/".b:netrw_fname,1))5716 + exe s:netrw_silentxfer."!".g:netrw_fetch_cmd." ".shellescape(tmpfile,1)." ".shellescape(netrw_option."://".g:netrw_uid.':'.s:netrw_passwd.'@'.g:netrw_machine."/".b:netrw_fname,1)5717 + else5718 +" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_fetch_cmd." ".shellescape(tmpfile,1)." ".shellescape(netrw_option."://".g:netrw_machine."/".b:netrw_fname,1))5719 + exe s:netrw_silentxfer."!".g:netrw_fetch_cmd." ".shellescape(tmpfile,1)." ".shellescape(netrw_option."://".g:netrw_machine."/".b:netrw_fname,1)5720 + endif5721 5722 - setl ff=unix5723 - call setline(1,'put "'.escape(tmpfile,'\').'" '.netrw_fname)5724 -" call Decho("filter input: ".getline('.'))5725 -" call Decho("executing: %!".g:netrw_sftp_cmd.' '.shellescape(uid_machine,1))5726 - let sftpcmd= substitute(g:netrw_sftp_cmd,"%TEMPFILE%",escape(tmpfile,'\'),"g")5727 - exe s:netrw_silentxfer."%!".sftpcmd.' '.shellescape(uid_machine,1)5728 - let filtbuf= bufnr("%")5729 - exe curbuf."b!"5730 - let &l:bh = bhkeep5731 - exe filtbuf."bw!"5732 + let result = s:NetrwGetFile(readcmd,tmpfile, b:netrw_method)5733 let b:netrw_lastfile = choice5734 +" call Decho("setl ro")5735 + setl ro5736 5737 ".........................................5738 - " NetWrite: Complain {{{35739 + " NetRead: (sftp) NetRead Method #9 {{{35740 + elseif b:netrw_method == 95741 +" call Decho("read via sftp (method #9)")5742 +" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_sftp_cmd." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".tmpfile)5743 + exe s:netrw_silentxfer."!".g:netrw_sftp_cmd." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".tmpfile5744 + let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)5745 + let b:netrw_lastfile = choice5746 +5747 + ".........................................5748 + " NetRead: Complain {{{35749 else5750 - call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . choice . ">",17)5751 - let leavemod= 15752 + call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . choice . ">",8)5753 endif5754 endwhile5755 5756 - " NetWrite: Cleanup: {{{35757 -" call Decho("cleanup")5758 - if s:FileReadable(tmpfile)5759 -" call Decho("tmpfile<".tmpfile."> readable, will now delete it")5760 - call s:NetrwDelete(tmpfile)5761 + " NetRead: cleanup {{{35762 + if exists("b:netrw_method")5763 +" call Decho("cleanup b:netrw_method and b:netrw_fname")5764 + unlet b:netrw_method5765 + unlet b:netrw_fname5766 endif5767 - call s:NetrwOptionRestore("w:")5768 -5769 - if a:firstline == 1 && a:lastline == line("$")5770 - " restore modifiability; usually equivalent to set nomod5771 - let &mod= mod5772 -" call Decho("(NetWrite) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")5773 - elseif !exists("leavemod")5774 - " indicate that the buffer has not been modified since last written5775 -" call Decho("(NetWrite) set nomod")5776 - set nomod5777 -" call Decho("(NetWrite) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")5778 + if s:FileReadable(tmpfile) && tmpfile !~ '.tar.bz2$' && tmpfile !~ '.tar.gz$' && tmpfile !~ '.zip' && tmpfile !~ '.tar' && readcmd != 't' && tmpfile !~ '.tar.xz$' && tmpfile !~ '.txz'5779 +" call Decho("cleanup by deleting tmpfile<".tmpfile.">")5780 + keepj call s:NetrwDelete(tmpfile)5781 endif5782 + keepj call s:NetrwOptionRestore("w:")5783 5784 -" call Dret("netrw#NetWrite")5785 +" call Dret("netrw#NetRead :5 getcwd<".getcwd().">")5786 endfun5787 5788 -" ---------------------------------------------------------------------5789 -" netrw#NetSource: source a remotely hosted vim script {{{25790 -" uses NetRead to get a copy of the file into a temporarily file,5791 -" then sources that file,5792 -" then removes that file.5793 -fun! netrw#NetSource(...)5794 -" call Dfunc("netrw#NetSource() a:0=".a:0)5795 - if a:0 > 0 && a:1 == '?'5796 - " give help5797 - echomsg 'NetSource Usage:'5798 - echomsg ':Nsource dav://machine[:port]/path uses cadaver'5799 - echomsg ':Nsource fetch://machine/path uses fetch'5800 - echomsg ':Nsource ftp://[user@]machine[:port]/path uses ftp autodetects <.netrc>'5801 - echomsg ':Nsource http[s]://[user@]machine/path uses http wget'5802 - echomsg ':Nsource rcp://[user@]machine/path uses rcp'5803 - echomsg ':Nsource rsync://machine[:port]/path uses rsync'5804 - echomsg ':Nsource scp://[user@]machine[[:#]port]/path uses scp'5805 - echomsg ':Nsource sftp://[user@]machine[[:#]port]/path uses sftp'5806 - sleep 45807 - else5808 - let i= 15809 - while i <= a:05810 - call netrw#NetRead(3,a:{i})5811 -" call Decho("(netrw#NetSource) s:netread_tmpfile<".s:netrw_tmpfile.">")5812 - if s:FileReadable(s:netrw_tmpfile)5813 -" call Decho("(netrw#NetSource) exe so ".fnameescape(s:netrw_tmpfile))5814 - exe "so ".fnameescape(s:netrw_tmpfile)5815 -" call Decho("(netrw#NetSource) delete(".s:netrw_tmpfile.")")5816 - call delete(s:netrw_tmpfile)5817 - unlet s:netrw_tmpfile5818 - else5819 - call netrw#ErrorMsg(s:ERROR,"unable to source <".a:{i}.">!",48)5820 - endif5821 - let i= i + 15822 - endwhile5823 - endif5824 -" call Dret("netrw#NetSource")5825 -endfun5826 +" ------------------------------------------------------------------------5827 +" netrw#NetWrite: responsible for writing a file over the net {{{25828 +fun! netrw#NetWrite(...) range5829 +" call Dfunc("netrw#NetWrite(a:0=".a:0.") ".g:loaded_netrw)5830 5831 -" ===========================================5832 -" s:NetrwGetFile: Function to read temporary file "tfile" with command "readcmd". {{{25833 -" readcmd == %r : replace buffer with newly read file5834 -" == 0r : read file at top of buffer5835 -" == r : read file after current line5836 -" == t : leave file in temporary form (ie. don't read into buffer)5837 -fun! s:NetrwGetFile(readcmd, tfile, method)5838 -" call Dfunc("NetrwGetFile(readcmd<".a:readcmd.">,tfile<".a:tfile."> method<".a:method.">)")5839 + " NetWrite: option handling {{{35840 + let mod= 05841 + call s:NetrwOptionSave("w:")5842 + call s:NetrwSafeOptions()5843 5844 - " readcmd=='t': simply do nothing5845 - if a:readcmd == 't'5846 -" call Decho("(NetrwGetFile) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")5847 -" call Dret("NetrwGetFile : skip read of <".a:tfile.">")5848 + " NetWrite: Get Temporary Filename {{{35849 + let tmpfile= s:GetTempfile("")5850 + if tmpfile == ""5851 +" call Dret("netrw#NetWrite : unable to get a tempfile!")5852 return5853 endif5854 5855 - " get name of remote filename (ie. url and all)5856 - let rfile= bufname("%")5857 -" call Decho("rfile<".rfile.">")5858 -5859 - if exists("*NetReadFixup")5860 - " for the use of NetReadFixup (not otherwise used internally)5861 - let line2= line("$")5862 + if a:0 == 05863 + let ichoice = 05864 + else5865 + let ichoice = 15866 endif5867 5868 - if a:readcmd[0] == '%'5869 - " get file into buffer5870 -" call Decho("get file into buffer")5871 -5872 - " rename the current buffer to the temp file (ie. tfile)5873 - if g:netrw_cygwin5874 - let tfile= substitute(a:tfile,'/cygdrive/\(.\)','\1:','')5875 - else5876 - let tfile= a:tfile5877 - endif5878 -" call Decho("exe sil! keepalt file ".fnameescape(tfile))5879 - exe "sil! keepalt file ".fnameescape(tfile)5880 -5881 - " edit temporary file (ie. read the temporary file in)5882 - if rfile =~ '\.zip$'5883 -" call Decho("handling remote zip file with zip#Browse(tfile<".tfile.">)")5884 - call zip#Browse(tfile)5885 - elseif rfile =~ '\.tar$'5886 -" call Decho("handling remote tar file with tar#Browse(tfile<".tfile.">)")5887 - call tar#Browse(tfile)5888 - elseif rfile =~ '\.tar\.gz$'5889 -" call Decho("handling remote gzip-compressed tar file")5890 - call tar#Browse(tfile)5891 - elseif rfile =~ '\.tar\.bz2$'5892 -" call Decho("handling remote bz2-compressed tar file")5893 - call tar#Browse(tfile)5894 - elseif rfile =~ '\.tar\.xz$'5895 -" call Decho("handling remote xz-compressed tar file")5896 - call tar#Browse(tfile)5897 - elseif rfile =~ '\.txz$'5898 -" call Decho("handling remote xz-compressed tar file (.txz)")5899 - call tar#Browse(tfile)5900 - else5901 -" call Decho("edit temporary file")5902 - e!5903 - endif5904 -5905 - " rename buffer back to remote filename5906 -" call Decho("exe sil! keepalt file ".fnameescape(rfile))5907 - exe "sil! keepj keepalt file ".fnameescape(rfile)5908 -5909 - " Detect filetype of local version of remote file.5910 - " Note that isk must not include a "/" for scripts.vim5911 - " to process this detection correctly.5912 -" call Decho("detect filetype of local version of remote file")5913 - let iskkeep= &l:isk5914 - setl isk-=/5915 - let &l:isk= iskkeep5916 -" call Dredir("renamed buffer back to remote filename<".rfile."> : expand(%)<".expand("%").">","ls!")5917 - let line1 = 15918 - let line2 = line("$")5919 -5920 - elseif s:FileReadable(a:tfile)5921 - " read file after current line5922 -" call Decho("read file<".a:tfile."> after current line")5923 - let curline = line(".")5924 - let lastline= line("$")5925 -" call Decho("exe<".a:readcmd." ".fnameescape(v:cmdarg)." ".fnameescape(a:tfile)."> line#".curline)5926 - exe "keepj ".a:readcmd." ".fnameescape(v:cmdarg)." ".fnameescape(a:tfile)5927 - let line1= curline + 15928 - let line2= line("$") - lastline + 15929 -5930 + let curbufname= expand("%")5931 +" call Decho("curbufname<".curbufname.">")5932 + if &binary5933 + " For binary writes, always write entire file.5934 + " (line numbers don't really make sense for that).5935 + " Also supports the writing of tar and zip files.5936 +" call Decho("(write entire file) sil exe w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile))5937 + exe "sil keepj w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile)5938 + elseif g:netrw_cygwin5939 + " write (selected portion of) file to temporary5940 + let cygtmpfile= substitute(tmpfile,g:netrw_cygdrive.'/\(.\)','\1:','')5941 +" call Decho("(write selected portion) sil exe ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(cygtmpfile))5942 + exe "sil keepj ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(cygtmpfile)5943 else5944 - " not readable5945 -" call Decho("(NetrwGetFile) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")5946 -" call Decho("tfile<".a:tfile."> not readable")5947 - keepj call netrw#ErrorMsg(s:WARNING,"file <".a:tfile."> not readable",9)5948 -" call Dret("NetrwGetFile : tfile<".a:tfile."> not readable")5949 - return5950 + " write (selected portion of) file to temporary5951 +" call Decho("(write selected portion) sil exe ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile))5952 + exe "sil keepj ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile)5953 endif5954 5955 - " User-provided (ie. optional) fix-it-up command5956 - if exists("*NetReadFixup")5957 -" call Decho("calling NetReadFixup(method<".a:method."> line1=".line1." line2=".line2.")")5958 - keepj call NetReadFixup(a:method, line1, line2)5959 -" else " Decho5960 -" call Decho("NetReadFixup() not called, doesn't exist (line1=".line1." line2=".line2.")")5961 + if curbufname == ""5962 + " when the file is [No Name], and one attempts to Nwrite it, the buffer takes5963 + " on the temporary file's name. Deletion of the temporary file during5964 + " cleanup then causes an error message.5965 + 0file!5966 endif5967 5968 - if has("gui") && has("menu") && has("gui_running") && &go =~# 'm' && g:netrw_menu5969 - " update the Buffers menu5970 - keepj call s:UpdateBuffersMenu()5971 - endif5972 + " NetWrite: while choice loop: {{{35973 + while ichoice <= a:05974 5975 -" call Decho("readcmd<".a:readcmd."> cmdarg<".v:cmdarg."> tfile<".a:tfile."> readable=".s:FileReadable(a:tfile))5976 + " Process arguments: {{{45977 + " attempt to repeat with previous host-file-etc5978 + if exists("b:netrw_lastfile") && a:0 == 05979 +" call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">")5980 + let choice = b:netrw_lastfile5981 + let ichoice= ichoice + 15982 + else5983 + exe "let choice= a:" . ichoice5984 5985 - " make sure file is being displayed5986 -" redraw!5987 + " Reconstruct Choice when choice starts with '"'5988 + if match(choice,"?") == 05989 + echomsg 'NetWrite Usage:"'5990 + echomsg ':Nwrite machine:path uses rcp'5991 + echomsg ':Nwrite "machine path" uses ftp with <.netrc>'5992 + echomsg ':Nwrite "machine id password path" uses ftp'5993 + echomsg ':Nwrite dav://[user@]machine/path uses cadaver'5994 + echomsg ':Nwrite fetch://[user@]machine/path uses fetch'5995 + echomsg ':Nwrite ftp://machine[#port]/path uses ftp (autodetects <.netrc>)'5996 + echomsg ':Nwrite rcp://machine/path uses rcp'5997 + echomsg ':Nwrite rsync://[user@]machine/path uses rsync'5998 + echomsg ':Nwrite scp://[user@]machine[[:#]port]/path uses scp'5999 + echomsg ':Nwrite sftp://[user@]machine/path uses sftp'6000 + sleep 46001 + break6002 6003 -" call Decho("(NetrwGetFile) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")6004 -" call Dret("NetrwGetFile")6005 -endfun6006 + elseif match(choice,"^\"") != -16007 + if match(choice,"\"$") != -16008 + " case "..."6009 + let choice=strpart(choice,1,strlen(choice)-2)6010 + else6011 + " case "... ... ..."6012 + let choice = strpart(choice,1,strlen(choice)-1)6013 + let wholechoice = ""6014 6015 -" ------------------------------------------------------------------------6016 -" s:NetrwMethod: determine method of transfer {{{26017 -" Input:6018 -" choice = url [protocol:]//[userid@]hostname[:port]/[path-to-file]6019 -" Output:6020 -" b:netrw_method= 1: rcp6021 -" 2: ftp + <.netrc>6022 -" 3: ftp + machine, id, password, and [path]filename6023 -" 4: scp6024 -" 5: http[s] (wget)6025 -" 6: dav6026 -" 7: rsync6027 -" 8: fetch6028 -" 9: sftp6029 -" g:netrw_machine= hostname6030 -" b:netrw_fname = filename6031 -" g:netrw_port = optional port number (for ftp)6032 -" g:netrw_choice = copy of input url (choice)6033 -fun! s:NetrwMethod(choice)6034 -" call Dfunc("NetrwMethod(a:choice<".a:choice.">)")6035 + while match(choice,"\"$") == -16036 + let wholechoice= wholechoice . " " . choice6037 + let ichoice = ichoice + 16038 + if choice > a:06039 + if !exists("g:netrw_quiet")6040 + call netrw#ErrorMsg(s:ERROR,"Unbalanced string in filename '". wholechoice ."'",13)6041 + endif6042 +" call Dret("netrw#NetWrite")6043 + return6044 + endif6045 + let choice= a:{ichoice}6046 + endwhile6047 + let choice= strpart(wholechoice,1,strlen(wholechoice)-1) . " " . strpart(choice,0,strlen(choice)-1)6048 + endif6049 + endif6050 + endif6051 + let ichoice= ichoice + 16052 +" call Decho("choice<" . choice . "> ichoice=".ichoice)6053 6054 - " sanity check: choice should have at least three slashes in it6055 - if strlen(substitute(a:choice,'[^/]','','g')) < 36056 - call netrw#ErrorMsg(s:ERROR,"not a netrw-style url; netrw uses protocol://[user@]hostname[:port]/[path])",78)6057 - let b:netrw_method = -16058 -" call Dret("NetrwMethod : incorrect url format<".a:choice.">")6059 + " Determine method of write (ftp, rcp, etc) {{{46060 + keepj call s:NetrwMethod(choice)6061 + if !exists("b:netrw_method") || b:netrw_method < 06062 +" call Dfunc("netrw#NetWrite : unsupported method")6063 return6064 endif6065 6066 - " record current g:netrw_machine, if any6067 - " curmachine used if protocol == ftp and no .netrc6068 - if exists("g:netrw_machine")6069 - let curmachine= g:netrw_machine6070 -" call Decho("curmachine<".curmachine.">")6071 - else6072 - let curmachine= "N O T A HOST"6073 - endif6074 - if exists("g:netrw_port")6075 - let netrw_port= g:netrw_port6076 + " =============6077 + " NetWrite: Perform Protocol-Based Write {{{36078 + " ============================6079 + if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 16080 + echo "(netrw) Processing your write request..."6081 +" call Decho("(netrw) Processing your write request...")6082 endif6083 6084 - " insure that netrw_ftp_cmd starts off every method determination6085 - " with the current g:netrw_ftp_cmd6086 - let s:netrw_ftp_cmd= g:netrw_ftp_cmd6087 + ".........................................6088 + " NetWrite: (rcp) NetWrite Method #1 {{{36089 + if b:netrw_method == 16090 +" call Decho("write via rcp (method #1)")6091 + if s:netrw_has_nt_rcp == 16092 + if exists("g:netrw_uid") && ( g:netrw_uid != "" )6093 + let uid_machine = g:netrw_machine .'.'. g:netrw_uid6094 + else6095 + let uid_machine = g:netrw_machine .'.'. $USERNAME6096 + endif6097 + else6098 + if exists("g:netrw_uid") && ( g:netrw_uid != "" )6099 + let uid_machine = g:netrw_uid .'@'. g:netrw_machine6100 + else6101 + let uid_machine = g:netrw_machine6102 + endif6103 + endif6104 +" call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".shellescape(tmpfile,1)." ".shellescape(uid_machine.":".b:netrw_fname,1))6105 + exe s:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".shellescape(tmpfile,1)." ".shellescape(uid_machine.":".b:netrw_fname,1)6106 + let b:netrw_lastfile = choice6107 6108 - " initialization6109 - let b:netrw_method = 06110 - let g:netrw_machine = ""6111 - let b:netrw_fname = ""6112 - let g:netrw_port = ""6113 - let g:netrw_choice = a:choice6114 + ".........................................6115 + " NetWrite: (ftp + <.netrc>) NetWrite Method #2 {{{36116 + elseif b:netrw_method == 26117 +" call Decho("write via ftp+.netrc (method #2)")6118 + let netrw_fname = b:netrw_fname6119 6120 - " Patterns:6121 - " mipf : a:machine a:id password filename Use ftp6122 - " mf : a:machine filename Use ftp + <.netrc> or g:netrw_uid s:netrw_passwd6123 - " ftpurm : ftp://[user@]host[[#:]port]/filename Use ftp + <.netrc> or g:netrw_uid s:netrw_passwd6124 - " rcpurm : rcp://[user@]host/filename Use rcp6125 - " rcphf : [user@]host:filename Use rcp6126 - " scpurm : scp://[user@]host[[#:]port]/filename Use scp6127 - " httpurm : http[s]://[user@]host/filename Use wget6128 - " davurm : dav[s]://host[:port]/path Use cadaver/curl6129 - " rsyncurm : rsync://host[:port]/path Use rsync6130 - " fetchurm : fetch://[user@]host[:http]/filename Use fetch (defaults to ftp, override for http)6131 - " sftpurm : sftp://[user@]host/filename Use scp6132 - let mipf = '^\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)$'6133 - let mf = '^\(\S\+\)\s\+\(\S\+\)$'6134 -" let ftpurm = '^ftp://\(\([^/@]\{-}\)@\)\=\([^/#:]\{-}\)\([#:]\d\+\)\=/\(.*\)$'6135 -" let rcpurm = '^rcp://\%(\([^/@]\{-}\)@\)\=\([^/]\{-}\)/\(.*\)$'6136 -" let fetchurm = '^fetch://\(\([^/@]\{-}\)@\)\=\([^/#:]\{-}\)\(:http\)\=/\(.*\)$'6137 - let ftpurm = '^ftp://\(\([^/]*\)@\)\=\([^/#:]\{-}\)\([#:]\d\+\)\=/\(.*\)$'6138 - let rcpurm = '^rcp://\%(\([^/]*\)@\)\=\([^/]\{-}\)/\(.*\)$'6139 - let rcphf = '^\(\(\h\w*\)@\)\=\(\h\w*\):\([^@]\+\)$'6140 - let scpurm = '^scp://\([^/#:]\+\)\%([#:]\(\d\+\)\)\=/\(.*\)$'6141 - let httpurm = '^https\=://\([^/]\{-}\)\(/.*\)\=$'6142 - let davurm = '^davs\=://\([^/]\+\)/\(.*/\)\([-_.~[:alnum:]]\+\)$'6143 - let rsyncurm = '^rsync://\([^/]\{-}\)/\(.*\)\=$'6144 - let fetchurm = '^fetch://\(\([^/]*\)@\)\=\([^/#:]\{-}\)\(:http\)\=/\(.*\)$'6145 - let sftpurm = '^sftp://\([^/]\{-}\)/\(.*\)\=$'6146 + " formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead6147 + let bhkeep = &l:bh6148 + let curbuf = bufnr("%")6149 + setl bh=hide6150 + keepalt enew6151 6152 -" call Decho("determine method:")6153 - " Determine Method6154 - " Method#1: rcp://user@hostname/...path-to-file {{{36155 - if match(a:choice,rcpurm) == 06156 -" call Decho("rcp://...")6157 - let b:netrw_method = 16158 - let userid = substitute(a:choice,rcpurm,'\1',"")6159 - let g:netrw_machine = substitute(a:choice,rcpurm,'\2',"")6160 - let b:netrw_fname = substitute(a:choice,rcpurm,'\3',"")6161 - if userid != ""6162 - let g:netrw_uid= userid6163 - endif6164 -6165 - " Method#4: scp://user@hostname/...path-to-file {{{36166 - elseif match(a:choice,scpurm) == 06167 -" call Decho("scp://...")6168 - let b:netrw_method = 46169 - let g:netrw_machine = substitute(a:choice,scpurm,'\1',"")6170 - let g:netrw_port = substitute(a:choice,scpurm,'\2',"")6171 - let b:netrw_fname = substitute(a:choice,scpurm,'\3',"")6172 +" call Decho("filter input window#".winnr())6173 + setl ff=unix6174 + keepj put =g:netrw_ftpmode6175 +" call Decho("filter input: ".getline('$'))6176 + if exists("g:netrw_ftpextracmd")6177 + keepj put =g:netrw_ftpextracmd6178 +" call Decho("filter input: ".getline("$"))6179 + endif6180 + keepj call setline(line("$")+1,'put "'.tmpfile.'" "'.netrw_fname.'"')6181 +" call Decho("filter input: ".getline("$"))6182 + if exists("g:netrw_port") && g:netrw_port != ""6183 +" call Decho("executing: %!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1))6184 + exe s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1)6185 + else6186 +" call Decho("filter input window#".winnr())6187 +" call Decho("executing: %!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1))6188 + exe s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)6189 + endif6190 + " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)6191 + if getline(1) !~ "^$"6192 + if !exists("g:netrw_quiet")6193 + keepj call netrw#ErrorMsg(s:ERROR,getline(1),14)6194 + endif6195 + let mod=16196 + endif6197 6198 - " Method#5: http[s]://user@hostname/...path-to-file {{{36199 - elseif match(a:choice,httpurm) == 06200 -" call Decho("http://...")6201 - let b:netrw_method = 56202 - let g:netrw_machine= substitute(a:choice,httpurm,'\1',"")6203 - let b:netrw_fname = substitute(a:choice,httpurm,'\2',"")6204 + " remove enew buffer (quietly)6205 + let filtbuf= bufnr("%")6206 + exe curbuf."b!"6207 + let &l:bh = bhkeep6208 + exe filtbuf."bw!"6209 6210 - " Method#6: dav://hostname[:port]/..path-to-file.. {{{36211 - elseif match(a:choice,davurm) == 06212 -" call Decho("dav://...")6213 - let b:netrw_method= 66214 - if a:choice =~ 'davs:'6215 - let g:netrw_machine= 'https://'.substitute(a:choice,davurm,'\1/\2',"")6216 - else6217 - let g:netrw_machine= 'http://'.substitute(a:choice,davurm,'\1/\2',"")6218 - endif6219 - let b:netrw_fname = substitute(a:choice,davurm,'\3',"")6220 + let b:netrw_lastfile = choice6221 6222 - " Method#7: rsync://user@hostname/...path-to-file {{{36223 - elseif match(a:choice,rsyncurm) == 06224 -" call Decho("rsync://...")6225 - let b:netrw_method = 76226 - let g:netrw_machine= substitute(a:choice,rsyncurm,'\1',"")6227 - let b:netrw_fname = substitute(a:choice,rsyncurm,'\2',"")6228 + ".........................................6229 + " NetWrite: (ftp + machine, id, passwd, filename) NetWrite Method #3 {{{36230 + elseif b:netrw_method == 36231 + " Construct execution string (three or more lines) which will be passed through filter6232 +" call Decho("read via ftp+mipf (method #3)")6233 + let netrw_fname = b:netrw_fname6234 + let bhkeep = &l:bh6235 6236 - " Methods 2,3: ftp://[user@]hostname[[:#]port]/...path-to-file {{{36237 - elseif match(a:choice,ftpurm) == 06238 -" call Decho("ftp://...")6239 - let userid = substitute(a:choice,ftpurm,'\2',"")6240 - let g:netrw_machine= substitute(a:choice,ftpurm,'\3',"")6241 - let g:netrw_port = substitute(a:choice,ftpurm,'\4',"")6242 - let b:netrw_fname = substitute(a:choice,ftpurm,'\5',"")6243 -" call Decho("g:netrw_machine<".g:netrw_machine.">")6244 - if userid != ""6245 - let g:netrw_uid= userid6246 - endif6247 + " formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead6248 + let curbuf = bufnr("%")6249 + setl bh=hide6250 + keepalt enew6251 + setl ff=unix6252 6253 - if curmachine != g:netrw_machine6254 - if exists("s:netwr_hup[".g:netrw_machine."]")6255 - call NetUserPass("ftp:".g:netrw_machine)6256 - elseif exists("s:netrw_passwd")6257 - " if there's a change in hostname, require password re-entry6258 - unlet s:netrw_passwd6259 + if exists("g:netrw_port") && g:netrw_port != ""6260 + keepj put ='open '.g:netrw_machine.' '.g:netrw_port6261 +" call Decho("filter input: ".getline('.'))6262 + else6263 + keepj put ='open '.g:netrw_machine6264 +" call Decho("filter input: ".getline('.'))6265 endif6266 - if exists("netrw_port")6267 - unlet netrw_port6268 + if exists("g:netrw_uid") && g:netrw_uid != ""6269 + if exists("g:netrw_ftp") && g:netrw_ftp == 16270 + keepj put =g:netrw_uid6271 +" call Decho("filter input: ".getline('.'))6272 + if exists("s:netrw_passwd") && s:netrw_passwd != ""6273 + keepj put ='\"'.s:netrw_passwd.'\"'6274 + endif6275 +" call Decho("filter input: ".getline('.'))6276 + elseif exists("s:netrw_passwd") && s:netrw_passwd != ""6277 + keepj put ='user \"'.g:netrw_uid.'\" \"'.s:netrw_passwd.'\"'6278 +" call Decho("filter input: ".getline('.'))6279 + endif6280 endif6281 - endif6282 -6283 - if exists("g:netrw_uid") && exists("s:netrw_passwd")6284 - let b:netrw_method = 36285 - else6286 - let host= substitute(g:netrw_machine,'\..*$','','')6287 - if exists("s:netrw_hup[host]")6288 - call NetUserPass("ftp:".host)6289 + keepj put =g:netrw_ftpmode6290 +" call Decho("filter input: ".getline('$'))6291 + if exists("g:netrw_ftpextracmd")6292 + keepj put =g:netrw_ftpextracmd6293 +" call Decho("filter input: ".getline("$"))6294 + endif6295 + keepj put ='put \"'.tmpfile.'\" \"'.netrw_fname.'\"'6296 +" call Decho("filter input: ".getline('.'))6297 + " save choice/id/password for future use6298 + let b:netrw_lastfile = choice6299 6300 - elseif (has("win32") || has("win95") || has("win64") || has("win16")) && s:netrw_ftp_cmd =~ '-[sS]:'6301 -" call Decho("has -s: : s:netrw_ftp_cmd<".s:netrw_ftp_cmd.">")6302 -" call Decho(" g:netrw_ftp_cmd<".g:netrw_ftp_cmd.">")6303 - if g:netrw_ftp_cmd =~ '-[sS]:\S*MACHINE\>'6304 - let s:netrw_ftp_cmd= substitute(g:netrw_ftp_cmd,'\<MACHINE\>',g:netrw_machine,'')6305 -" call Decho("s:netrw_ftp_cmd<".s:netrw_ftp_cmd.">")6306 - endif6307 - let b:netrw_method= 26308 - elseif s:FileReadable(expand("$HOME/.netrc")) && !g:netrw_ignorenetrc6309 -" call Decho("using <".expand("$HOME/.netrc")."> (readable)")6310 - let b:netrw_method= 26311 - else6312 - if !exists("g:netrw_uid") || g:netrw_uid == ""6313 - call NetUserPass()6314 - elseif !exists("s:netrw_passwd") || s:netrw_passwd == ""6315 - call NetUserPass(g:netrw_uid)6316 - " else just use current g:netrw_uid and s:netrw_passwd6317 + " perform ftp:6318 + " -i : turns off interactive prompting from ftp6319 + " -n unix : DON'T use <.netrc>, even though it exists6320 + " -n win32: quit being obnoxious about password6321 + keepj norm! 1Gdd6322 +" call Decho("executing: %!".s:netrw_ftp_cmd." ".g:netrw_ftp_options)6323 + exe s:netrw_silentxfer."%!".s:netrw_ftp_cmd." ".g:netrw_ftp_options6324 + " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)6325 + if getline(1) !~ "^$"6326 + if !exists("g:netrw_quiet")6327 + call netrw#ErrorMsg(s:ERROR,getline(1),15)6328 endif6329 - let b:netrw_method= 36330 + let mod=16331 endif6332 - endif6333 6334 - " Method#8: fetch {{{36335 - elseif match(a:choice,fetchurm) == 06336 -" call Decho("fetch://...")6337 - let b:netrw_method = 86338 - let g:netrw_userid = substitute(a:choice,fetchurm,'\2',"")6339 - let g:netrw_machine= substitute(a:choice,fetchurm,'\3',"")6340 - let b:netrw_option = substitute(a:choice,fetchurm,'\4',"")6341 - let b:netrw_fname = substitute(a:choice,fetchurm,'\5',"")6342 + " remove enew buffer (quietly)6343 + let filtbuf= bufnr("%")6344 + exe curbuf."b!"6345 + let &l:bh= bhkeep6346 + exe filtbuf."bw!"6347 6348 - " Method#3: Issue an ftp : "machine id password [path/]filename" {{{36349 - elseif match(a:choice,mipf) == 06350 -" call Decho("(ftp) host id pass file")6351 - let b:netrw_method = 36352 - let g:netrw_machine = substitute(a:choice,mipf,'\1',"")6353 - let g:netrw_uid = substitute(a:choice,mipf,'\2',"")6354 - let s:netrw_passwd = substitute(a:choice,mipf,'\3',"")6355 - let b:netrw_fname = substitute(a:choice,mipf,'\4',"")6356 - call NetUserPass(g:netrw_machine,g:netrw_uid,s:netrw_passwd)6357 + ".........................................6358 + " NetWrite: (scp) NetWrite Method #4 {{{36359 + elseif b:netrw_method == 46360 +" call Decho("write via scp (method #4)")6361 + if exists("g:netrw_port") && g:netrw_port != ""6362 + let useport= " ".g:netrw_scpport." ".fnameescape(g:netrw_port)6363 + else6364 + let useport= ""6365 + endif6366 +" call Decho("exe ".s:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".shellescape(tmpfile,1)." ".shellescape(g:netrw_machine.":".b:netrw_fname,1))6367 + exe s:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".shellescape(tmpfile,1)." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)6368 + let b:netrw_lastfile = choice6369 6370 - " Method#3: Issue an ftp: "hostname [path/]filename" {{{36371 - elseif match(a:choice,mf) == 06372 -" call Decho("(ftp) host file")6373 - if exists("g:netrw_uid") && exists("s:netrw_passwd")6374 - let b:netrw_method = 36375 - let g:netrw_machine = substitute(a:choice,mf,'\1',"")6376 - let b:netrw_fname = substitute(a:choice,mf,'\2',"")6377 + ".........................................6378 + " NetWrite: (http) NetWrite Method #5 {{{36379 + elseif b:netrw_method == 56380 +" call Decho("write via http (method #5)")6381 5143 + let curl= substitute(g:netrw_http_put_cmd,'\s\+.*$',"","") 6382 5144 + if executable(curl) … … 6386 5148 + elseif !exists("g:netrw_quiet") 6387 5149 + call netrw#ErrorMsg(s:ERROR,"can't write to http using <".g:netrw_http_put_cmd".">".",16) 6388 + endif6389 6390 - elseif s:FileReadable(expand("$HOME/.netrc"))6391 - let b:netrw_method = 26392 - let g:netrw_machine = substitute(a:choice,mf,'\1',"")6393 - let b:netrw_fname = substitute(a:choice,mf,'\2',"")6394 - endif6395 + ".........................................6396 + " NetWrite: (dav) NetWrite Method #6 (cadaver) {{{36397 + elseif b:netrw_method == 66398 +" call Decho("write via cadaver (method #6)")6399 6400 - " Method#9: sftp://user@hostname/...path-to-file {{{36401 - elseif match(a:choice,sftpurm) == 06402 -" call Decho("sftp://...")6403 - let b:netrw_method = 96404 - let g:netrw_machine= substitute(a:choice,sftpurm,'\1',"")6405 - let b:netrw_fname = substitute(a:choice,sftpurm,'\2',"")6406 + " Construct execution string (four lines) which will be passed through filter6407 + let netrw_fname = escape(b:netrw_fname,g:netrw_fname_escape)6408 + let bhkeep = &l:bh6409 6410 - " Method#1: Issue an rcp: hostname:filename" (this one should be last) {{{36411 - elseif match(a:choice,rcphf) == 06412 -" call Decho("(rcp) [user@]host:file) rcphf<".rcphf.">")6413 - let b:netrw_method = 16414 - let userid = substitute(a:choice,rcphf,'\2',"")6415 - let g:netrw_machine = substitute(a:choice,rcphf,'\3',"")6416 - let b:netrw_fname = substitute(a:choice,rcphf,'\4',"")6417 -" call Decho('\1<'.substitute(a:choice,rcphf,'\1',"").">")6418 -" call Decho('\2<'.substitute(a:choice,rcphf,'\2',"").">")6419 -" call Decho('\3<'.substitute(a:choice,rcphf,'\3',"").">")6420 -" call Decho('\4<'.substitute(a:choice,rcphf,'\4',"").">")6421 - if userid != ""6422 - let g:netrw_uid= userid6423 - endif6424 + " formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead6425 + let curbuf = bufnr("%")6426 + setl bh=hide6427 + keepalt enew6428 6429 - " Cannot Determine Method {{{36430 - else6431 - if !exists("g:netrw_quiet")6432 - call netrw#ErrorMsg(s:WARNING,"cannot determine method (format: protocol://[user@]hostname[:port]/[path])",45)6433 - endif6434 - let b:netrw_method = -16435 - endif6436 - "}}}36437 + setl ff=unix6438 + if exists("g:netrw_port") && g:netrw_port != ""6439 + keepj put ='open '.g:netrw_machine.' '.g:netrw_port6440 + else6441 + keepj put ='open '.g:netrw_machine6442 + endif6443 + if exists("g:netrw_uid") && exists("s:netrw_passwd") && g:netrw_uid != ""6444 + keepj put ='user '.g:netrw_uid.' '.s:netrw_passwd6445 + endif6446 + keepj put ='put '.tmpfile.' '.netrw_fname6447 6448 - if g:netrw_port != ""6449 - " remove any leading [:#] from port number6450 - let g:netrw_port = substitute(g:netrw_port,'[#:]\+','','')6451 - elseif exists("netrw_port")6452 - " retain port number as implicit for subsequent ftp operations6453 - let g:netrw_port= netrw_port6454 - endif6455 + " perform cadaver operation:6456 + keepj norm! 1Gdd6457 +" call Decho("executing: %!".g:netrw_dav_cmd)6458 + exe s:netrw_silentxfer."%!".g:netrw_dav_cmd6459 6460 -" call Decho("a:choice <".a:choice.">")6461 -" call Decho("b:netrw_method <".b:netrw_method.">")6462 -" call Decho("g:netrw_machine<".g:netrw_machine.">")6463 -" call Decho("g:netrw_port <".g:netrw_port.">")6464 -" if exists("g:netrw_uid") "Decho6465 -" call Decho("g:netrw_uid <".g:netrw_uid.">")6466 -" endif "Decho6467 -" if exists("s:netrw_passwd") "Decho6468 -" call Decho("s:netrw_passwd <".s:netrw_passwd.">")6469 -" endif "Decho6470 -" call Decho("b:netrw_fname <".b:netrw_fname.">")6471 -" call Dret("NetrwMethod : b:netrw_method=".b:netrw_method." g:netrw_port=".g:netrw_port)6472 -endfun6473 + " remove enew buffer (quietly)6474 + let filtbuf= bufnr("%")6475 + exe curbuf."b!"6476 + let &l:bh = bhkeep6477 + exe filtbuf."bw!"6478 6479 -" ------------------------------------------------------------------------6480 -" NetReadFixup: this sort of function is typically written by the user {{{26481 -" to handle extra junk that their system's ftp dumps6482 -" into the transfer. This function is provided as an6483 -" example and as a fix for a Windows 95 problem: in my6484 -" experience, win95's ftp always dumped four blank lines6485 -" at the end of the transfer.6486 -if has("win95") && exists("g:netrw_win95ftp") && g:netrw_win95ftp6487 - fun! NetReadFixup(method, line1, line2)6488 -" call Dfunc("NetReadFixup(method<".a:method."> line1=".a:line1." line2=".a:line2.")")6489 + let b:netrw_lastfile = choice6490 6491 - " sanity checks -- attempt to convert inputs to integers6492 - let method = a:method + 06493 - let line1 = a:line1 + 06494 - let line2 = a:line2 + 06495 - if type(method) != 0 || type(line1) != 0 || type(line2) != 0 || method < 0 || line1 <= 0 || line2 <= 06496 -" call Dret("NetReadFixup")6497 - return6498 - endif6499 + ".........................................6500 + " NetWrite: (rsync) NetWrite Method #7 {{{36501 + elseif b:netrw_method == 76502 +" call Decho("write via rsync (method #7)")6503 +" call Decho("executing: !".g:netrw_rsync_cmd." ".shellescape(tmpfile,1)." ".shellescape(g:netrw_machine.":".b:netrw_fname,1))6504 + exe s:netrw_silentxfer."!".g:netrw_rsync_cmd." ".shellescape(tmpfile,1)." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)6505 + let b:netrw_lastfile = choice6506 6507 - if method == 3 " ftp (no <.netrc>)6508 - let fourblanklines= line2 - 36509 - if fourblanklines >= line16510 - exe "sil keepj ".fourblanklines.",".line2."g/^\s*$/d"6511 - call histdel("/",-1)6512 + ".........................................6513 + " NetWrite: (sftp) NetWrite Method #9 {{{36514 + elseif b:netrw_method == 96515 +" call Decho("write via sftp (method #9)")6516 + let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)6517 + if exists("g:netrw_uid") && ( g:netrw_uid != "" )6518 + let uid_machine = g:netrw_uid .'@'. g:netrw_machine6519 + else6520 + let uid_machine = g:netrw_machine6521 5150 endif 6522 - endif 6523 - 6524 -" call Dret("NetReadFixup") 6525 - endfun 6526 -endif 6527 - 6528 -" --------------------------------------------------------------------- 6529 -" NetUserPass: set username and password for subsequent ftp transfer {{{2 6530 -" Usage: :call NetUserPass() -- will prompt for userid and password 6531 -" :call NetUserPass("uid") -- will prompt for password 6532 -" :call NetUserPass("uid","password") -- sets global userid and password 6533 -" :call NetUserPass("ftp:host") -- looks up userid and password using hup dictionary 6534 -" :call NetUserPass("host","uid","password") -- sets hup dictionary with host, userid, password 6535 -fun! NetUserPass(...) 6536 6537 -" call Dfunc("NetUserPass() a:0=".a:0) 6538 + " formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead 6539 + let bhkeep = &l:bh 6540 + let curbuf = bufnr("%") 6541 + setl bh=hide 6542 + keepalt enew 6543 6544 - if !exists('s:netrw_hup') 6545 - let s:netrw_hup= {} 6546 - endif 6547 + setl ff=unix 6548 + call setline(1,'put "'.escape(tmpfile,'\').'" '.netrw_fname) 6549 +" call Decho("filter input: ".getline('.')) 6550 +" call Decho("executing: %!".g:netrw_sftp_cmd.' '.shellescape(uid_machine,1)) 6551 + let sftpcmd= substitute(g:netrw_sftp_cmd,"%TEMPFILE%",escape(tmpfile,'\'),"g") 6552 + exe s:netrw_silentxfer."%!".sftpcmd.' '.shellescape(uid_machine,1) 6553 + let filtbuf= bufnr("%") 6554 + exe curbuf."b!" 6555 + let &l:bh = bhkeep 6556 + exe filtbuf."bw!" 6557 + let b:netrw_lastfile = choice 6558 6559 - if a:0 == 0 6560 - " case: no input arguments 6561 + "......................................... 6562 + " NetWrite: Complain {{{3 6563 + else 6564 + call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . choice . ">",17) 6565 + let leavemod= 1 6566 + endif 6567 + endwhile 6568 6569 - " change host and username if not previously entered; get new password 6570 - if !exists("g:netrw_machine") 6571 - let g:netrw_machine= input('Enter hostname: ') 6572 - endif 6573 - if !exists("g:netrw_uid") || g:netrw_uid == "" 6574 - " get username (user-id) via prompt 6575 - let g:netrw_uid= input('Enter username: ') 6576 + " NetWrite: Cleanup: {{{3 6577 +" call Decho("cleanup") 6578 + if s:FileReadable(tmpfile) 6579 +" call Decho("tmpfile<".tmpfile."> readable, will now delete it") 6580 + call s:NetrwDelete(tmpfile) 6581 endif 6582 - " get password via prompting 6583 - let s:netrw_passwd= inputsecret("Enter Password: ") 6584 + call s:NetrwOptionRestore("w:") 6585 6586 - " set up hup database 6587 - let host = substitute(g:netrw_machine,'\..*$','','') 6588 - if !exists('s:netrw_hup[host]') 6589 - let s:netrw_hup[host]= {} 6590 + if a:firstline == 1 && a:lastline == line("$") 6591 + " restore modifiability; usually equivalent to set nomod 6592 + let &mod= mod 5151 5152 "......................................... 5153 @@ -2313,12 +2518,12 @@ 5154 if a:firstline == 1 && a:lastline == line("$") 5155 " restore modifiability; usually equivalent to set nomod 5156 let &mod= mod 5157 -" call Decho("(NetWrite) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 6593 5158 +" call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 6594 + elseif !exists("leavemod") 6595 + " indicate that the buffer has not been modified since last written 5159 elseif !exists("leavemod") 5160 " indicate that the buffer has not been modified since last written 5161 -" call Decho("(NetWrite) set nomod") 5162 - set nomod 5163 -" call Decho("(NetWrite) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 6596 5164 +" call Decho("set nomod") 6597 5165 + setl nomod 6598 5166 +" call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 6599 5167 endif 6600 - let s:netrw_hup[host].uid = g:netrw_uid 6601 - let s:netrw_hup[host].passwd = s:netrw_passwd 6602 6603 - elseif a:0 == 1 6604 - " case: one input argument 6605 - 6606 - if a:1 =~ '^ftp:' 6607 - " get host from ftp:... url 6608 - " access userid and password from hup (host-user-passwd) dictionary 6609 - let host = substitute(a:1,'^ftp:','','') 6610 - let host = substitute(host,'\..*','','') 6611 - if exists("s:netrw_hup[host]") 6612 - let g:netrw_uid = s:netrw_hup[host].uid 6613 - let s:netrw_passwd = s:netrw_hup[host].passwd 6614 -" call Decho("get s:netrw_hup[".host."].uid <".s:netrw_hup[host].uid.">") 6615 -" call Decho("get s:netrw_hup[".host."].passwd<".s:netrw_hup[host].passwd.">") 6616 - else 6617 - let g:netrw_uid = input("Enter UserId: ") 6618 - let s:netrw_passwd = inputsecret("Enter Password: ") 6619 - endif 6620 +" call Dret("netrw#NetWrite") 6621 +endfun 6622 6623 +" --------------------------------------------------------------------- 6624 +" netrw#NetSource: source a remotely hosted vim script {{{2 6625 +" uses NetRead to get a copy of the file into a temporarily file, 6626 +" then sources that file, 6627 +" then removes that file. 6628 +fun! netrw#NetSource(...) 6629 +" call Dfunc("netrw#NetSource() a:0=".a:0) 6630 + if a:0 > 0 && a:1 == '?' 6631 + " give help 6632 + echomsg 'NetSource Usage:' 6633 + echomsg ':Nsource dav://machine[:port]/path uses cadaver' 6634 + echomsg ':Nsource fetch://machine/path uses fetch' 6635 + echomsg ':Nsource ftp://[user@]machine[:port]/path uses ftp autodetects <.netrc>' 6636 + echomsg ':Nsource http[s]://[user@]machine/path uses http wget' 6637 + echomsg ':Nsource rcp://[user@]machine/path uses rcp' 6638 + echomsg ':Nsource rsync://machine[:port]/path uses rsync' 6639 + echomsg ':Nsource scp://[user@]machine[[:#]port]/path uses scp' 6640 + echomsg ':Nsource sftp://[user@]machine[[:#]port]/path uses sftp' 6641 + sleep 4 6642 else 6643 - " case: one input argument, not an url. Using it as a new user-id. 6644 - if exists("g:netrw_machine") 6645 - let host= substitute(g:netrw_machine,'\..*$','','') 6646 - else 6647 - let g:netrw_machine= input('Enter hostname: ') 6648 - endif 6649 - let g:netrw_uid = a:1 6650 -" call Decho("set g:netrw_uid= <".g:netrw_uid.">") 6651 - if exists("g:netrw_passwd") 6652 - " ask for password if one not previously entered 6653 - let s:netrw_passwd= g:netrw_passwd 6654 - else 6655 - let s:netrw_passwd = inputsecret("Enter Password: ") 6656 - endif 6657 + let i= 1 6658 + while i <= a:0 6659 + call netrw#NetRead(3,a:{i}) 5168 5169 " call Dret("netrw#NetWrite") 5170 @@ -2347,11 +2552,11 @@ 5171 let i= 1 5172 while i <= a:0 5173 call netrw#NetRead(3,a:{i}) 5174 -" call Decho("(netrw#NetSource) s:netread_tmpfile<".s:netrw_tmpfile.">") 6660 5175 +" call Decho("s:netread_tmpfile<".s:netrw_tmpfile.">") 6661 + if s:FileReadable(s:netrw_tmpfile) 5176 if s:FileReadable(s:netrw_tmpfile) 5177 -" call Decho("(netrw#NetSource) exe so ".fnameescape(s:netrw_tmpfile)) 6662 5178 +" call Decho("exe so ".fnameescape(s:netrw_tmpfile)) 6663 + exe "so ".fnameescape(s:netrw_tmpfile) 5179 exe "so ".fnameescape(s:netrw_tmpfile) 5180 -" call Decho("(netrw#NetSource) delete(".s:netrw_tmpfile.")") 6664 5181 +" call Decho("delete(".s:netrw_tmpfile.")") 6665 + call delete(s:netrw_tmpfile) 6666 + unlet s:netrw_tmpfile 6667 + else 6668 + call netrw#ErrorMsg(s:ERROR,"unable to source <".a:{i}.">!",48) 6669 + endif 6670 + let i= i + 1 6671 + endwhile 6672 endif 6673 +" call Dret("netrw#NetSource") 6674 +endfun 6675 6676 -" call Decho("host<".host.">") 6677 - if exists("host") 6678 - if !exists('s:netrw_hup[host]') 6679 - let s:netrw_hup[host]= {} 6680 - endif 6681 - let s:netrw_hup[host].uid = g:netrw_uid 6682 - let s:netrw_hup[host].passwd = s:netrw_passwd 5182 call delete(s:netrw_tmpfile) 5183 unlet s:netrw_tmpfile 5184 else 5185 @@ -2363,6 +2568,49 @@ 5186 " call Dret("netrw#NetSource") 5187 endfun 5188 6683 5189 +" --------------------------------------------------------------------- 6684 5190 +" netrw#SetTreetop: resets the tree top to the current directory/specified directory {{{2 … … 6720 5226 + else 6721 5227 + call s:NetrwBrowse(islocal,s:NetrwBrowseChgDir(islocal,treedir)) 6722 5228 + endif 6723 5229 +" call Dret("netrw#SetTreetop") 6724 5230 +endfun 6725 6726 - elseif a:0 == 2 6727 - let g:netrw_uid = a:1 6728 - let s:netrw_passwd = a:2 6729 +" =========================================== 6730 +" s:NetrwGetFile: Function to read temporary file "tfile" with command "readcmd". {{{2 6731 +" readcmd == %r : replace buffer with newly read file 6732 +" == 0r : read file at top of buffer 6733 +" == r : read file after current line 6734 +" == t : leave file in temporary form (ie. don't read into buffer) 6735 +fun! s:NetrwGetFile(readcmd, tfile, method) 6736 +" call Dfunc("NetrwGetFile(readcmd<".a:readcmd.">,tfile<".a:tfile."> method<".a:method.">)") 6737 6738 - elseif a:0 == 3 6739 - " enter hostname, user-id, and password into the hup dictionary 6740 - let host = substitute(a:1,'^\a\+:','','') 6741 - let host = substitute(host,'\..*$','','') 6742 - if !exists('s:netrw_hup[host]') 6743 - let s:netrw_hup[host]= {} 6744 + " readcmd=='t': simply do nothing 6745 + if a:readcmd == 't' 5231 + 5232 " =========================================== 5233 " s:NetrwGetFile: Function to read temporary file "tfile" with command "readcmd". {{{2 5234 " readcmd == %r : replace buffer with newly read file 5235 @@ -2374,7 +2622,7 @@ 5236 5237 " readcmd=='t': simply do nothing 5238 if a:readcmd == 't' 5239 -" call Decho("(NetrwGetFile) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 6746 5240 +" call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 6747 +" call Dret("NetrwGetFile : skip read of <".a:tfile.">") 5241 " call Dret("NetrwGetFile : skip read of <".a:tfile.">") 5242 return 5243 endif 5244 @@ -2394,7 +2642,7 @@ 5245 5246 " rename the current buffer to the temp file (ie. tfile) 5247 if g:netrw_cygwin 5248 - let tfile= substitute(a:tfile,'/cygdrive/\(.\)','\1:','') 5249 + let tfile= substitute(a:tfile,g:netrw_cygdrive.'/\(.\)','\1:','') 5250 else 5251 let tfile= a:tfile 5252 endif 5253 @@ -2440,6 +2688,12 @@ 5254 let line1 = 1 5255 let line2 = line("$") 5256 5257 + elseif !&ma 5258 + " attempting to read a file after the current line in the file, but the buffer is not modifiable 5259 + keepj call netrw#ErrorMsg(s:WARNING,"attempt to read<".a:tfile."> into a non-modifiable buffer!",94) 5260 +" call Dret("NetrwGetFile : attempt to read<".a:tfile."> into a non-modifiable buffer!") 6748 5261 + return 6749 endif 6750 - let s:netrw_hup[host].uid = a:2 6751 - let s:netrw_hup[host].passwd = a:3 6752 - let g:netrw_uid = s:netrw_hup[host].uid 6753 - let s:netrw_passwd = s:netrw_hup[host].passwd 6754 -" call Decho("set s:netrw_hup[".host."].uid <".s:netrw_hup[host].uid.">") 6755 -" call Decho("set s:netrw_hup[".host."].passwd<".s:netrw_hup[host].passwd.">") 6756 - endif 6757 6758 -" call Dret("NetUserPass : uid<".g:netrw_uid."> passwd<".s:netrw_passwd.">") 6759 -endfun 6760 + " get name of remote filename (ie. url and all) 6761 + let rfile= bufname("%") 6762 +" call Decho("rfile<".rfile.">") 6763 6764 -" =========================================== 6765 -" Shared Browsing Support: {{{1 6766 -" =========================================== 6767 + if exists("*NetReadFixup") 6768 + " for the use of NetReadFixup (not otherwise used internally) 6769 + let line2= line("$") 6770 + endif 6771 6772 -" --------------------------------------------------------------------- 5262 + 5263 elseif s:FileReadable(a:tfile) 5264 " read file after current line 5265 " call Decho("read file<".a:tfile."> after current line") 5266 @@ -2452,7 +2706,7 @@ 5267 5268 else 5269 " not readable 5270 -" call Decho("(NetrwGetFile) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 5271 +" call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 5272 " call Decho("tfile<".a:tfile."> not readable") 5273 keepj call netrw#ErrorMsg(s:WARNING,"file <".a:tfile."> not readable",9) 5274 " call Dret("NetrwGetFile : tfile<".a:tfile."> not readable") 5275 @@ -2477,7 +2731,7 @@ 5276 " make sure file is being displayed 5277 " redraw! 5278 5279 -" call Decho("(NetrwGetFile) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 5280 +" call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 5281 " call Dret("NetrwGetFile") 5282 endfun 5283 5284 @@ -2583,10 +2837,11 @@ 5285 5286 " Method#5: http[s]://user@hostname/...path-to-file {{{3 5287 elseif match(a:choice,httpurm) == 0 5288 -" call Decho("http://...") 5289 +" call Decho("http[s]://...") 5290 let b:netrw_method = 5 5291 let g:netrw_machine= substitute(a:choice,httpurm,'\1',"") 5292 let b:netrw_fname = substitute(a:choice,httpurm,'\2',"") 5293 + let b:netrw_http = (a:choice =~ '^https:')? "https" : "http" 5294 5295 " Method#6: dav://hostname[:port]/..path-to-file.. {{{3 5296 elseif match(a:choice,davurm) == 0 5297 @@ -2820,6 +3075,7 @@ 5298 if a:1 =~ '^ftp:' 5299 " get host from ftp:... url 5300 " access userid and password from hup (host-user-passwd) dictionary 5301 +" call Decho("case a:0=1: a:1<".a:1."> (get host from ftp:... url)") 5302 let host = substitute(a:1,'^ftp:','','') 5303 let host = substitute(host,'\..*','','') 5304 if exists("s:netrw_hup[host]") 5305 @@ -2834,8 +3090,13 @@ 5306 5307 else 5308 " case: one input argument, not an url. Using it as a new user-id. 5309 +" call Decho("case a:0=1: a:1<".a:1."> (get host from input argument, not an url)") 5310 if exists("g:netrw_machine") 5311 - let host= substitute(g:netrw_machine,'\..*$','','') 5312 + if g:netrw_machine =~ '[0-9.]\+' 5313 + let host= g:netrw_machine 5314 + else 5315 + let host= substitute(g:netrw_machine,'\..*$','','') 5316 + endif 5317 else 5318 let g:netrw_machine= input('Enter hostname: ') 5319 endif 5320 @@ -2885,365 +3146,32 @@ 5321 " =========================================== 5322 5323 " --------------------------------------------------------------------- 6773 5324 -" s:NetrwMaps: {{{2 6774 5325 -fun! s:NetrwMaps(islocal) 6775 5326 -" call Dfunc("s:NetrwMaps(islocal=".a:islocal.") b:netrw_curdir<".b:netrw_curdir.">") 6776 + if a:readcmd[0] == '%' 6777 + " get file into buffer 6778 +" call Decho("get file into buffer") 5327 +" s:ExplorePatHls: converts an Explore pattern into a regular expression search pattern {{{2 5328 +fun! s:ExplorePatHls(pattern) 5329 +" call Dfunc("s:ExplorePatHls(pattern<".a:pattern.">)") 5330 + let repat= substitute(a:pattern,'^**/\{1,2}','','') 5331 +" call Decho("repat<".repat.">") 5332 + let repat= escape(repat,'][.\') 5333 +" call Decho("repat<".repat.">") 5334 + let repat= '\<'.substitute(repat,'\*','\\(\\S\\+ \\)*\\S\\+','g').'\>' 5335 +" call Dret("s:ExplorePatHls repat<".repat.">") 5336 + return repat 5337 +endfun 6779 5338 6780 5339 - " set up Rexplore and [ 2-leftmouse-click -or- c-leftmouse ] … … 6791 5350 - nmap <unique> <silent> <c-leftmouse> <Plug>NetrwReturn 6792 5351 - endif 6793 + " rename the current buffer to the temp file (ie. tfile) 6794 + if g:netrw_cygwin 6795 + let tfile= substitute(a:tfile,g:netrw_cygdrive.'/\(.\)','\1:','') 6796 + else 6797 + let tfile= a:tfile 6798 endif 5352 - endif 6799 5353 - nno <silent> <Plug>NetrwReturn :Rexplore<cr> 6800 5354 -" call Decho("(NetrwMaps) made <Plug>NetrwReturn map") 6801 +" call Decho("exe sil! keepalt file ".fnameescape(tfile)) 6802 + exe "sil! keepalt file ".fnameescape(tfile) 6803 + 6804 + " edit temporary file (ie. read the temporary file in) 6805 + if rfile =~ '\.zip$' 6806 +" call Decho("handling remote zip file with zip#Browse(tfile<".tfile.">)") 6807 + call zip#Browse(tfile) 6808 + elseif rfile =~ '\.tar$' 6809 +" call Decho("handling remote tar file with tar#Browse(tfile<".tfile.">)") 6810 + call tar#Browse(tfile) 6811 + elseif rfile =~ '\.tar\.gz$' 6812 +" call Decho("handling remote gzip-compressed tar file") 6813 + call tar#Browse(tfile) 6814 + elseif rfile =~ '\.tar\.bz2$' 6815 +" call Decho("handling remote bz2-compressed tar file") 6816 + call tar#Browse(tfile) 6817 + elseif rfile =~ '\.tar\.xz$' 6818 +" call Decho("handling remote xz-compressed tar file") 6819 + call tar#Browse(tfile) 6820 + elseif rfile =~ '\.txz$' 6821 +" call Decho("handling remote xz-compressed tar file (.txz)") 6822 + call tar#Browse(tfile) 6823 + else 6824 +" call Decho("edit temporary file") 6825 + e! 6826 + endif 6827 + 6828 + " rename buffer back to remote filename 6829 +" call Decho("exe sil! keepalt file ".fnameescape(rfile)) 6830 + exe "sil! keepj keepalt file ".fnameescape(rfile) 6831 + 6832 + " Detect filetype of local version of remote file. 6833 + " Note that isk must not include a "/" for scripts.vim 6834 + " to process this detection correctly. 6835 +" call Decho("detect filetype of local version of remote file") 6836 + let iskkeep= &l:isk 6837 + setl isk-=/ 6838 + let &l:isk= iskkeep 6839 +" call Dredir("renamed buffer back to remote filename<".rfile."> : expand(%)<".expand("%").">","ls!") 6840 + let line1 = 1 6841 + let line2 = line("$") 6842 + 6843 + elseif !&ma 6844 + " attempting to read a file after the current line in the file, but the buffer is not modifiable 6845 + keepj call netrw#ErrorMsg(s:WARNING,"attempt to read<".a:tfile."> into a non-modifiable buffer!",94) 6846 +" call Dret("NetrwGetFile : attempt to read<".a:tfile."> into a non-modifiable buffer!") 6847 + return 6848 + 6849 + elseif s:FileReadable(a:tfile) 6850 + " read file after current line 6851 +" call Decho("read file<".a:tfile."> after current line") 6852 + let curline = line(".") 6853 + let lastline= line("$") 6854 +" call Decho("exe<".a:readcmd." ".fnameescape(v:cmdarg)." ".fnameescape(a:tfile)."> line#".curline) 6855 + exe "keepj ".a:readcmd." ".fnameescape(v:cmdarg)." ".fnameescape(a:tfile) 6856 + let line1= curline + 1 6857 + let line2= line("$") - lastline + 1 6858 + 6859 + else 6860 + " not readable 6861 +" call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 6862 +" call Decho("tfile<".a:tfile."> not readable") 6863 + keepj call netrw#ErrorMsg(s:WARNING,"file <".a:tfile."> not readable",9) 6864 +" call Dret("NetrwGetFile : tfile<".a:tfile."> not readable") 6865 + return 6866 endif 6867 5355 - endif 5356 - 6868 5357 - if a:islocal 6869 5358 -" call Decho("(NetrwMaps) make local maps") … … 6971 5460 - nmap <buffer> <unique> <c-h> <Plug>NetrwHideEdit 6972 5461 - imap <buffer> <unique> <c-h> <Plug>NetrwHideEdit 6973 + " User-provided (ie. optional) fix-it-up command 6974 + if exists("*NetReadFixup") 6975 +" call Decho("calling NetReadFixup(method<".a:method."> line1=".line1." line2=".line2.")") 6976 + keepj call NetReadFixup(a:method, line1, line2) 6977 +" else " Decho 6978 +" call Decho("NetReadFixup() not called, doesn't exist (line1=".line1." line2=".line2.")") 6979 + endif 6980 + 6981 + if has("gui") && has("menu") && has("gui_running") && &go =~# 'm' && g:netrw_menu 6982 + " update the Buffers menu 6983 + keepj call s:UpdateBuffersMenu() 6984 + endif 6985 + 6986 +" call Decho("readcmd<".a:readcmd."> cmdarg<".v:cmdarg."> tfile<".a:tfile."> readable=".s:FileReadable(a:tfile)) 6987 + 6988 + " make sure file is being displayed 6989 +" redraw! 6990 + 6991 +" call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 6992 +" call Dret("NetrwGetFile") 6993 +endfun 6994 + 6995 +" ------------------------------------------------------------------------ 6996 +" s:NetrwMethod: determine method of transfer {{{2 6997 +" Input: 6998 +" choice = url [protocol:]//[userid@]hostname[:port]/[path-to-file] 6999 +" Output: 7000 +" b:netrw_method= 1: rcp 7001 +" 2: ftp + <.netrc> 7002 +" 3: ftp + machine, id, password, and [path]filename 7003 +" 4: scp 7004 +" 5: http[s] (wget) 7005 +" 6: dav 7006 +" 7: rsync 7007 +" 8: fetch 7008 +" 9: sftp 7009 +" g:netrw_machine= hostname 7010 +" b:netrw_fname = filename 7011 +" g:netrw_port = optional port number (for ftp) 7012 +" g:netrw_choice = copy of input url (choice) 7013 +fun! s:NetrwMethod(choice) 7014 +" call Dfunc("NetrwMethod(a:choice<".a:choice.">)") 7015 + 7016 + " sanity check: choice should have at least three slashes in it 7017 + if strlen(substitute(a:choice,'[^/]','','g')) < 3 7018 + call netrw#ErrorMsg(s:ERROR,"not a netrw-style url; netrw uses protocol://[user@]hostname[:port]/[path])",78) 7019 + let b:netrw_method = -1 7020 +" call Dret("NetrwMethod : incorrect url format<".a:choice.">") 7021 + return 7022 endif 5462 - endif 7023 5463 - nnoremap <buffer> <silent> <Plug>NetrwHideEdit :call <SID>NetrwHideEdit(1)<cr> 7024 5464 - if !hasmapto('<Plug>NetrwRefresh') 7025 5465 - nmap <buffer> <unique> <c-l> <Plug>NetrwRefresh 7026 5466 - imap <buffer> <unique> <c-l> <Plug>NetrwRefresh 7027 + 7028 + " record current g:netrw_machine, if any 7029 + " curmachine used if protocol == ftp and no .netrc 7030 + if exists("g:netrw_machine") 7031 + let curmachine= g:netrw_machine 7032 +" call Decho("curmachine<".curmachine.">") 7033 + else 7034 + let curmachine= "N O T A HOST" 7035 endif 5467 - endif 7036 5468 - nnoremap <buffer> <silent> <Plug>NetrwRefresh :call <SID>NetrwRefresh(1,<SID>NetrwBrowseChgDir(1,'./'))<cr> 7037 5469 - if s:didstarstar || !mapcheck("<s-down>","n") … … 7064 5496 - exe 'vnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' 7065 5497 - exe 'inoremap <buffer> <silent> <rightmouse> <c-o><leftmouse><c-o>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' 7066 + if exists("g:netrw_port") 7067 + let netrw_port= g:netrw_port 7068 endif 5498 - endif 7069 5499 - exe 'nnoremap <buffer> <silent> <del> :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' 7070 5500 - exe 'nnoremap <buffer> <silent> D :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' … … 7079 5509 - exe 'inoremap <buffer> <silent> <Leader>m <c-o>:call <SID>NetrwMakeDir("")<cr>' 7080 5510 - nnoremap <buffer> <F1> :he netrw-quickhelp<cr> 7081 5511 - 7082 5512 - else " remote 7083 5513 -" call Decho("(NetrwMaps) make remote maps") … … 7189 5619 - imap <buffer> <c-l> <Plug>NetrwRefresh 7190 5620 - endif 7191 + " insure that netrw_ftp_cmd starts off every method determination 7192 + " with the current g:netrw_ftp_cmd 7193 + let s:netrw_ftp_cmd= g:netrw_ftp_cmd 7194 5621 - 7195 5622 - let mapsafepath = escape(s:path, s:netrw_map_escape) 7196 5623 - let mapsafeusermach = escape(s:user.s:machine, s:netrw_map_escape) 7197 + " initialization 7198 + let b:netrw_method = 0 7199 + let g:netrw_machine = "" 7200 + let b:netrw_fname = "" 7201 + let g:netrw_port = "" 7202 + let g:netrw_choice = a:choice 7203 5624 - 7204 5625 - nnoremap <buffer> <silent> <Plug>NetrwRefresh :call <SID>NetrwRefresh(0,<SID>NetrwBrowseChgDir(0,'./'))<cr> 7205 5626 - if g:netrw_mousemaps == 1 … … 7223 5644 - exe 'vnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>' 7224 5645 - exe 'inoremap <buffer> <silent> <rightmouse> <c-o><leftmouse><c-o>:call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>' 7225 + " Patterns: 7226 + " mipf : a:machine a:id password filename Use ftp 7227 + " mf : a:machine filename Use ftp + <.netrc> or g:netrw_uid s:netrw_passwd 7228 + " ftpurm : ftp://[user@]host[[#:]port]/filename Use ftp + <.netrc> or g:netrw_uid s:netrw_passwd 7229 + " rcpurm : rcp://[user@]host/filename Use rcp 7230 + " rcphf : [user@]host:filename Use rcp 7231 + " scpurm : scp://[user@]host[[#:]port]/filename Use scp 7232 + " httpurm : http[s]://[user@]host/filename Use wget 7233 + " davurm : dav[s]://host[:port]/path Use cadaver/curl 7234 + " rsyncurm : rsync://host[:port]/path Use rsync 7235 + " fetchurm : fetch://[user@]host[:http]/filename Use fetch (defaults to ftp, override for http) 7236 + " sftpurm : sftp://[user@]host/filename Use scp 7237 + let mipf = '^\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)$' 7238 + let mf = '^\(\S\+\)\s\+\(\S\+\)$' 7239 +" let ftpurm = '^ftp://\(\([^/@]\{-}\)@\)\=\([^/#:]\{-}\)\([#:]\d\+\)\=/\(.*\)$' 7240 +" let rcpurm = '^rcp://\%(\([^/@]\{-}\)@\)\=\([^/]\{-}\)/\(.*\)$' 7241 +" let fetchurm = '^fetch://\(\([^/@]\{-}\)@\)\=\([^/#:]\{-}\)\(:http\)\=/\(.*\)$' 7242 + let ftpurm = '^ftp://\(\([^/]*\)@\)\=\([^/#:]\{-}\)\([#:]\d\+\)\=/\(.*\)$' 7243 + let rcpurm = '^rcp://\%(\([^/]*\)@\)\=\([^/]\{-}\)/\(.*\)$' 7244 + let rcphf = '^\(\(\h\w*\)@\)\=\(\h\w*\):\([^@]\+\)$' 7245 + let scpurm = '^scp://\([^/#:]\+\)\%([#:]\(\d\+\)\)\=/\(.*\)$' 7246 + let httpurm = '^https\=://\([^/]\{-}\)\(/.*\)\=$' 7247 + let davurm = '^davs\=://\([^/]\+\)/\(.*/\)\([-_.~[:alnum:]]\+\)$' 7248 + let rsyncurm = '^rsync://\([^/]\{-}\)/\(.*\)\=$' 7249 + let fetchurm = '^fetch://\(\([^/]*\)@\)\=\([^/#:]\{-}\)\(:http\)\=/\(.*\)$' 7250 + let sftpurm = '^sftp://\([^/]\{-}\)/\(.*\)\=$' 7251 + 7252 +" call Decho("determine method:") 7253 + " Determine Method 7254 + " Method#1: rcp://user@hostname/...path-to-file {{{3 7255 + if match(a:choice,rcpurm) == 0 7256 +" call Decho("rcp://...") 7257 + let b:netrw_method = 1 7258 + let userid = substitute(a:choice,rcpurm,'\1',"") 7259 + let g:netrw_machine = substitute(a:choice,rcpurm,'\2',"") 7260 + let b:netrw_fname = substitute(a:choice,rcpurm,'\3',"") 7261 + if userid != "" 7262 + let g:netrw_uid= userid 7263 endif 5646 - endif 7264 5647 - exe 'nnoremap <buffer> <silent> <del> :call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>' 7265 5648 - exe 'nnoremap <buffer> <silent> d :call <SID>NetrwMakeDir("'.mapsafeusermach.'")<cr>' … … 7276 5659 - inoremap <buffer> <F1> <c-o>:he netrw-quickhelp<cr> 7277 5660 - endif 7278 5661 - 7279 5662 - keepj call s:SetRexDir(a:islocal,b:netrw_curdir) 7280 + " Method#4: scp://user@hostname/...path-to-file {{{3 7281 + elseif match(a:choice,scpurm) == 0 7282 +" call Decho("scp://...") 7283 + let b:netrw_method = 4 7284 + let g:netrw_machine = substitute(a:choice,scpurm,'\1',"") 7285 + let g:netrw_port = substitute(a:choice,scpurm,'\2',"") 7286 + let b:netrw_fname = substitute(a:choice,scpurm,'\3',"") 7287 5663 - 7288 5664 -" call Dret("s:NetrwMaps") 7289 5665 -endfun 7290 + " Method#5: http[s]://user@hostname/...path-to-file {{{3 7291 + elseif match(a:choice,httpurm) == 0 7292 +" call Decho("http[s]://...") 7293 + let b:netrw_method = 5 7294 + let g:netrw_machine= substitute(a:choice,httpurm,'\1',"") 7295 + let b:netrw_fname = substitute(a:choice,httpurm,'\2',"") 7296 + let b:netrw_http = (a:choice =~ '^https:')? "https" : "http" 7297 5666 - 7298 5667 -" --------------------------------------------------------------------- 7299 5668 -" s:ExplorePatHls: converts an Explore pattern into a regular expression search pattern {{{2 … … 7308 5677 - return repat 7309 5678 -endfun 7310 + " Method#6: dav://hostname[:port]/..path-to-file.. {{{3 7311 + elseif match(a:choice,davurm) == 0 7312 +" call Decho("dav://...") 7313 + let b:netrw_method= 6 7314 + if a:choice =~ 'davs:' 7315 + let g:netrw_machine= 'https://'.substitute(a:choice,davurm,'\1/\2',"") 7316 + else 7317 + let g:netrw_machine= 'http://'.substitute(a:choice,davurm,'\1/\2',"") 7318 + endif 7319 + let b:netrw_fname = substitute(a:choice,davurm,'\3',"") 7320 5679 - 7321 5680 -" --------------------------------------------------------------------- 7322 5681 -" s:NetrwBookHistHandler: {{{2 … … 7333 5692 -" " call Dret("s:NetrwBookHistHandler - suppressed due to g:netrw_dirhistmax") 7334 5693 - return 7335 - endif7336 + " Method#7: rsync://user@hostname/...path-to-file {{{37337 + elseif match(a:choice,rsyncurm) == 07338 +" call Decho("rsync://...")7339 + let b:netrw_method = 77340 + let g:netrw_machine= substitute(a:choice,rsyncurm,'\1',"")7341 + let b:netrw_fname = substitute(a:choice,rsyncurm,'\2',"")7342 7343 - let ykeep= @@7344 - if a:chg == 07345 - " bookmark the current directory7346 -" call Decho("(user: <b>) bookmark the current directory")7347 - if !exists("g:netrw_bookmarklist")7348 - let g:netrw_bookmarklist= []7349 - endif7350 - if index(g:netrw_bookmarklist,a:curdir) == -17351 - " curdir not currently in g:netrw_bookmarklist, so include it7352 - call add(g:netrw_bookmarklist,a:curdir)7353 - call sort(g:netrw_bookmarklist)7354 + " Methods 2,3: ftp://[user@]hostname[[:#]port]/...path-to-file {{{37355 + elseif match(a:choice,ftpurm) == 07356 +" call Decho("ftp://...")7357 + let userid = substitute(a:choice,ftpurm,'\2',"")7358 + let g:netrw_machine= substitute(a:choice,ftpurm,'\3',"")7359 + let g:netrw_port = substitute(a:choice,ftpurm,'\4',"")7360 + let b:netrw_fname = substitute(a:choice,ftpurm,'\5',"")7361 +" call Decho("g:netrw_machine<".g:netrw_machine.">")7362 + if userid != ""7363 + let g:netrw_uid= userid7364 endif7365 - echo "bookmarked the current directory"7366 7367 - elseif a:chg == 17368 - " change to the bookmarked directory7369 -" call Decho("(user: <".v:count."gb>) change to the bookmarked directory")7370 - if exists("g:netrw_bookmarklist[v:count-1]")7371 -" call Decho("(user: <".v:count."gb>) bookmarklist=".string(g:netrw_bookmarklist))7372 - exe "keepj e ".fnameescape(g:netrw_bookmarklist[v:count-1])7373 - else7374 - echomsg "Sorry, bookmark#".v:count." doesn't exist!"7375 + if curmachine != g:netrw_machine7376 + if exists("s:netwr_hup[".g:netrw_machine."]")7377 + call NetUserPass("ftp:".g:netrw_machine)7378 + elseif exists("s:netrw_passwd")7379 + " if there's a change in hostname, require password re-entry7380 + unlet s:netrw_passwd7381 + endif7382 + if exists("netrw_port")7383 + unlet netrw_port7384 + endif7385 endif7386 7387 - elseif a:chg == 27388 -" redraw!7389 - let didwork= 07390 - " list user's bookmarks7391 -" call Decho("(user: <q>) list user's bookmarks")7392 - if exists("g:netrw_bookmarklist")7393 -" call Decho('list '.len(g:netrw_bookmarklist).' bookmarks')7394 - let cnt= 17395 - for bmd in g:netrw_bookmarklist7396 -" call Decho("Netrw Bookmark#".cnt.": ".g:netrw_bookmarklist[cnt-1])7397 - echo printf("Netrw Bookmark#%-2d: %s",cnt,g:netrw_bookmarklist[cnt-1])7398 - let didwork = 17399 - let cnt = cnt + 17400 - endfor7401 - endif7402 + if exists("g:netrw_uid") && exists("s:netrw_passwd")7403 + let b:netrw_method = 37404 + else7405 + let host= substitute(g:netrw_machine,'\..*$','','')7406 + if exists("s:netrw_hup[host]")7407 + call NetUserPass("ftp:".host)7408 7409 - " list directory history7410 - let cnt = g:netrw_dirhist_cnt7411 - let first = 17412 - let histcnt = 07413 - if g:netrw_dirhistmax > 07414 - while ( first || cnt != g:netrw_dirhist_cnt )7415 -" call Decho("first=".first." cnt=".cnt." dirhist_cnt=".g:netrw_dirhist_cnt)7416 - if exists("g:netrw_dirhist_{cnt}")7417 -" call Decho("Netrw History#".histcnt.": ".g:netrw_dirhist_{cnt})7418 - echo printf("Netrw History#%-2d: %s",histcnt,g:netrw_dirhist_{cnt})7419 - let didwork= 17420 + elseif (has("win32") || has("win95") || has("win64") || has("win16")) && s:netrw_ftp_cmd =~ '-[sS]:'7421 +" call Decho("has -s: : s:netrw_ftp_cmd<".s:netrw_ftp_cmd.">")7422 +" call Decho(" g:netrw_ftp_cmd<".g:netrw_ftp_cmd.">")7423 + if g:netrw_ftp_cmd =~ '-[sS]:\S*MACHINE\>'7424 + let s:netrw_ftp_cmd= substitute(g:netrw_ftp_cmd,'\<MACHINE\>',g:netrw_machine,'')7425 +" call Decho("s:netrw_ftp_cmd<".s:netrw_ftp_cmd.">")7426 endif7427 - let histcnt = histcnt + 17428 - let first = 07429 - let cnt = ( cnt - 1 ) % g:netrw_dirhistmax7430 - if cnt < 07431 - let cnt= cnt + g:netrw_dirhistmax7432 + let b:netrw_method= 27433 + elseif s:FileReadable(expand("$HOME/.netrc")) && !g:netrw_ignorenetrc7434 +" call Decho("using <".expand("$HOME/.netrc")."> (readable)")7435 + let b:netrw_method= 27436 + else7437 + if !exists("g:netrw_uid") || g:netrw_uid == ""7438 + call NetUserPass()7439 + elseif !exists("s:netrw_passwd") || s:netrw_passwd == ""7440 + call NetUserPass(g:netrw_uid)7441 + " else just use current g:netrw_uid and s:netrw_passwd7442 endif7443 - endwhile7444 - else7445 - let g:netrw_dirhist_cnt= 07446 - endif7447 - if didwork7448 - call inputsave()|call input("Press <cr> to continue")|call inputrestore()7449 - endif7450 -7451 - elseif a:chg == 37452 - " saves most recently visited directories (when they differ)7453 -" call Decho("(browsing) record curdir history")7454 - if !exists("g:netrw_dirhist_cnt") || !exists("g:netrw_dirhist_{g:netrw_dirhist_cnt}") || g:netrw_dirhist_{g:netrw_dirhist_cnt} != a:curdir7455 - if g:netrw_dirhistmax > 07456 - let g:netrw_dirhist_cnt = ( g:netrw_dirhist_cnt + 1 ) % g:netrw_dirhistmax7457 - let g:netrw_dirhist_{g:netrw_dirhist_cnt} = a:curdir7458 + let b:netrw_method= 37459 endif7460 -" call Decho("save dirhist#".g:netrw_dirhist_cnt."<".g:netrw_dirhist_{g:netrw_dirhist_cnt}.">")7461 endif7462 7463 - elseif a:chg == 47464 - " u: change to the previous directory stored on the history list7465 -" call Decho("(user: <u>) chg to prev dir from history")7466 - if g:netrw_dirhistmax > 07467 - let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt - v:count1 ) % g:netrw_dirhistmax7468 - if g:netrw_dirhist_cnt < 07469 - let g:netrw_dirhist_cnt= g:netrw_dirhist_cnt + g:netrw_dirhistmax7470 - endif7471 - else7472 - let g:netrw_dirhist_cnt= 07473 - endif7474 - if exists("g:netrw_dirhist_{g:netrw_dirhist_cnt}")7475 -" call Decho("changedir u#".g:netrw_dirhist_cnt."<".g:netrw_dirhist_{g:netrw_dirhist_cnt}.">")7476 - if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir")7477 - setl ma noro7478 -" call Decho("(NetrwBookHistHandler) setl ma noro")7479 - sil! keepj %d7480 - setl nomod7481 -" call Decho("(NetrwBookHistHandler) setl nomod")7482 -" call Decho("(NetrwBookHistHandler) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")7483 - endif7484 -" " call Decho("exe e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt}))7485 - exe "keepj e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt})7486 - else7487 - if g:netrw_dirhistmax > 07488 - let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt + v:count1 ) % g:netrw_dirhistmax7489 - else7490 - let g:netrw_dirhist_cnt= 07491 - endif7492 - echo "Sorry, no predecessor directory exists yet"7493 + " Method#8: fetch {{{37494 + elseif match(a:choice,fetchurm) == 07495 +" call Decho("fetch://...")7496 + let b:netrw_method = 87497 + let g:netrw_userid = substitute(a:choice,fetchurm,'\2',"")7498 + let g:netrw_machine= substitute(a:choice,fetchurm,'\3',"")7499 + let b:netrw_option = substitute(a:choice,fetchurm,'\4',"")7500 + let b:netrw_fname = substitute(a:choice,fetchurm,'\5',"")7501 +7502 + " Method#3: Issue an ftp : "machine id password [path/]filename" {{{37503 + elseif match(a:choice,mipf) == 07504 +" call Decho("(ftp) host id pass file")7505 + let b:netrw_method = 37506 + let g:netrw_machine = substitute(a:choice,mipf,'\1',"")7507 + let g:netrw_uid = substitute(a:choice,mipf,'\2',"")7508 + let s:netrw_passwd = substitute(a:choice,mipf,'\3',"")7509 + let b:netrw_fname = substitute(a:choice,mipf,'\4',"")7510 + call NetUserPass(g:netrw_machine,g:netrw_uid,s:netrw_passwd)7511 +7512 + " Method#3: Issue an ftp: "hostname [path/]filename" {{{37513 + elseif match(a:choice,mf) == 07514 +" call Decho("(ftp) host file")7515 + if exists("g:netrw_uid") && exists("s:netrw_passwd")7516 + let b:netrw_method = 37517 + let g:netrw_machine = substitute(a:choice,mf,'\1',"")7518 + let b:netrw_fname = substitute(a:choice,mf,'\2',"")7519 +7520 + elseif s:FileReadable(expand("$HOME/.netrc"))7521 + let b:netrw_method = 27522 + let g:netrw_machine = substitute(a:choice,mf,'\1',"")7523 + let b:netrw_fname = substitute(a:choice,mf,'\2',"")7524 endif7525 7526 - elseif a:chg == 57527 - " U: change to the subsequent directory stored on the history list7528 -" call Decho("(user: <U>) chg to next dir from history")7529 - if g:netrw_dirhistmax > 07530 - let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt + 1 ) % g:netrw_dirhistmax7531 - if exists("g:netrw_dirhist_{g:netrw_dirhist_cnt}")7532 -" call Decho("changedir U#".g:netrw_dirhist_cnt."<".g:netrw_dirhist_{g:netrw_dirhist_cnt}.">")7533 - if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir")7534 -" call Decho("(NetrwBookHistHandler) setl ma noro")7535 - setl ma noro7536 - sil! keepj %d7537 -" call Decho("removed all lines from buffer (%d)")7538 -" call Decho("(NetrwBookHistHandler) setl nomod")7539 - setl nomod7540 -" call Decho("(set nomod) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")7541 - endif7542 -" call Decho("exe e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt}))7543 - exe "keepj e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt})7544 - else7545 - let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt - 1 ) % g:netrw_dirhistmax7546 - if g:netrw_dirhist_cnt < 07547 - let g:netrw_dirhist_cnt= g:netrw_dirhist_cnt + g:netrw_dirhistmax7548 - endif7549 - echo "Sorry, no successor directory exists yet"7550 - endif7551 - else7552 - let g:netrw_dirhist_cnt= 07553 - echo "Sorry, no successor directory exists yet (g:netrw_dirhistmax is ".g:netrw_dirhistmax.")"7554 + " Method#9: sftp://user@hostname/...path-to-file {{{37555 + elseif match(a:choice,sftpurm) == 07556 +" call Decho("sftp://...")7557 + let b:netrw_method = 97558 + let g:netrw_machine= substitute(a:choice,sftpurm,'\1',"")7559 + let b:netrw_fname = substitute(a:choice,sftpurm,'\2',"")7560 +7561 + " Method#1: Issue an rcp: hostname:filename" (this one should be last) {{{37562 + elseif match(a:choice,rcphf) == 07563 +" call Decho("(rcp) [user@]host:file) rcphf<".rcphf.">")7564 + let b:netrw_method = 17565 + let userid = substitute(a:choice,rcphf,'\2',"")7566 + let g:netrw_machine = substitute(a:choice,rcphf,'\3',"")7567 + let b:netrw_fname = substitute(a:choice,rcphf,'\4',"")7568 +" call Decho('\1<'.substitute(a:choice,rcphf,'\1',"").">")7569 +" call Decho('\2<'.substitute(a:choice,rcphf,'\2',"").">")7570 +" call Decho('\3<'.substitute(a:choice,rcphf,'\3',"").">")7571 +" call Decho('\4<'.substitute(a:choice,rcphf,'\4',"").">")7572 + if userid != ""7573 + let g:netrw_uid= userid7574 endif7575 7576 - elseif a:chg == 67577 - " delete the v:count'th bookmark7578 -" call Decho("delete bookmark#".v:count."<".g:netrw_bookmarklist[v:count-1].">")7579 - let savefile= s:NetrwHome()."/.netrwbook"7580 - if filereadable(savefile)7581 -" call Decho("merge bookmarks (active and file)")7582 - keepj call s:NetrwBookHistSave() " done here to merge bookmarks first7583 -" call Decho("bookmark delete savefile<".savefile.">")7584 - keepj call delete(savefile)7585 + " Cannot Determine Method {{{37586 + else7587 + if !exists("g:netrw_quiet")7588 + call netrw#ErrorMsg(s:WARNING,"cannot determine method (format: protocol://[user@]hostname[:port]/[path])",45)7589 endif7590 -" call Decho("remove g:netrw_bookmarklist[".(v:count-1)."]")7591 - keepj call remove(g:netrw_bookmarklist,v:count-1)7592 -" call Decho("resulting g:netrw_bookmarklist=".string(g:netrw_bookmarklist))7593 + let b:netrw_method = -17594 endif7595 - call s:NetrwBookmarkMenu()7596 - call s:NetrwTgtMenu()7597 - let @@= ykeep7598 -" call Dret("s:NetrwBookHistHandler")7599 -endfun7600 + "}}}37601 7602 -" ---------------------------------------------------------------------7603 -" s:NetrwBookHistRead: this function reads bookmarks and history {{{27604 -" Sister function: s:NetrwBookHistSave()7605 -fun! s:NetrwBookHistRead()7606 -" call Dfunc("s:NetrwBookHistRead()")7607 - if !exists("g:netrw_dirhistmax") || g:netrw_dirhistmax <= 07608 -" " call Dret("s:NetrwBookHistRead - suppressed due to g:netrw_dirhistmax")7609 - return7610 + if g:netrw_port != ""7611 + " remove any leading [:#] from port number7612 + let g:netrw_port = substitute(g:netrw_port,'[#:]\+','','')7613 + elseif exists("netrw_port")7614 + " retain port number as implicit for subsequent ftp operations7615 + let g:netrw_port= netrw_port7616 endif7617 - let ykeep= @@7618 - if !exists("s:netrw_initbookhist")7619 - let home = s:NetrwHome()7620 - let savefile= home."/.netrwbook"7621 - if filereadable(savefile)7622 -" call Decho("sourcing .netrwbook")7623 - exe "keepalt keepj so ".savefile7624 +7625 +" call Decho("a:choice <".a:choice.">")7626 +" call Decho("b:netrw_method <".b:netrw_method.">")7627 +" call Decho("g:netrw_machine<".g:netrw_machine.">")7628 +" call Decho("g:netrw_port <".g:netrw_port.">")7629 +" if exists("g:netrw_uid") "Decho7630 +" call Decho("g:netrw_uid <".g:netrw_uid.">")7631 +" endif "Decho7632 +" if exists("s:netrw_passwd") "Decho7633 +" call Decho("s:netrw_passwd <".s:netrw_passwd.">")7634 +" endif "Decho7635 +" call Decho("b:netrw_fname <".b:netrw_fname.">")7636 +" call Dret("NetrwMethod : b:netrw_method=".b:netrw_method." g:netrw_port=".g:netrw_port)7637 +endfun7638 +7639 +" ------------------------------------------------------------------------7640 +" NetReadFixup: this sort of function is typically written by the user {{{27641 +" to handle extra junk that their system's ftp dumps7642 +" into the transfer. This function is provided as an7643 +" example and as a fix for a Windows 95 problem: in my7644 +" experience, win95's ftp always dumped four blank lines7645 +" at the end of the transfer.7646 +if has("win95") && exists("g:netrw_win95ftp") && g:netrw_win95ftp7647 + fun! NetReadFixup(method, line1, line2)7648 +" call Dfunc("NetReadFixup(method<".a:method."> line1=".a:line1." line2=".a:line2.")")7649 +7650 + " sanity checks -- attempt to convert inputs to integers7651 + let method = a:method + 07652 + let line1 = a:line1 + 07653 + let line2 = a:line2 + 07654 + if type(method) != 0 || type(line1) != 0 || type(line2) != 0 || method < 0 || line1 <= 0 || line2 <= 07655 +" call Dret("NetReadFixup")7656 + return7657 endif7658 - if g:netrw_dirhistmax > 07659 - let savefile= home."/.netrwhist"7660 - if filereadable(savefile)7661 -" call Decho("sourcing .netrwhist")7662 - exe "keepalt keepj so ".savefile7663 +7664 + if method == 3 " ftp (no <.netrc>)7665 + let fourblanklines= line2 - 37666 + if fourblanklines >= line17667 + exe "sil keepj ".fourblanklines.",".line2."g/^\s*$/d"7668 + call histdel("/",-1)7669 endif7670 - let s:netrw_initbookhist= 17671 - au VimLeave * call s:NetrwBookHistSave()7672 endif7673 - endif7674 - let @@= ykeep7675 -" call Dret("s:NetrwBookHistRead")7676 -endfun7677 +7678 +" call Dret("NetReadFixup")7679 + endfun7680 +endif7681 7682 " ---------------------------------------------------------------------7683 -" s:NetrwBookHistSave: this function saves bookmarks and history {{{27684 -" Sister function: s:NetrwBookHistRead()7685 -" I used to do this via viminfo but that appears to7686 -" be unreliable for long-term storage7687 -fun! s:NetrwBookHistSave()7688 -" call Dfunc("s:NetrwBookHistSave() dirhistmax=".g:netrw_dirhistmax)7689 - if !exists("g:netrw_dirhistmax") || g:netrw_dirhistmax <= 07690 -" call Dret("s:NetrwBookHistSave : dirhistmax=".g:netrw_dirhistmax)7691 - return7692 - endif7693 +" NetUserPass: set username and password for subsequent ftp transfer {{{27694 +" Usage: :call NetUserPass() -- will prompt for userid and password7695 +" :call NetUserPass("uid") -- will prompt for password7696 +" :call NetUserPass("uid","password") -- sets global userid and password7697 +" :call NetUserPass("ftp:host") -- looks up userid and password using hup dictionary7698 +" :call NetUserPass("host","uid","password") -- sets hup dictionary with host, userid, password7699 +fun! NetUserPass(...)7700 7701 - let savefile= s:NetrwHome()."/.netrwhist"7702 - 1split7703 - call s:NetrwEnew()7704 - setl cino= com= cpo-=a cpo-=A fo=nroql2 tw=0 report=10000 noswf7705 - setl nocin noai noci magic nospell nohid wig= noaw7706 - setl ma noro write7707 - if exists("+acd") | setl noacd | endif7708 - sil! keepj keepalt %d7709 +" call Dfunc("NetUserPass() a:0=".a:0)7710 7711 - " save .netrwhist -- no attempt to merge7712 - sil! keepalt file .netrwhist7713 - call setline(1,"let g:netrw_dirhistmax =".g:netrw_dirhistmax)7714 - call setline(2,"let g:netrw_dirhist_cnt =".g:netrw_dirhist_cnt)7715 - let lastline = line("$")7716 - let cnt = 17717 - while cnt <= g:netrw_dirhist_cnt7718 - call setline((cnt+lastline),'let g:netrw_dirhist_'.cnt."='".g:netrw_dirhist_{cnt}."'")7719 - let cnt= cnt + 17720 - endwhile7721 - exe "sil! w! ".savefile7722 + if !exists('s:netrw_hup')7723 + let s:netrw_hup= {}7724 + endif7725 7726 - sil keepj %d7727 - if exists("g:netrw_bookmarklist") && g:netrw_bookmarklist != []7728 - " merge and write .netrwbook7729 - let savefile= s:NetrwHome()."/.netrwbook"7730 + if a:0 == 07731 + " case: no input arguments7732 7733 - if filereadable(savefile)7734 - let booklist= deepcopy(g:netrw_bookmarklist)7735 - exe "sil keepj keepalt so ".savefile7736 - for bdm in booklist7737 - if index(g:netrw_bookmarklist,bdm) == -17738 - call add(g:netrw_bookmarklist,bdm)7739 - endif7740 - endfor7741 - call sort(g:netrw_bookmarklist)7742 - exe "sil! w! ".savefile7743 - endif7744 + " change host and username if not previously entered; get new password7745 + if !exists("g:netrw_machine")7746 + let g:netrw_machine= input('Enter hostname: ')7747 + endif7748 + if !exists("g:netrw_uid") || g:netrw_uid == ""7749 + " get username (user-id) via prompt7750 + let g:netrw_uid= input('Enter username: ')7751 + endif7752 + " get password via prompting7753 + let s:netrw_passwd= inputsecret("Enter Password: ")7754 7755 - " construct and save .netrwbook7756 - call setline(1,"let g:netrw_bookmarklist= ".string(g:netrw_bookmarklist))7757 - exe "sil! w! ".savefile7758 + " set up hup database7759 + let host = substitute(g:netrw_machine,'\..*$','','')7760 + if !exists('s:netrw_hup[host]')7761 + let s:netrw_hup[host]= {}7762 endif7763 - let bgone= bufnr("%")7764 - q!7765 - exe "keepalt ".bgone."bwipe!"7766 + let s:netrw_hup[host].uid = g:netrw_uid7767 + let s:netrw_hup[host].passwd = s:netrw_passwd7768 7769 -" call Dret("s:NetrwBookHistSave")7770 -endfun7771 + elseif a:0 == 17772 + " case: one input argument7773 7774 -" ---------------------------------------------------------------------7775 -" s:NetrwBrowse: This function uses the command in g:netrw_list_cmd to provide a {{{27776 -" list of the contents of a local or remote directory. It is assumed that the7777 -" g:netrw_list_cmd has a string, USEPORT HOSTNAME, that needs to be substituted7778 -" with the requested remote hostname first.7779 -fun! s:NetrwBrowse(islocal,dirname)7780 - if !exists("w:netrw_liststyle")|let w:netrw_liststyle= g:netrw_liststyle|endif7781 -" call Dfunc("s:NetrwBrowse(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".w:netrw_liststyle." ".g:loaded_netrw." buf#".bufnr("%")."<".bufname("%")."> win#".winnr())7782 -" call Decho("(NetrwBrowse) tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")." modified=".&modified." modifiable=".&modifiable." readonly=".&readonly)7783 - " s:NetrwBrowse: initialize history {{{37784 - if !exists("s:netrw_initbookhist")7785 - keepj call s:NetrwBookHistRead()7786 - endif7787 + if a:1 =~ '^ftp:'7788 + " get host from ftp:... url7789 + " access userid and password from hup (host-user-passwd) dictionary7790 +" call Decho("case a:0=1: a:1<".a:1."> (get host from ftp:... url)")7791 + let host = substitute(a:1,'^ftp:','','')7792 + let host = substitute(host,'\..*','','')7793 + if exists("s:netrw_hup[host]")7794 + let g:netrw_uid = s:netrw_hup[host].uid7795 + let s:netrw_passwd = s:netrw_hup[host].passwd7796 +" call Decho("get s:netrw_hup[".host."].uid <".s:netrw_hup[host].uid.">")7797 +" call Decho("get s:netrw_hup[".host."].passwd<".s:netrw_hup[host].passwd.">")7798 + else7799 + let g:netrw_uid = input("Enter UserId: ")7800 + let s:netrw_passwd = inputsecret("Enter Password: ")7801 + endif7802 7803 - " s:NetrwBrowse: simplify the dirname (especially for ".."s in dirnames) {{{37804 - if a:dirname !~ '^\a\+://'7805 - let dirname= simplify(a:dirname)7806 else7807 - let dirname= a:dirname7808 - endif7809 -7810 - if exists("s:netrw_skipbrowse")7811 - unlet s:netrw_skipbrowse7812 -" call Decho("(NetrwBrowse) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")7813 -" call Dret("s:NetrwBrowse : s:netrw_skipbrowse=".s:netrw_skipbrowse)7814 - return7815 + " case: one input argument, not an url. Using it as a new user-id.7816 +" call Decho("case a:0=1: a:1<".a:1."> (get host from input argument, not an url)")7817 + if exists("g:netrw_machine")7818 + if g:netrw_machine =~ '[0-9.]\+'7819 + let host= g:netrw_machine7820 + else7821 + let host= substitute(g:netrw_machine,'\..*$','','')7822 + endif7823 + else7824 + let g:netrw_machine= input('Enter hostname: ')7825 + endif7826 + let g:netrw_uid = a:17827 +" call Decho("set g:netrw_uid= <".g:netrw_uid.">")7828 + if exists("g:netrw_passwd")7829 + " ask for password if one not previously entered7830 + let s:netrw_passwd= g:netrw_passwd7831 + else7832 + let s:netrw_passwd = inputsecret("Enter Password: ")7833 + endif7834 endif7835 7836 - " s:NetrwBrowse: sanity checks: {{{37837 - if !exists("*shellescape")7838 - keepj call netrw#ErrorMsg(s:ERROR,"netrw can't run -- your vim is missing shellescape()",69)7839 -" call Dret("s:NetrwBrowse : missing shellescape()")7840 - return7841 - endif7842 - if !exists("*fnameescape")7843 - keepj call netrw#ErrorMsg(s:ERROR,"netrw can't run -- your vim is missing fnameescape()",70)7844 -" call Dret("s:NetrwBrowse : missing fnameescape()")7845 - return7846 +" call Decho("host<".host.">")7847 + if exists("host")7848 + if !exists('s:netrw_hup[host]')7849 + let s:netrw_hup[host]= {}7850 + endif7851 + let s:netrw_hup[host].uid = g:netrw_uid7852 + let s:netrw_hup[host].passwd = s:netrw_passwd7853 endif7854 7855 - " s:NetrwBrowse: save options: {{{37856 - call s:NetrwOptionSave("w:")7857 + elseif a:0 == 27858 + let g:netrw_uid = a:17859 + let s:netrw_passwd = a:27860 7861 - " s:NetrwBrowse: re-instate any marked files {{{37862 - if exists("s:netrwmarkfilelist_{bufnr('%')}")7863 -" call Decho("(NetrwBrowse) clearing marked files")7864 - exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/"7865 + elseif a:0 == 37866 + " enter hostname, user-id, and password into the hup dictionary7867 + let host = substitute(a:1,'^\a\+:','','')7868 + let host = substitute(host,'\..*$','','')7869 + if !exists('s:netrw_hup[host]')7870 + let s:netrw_hup[host]= {}7871 endif7872 + let s:netrw_hup[host].uid = a:27873 + let s:netrw_hup[host].passwd = a:37874 + let g:netrw_uid = s:netrw_hup[host].uid7875 + let s:netrw_passwd = s:netrw_hup[host].passwd7876 +" call Decho("set s:netrw_hup[".host."].uid <".s:netrw_hup[host].uid.">")7877 +" call Decho("set s:netrw_hup[".host."].passwd<".s:netrw_hup[host].passwd.">")7878 + endif7879 7880 - if a:islocal && exists("w:netrw_acdkeep") && w:netrw_acdkeep7881 - " s:NetrwBrowse: set up "safe" options for local directory/file {{{37882 -" call Decho("(NetrwBrowse) handle w:netrw_acdkeep:")7883 -" call Decho("(NetrwBrowse) keepjumps lcd ".fnameescape(dirname)." (due to w:netrw_acdkeep=".w:netrw_acdkeep." - acd=".&acd.")")7884 - exe 'keepj lcd '.fnameescape(dirname)7885 - call s:NetrwSafeOptions()7886 -" call Decho("(NetrwBrowse) getcwd<".getcwd().">")7887 +" call Dret("NetUserPass : uid<".g:netrw_uid."> passwd<".s:netrw_passwd.">")7888 +endfun7889 7890 - elseif !a:islocal && dirname !~ '[\/]$' && dirname !~ '^"'7891 - " s:NetrwBrowse: looks like a remote regular file, attempt transfer {{{37892 -" call Decho("(NetrwBrowse) attempt transfer as regular file<".dirname.">")7893 +" ===========================================7894 +" Shared Browsing Support: {{{17895 +" ===========================================7896 7897 - " remove any filetype indicator from end of dirname, except for the7898 - " "this is a directory" indicator (/).7899 - " There shouldn't be one of those here, anyway.7900 - let path= substitute(dirname,'[*=@|]\r\=$','','e')7901 -" call Decho("(NetrwBrowse) new path<".path.">")7902 - call s:RemotePathAnalysis(dirname)7903 -7904 - " s:NetrwBrowse: remote-read the requested file into current buffer {{{37905 - keepj mark '7906 - call s:NetrwEnew(dirname)7907 - call s:NetrwSafeOptions()7908 - setl ma noro7909 -" call Decho("(NetrwBrowse) setl ma noro")7910 - let b:netrw_curdir = dirname7911 - let url = s:method."://".s:user.s:machine.(s:port ? ":".s:port : "")."/".s:path7912 -" call Decho("(NetrwBrowse) exe sil! keepalt file ".fnameescape(url)." (bt=".&bt.")")7913 - exe "sil! keepj keepalt file ".fnameescape(url)7914 - exe "sil! keepj keepalt doau BufReadPre ".fnameescape(s:fname)7915 - sil call netrw#NetRead(2,url)7916 - if s:path !~ '.tar.bz2$' && s:path !~ '.tar.gz' && s:path !~ '.tar.xz' && s:path !~ '.txz'7917 - " netrw.vim and tar.vim have already handled decompression of the tarball; avoiding gzip.vim error7918 - exe "sil keepj keepalt doau BufReadPost ".fnameescape(s:fname)7919 - endif7920 -7921 - " s:NetrwBrowse: save certain window-oriented variables into buffer-oriented variables {{{37922 - call s:SetBufWinVars()7923 - call s:NetrwOptionRestore("w:")7924 -" call Decho("(NetrwBrowse) setl ma nomod")7925 - setl ma nomod7926 -" call Decho("(NetrwBrowse) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")7927 +" ---------------------------------------------------------------------7928 +" s:ExplorePatHls: converts an Explore pattern into a regular expression search pattern {{{27929 +fun! s:ExplorePatHls(pattern)7930 +" call Dfunc("s:ExplorePatHls(pattern<".a:pattern.">)")7931 + let repat= substitute(a:pattern,'^**/\{1,2}','','')7932 +" call Decho("repat<".repat.">")7933 + let repat= escape(repat,'][.\')7934 +" call Decho("repat<".repat.">")7935 + let repat= '\<'.substitute(repat,'\*','\\(\\S\\+ \\)*\\S\\+','g').'\>'7936 +" call Dret("s:ExplorePatHls repat<".repat.">")7937 + return repat7938 +endfun7939 7940 -" call Dret("s:NetrwBrowse : file<".s:fname.">")7941 5694 +" --------------------------------------------------------------------- 7942 5695 +" s:NetrwBookHistHandler: {{{2 … … 7952 5705 + if !exists("g:netrw_dirhistmax") || g:netrw_dirhistmax <= 0 7953 5706 +" " call Dret("s:NetrwBookHistHandler - suppressed due to g:netrw_dirhistmax") 5707 + return 5708 endif 5709 5710 let ykeep= @@ 5711 @@ -3338,13 +3266,13 @@ 5712 " call Decho("changedir u#".g:netrw_dirhist_cnt."<".g:netrw_dirhist_{g:netrw_dirhist_cnt}.">") 5713 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir") 5714 setl ma noro 5715 -" call Decho("(NetrwBookHistHandler) setl ma noro") 5716 +" call Decho("setl ma noro") 5717 sil! keepj %d 5718 setl nomod 5719 -" call Decho("(NetrwBookHistHandler) setl nomod") 5720 -" call Decho("(NetrwBookHistHandler) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 5721 +" call Decho("setl nomod") 5722 +" call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 5723 endif 5724 -" " call Decho("exe e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt})) 5725 +" call Decho("exe e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt})) 5726 exe "keepj e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt}) 5727 else 5728 if g:netrw_dirhistmax > 0 5729 @@ -3363,11 +3291,11 @@ 5730 if exists("g:netrw_dirhist_{g:netrw_dirhist_cnt}") 5731 " call Decho("changedir U#".g:netrw_dirhist_cnt."<".g:netrw_dirhist_{g:netrw_dirhist_cnt}.">") 5732 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir") 5733 -" call Decho("(NetrwBookHistHandler) setl ma noro") 5734 +" call Decho("setl ma noro") 5735 setl ma noro 5736 sil! keepj %d 5737 " call Decho("removed all lines from buffer (%d)") 5738 -" call Decho("(NetrwBookHistHandler) setl nomod") 5739 +" call Decho("setl nomod") 5740 setl nomod 5741 " call Decho("(set nomod) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 5742 endif 5743 @@ -3505,7 +3433,9 @@ 5744 fun! s:NetrwBrowse(islocal,dirname) 5745 if !exists("w:netrw_liststyle")|let w:netrw_liststyle= g:netrw_liststyle|endif 5746 " call Dfunc("s:NetrwBrowse(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".w:netrw_liststyle." ".g:loaded_netrw." buf#".bufnr("%")."<".bufname("%")."> win#".winnr()) 5747 -" call Decho("(NetrwBrowse) tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")." modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) 5748 +" call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")." modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) 5749 +" call Dredir("ls!") 5750 + 5751 " s:NetrwBrowse: initialize history {{{3 5752 if !exists("s:netrw_initbookhist") 5753 keepj call s:NetrwBookHistRead() 5754 @@ -3520,8 +3450,8 @@ 5755 5756 if exists("s:netrw_skipbrowse") 5757 unlet s:netrw_skipbrowse 5758 -" call Decho("(NetrwBrowse) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 5759 -" call Dret("s:NetrwBrowse : s:netrw_skipbrowse=".s:netrw_skipbrowse) 5760 +" call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." filename<".expand("%")."> win#".winnr()." ft<".&ft.">") 5761 +" call Dret("s:NetrwBrowse : s:netrw_skipbrowse existed") 7954 5762 return 7955 5763 endif 7956 5764 7957 - " use buffer-oriented WinVars if buffer variables exist but associated window variables don't {{{3 7958 - call s:UseBufWinVars() 7959 - 7960 - " set up some variables {{{3 7961 - let b:netrw_browser_active = 1 7962 - let dirname = dirname 7963 - let s:last_sort_by = g:netrw_sort_by 7964 - 7965 - " set up menu {{{3 7966 - keepj call s:NetrwMenu(1) 7967 - 7968 - " get/set-up buffer {{{3 7969 - let reusing= s:NetrwGetBuffer(a:islocal,dirname) 7970 - " maintain markfile highlighting 7971 - if exists("s:netrwmarkfilemtch_{bufnr('%')}") && s:netrwmarkfilemtch_{bufnr("%")} != "" 5765 @@ -3542,27 +3472,27 @@ 5766 5767 " s:NetrwBrowse: re-instate any marked files {{{3 5768 if exists("s:netrwmarkfilelist_{bufnr('%')}") 5769 -" call Decho("(NetrwBrowse) clearing marked files") 5770 +" call Decho("clearing marked files") 5771 exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/" 5772 endif 5773 5774 if a:islocal && exists("w:netrw_acdkeep") && w:netrw_acdkeep 5775 " s:NetrwBrowse: set up "safe" options for local directory/file {{{3 5776 -" call Decho("(NetrwBrowse) handle w:netrw_acdkeep:") 5777 -" call Decho("(NetrwBrowse) keepjumps lcd ".fnameescape(dirname)." (due to w:netrw_acdkeep=".w:netrw_acdkeep." - acd=".&acd.")") 5778 - exe 'keepj lcd '.fnameescape(dirname) 5779 +" call Decho("handle w:netrw_acdkeep:") 5780 +" call Decho("keepjumps lcd ".fnameescape(dirname)." (due to w:netrw_acdkeep=".w:netrw_acdkeep." - acd=".&acd.")") 5781 + call s:NetrwLcd(dirname) 5782 call s:NetrwSafeOptions() 5783 -" call Decho("(NetrwBrowse) getcwd<".getcwd().">") 5784 +" call Decho("getcwd<".getcwd().">") 5785 5786 elseif !a:islocal && dirname !~ '[\/]$' && dirname !~ '^"' 5787 " s:NetrwBrowse: looks like a remote regular file, attempt transfer {{{3 5788 -" call Decho("(NetrwBrowse) attempt transfer as regular file<".dirname.">") 5789 +" call Decho("attempt transfer as regular file<".dirname.">") 5790 5791 " remove any filetype indicator from end of dirname, except for the 5792 " "this is a directory" indicator (/). 5793 " There shouldn't be one of those here, anyway. 5794 let path= substitute(dirname,'[*=@|]\r\=$','','e') 5795 -" call Decho("(NetrwBrowse) new path<".path.">") 5796 +" call Decho("new path<".path.">") 5797 call s:RemotePathAnalysis(dirname) 5798 5799 " s:NetrwBrowse: remote-read the requested file into current buffer {{{3 5800 @@ -3570,24 +3500,33 @@ 5801 call s:NetrwEnew(dirname) 5802 call s:NetrwSafeOptions() 5803 setl ma noro 5804 -" call Decho("(NetrwBrowse) setl ma noro") 5805 +" call Decho("setl ma noro") 5806 let b:netrw_curdir = dirname 5807 let url = s:method."://".s:user.s:machine.(s:port ? ":".s:port : "")."/".s:path 5808 -" call Decho("(NetrwBrowse) exe sil! keepalt file ".fnameescape(url)." (bt=".&bt.")") 5809 +" call Decho("exe sil! keepalt file ".fnameescape(url)." (bt=".&bt.")") 5810 exe "sil! keepj keepalt file ".fnameescape(url) 5811 exe "sil! keepj keepalt doau BufReadPre ".fnameescape(s:fname) 5812 sil call netrw#NetRead(2,url) 5813 - if s:path !~ '.tar.bz2$' && s:path !~ '.tar.gz' && s:path !~ '.tar.xz' && s:path !~ '.txz' 5814 - " netrw.vim and tar.vim have already handled decompression of the tarball; avoiding gzip.vim error 5815 + " netrw.vim and tar.vim have already handled decompression of the tarball; avoiding gzip.vim error 5816 +" call Decho("url<".url.">") 5817 +" call Decho("s:path<".s:path.">") 5818 +" call Decho("s:fname<".s:fname.">") 5819 + if s:path =~ '.bz2' 5820 + exe "sil keepj keepalt doau BufReadPost ".fnameescape(substitute(s:fname,'\.bz2$','','')) 5821 + elseif s:path =~ '.gz' 5822 + exe "sil keepj keepalt doau BufReadPost ".fnameescape(substitute(s:fname,'\.gz$','','')) 5823 + elseif s:path =~ '.gz' 5824 + exe "sil keepj keepalt doau BufReadPost ".fnameescape(substitute(s:fname,'\.txz$','','')) 5825 + else 5826 exe "sil keepj keepalt doau BufReadPost ".fnameescape(s:fname) 5827 endif 5828 5829 " s:NetrwBrowse: save certain window-oriented variables into buffer-oriented variables {{{3 5830 call s:SetBufWinVars() 5831 call s:NetrwOptionRestore("w:") 5832 -" call Decho("(NetrwBrowse) setl ma nomod") 5833 +" call Decho("setl ma nomod") 5834 setl ma nomod 5835 -" call Decho("(NetrwBrowse) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 5836 +" call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 5837 5838 " call Dret("s:NetrwBrowse : file<".s:fname.">") 5839 return 5840 @@ -3608,28 +3547,31 @@ 5841 let reusing= s:NetrwGetBuffer(a:islocal,dirname) 5842 " maintain markfile highlighting 5843 if exists("s:netrwmarkfilemtch_{bufnr('%')}") && s:netrwmarkfilemtch_{bufnr("%")} != "" 7972 5844 -" call Decho("(NetrwBrowse) bufnr(%)=".bufnr('%')) 7973 5845 -" call Decho("(NetrwBrowse) exe 2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/") 7974 - exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/" 7975 - else 5846 +" call Decho("bufnr(%)=".bufnr('%')) 5847 +" call Decho("exe 2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/") 5848 exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/" 5849 else 7976 5850 -" call Decho("(NetrwBrowse) 2match none") 7977 - 2match none 7978 - endif 7979 - if reusing && line("$") > 1 7980 - call s:NetrwOptionRestore("w:") 5851 +" call Decho("2match none") 5852 2match none 5853 endif 5854 if reusing && line("$") > 1 5855 call s:NetrwOptionRestore("w:") 7981 5856 -" call Decho("(NetrwBrowse) setl noma nomod nowrap") 7982 - setl noma nomod nowrap 5857 +" call Decho("setl noma nomod nowrap") 5858 setl noma nomod nowrap 7983 5859 -" call Decho("(NetrwBrowse) (set noma nomod nowrap) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 7984 -" call Dret("s:NetrwBrowse : re-using buffer") 7985 - return 7986 - endif 7987 + let ykeep= @@ 7988 + if a:chg == 0 7989 + " bookmark the current directory 7990 +" call Decho("(user: <b>) bookmark the current directory") 7991 + if !exists("g:netrw_bookmarklist") 7992 + let g:netrw_bookmarklist= [] 7993 + endif 7994 + if index(g:netrw_bookmarklist,a:curdir) == -1 7995 + " curdir not currently in g:netrw_bookmarklist, so include it 7996 + call add(g:netrw_bookmarklist,a:curdir) 7997 + call sort(g:netrw_bookmarklist) 7998 + endif 7999 + echo "bookmarked the current directory" 8000 8001 - " set b:netrw_curdir to the new directory name {{{3 5860 +" call Decho("(set noma nomod nowrap) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 5861 " call Dret("s:NetrwBrowse : re-using buffer") 5862 return 5863 endif 5864 5865 " set b:netrw_curdir to the new directory name {{{3 8002 5866 -" call Decho("(NetrwBrowse) set b:netrw_curdir to the new directory name: (buf#".bufnr("%").")") 8003 - let b:netrw_curdir= dirname 8004 - if b:netrw_curdir =~ '[/\\]$' 8005 - let b:netrw_curdir= substitute(b:netrw_curdir,'[/\\]$','','e') 8006 - endif 8007 - if b:netrw_curdir == '' 8008 - if has("amiga") 8009 - " On the Amiga, the empty string connotes the current directory 8010 - let b:netrw_curdir= getcwd() 8011 + elseif a:chg == 1 8012 + " change to the bookmarked directory 8013 +" call Decho("(user: <".v:count."gb>) change to the bookmarked directory") 8014 + if exists("g:netrw_bookmarklist[v:count-1]") 8015 +" call Decho("(user: <".v:count."gb>) bookmarklist=".string(g:netrw_bookmarklist)) 8016 + exe "keepj e ".fnameescape(g:netrw_bookmarklist[v:count-1]) 8017 else 8018 - " under unix, when the root directory is encountered, the result 8019 - " from the preceding substitute is an empty string. 8020 - let b:netrw_curdir= '/' 8021 + echomsg "Sorry, bookmark#".v:count." doesn't exist!" 8022 endif 8023 - endif 8024 - if !a:islocal && b:netrw_curdir !~ '/$' 8025 - let b:netrw_curdir= b:netrw_curdir.'/' 8026 - endif 5867 +" call Decho("set b:netrw_curdir to the new directory name<".dirname."> (buf#".bufnr("%").")") 5868 let b:netrw_curdir= dirname 5869 if b:netrw_curdir =~ '[/\\]$' 5870 let b:netrw_curdir= substitute(b:netrw_curdir,'[/\\]$','','e') 5871 endif 5872 + if b:netrw_curdir =~ '\a:$' && (has("win32") || has("win95") || has("win64") || has("win16")) 5873 + let b:netrw_curdir= b:netrw_curdir."/" 5874 + endif 5875 if b:netrw_curdir == '' 5876 if has("amiga") 5877 " On the Amiga, the empty string connotes the current directory 5878 @@ -3643,39 +3585,23 @@ 5879 if !a:islocal && b:netrw_curdir !~ '/$' 5880 let b:netrw_curdir= b:netrw_curdir.'/' 5881 endif 8027 5882 -" call Decho("(NetrwBrowse) b:netrw_curdir<".b:netrw_curdir.">") 8028 - 8029 - " ------------ 8030 - " (local only) {{{3 8031 - " ------------ 8032 - if a:islocal 5883 +" call Decho("b:netrw_curdir<".b:netrw_curdir.">") 5884 5885 " ------------ 5886 " (local only) {{{3 5887 " ------------ 5888 if a:islocal 8033 5889 -" call Decho("(NetrwBrowse) local only:") 8034 - 8035 - " Set up ShellCmdPost handling. Append current buffer to browselist 8036 - call s:LocalFastBrowser() 8037 8038 - " handle g:netrw_keepdir: set vim's current directory to netrw's notion of the current directory {{{3 8039 - if !g:netrw_keepdir 5890 +" call Decho("local only:") 5891 5892 " Set up ShellCmdPost handling. Append current buffer to browselist 5893 call s:LocalFastBrowser() 5894 5895 " handle g:netrw_keepdir: set vim's current directory to netrw's notion of the current directory {{{3 5896 if !g:netrw_keepdir 8040 5897 -" call Decho("(NetrwBrowse) handle g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd) 8041 5898 -" call Decho("(NetrwBrowse) l:acd".(exists("&l:acd")? "=".&l:acd : " doesn't exist")) 8042 - if !exists("&l:acd") || !&l:acd 5899 +" call Decho("handle g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd) 5900 +" call Decho("l:acd".(exists("&l:acd")? "=".&l:acd : " doesn't exist")) 5901 if !exists("&l:acd") || !&l:acd 8043 5902 -" call Decho('exe keepjumps lcd '.fnameescape(b:netrw_curdir)) 8044 5903 - try … … 8058 5917 - endif 8059 5918 - endtry 8060 - endif 8061 + elseif a:chg == 2 8062 +" redraw! 8063 + let didwork= 0 8064 + " list user's bookmarks 8065 +" call Decho("(user: <q>) list user's bookmarks") 8066 + if exists("g:netrw_bookmarklist") 8067 +" call Decho('list '.len(g:netrw_bookmarklist).' bookmarks') 8068 + let cnt= 1 8069 + for bmd in g:netrw_bookmarklist 8070 +" call Decho("Netrw Bookmark#".cnt.": ".g:netrw_bookmarklist[cnt-1]) 8071 + echo printf("Netrw Bookmark#%-2d: %s",cnt,g:netrw_bookmarklist[cnt-1]) 8072 + let didwork = 1 8073 + let cnt = cnt + 1 8074 + endfor 5919 + call s:NetrwLcd(b:netrw_curdir) 5920 endif 8075 5921 endif 8076 5922 8077 - " -------------------------------- 8078 -" remote handling: {{{38079 -" --------------------------------8080 -else5923 @@ -3683,23 +3609,23 @@ 5924 " remote handling: {{{3 5925 " -------------------------------- 5926 else 8081 5927 -" call Decho("(NetrwBrowse) remote only:") 8082 - 8083 - " analyze dirname and g:netrw_list_cmd {{{3 5928 +" call Decho("remote only:") 5929 5930 " analyze dirname and g:netrw_list_cmd {{{3 8084 5931 -" call Decho("(NetrwBrowse) b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "doesn't exist")."> dirname<".dirname.">") 8085 - if dirname =~ "^NetrwTreeListing\>" 8086 - let dirname= b:netrw_curdir 5932 +" call Decho("b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "doesn't exist")."> dirname<".dirname.">") 5933 if dirname =~ "^NetrwTreeListing\>" 5934 let dirname= b:netrw_curdir 8087 5935 -" call Decho("(NetrwBrowse) (dirname was <NetrwTreeListing>) dirname<".dirname.">") 8088 - elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir") 8089 - let dirname= substitute(b:netrw_curdir,'\\','/','g') 8090 - if dirname !~ '/$' 8091 - let dirname= dirname.'/' 8092 - endif 8093 - let b:netrw_curdir = dirname 5936 +" call Decho("(dirname was <NetrwTreeListing>) dirname<".dirname.">") 5937 elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir") 5938 let dirname= substitute(b:netrw_curdir,'\\','/','g') 5939 if dirname !~ '/$' 5940 let dirname= dirname.'/' 5941 endif 5942 let b:netrw_curdir = dirname 8094 5943 -" call Decho("(NetrwBrowse) (liststyle is TREELIST) dirname<".dirname.">") 8095 + " list directory history 8096 + let cnt = g:netrw_dirhist_cnt 8097 + let first = 1 8098 + let histcnt = 0 8099 + if g:netrw_dirhistmax > 0 8100 + while ( first || cnt != g:netrw_dirhist_cnt ) 8101 +" call Decho("first=".first." cnt=".cnt." dirhist_cnt=".g:netrw_dirhist_cnt) 8102 + if exists("g:netrw_dirhist_{cnt}") 8103 +" call Decho("Netrw History#".histcnt.": ".g:netrw_dirhist_{cnt}) 8104 + echo printf("Netrw History#%-2d: %s",histcnt,g:netrw_dirhist_{cnt}) 8105 + let didwork= 1 8106 + endif 8107 + let histcnt = histcnt + 1 8108 + let first = 0 8109 + let cnt = ( cnt - 1 ) % g:netrw_dirhistmax 8110 + if cnt < 0 8111 + let cnt= cnt + g:netrw_dirhistmax 8112 + endif 8113 + endwhile 5944 +" call Decho("(liststyle is TREELIST) dirname<".dirname.">") 8114 5945 else 8115 -let dirname = substitute(dirname,'\\','/','g')5946 let dirname = substitute(dirname,'\\','/','g') 8116 5947 -" call Decho("(NetrwBrowse) (normal) dirname<".dirname.">") 8117 + let g:netrw_dirhist_cnt= 0 8118 + endif 8119 + if didwork 8120 + call inputsave()|call input("Press <cr> to continue")|call inputrestore() 5948 +" call Decho("(normal) dirname<".dirname.">") 8121 5949 endif 8122 5950 8123 - let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/]\+\)/\(.*\)$' 8124 - if dirname !~ dirpat 8125 - if !exists("g:netrw_quiet") 8126 - keepj call netrw#ErrorMsg(s:ERROR,"netrw doesn't understand your dirname<".dirname.">",20) 8127 + elseif a:chg == 3 8128 + " saves most recently visited directories (when they differ) 8129 +" call Decho("(browsing) record curdir history") 8130 + if !exists("g:netrw_dirhist_cnt") || !exists("g:netrw_dirhist_{g:netrw_dirhist_cnt}") || g:netrw_dirhist_{g:netrw_dirhist_cnt} != a:curdir 8131 + if g:netrw_dirhistmax > 0 8132 + let g:netrw_dirhist_cnt = ( g:netrw_dirhist_cnt + 1 ) % g:netrw_dirhistmax 8133 + let g:netrw_dirhist_{g:netrw_dirhist_cnt} = a:curdir 5951 let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/]\+\)/\(.*\)$' 5952 @@ -3708,37 +3634,34 @@ 5953 keepj call netrw#ErrorMsg(s:ERROR,"netrw doesn't understand your dirname<".dirname.">",20) 8134 5954 endif 8135 -keepj call s:NetrwOptionRestore("w:")5955 keepj call s:NetrwOptionRestore("w:") 8136 5956 -" call Decho("(NetrwBrowse) setl noma nomod nowrap") 8137 - setl noma nomod nowrap 5957 +" call Decho("setl noma nomod nowrap") 5958 setl noma nomod nowrap 8138 5959 -" call Decho("(NetrwBrowse) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 8139 -" call Dret("s:NetrwBrowse : badly formatted dirname<".dirname.">")8140 - return 8141 +" call Decho("save dirhist#".g:netrw_dirhist_cnt."<".g:netrw_dirhist_{g:netrw_dirhist_cnt}.">") 5960 +" call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 5961 " call Dret("s:NetrwBrowse : badly formatted dirname<".dirname.">") 5962 return 8142 5963 endif 8143 -let b:netrw_curdir= dirname5964 let b:netrw_curdir= dirname 8144 5965 -" call Decho("(NetrwBrowse) b:netrw_curdir<".b:netrw_curdir."> (remote)") 8145 - endif " (additional remote handling) 8146 - 8147 - " ----------------------- 8148 - " Directory Listing: {{{3 8149 - " ----------------------- 8150 - keepj call s:NetrwMaps(a:islocal) 8151 - keepj call s:PerformListing(a:islocal) 8152 - if v:version >= 700 && has("balloon_eval") && &beval == 0 && &l:bexpr == "" && !exists("g:netrw_nobeval") 5966 +" call Decho("b:netrw_curdir<".b:netrw_curdir."> (remote)") 5967 endif " (additional remote handling) 5968 5969 " ----------------------- 5970 " Directory Listing: {{{3 5971 " ----------------------- 5972 keepj call s:NetrwMaps(a:islocal) 5973 + keepj call s:NetrwCommands(a:islocal) 5974 keepj call s:PerformListing(a:islocal) 5975 if v:version >= 700 && has("balloon_eval") && &beval == 0 && &l:bexpr == "" && !exists("g:netrw_nobeval") 8153 5976 - let &l:bexpr= "netrw#NetrwBalloonHelp()" 8154 5977 -" call Decho("(NetrwBrowse) set up balloon help: l:bexpr=".&l:bexpr) 8155 5978 - set beval 8156 - endif 8157 - call s:NetrwOptionRestore("w:") 8158 - 5979 + let &l:bexpr= "netrw#BalloonHelp()" 5980 +" call Decho("set up balloon help: l:bexpr=".&l:bexpr) 5981 + setl beval 5982 endif 5983 call s:NetrwOptionRestore("w:") 5984 8159 5985 - " The s:LocalBrowseShellCmdRefresh() function is called by an autocmd 8160 - " installed by s:LocalFastBrowser() when g:netrw_fastbrowse <= 1 (ie. slow, medium speed). 5986 + " The s:LocalBrowseRefresh() function is called by an autocmd 5987 " installed by s:LocalFastBrowser() when g:netrw_fastbrowse <= 1 (ie. slow, medium speed). 8161 5988 - " However, s:NetrwBrowse() causes the ShellCmdPost event itself to fire once; setting 8162 5989 - " the variable below avoids that second refresh of the screen. The s:LocalBrowseShellCmdRefresh() … … 8164 5991 - " and skips the refresh and sets s:locbrowseshellcmd to zero. Oct 13, 2008 8165 5992 - let s:locbrowseshellcmd= 1 8166 - 5993 + " However, s:NetrwBrowse() causes the FocusGained event to fire the firstt time. 5994 8167 5995 -" call Decho("(NetrwBrowse) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 8168 -" call Dret("s:NetrwBrowse : did PerformListing ft<".&ft.">") 8169 - return 8170 -endfun 8171 8172 -" --------------------------------------------------------------------- 8173 -" s:NetrwFileInfo: supports qf (query for file information) {{{2 8174 -fun! s:NetrwFileInfo(islocal,fname) 5996 +" call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 5997 " call Dret("s:NetrwBrowse : did PerformListing ft<".&ft.">") 5998 return 5999 endfun 6000 @@ -3746,20 +3669,33 @@ 6001 " --------------------------------------------------------------------- 6002 " s:NetrwFileInfo: supports qf (query for file information) {{{2 6003 fun! s:NetrwFileInfo(islocal,fname) 8175 6004 -" call Dfunc("s:NetrwFileInfo(islocal=".a:islocal." fname<".a:fname.">)") 8176 - let ykeep= @@ 8177 - if a:islocal 8178 - if (has("unix") || has("macunix")) && executable("/bin/ls") 6005 +" call Dfunc("s:NetrwFileInfo(islocal=".a:islocal." fname<".a:fname.">) b:netrw_curdir<".b:netrw_curdir.">") 6006 let ykeep= @@ 6007 if a:islocal 6008 if (has("unix") || has("macunix")) && executable("/bin/ls") 8179 6009 - if exists("b:netrw_curdir") 8180 6010 -" call Decho('using ls with b:netrw_curdir<'.b:netrw_curdir.'>') 8181 - if b:netrw_curdir =~ '/$' 8182 - echo system("/bin/ls -lsad ".shellescape(b:netrw_curdir.a:fname)) 8183 - else 8184 - echo system("/bin/ls -lsad ".shellescape(b:netrw_curdir."/".a:fname)) 8185 - endif 8186 - else 8187 -" call Decho('using ls '.a:fname." using cwd<".getcwd().">") 8188 - echo system("/bin/ls -lsad ".shellescape(a:fname)) 8189 + elseif a:chg == 4 8190 + " u: change to the previous directory stored on the history list 8191 +" call Decho("(user: <u>) chg to prev dir from history") 8192 + if g:netrw_dirhistmax > 0 8193 + let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt - v:count1 ) % g:netrw_dirhistmax 8194 + if g:netrw_dirhist_cnt < 0 8195 + let g:netrw_dirhist_cnt= g:netrw_dirhist_cnt + g:netrw_dirhistmax 6011 + 6012 + if getline(".") == "../" 6013 + echo system("/bin/ls -lsad ".shellescape("..")) 6014 +" call Decho("#1: echo system(/bin/ls -lsad ".shellescape(..).")") 6015 + 6016 + elseif w:netrw_liststyle == s:TREELIST && getline(".") !~ '^'.s:treedepthstring 6017 + echo system("/bin/ls -lsad ".shellescape(b:netrw_curdir)) 6018 +" call Decho("#2: echo system(/bin/ls -lsad ".shellescape(b:netrw_curdir).")") 6019 + 6020 + elseif exists("b:netrw_curdir") 6021 if b:netrw_curdir =~ '/$' 6022 echo system("/bin/ls -lsad ".shellescape(b:netrw_curdir.a:fname)) 6023 +" call Decho("#3: echo system(/bin/ls -lsad ".shellescape(b:netrw_curdir.a:fname).")") 6024 + 6025 else 6026 echo system("/bin/ls -lsad ".shellescape(b:netrw_curdir."/".a:fname)) 6027 +" call Decho("#4: echo system(/bin/ls -lsad ".shellescape(b:netrw_curdir."/".a:fname).")") 6028 endif 6029 + 6030 else 6031 " call Decho('using ls '.a:fname." using cwd<".getcwd().">") 6032 echo system("/bin/ls -lsad ".shellescape(a:fname)) 6033 +" call Decho("#5: echo system(/bin/ls -lsad ".shellescape(a:fname).")") 8196 6034 endif 8197 6035 else 8198 - " use vim functions to return information about file below cursor 8199 -" call Decho("using vim functions to query for file info") 8200 - if !isdirectory(a:fname) && !filereadable(a:fname) && a:fname =~ '[*@/]' 8201 - let fname= substitute(a:fname,".$","","") 8202 + let g:netrw_dirhist_cnt= 0 8203 + endif 8204 + if exists("g:netrw_dirhist_{g:netrw_dirhist_cnt}") 8205 +" call Decho("changedir u#".g:netrw_dirhist_cnt."<".g:netrw_dirhist_{g:netrw_dirhist_cnt}.">") 8206 + if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir") 8207 + setl ma noro 8208 +" call Decho("setl ma noro") 8209 + sil! keepj %d 8210 + setl nomod 8211 +" call Decho("setl nomod") 8212 +" call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 8213 + endif 8214 +" call Decho("exe e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt})) 8215 + exe "keepj e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt}) 8216 + else 8217 + if g:netrw_dirhistmax > 0 8218 + let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt + v:count1 ) % g:netrw_dirhistmax 8219 else 8220 - let fname= a:fname 8221 - endif 8222 - let t = getftime(fname) 8223 - let sz = getfsize(fname) 8224 - echo a:fname.": ".sz." ".strftime(g:netrw_timefmt,getftime(fname)) 6036 " use vim functions to return information about file below cursor 6037 @@ -3772,7 +3708,7 @@ 6038 let t = getftime(fname) 6039 let sz = getfsize(fname) 6040 echo a:fname.": ".sz." ".strftime(g:netrw_timefmt,getftime(fname)) 8225 6041 -" call Decho(fname.": ".sz." ".strftime(g:netrw_timefmt,getftime(fname))) 8226 - endif 8227 - else 8228 - echo "sorry, \"qf\" not supported yet for remote files" 8229 - endif 8230 - let @@= ykeep 8231 -" call Dret("s:NetrwFileInfo") 8232 -endfun 8233 - 8234 -" --------------------------------------------------------------------- 8235 -" s:NetrwGetBuffer: {{{2 8236 -" returns 0=cleared buffer 8237 -" 1=re-used buffer 8238 -fun! s:NetrwGetBuffer(islocal,dirname) 8239 -" call Dfunc("s:NetrwGetBuffer(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".g:netrw_liststyle) 6042 +" call Decho("fname.": ".sz." ".strftime(g:netrw_timefmt,getftime(fname))) 6043 endif 6044 else 6045 echo "sorry, \"qf\" not supported yet for remote files" 6046 @@ -3787,40 +3723,42 @@ 6047 " 1=re-used buffer 6048 fun! s:NetrwGetBuffer(islocal,dirname) 6049 " call Dfunc("s:NetrwGetBuffer(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".g:netrw_liststyle) 8240 6050 -" call Decho("(NetrwGetBuffer) modiable=".&mod." modifiable=".&ma." readonly=".&ro) 8241 - let dirname= a:dirname 8242 - 8243 - " re-use buffer if possible {{{3 6051 +" call Decho("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) 6052 let dirname= a:dirname 6053 6054 " re-use buffer if possible {{{3 8244 6055 -" call Decho("(NetrwGetBuffer) --re-use a buffer if possible--") 8245 - if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST 8246 - " find NetrwTreeList buffer if there is one 6056 +" call Decho("--re-use a buffer if possible--") 6057 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST 6058 " find NetrwTreeList buffer if there is one 8247 6059 -" call Decho("(NetrwGetBuffer) case liststyle=treelist: find NetrwTreeList buffer if there is one") 8248 - if exists("w:netrw_treebufnr") && w:netrw_treebufnr > 0 6060 +" call Decho("case liststyle=treelist: find NetrwTreeList buffer if there is one") 6061 if exists("w:netrw_treebufnr") && w:netrw_treebufnr > 0 8249 6062 -" call Decho("(NetrwGetBuffer) re-using w:netrw_treebufnr=".w:netrw_treebufnr) 8250 6063 - setl mod 8251 6064 - sil! keepj %d 8252 - let eikeep= &ei 6065 +" call Decho(" re-using w:netrw_treebufnr=".w:netrw_treebufnr) 6066 let eikeep= &ei 8253 6067 - set ei=all 8254 6068 - exe "sil! keepalt b ".w:netrw_treebufnr 8255 - let &ei= eikeep 8256 -" call Dret("s:NetrwGetBuffer 0<buffer cleared> : bufnum#".w:netrw_treebufnr."<NetrwTreeListing>") 8257 - return 0 8258 - endif 8259 - let bufnum= -1 6069 + setl ei=all 6070 + exe "sil! noswapfile keepalt b ".w:netrw_treebufnr 6071 let &ei= eikeep 6072 + setl ma 6073 + sil! keepj %d 6074 +" call Decho("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) 6075 " call Dret("s:NetrwGetBuffer 0<buffer cleared> : bufnum#".w:netrw_treebufnr."<NetrwTreeListing>") 6076 return 0 6077 endif 6078 let bufnum= -1 8260 6079 -" call Decho("(NetrwGetBuffer) liststyle=TREE but w:netrw_treebufnr doesn't exist") 8261 - 8262 - else 8263 - " find buffer number of buffer named precisely the same as dirname {{{3 6080 +" call Decho(" liststyle=TREE but w:netrw_treebufnr doesn't exist") 6081 6082 else 6083 " find buffer number of buffer named precisely the same as dirname {{{3 8264 6084 -" call Decho("(NetrwGetBuffer) case listtyle not treelist: find buffer numnber of buffer named precisely the same as dirname--") 8265 - 8266 - " get dirname and associated buffer number 8267 - let bufnum = bufnr(escape(dirname,'\')) 6085 +" call Decho("case listtyle not treelist: find buffer numnber of buffer named precisely the same as dirname--") 6086 +" call Dredir("(NetrwGetBuffer) ls!","ls!") 6087 6088 " get dirname and associated buffer number 6089 let bufnum = bufnr(escape(dirname,'\')) 8268 6090 -" call Decho("(NetrwGetBuffer) find buffer<".dirname.">'s number ") 8269 6091 -" call Decho("(NetrwGetBuffer) bufnr(dirname<".escape(dirname,'\').">)=".bufnum) 8270 - 8271 - if bufnum < 0 && dirname !~ '/$' 8272 - " try appending a trailing / 6092 +" call Decho(" find buffer<".dirname.">'s number ") 6093 +" call Decho(" bufnr(dirname<".escape(dirname,'\').">)=".bufnum) 6094 6095 if bufnum < 0 && dirname !~ '/$' 6096 " try appending a trailing / 8273 6097 -" call Decho("(NetrwGetBuffer) try appending a trailing / to dirname<".dirname.">") 8274 - let bufnum= bufnr(escape(dirname.'/','\'))8275 - if bufnum > 0 8276 - let dirname= dirname.'/' 8277 - endif 8278 - endif 8279 - 8280 -if bufnum < 0 && dirname =~ '/$'8281 -" try removing a trailing /6098 +" call Decho(" try appending a trailing / to dirname<".dirname.">") 6099 let bufnum= bufnr(escape(dirname.'/','\')) 6100 if bufnum > 0 6101 let dirname= dirname.'/' 6102 @@ -3829,30 +3767,30 @@ 6103 6104 if bufnum < 0 && dirname =~ '/$' 6105 " try removing a trailing / 8282 6106 -" call Decho("(NetrwGetBuffer) try removing a trailing / from dirname<".dirname.">") 8283 - let bufnum= bufnr(escape(substitute(dirname,'/$','',''),'\'))8284 - if bufnum > 0 8285 - let dirname= substitute(dirname,'/$','','') 8286 + let g:netrw_dirhist_cnt= 0 6107 +" call Decho(" try removing a trailing / from dirname<".dirname.">") 6108 let bufnum= bufnr(escape(substitute(dirname,'/$','',''),'\')) 6109 if bufnum > 0 6110 let dirname= substitute(dirname,'/$','','') 8287 6111 endif 8288 + echo "Sorry, no predecessor directory exists yet"8289 6112 endif 8290 6113 8291 6114 -" call Decho("(NetrwGetBuffer) findbuf1: bufnum=bufnr('".dirname."')=".bufnum." bufname(".bufnum.")<".bufname(bufnum)."> (initial)") 8292 - " note: !~ was used just below, but that means using ../ to go back would match (ie. abc/def/ and abc/ matches) 8293 - if bufnum > 0 && bufname(bufnum) != dirname && bufname(bufnum) != '.' 8294 - " handle approximate matches 6115 +" call Decho(" findbuf1: bufnum=bufnr('".dirname."')=".bufnum." bufname(".bufnum.")<".bufname(bufnum)."> (initial)") 6116 " note: !~ was used just below, but that means using ../ to go back would match (ie. abc/def/ and abc/ matches) 6117 if bufnum > 0 && bufname(bufnum) != dirname && bufname(bufnum) != '.' 6118 " handle approximate matches 8295 6119 -" call Decho("(NetrwGetBuffer) handling approx match: bufnum#".bufnum.">0 AND bufname<".bufname(bufnum).">!=dirname<".dirname."> AND bufname(".bufnum.")!='.'") 8296 - let ibuf = 1 8297 - let buflast = bufnr("$") 6120 +" call Decho(" handling approx match: bufnum#".bufnum.">0 AND bufname<".bufname(bufnum).">!=dirname<".dirname."> AND bufname(".bufnum.")!='.'") 6121 let ibuf = 1 6122 let buflast = bufnr("$") 8298 6123 -" call Decho("(NetrwGetBuffer) findbuf2: buflast=bufnr($)=".buflast) 8299 - while ibuf <= buflast 8300 - let bname= substitute(bufname(ibuf),'\\','/','g') 8301 - let bname= substitute(bname,'.\zs/$','','') 6124 +" call Decho(" findbuf2: buflast=bufnr($)=".buflast) 6125 while ibuf <= buflast 6126 let bname= substitute(bufname(ibuf),'\\','/','g') 6127 let bname= substitute(bname,'.\zs/$','','') 8302 6128 -" call Decho("(NetrwGetBuffer) findbuf3: while [ibuf=",ibuf."]<=[buflast=".buflast."]: dirname<".dirname."> bname=bufname(".ibuf.")<".bname.">") 8303 - if bname != '' && dirname =~ '/'.bname.'/\=$' && dirname !~ '^/' 8304 - " bname is not empty 8305 - " dirname ends with bname, 8306 - " dirname doesn't start with /, so its not a absolute path 6129 +" call Decho(" findbuf3: while [ibuf=",ibuf."]<=[buflast=".buflast."]: dirname<".dirname."> bname=bufname(".ibuf.")<".bname.">") 6130 if bname != '' && dirname =~ '/'.bname.'/\=$' && dirname !~ '^/' 6131 " bname is not empty 6132 " dirname ends with bname, 6133 " dirname doesn't start with /, so its not a absolute path 8307 6134 -" call Decho("(NetrwGetBuffer) findbuf3a: passes test 1 : dirname<".dirname.'> =~ /'.bname.'/\=$ && dirname !~ ^/') 8308 - break 8309 - endif 8310 - if bname =~ '^'.dirname.'/\=$' 8311 - " bname begins with dirname 8312 -" call Decho(' findbuf3b: passes test 2 : bname<'.bname.'>=~^'.dirname.'/\=$') 8313 - break 8314 - endif 8315 - if dirname =~ '^'.bname.'/$' 8316 -" call Decho(' findbuf3c: passes test 3 : dirname<'.dirname.'>=~^'.bname.'/$') 8317 - break 8318 - endif 8319 - if bname != '' && dirname =~ '/'.bname.'$' && bname == bufname("%") && line("$") == 1 8320 -" call Decho(' findbuf3d: passes test 4 : dirname<'.dirname.'>=~ /'.bname.'$') 8321 - break 8322 + elseif a:chg == 5 8323 + " U: change to the subsequent directory stored on the history list 8324 +" call Decho("(user: <U>) chg to next dir from history") 8325 + if g:netrw_dirhistmax > 0 8326 + let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt + 1 ) % g:netrw_dirhistmax 8327 + if exists("g:netrw_dirhist_{g:netrw_dirhist_cnt}") 8328 +" call Decho("changedir U#".g:netrw_dirhist_cnt."<".g:netrw_dirhist_{g:netrw_dirhist_cnt}.">") 8329 + if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir") 8330 +" call Decho("setl ma noro") 8331 + setl ma noro 8332 + sil! keepj %d 8333 +" call Decho("removed all lines from buffer (%d)") 8334 +" call Decho("setl nomod") 8335 + setl nomod 8336 +" call Decho("(set nomod) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 6135 +" call Decho(" findbuf3a: passes test 1 : dirname<".dirname.'> =~ /'.bname.'/\=$ && dirname !~ ^/') 6136 break 8337 6137 endif 8338 - let ibuf= ibuf + 1 8339 - endwhile 8340 - if ibuf > buflast 8341 - let bufnum= -1 8342 - else 8343 - let bufnum= ibuf 8344 - endif 6138 if bname =~ '^'.dirname.'/\=$' 6139 @@ -3875,79 +3813,83 @@ 6140 else 6141 let bufnum= ibuf 6142 endif 8345 6143 -" call Decho("(NetrwGetBuffer) findbuf4: bufnum=".bufnum." (ibuf=".ibuf." buflast=".buflast.")") 8346 - endif 8347 - endif 8348 - 8349 - " get enew buffer and name it -or- re-use buffer {{{3 6144 +" call Decho(" findbuf4: bufnum=".bufnum." (ibuf=".ibuf." buflast=".buflast.")") 6145 endif 6146 endif 6147 6148 " get enew buffer and name it -or- re-use buffer {{{3 8350 6149 -" call Decho("(NetrwGetBuffer) get enew buffer and name it OR re-use buffer") 8351 - sil! keepj keepalt mark ' 8352 - if bufnum < 0 || !bufexists(bufnum) 6150 +" call Decho(" get enew buffer and name it OR re-use buffer") 6151 sil! keepj keepalt mark ' 6152 if bufnum < 0 || !bufexists(bufnum) 8353 6153 -" call Decho("(NetrwGetBuffer) --get enew buffer and name it (bufnum#".bufnum."<0 OR bufexists(".bufnum.")=".bufexists(bufnum)."==0)") 8354 - call s:NetrwEnew(dirname) 6154 +" call Decho("--get enew buffer and name it (bufnum#".bufnum."<0 OR bufexists(".bufnum.")=".bufexists(bufnum)."==0)") 6155 call s:NetrwEnew(dirname) 8355 6156 -" call Decho("(NetrwGetBuffer) got enew buffer#".bufnr("%")." (altbuf<".expand("#").">)") 8356 - " name the buffer 8357 - if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST 8358 - " Got enew buffer; transform into a NetrwTreeListing 6157 +" call Decho(" got enew buffer#".bufnr("%")." (altbuf<".expand("#").">)") 6158 " name the buffer 6159 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST 6160 " Got enew buffer; transform into a NetrwTreeListing 8359 6161 -" call Decho("(NetrwGetBuffer) --transform enew buffer#".bufnr("%")." into a NetrwTreeListing --") 8360 - if !exists("s:netrw_treelistnum") 8361 - let s:netrw_treelistnum= 1 8362 +" call Decho("exe e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt})) 8363 + exe "keepj e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt}) 6162 +" call Decho("--transform enew buffer#".bufnr("%")." into a NetrwTreeListing --") 6163 if !exists("s:netrw_treelistnum") 6164 let s:netrw_treelistnum= 1 8364 6165 else 8365 - let s:netrw_treelistnum= s:netrw_treelistnum + 1 8366 + let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt - 1 ) % g:netrw_dirhistmax 8367 + if g:netrw_dirhist_cnt < 0 8368 + let g:netrw_dirhist_cnt= g:netrw_dirhist_cnt + g:netrw_dirhistmax 8369 + endif 8370 + echo "Sorry, no successor directory exists yet" 6166 let s:netrw_treelistnum= s:netrw_treelistnum + 1 8371 6167 endif 8372 -let w:netrw_treebufnr= bufnr("%")6168 let w:netrw_treebufnr= bufnr("%") 8373 6169 -" call Decho("(NetrwGetBuffer) exe sil! keepalt file NetrwTreeListing ".fnameescape(s:netrw_treelistnum)) 8374 - exe 'sil! keepalt file NetrwTreeListing\ '.fnameescape(s:netrw_treelistnum) 6170 +" call Decho(" exe sil! keepalt file NetrwTreeListing ".fnameescape(s:netrw_treelistnum)) 6171 exe 'sil! keepalt file NetrwTreeListing\ '.fnameescape(s:netrw_treelistnum) 8375 6172 - set bt=nofile noswf 8376 - nnoremap <silent> <buffer> [ :sil call <SID>TreeListMove('[')<cr> 8377 - nnoremap <silent> <buffer> ] :sil call <SID>TreeListMove(']')<cr> 8378 - nnoremap <silent> <buffer> [[ :sil call <SID>TreeListMove('[')<cr> 8379 - nnoremap <silent> <buffer> ]] :sil call <SID>TreeListMove(']')<cr> 6173 + setl bt=nofile noswf 6174 nnoremap <silent> <buffer> [ :sil call <SID>TreeListMove('[')<cr> 6175 nnoremap <silent> <buffer> ] :sil call <SID>TreeListMove(']')<cr> 6176 nnoremap <silent> <buffer> [[ :sil call <SID>TreeListMove('[')<cr> 6177 nnoremap <silent> <buffer> ]] :sil call <SID>TreeListMove(']')<cr> 8380 6178 -" call Decho("(NetrwGetBuffer) tree listing#".s:netrw_treelistnum." bufnr=".w:netrw_treebufnr) 6179 +" call Decho(" tree listing#".s:netrw_treelistnum." bufnr=".w:netrw_treebufnr) 8381 6180 else 8382 -" let v:errmsg= "" " Decho8383 -let escdirname= fnameescape(dirname)6181 " let v:errmsg= "" " Decho 6182 let escdirname= fnameescape(dirname) 8384 6183 -" call Decho("(NetrwGetBuffer) errmsg<".v:errmsg."> bufnr(escdirname<".escdirname.">)=".bufnr(escdirname)." bufname()<".bufname(bufnr(escdirname)).">") 8385 -" call Decho(' exe sil! keepalt file '.escdirname) 8386 -" let v:errmsg= "" " Decho 8387 - exe 'sil! keepalt file '.escdirname 6184 +" call Decho(" errmsg<".v:errmsg."> bufnr(escdirname<".escdirname.">)=".bufnr(escdirname)." bufname()<".bufname(bufnr(escdirname)).">") 6185 " call Decho(' exe sil! keepalt file '.escdirname) 6186 " let v:errmsg= "" " Decho 6187 exe 'sil! keepalt file '.escdirname 8388 6188 -" call Decho("(NetrwGetBuffer) errmsg<".v:errmsg."> bufnr(".escdirname.")=".bufnr(escdirname)."<".bufname(bufnr(escdirname)).">") 8389 + let g:netrw_dirhist_cnt= 0 8390 + echo "Sorry, no successor directory exists yet (g:netrw_dirhistmax is ".g:netrw_dirhistmax.")" 6189 +" call Decho(" errmsg<".v:errmsg."> bufnr(".escdirname.")=".bufnr(escdirname)."<".bufname(bufnr(escdirname)).">") 8391 6190 endif 8392 6191 -" call Decho("(NetrwGetBuffer) named enew buffer#".bufnr("%")."<".bufname("%").">") 8393 8394 - else " Re-use the buffer 6192 +" call Decho(" named enew buffer#".bufnr("%")."<".bufname("%").">") 6193 6194 else " Re-use the buffer 8395 6195 -" call Decho("(NetrwGetBuffer) --re-use buffer#".bufnum." (bufnum#".bufnum.">=0 AND bufexists(".bufnum.")=".bufexists(bufnum)."!=0)") 8396 - let eikeep= &ei 6196 +" call Decho("--re-use buffer#".bufnum." (bufnum#".bufnum.">=0 AND bufexists(".bufnum.")=".bufexists(bufnum)."!=0)") 6197 let eikeep= &ei 8397 6198 - set ei=all 8398 - if getline(2) =~ '^" Netrw Directory Listing' 6199 + setl ei=all 6200 if getline(2) =~ '^" Netrw Directory Listing' 8399 6201 -" call Decho("(NetrwGetBuffer) getline(2)<".getline(2).'> matches "Netrw Directory Listing" : using keepalt b '.bufnum) 8400 6202 - exe "sil! keepalt b ".bufnum 8401 - else 6203 +" call Decho(" getline(2)<".getline(2).'> matches "Netrw Directory Listing" : using keepalt b '.bufnum) 6204 + exe "sil! noswapfile keepalt b ".bufnum 6205 else 8402 6206 -" call Decho("(NetrwGetBuffer) getline(2)<".getline(2).'> does not match "Netrw Directory Listing" : using b '.bufnum) 8403 6207 - exe "sil! keepalt b ".bufnum 8404 - endif 8405 - if bufname("%") == '.' 6208 +" call Decho(" getline(2)<".getline(2).'> does not match "Netrw Directory Listing" : using b '.bufnum) 6209 + exe "sil! noswapfile keepalt b ".bufnum 6210 endif 6211 if bufname("%") == '.' 8406 6212 -" call Decho("(NetrwGetBuffer) exe sil! keepalt file ".fnameescape(getcwd())) 8407 - exe "sil! keepalt file ".fnameescape(getcwd()) 8408 - endif 8409 - let &ei= eikeep 8410 - if line("$") <= 1 8411 - keepj call s:NetrwListSettings(a:islocal) 8412 -" call Dret("s:NetrwGetBuffer 0<buffer empty> : re-using buffer#".bufnr("%").", but its empty, so refresh it") 8413 - return 0 8414 - elseif g:netrw_fastbrowse == 0 || (a:islocal && g:netrw_fastbrowse == 1) 8415 - keepj call s:NetrwListSettings(a:islocal) 8416 - sil keepj %d 8417 -" call Dret("s:NetrwGetBuffer 0<cleared buffer> : re-using buffer#".bufnr("%").", but refreshing due to g:netrw_fastbrowse=".g:netrw_fastbrowse) 8418 - return 0 8419 - elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST 6213 +" call Decho("exe sil! keepalt file ".fnameescape(getcwd())) 6214 exe "sil! keepalt file ".fnameescape(getcwd()) 6215 endif 6216 let &ei= eikeep 6217 if line("$") <= 1 6218 keepj call s:NetrwListSettings(a:islocal) 6219 +" call Decho("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) 6220 " call Dret("s:NetrwGetBuffer 0<buffer empty> : re-using buffer#".bufnr("%").", but its empty, so refresh it") 6221 return 0 6222 elseif g:netrw_fastbrowse == 0 || (a:islocal && g:netrw_fastbrowse == 1) 6223 keepj call s:NetrwListSettings(a:islocal) 6224 sil keepj %d 6225 +" call Decho("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) 6226 " call Dret("s:NetrwGetBuffer 0<cleared buffer> : re-using buffer#".bufnr("%").", but refreshing due to g:netrw_fastbrowse=".g:netrw_fastbrowse) 6227 return 0 6228 elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST 8420 6229 -" call Decho("(NetrwGetBuffer) --re-use tree listing--") 8421 6230 -" call Decho("(NetrwGetBuffer) clear buffer<".expand("%")."> with :%d") 8422 - sil keepj %d 8423 - keepj call s:NetrwListSettings(a:islocal) 8424 -" call Dret("s:NetrwGetBuffer 0<cleared buffer> : re-using buffer#".bufnr("%").", but treelist mode always needs a refresh") 8425 - return 0 8426 - else 8427 -" call Dret("s:NetrwGetBuffer 1<buffer not cleared> : buf#".bufnr("%")) 8428 - return 1 8429 + elseif a:chg == 6 8430 + " delete the v:count'th bookmark 8431 +" call Decho("delete bookmark#".v:count."<".g:netrw_bookmarklist[v:count-1].">") 8432 + let savefile= s:NetrwHome()."/.netrwbook" 8433 + if filereadable(savefile) 8434 +" call Decho("merge bookmarks (active and file)") 8435 + keepj call s:NetrwBookHistSave() " done here to merge bookmarks first 8436 +" call Decho("bookmark delete savefile<".savefile.">") 8437 + keepj call delete(savefile) 6231 +" call Decho("--re-use tree listing--") 6232 +" call Decho(" clear buffer<".expand("%")."> with :%d") 6233 sil keepj %d 6234 keepj call s:NetrwListSettings(a:islocal) 6235 +" call Decho("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) 6236 " call Dret("s:NetrwGetBuffer 0<cleared buffer> : re-using buffer#".bufnr("%").", but treelist mode always needs a refresh") 6237 return 0 6238 else 6239 +" call Decho("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) 6240 " call Dret("s:NetrwGetBuffer 1<buffer not cleared> : buf#".bufnr("%")) 6241 return 1 8438 6242 endif 8439 +" call Decho("remove g:netrw_bookmarklist[".(v:count-1)."]") 8440 + keepj call remove(g:netrw_bookmarklist,v:count-1) 8441 +" call Decho("resulting g:netrw_bookmarklist=".string(g:netrw_bookmarklist)) 8442 endif 8443 - 8444 - " do netrw settings: make this buffer not-a-file, modifiable, not line-numbered, etc {{{3 8445 - " fastbrowse Local Remote Hiding a buffer implies it may be re-used (fast) 8446 - " slow 0 D D Deleting a buffer implies it will not be re-used (slow) 8447 - " med 1 D H 8448 - " fast 2 H H 6243 @@ -3958,18 +3900,19 @@ 6244 " slow 0 D D Deleting a buffer implies it will not be re-used (slow) 6245 " med 1 D H 6246 " fast 2 H H 8449 6247 -" call Decho("(NetrwGetBuffer) --do netrw settings: make this buffer#".bufnr("%")." not-a-file, modifiable, not line-numbered, etc--") 8450 - let fname= expand("%") 8451 - keepj call s:NetrwListSettings(a:islocal) 6248 +" call Decho("--do netrw settings: make this buffer#".bufnr("%")." not-a-file, modifiable, not line-numbered, etc--") 6249 let fname= expand("%") 6250 keepj call s:NetrwListSettings(a:islocal) 8452 6251 -" call Decho("(NetrwGetBuffer) exe sil! keepalt file ".fnameescape(fname)) 8453 - exe "sil! keepj keepalt file ".fnameescape(fname) 8454 - 8455 - " delete all lines from buffer {{{3 6252 +" call Decho("exe sil! keepalt file ".fnameescape(fname)) 6253 exe "sil! keepj keepalt file ".fnameescape(fname) 6254 6255 " delete all lines from buffer {{{3 8456 6256 -" call Decho("(NetrwGetBuffer) --delete all lines from buffer--") 8457 6257 -" call Decho("(NetrwGetBuffer) clear buffer<".expand("%")."> with :%d") 8458 - sil! keepalt keepj %d 8459 - 6258 +" call Decho("--delete all lines from buffer--") 6259 +" call Decho(" clear buffer<".expand("%")."> with :%d") 6260 sil! keepalt keepj %d 6261 8460 6262 -" call Dret("s:NetrwGetBuffer 0<cleared buffer> : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) 8461 - return 0 8462 + call s:NetrwBookmarkMenu() 8463 + call s:NetrwTgtMenu() 8464 + let @@= ykeep 8465 +" call Dret("s:NetrwBookHistHandler") 6263 +" call Decho("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) 6264 +" call Dret("s:NetrwGetBuffer 0<cleared buffer> : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")) 6265 return 0 8466 6266 endfun 8467 6267 8468 " --------------------------------------------------------------------- 8469 -" s:NetrwGetcwd: get the current directory. {{{2 8470 -" Change backslashes to forward slashes, if any. 8471 -" If doesc is true, escape certain troublesome characters 8472 -fun! s:NetrwGetcwd(doesc) 8473 -" call Dfunc("NetrwGetcwd(doesc=".a:doesc.")") 8474 - let curdir= substitute(getcwd(),'\\','/','ge') 8475 - if curdir !~ '[\/]$' 8476 - let curdir= curdir.'/' 8477 +" s:NetrwBookHistRead: this function reads bookmarks and history {{{2 8478 +" Sister function: s:NetrwBookHistSave() 8479 +fun! s:NetrwBookHistRead() 8480 +" call Dfunc("s:NetrwBookHistRead()") 8481 + if !exists("g:netrw_dirhistmax") || g:netrw_dirhistmax <= 0 8482 +" " call Dret("s:NetrwBookHistRead - suppressed due to g:netrw_dirhistmax") 8483 + return 8484 endif 8485 - if a:doesc 8486 - let curdir= fnameescape(curdir) 8487 + let ykeep= @@ 8488 + if !exists("s:netrw_initbookhist") 8489 + let home = s:NetrwHome() 8490 + let savefile= home."/.netrwbook" 8491 + if filereadable(savefile) 8492 +" call Decho("sourcing .netrwbook") 8493 + exe "keepalt keepj so ".savefile 8494 + endif 8495 + if g:netrw_dirhistmax > 0 8496 + let savefile= home."/.netrwhist" 8497 + if filereadable(savefile) 8498 +" call Decho("sourcing .netrwhist") 8499 + exe "keepalt keepj so ".savefile 8500 + endif 8501 + let s:netrw_initbookhist= 1 8502 + au VimLeave * call s:NetrwBookHistSave() 8503 + endif 8504 endif 8505 -" call Dret("NetrwGetcwd <".curdir.">") 8506 - return curdir 8507 + let @@= ykeep 8508 +" call Dret("s:NetrwBookHistRead") 8509 endfun 8510 8511 " --------------------------------------------------------------------- 8512 -" s:NetrwGetWord: it gets the directory/file named under the cursor {{{2 8513 -fun! s:NetrwGetWord() 8514 -" call Dfunc("s:NetrwGetWord() line#".line(".")." liststyle=".g:netrw_liststyle." virtcol=".virtcol(".")) 8515 - call s:UseBufWinVars() 8516 - 8517 - " insure that w:netrw_liststyle is set up 8518 - if !exists("w:netrw_liststyle") 8519 - if exists("g:netrw_liststyle") 8520 - let w:netrw_liststyle= g:netrw_liststyle 8521 - else 8522 - let w:netrw_liststyle= s:THINLIST 8523 - endif 8524 -" call Decho("w:netrw_liststyle=".w:netrw_liststyle) 8525 +" s:NetrwBookHistSave: this function saves bookmarks and history {{{2 8526 +" Sister function: s:NetrwBookHistRead() 8527 +" I used to do this via viminfo but that appears to 8528 +" be unreliable for long-term storage 8529 +fun! s:NetrwBookHistSave() 8530 +" call Dfunc("s:NetrwBookHistSave() dirhistmax=".g:netrw_dirhistmax) 8531 + if !exists("g:netrw_dirhistmax") || g:netrw_dirhistmax <= 0 8532 +" call Dret("s:NetrwBookHistSave : dirhistmax=".g:netrw_dirhistmax) 8533 + return 8534 endif 8535 8536 - if exists("w:netrw_bannercnt") && line(".") < w:netrw_bannercnt 8537 - " Active Banner support 8538 -" call Decho("active banner handling") 8539 - keepj norm! 0 8540 - let dirname= "./" 8541 - let curline= getline('.') 8542 - 8543 - if curline =~ '"\s*Sorted by\s' 8544 - keepj norm s 8545 - let s:netrw_skipbrowse= 1 8546 - echo 'Pressing "s" also works' 8547 - 8548 - elseif curline =~ '"\s*Sort sequence:' 8549 - let s:netrw_skipbrowse= 1 8550 - echo 'Press "S" to edit sorting sequence' 8551 + let savefile= s:NetrwHome()."/.netrwhist" 8552 + 1split 8553 + call s:NetrwEnew() 8554 + setl cino= com= cpo-=a cpo-=A fo=nroql2 tw=0 report=10000 noswf 8555 + setl nocin noai noci magic nospell nohid wig= noaw 8556 + setl ma noro write 8557 + if exists("+acd") | setl noacd | endif 8558 + sil! keepj keepalt %d 8559 8560 - elseif curline =~ '"\s*Quick Help:' 8561 - keepj norm ? 8562 - let s:netrw_skipbrowse= 1 8563 - echo 'Pressing "?" also works' 8564 + " save .netrwhist -- no attempt to merge 8565 + sil! keepalt file .netrwhist 8566 + call setline(1,"let g:netrw_dirhistmax =".g:netrw_dirhistmax) 8567 + call setline(2,"let g:netrw_dirhist_cnt =".g:netrw_dirhist_cnt) 8568 + let lastline = line("$") 8569 + let cnt = 1 8570 + while cnt <= g:netrw_dirhist_cnt 8571 + call setline((cnt+lastline),'let g:netrw_dirhist_'.cnt."='".g:netrw_dirhist_{cnt}."'") 8572 + let cnt= cnt + 1 8573 + endwhile 8574 + exe "sil! w! ".savefile 8575 8576 - elseif curline =~ '"\s*\%(Hiding\|Showing\):' 8577 - keepj norm a 8578 - let s:netrw_skipbrowse= 1 8579 - echo 'Pressing "a" also works' 8580 + sil keepj %d 8581 + if exists("g:netrw_bookmarklist") && g:netrw_bookmarklist != [] 8582 + " merge and write .netrwbook 8583 + let savefile= s:NetrwHome()."/.netrwbook" 8584 8585 - elseif line("$") > w:netrw_bannercnt 8586 - exe 'sil keepj '.w:netrw_bannercnt 8587 + if filereadable(savefile) 8588 + let booklist= deepcopy(g:netrw_bookmarklist) 8589 + exe "sil keepj keepalt so ".savefile 8590 + for bdm in booklist 8591 + if index(g:netrw_bookmarklist,bdm) == -1 8592 + call add(g:netrw_bookmarklist,bdm) 8593 + endif 8594 + endfor 8595 + call sort(g:netrw_bookmarklist) 8596 + exe "sil! w! ".savefile 8597 endif 8598 8599 - elseif w:netrw_liststyle == s:THINLIST 8600 -" call Decho("thin column handling") 8601 - keepj norm! 0 8602 - let dirname= getline('.') 8603 - 8604 - elseif w:netrw_liststyle == s:LONGLIST 8605 -" call Decho("long column handling") 8606 - keepj norm! 0 8607 - let dirname= substitute(getline('.'),'^\(\%(\S\+ \)*\S\+\).\{-}$','\1','e') 8608 + " construct and save .netrwbook 8609 + call setline(1,"let g:netrw_bookmarklist= ".string(g:netrw_bookmarklist)) 8610 + exe "sil! w! ".savefile 8611 + endif 8612 + let bgone= bufnr("%") 8613 + q! 8614 + exe "keepalt ".bgone."bwipe!" 8615 8616 - elseif w:netrw_liststyle == s:TREELIST 8617 -" call Decho("treelist handling") 6268 @@ -4048,7 +3991,7 @@ 6269 6270 elseif w:netrw_liststyle == s:TREELIST 6271 " call Decho("treelist handling") 8618 6272 - let dirname= substitute(getline('.'),'^\(| \)*','','e') 8619 +" call Dret("s:NetrwBookHistSave") 8620 +endfun 8621 8622 - else 8623 -" call Decho("obtain word from wide listing") 8624 - let dirname= getline('.') 8625 +" --------------------------------------------------------------------- 8626 +" s:NetrwBrowse: This function uses the command in g:netrw_list_cmd to provide a {{{2 8627 +" list of the contents of a local or remote directory. It is assumed that the 8628 +" g:netrw_list_cmd has a string, USEPORT HOSTNAME, that needs to be substituted 8629 +" with the requested remote hostname first. 8630 +fun! s:NetrwBrowse(islocal,dirname) 8631 + if !exists("w:netrw_liststyle")|let w:netrw_liststyle= g:netrw_liststyle|endif 8632 +" call Dfunc("s:NetrwBrowse(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".w:netrw_liststyle." ".g:loaded_netrw." buf#".bufnr("%")."<".bufname("%")."> win#".winnr()) 8633 +" call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")." modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) 8634 +" call Dredir("ls!") 8635 8636 - if !exists("b:netrw_cpf") 8637 - let b:netrw_cpf= 0 8638 - exe 'sil keepj '.w:netrw_bannercnt.',$g/^./if virtcol("$") > b:netrw_cpf|let b:netrw_cpf= virtcol("$")|endif' 8639 - call histdel("/",-1) 8640 -" call Decho("computed cpf=".b:netrw_cpf) 8641 - endif 8642 + " s:NetrwBrowse: initialize history {{{3 8643 + if !exists("s:netrw_initbookhist") 8644 + keepj call s:NetrwBookHistRead() 8645 + endif 8646 8647 -" call Decho("buf#".bufnr("%")."<".bufname("%").">") 8648 - let filestart = (virtcol(".")/b:netrw_cpf)*b:netrw_cpf 8649 -" call Decho("filestart= ([virtcol=".virtcol(".")."]/[b:netrw_cpf=".b:netrw_cpf."])*b:netrw_cpf=".filestart." bannercnt=".w:netrw_bannercnt) 8650 -" call Decho("1: dirname<".dirname.">") 8651 - if filestart == 0 8652 - keepj norm! 0ma 8653 - else 8654 - call cursor(line("."),filestart+1) 8655 - keepj norm! ma 8656 - endif 8657 - let rega= @a 8658 - let eofname= filestart + b:netrw_cpf + 1 8659 - if eofname <= col("$") 8660 - call cursor(line("."),filestart+b:netrw_cpf+1) 8661 - keepj norm! "ay`a 8662 - else 8663 - keepj norm! "ay$ 8664 - endif 8665 - let dirname = @a 8666 - let @a = rega 8667 -" call Decho("2: dirname<".dirname.">") 8668 - let dirname= substitute(dirname,'\s\+$','','e') 8669 -" call Decho("3: dirname<".dirname.">") 8670 + " s:NetrwBrowse: simplify the dirname (especially for ".."s in dirnames) {{{3 8671 + if a:dirname !~ '^\a\+://' 8672 + let dirname= simplify(a:dirname) 8673 + else 8674 + let dirname= a:dirname 8675 endif 8676 8677 - " symlinks are indicated by a trailing "@". Remove it before further processing. 8678 - let dirname= substitute(dirname,"@$","","") 8679 + if exists("s:netrw_skipbrowse") 8680 + unlet s:netrw_skipbrowse 8681 +" call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." filename<".expand("%")."> win#".winnr()." ft<".&ft.">") 8682 +" call Dret("s:NetrwBrowse : s:netrw_skipbrowse existed") 8683 + return 8684 + endif 8685 8686 - " executables are indicated by a trailing "*". Remove it before further processing. 8687 - let dirname= substitute(dirname,"\*$","","") 8688 + " s:NetrwBrowse: sanity checks: {{{3 8689 + if !exists("*shellescape") 8690 + keepj call netrw#ErrorMsg(s:ERROR,"netrw can't run -- your vim is missing shellescape()",69) 8691 +" call Dret("s:NetrwBrowse : missing shellescape()") 8692 + return 8693 + endif 8694 + if !exists("*fnameescape") 8695 + keepj call netrw#ErrorMsg(s:ERROR,"netrw can't run -- your vim is missing fnameescape()",70) 8696 +" call Dret("s:NetrwBrowse : missing fnameescape()") 8697 + return 8698 + endif 8699 8700 -" call Dret("s:NetrwGetWord <".dirname.">") 8701 - return dirname 8702 -endfun 8703 + " s:NetrwBrowse: save options: {{{3 8704 + call s:NetrwOptionSave("w:") 8705 8706 -" --------------------------------------------------------------------- 8707 -" s:NetrwListSettings: make standard settings for a netrw listing {{{2 8708 -fun! s:NetrwListSettings(islocal) 8709 -" call Dfunc("s:NetrwListSettings(islocal=".a:islocal.")") 8710 - let fname= bufname("%") 6273 + let dirname= substitute(getline('.'),'^\('.s:treedepthstring.'\)*','','e') 6274 6275 else 6276 " call Decho("obtain word from wide listing") 6277 @@ -4100,14 +4043,16 @@ 6278 " s:NetrwListSettings: make standard settings for a netrw listing {{{2 6279 fun! s:NetrwListSettings(islocal) 6280 " call Dfunc("s:NetrwListSettings(islocal=".a:islocal.")") 6281 +" call Decho("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) 6282 let fname= bufname("%") 8711 6283 -" call Decho("(NetrwListSettings) setl bt=nofile nobl ma nonu nowrap noro") 8712 6284 - setl bt=nofile nobl ma nonu nowrap noro 8713 -" call Decho("(NetrwListSettings) exe sil! keepalt file ".fnameescape(fname)) 8714 - exe "sil! keepalt file ".fnameescape(fname) 8715 - if g:netrw_use_noswf 8716 - setl noswf 8717 - endif 8718 -" call Decho("(NetrwListSettings) exe setl ts=".(g:netrw_maxfilenamelen+1)) 8719 - exe "setl ts=".(g:netrw_maxfilenamelen+1) 8720 - setl isk+=.,~,- 8721 - if g:netrw_fastbrowse > a:islocal 8722 - setl bh=hide 8723 - else 8724 - setl bh=delete 8725 + " s:NetrwBrowse: re-instate any marked files {{{3 8726 + if exists("s:netrwmarkfilelist_{bufnr('%')}") 8727 +" call Decho("clearing marked files") 8728 + exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/" 6285 +" " call Decho("(NetrwListSettings) setl bt=nofile nobl ma nonu nowrap noro nornu") 6286 + setl bt=nofile nobl ma nonu nowrap noro nornu 6287 " call Decho("(NetrwListSettings) exe sil! keepalt file ".fnameescape(fname)) 6288 exe "sil! keepalt file ".fnameescape(fname) 6289 if g:netrw_use_noswf 6290 setl noswf 8729 6291 endif 8730 -" call Dret("s:NetrwListSettings") 8731 -endfun 8732 8733 -" --------------------------------------------------------------------- 8734 -" s:NetrwListStyle: {{{2 8735 -" islocal=0: remote browsing 8736 -" =1: local browsing 8737 -fun! s:NetrwListStyle(islocal) 8738 -" call Dfunc("NetrwListStyle(islocal=".a:islocal.") w:netrw_liststyle=".w:netrw_liststyle) 8739 - let ykeep = @@ 8740 - let fname = s:NetrwGetWord() 8741 - if !exists("w:netrw_liststyle")|let w:netrw_liststyle= g:netrw_liststyle|endif 8742 - let w:netrw_liststyle = (w:netrw_liststyle + 1) % s:MAXLIST 8743 -" call Decho("fname<".fname.">") 8744 -" call Decho("chgd w:netrw_liststyle to ".w:netrw_liststyle) 8745 -" call Decho("b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "doesn't exist").">") 8746 + if a:islocal && exists("w:netrw_acdkeep") && w:netrw_acdkeep 8747 + " s:NetrwBrowse: set up "safe" options for local directory/file {{{3 8748 +" call Decho("handle w:netrw_acdkeep:") 8749 +" call Decho("keepjumps lcd ".fnameescape(dirname)." (due to w:netrw_acdkeep=".w:netrw_acdkeep." - acd=".&acd.")") 8750 + call s:NetrwLcd(dirname) 8751 + call s:NetrwSafeOptions() 8752 +" call Decho("getcwd<".getcwd().">") 8753 8754 - if w:netrw_liststyle == s:THINLIST 8755 - " use one column listing 8756 -" call Decho("use one column list") 8757 - let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge') 8758 + elseif !a:islocal && dirname !~ '[\/]$' && dirname !~ '^"' 8759 + " s:NetrwBrowse: looks like a remote regular file, attempt transfer {{{3 8760 +" call Decho("attempt transfer as regular file<".dirname.">") 8761 8762 - elseif w:netrw_liststyle == s:LONGLIST 8763 - " use long list 8764 -" call Decho("use long list") 8765 - let g:netrw_list_cmd = g:netrw_list_cmd." -l" 8766 + " remove any filetype indicator from end of dirname, except for the 8767 + " "this is a directory" indicator (/). 8768 + " There shouldn't be one of those here, anyway. 8769 + let path= substitute(dirname,'[*=@|]\r\=$','','e') 8770 +" call Decho("new path<".path.">") 8771 + call s:RemotePathAnalysis(dirname) 8772 8773 - elseif w:netrw_liststyle == s:WIDELIST 8774 - " give wide list 8775 -" call Decho("use wide list") 8776 - let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge') 8777 + " s:NetrwBrowse: remote-read the requested file into current buffer {{{3 8778 + keepj mark ' 8779 + call s:NetrwEnew(dirname) 8780 + call s:NetrwSafeOptions() 8781 + setl ma noro 8782 +" call Decho("setl ma noro") 8783 + let b:netrw_curdir = dirname 8784 + let url = s:method."://".s:user.s:machine.(s:port ? ":".s:port : "")."/".s:path 8785 +" call Decho("exe sil! keepalt file ".fnameescape(url)." (bt=".&bt.")") 8786 + exe "sil! keepj keepalt file ".fnameescape(url) 8787 + exe "sil! keepj keepalt doau BufReadPre ".fnameescape(s:fname) 8788 + sil call netrw#NetRead(2,url) 8789 + " netrw.vim and tar.vim have already handled decompression of the tarball; avoiding gzip.vim error 8790 +" call Decho("url<".url.">") 8791 +" call Decho("s:path<".s:path.">") 8792 +" call Decho("s:fname<".s:fname.">") 8793 + if s:path =~ '.bz2' 8794 + exe "sil keepj keepalt doau BufReadPost ".fnameescape(substitute(s:fname,'\.bz2$','','')) 8795 + elseif s:path =~ '.gz' 8796 + exe "sil keepj keepalt doau BufReadPost ".fnameescape(substitute(s:fname,'\.gz$','','')) 8797 + elseif s:path =~ '.gz' 8798 + exe "sil keepj keepalt doau BufReadPost ".fnameescape(substitute(s:fname,'\.txz$','','')) 8799 + else 8800 + exe "sil keepj keepalt doau BufReadPost ".fnameescape(s:fname) 8801 + endif 8802 8803 - elseif w:netrw_liststyle == s:TREELIST 8804 -" call Decho("use tree list") 8805 - let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge') 8806 + " s:NetrwBrowse: save certain window-oriented variables into buffer-oriented variables {{{3 8807 + call s:SetBufWinVars() 8808 + call s:NetrwOptionRestore("w:") 8809 +" call Decho("setl ma nomod") 8810 + setl ma nomod 8811 +" call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 8812 8813 - else 8814 - keepj call netrw#ErrorMsg(s:WARNING,"bad value for g:netrw_liststyle (=".w:netrw_liststyle.")",46) 8815 - let g:netrw_liststyle = s:THINLIST 8816 - let w:netrw_liststyle = g:netrw_liststyle 8817 - let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge') 8818 +" call Dret("s:NetrwBrowse : file<".s:fname.">") 8819 + return 6292 +" call Dredir("ls!") 6293 " call Decho("(NetrwListSettings) exe setl ts=".(g:netrw_maxfilenamelen+1)) 6294 exe "setl ts=".(g:netrw_maxfilenamelen+1) 6295 setl isk+=.,~,- 6296 @@ -4116,6 +4061,7 @@ 6297 else 6298 setl bh=delete 8820 6299 endif 8821 - setl ma noro 8822 -" call Decho("setl ma noro") 8823 - 8824 - " clear buffer - this will cause NetrwBrowse/LocalBrowseCheck to do a refresh 8825 -" call Decho("clear buffer<".expand("%")."> with :%d") 8826 - sil! keepj %d 8827 - " following prevents tree listing buffer from being marked "modified" 6300 +" call Decho("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) 6301 " call Dret("s:NetrwListSettings") 6302 endfun 6303 6304 @@ -4125,9 +4071,11 @@ 6305 " =1: local browsing 6306 fun! s:NetrwListStyle(islocal) 6307 " call Dfunc("NetrwListStyle(islocal=".a:islocal.") w:netrw_liststyle=".w:netrw_liststyle) 6308 + 6309 let ykeep = @@ 6310 let fname = s:NetrwGetWord() 6311 if !exists("w:netrw_liststyle")|let w:netrw_liststyle= g:netrw_liststyle|endif 6312 + let svpos = netrw#SavePosn() 6313 let w:netrw_liststyle = (w:netrw_liststyle + 1) % s:MAXLIST 6314 " call Decho("fname<".fname.">") 6315 " call Decho("chgd w:netrw_liststyle to ".w:netrw_liststyle) 6316 @@ -4165,24 +4113,17 @@ 6317 " call Decho("clear buffer<".expand("%")."> with :%d") 6318 sil! keepj %d 6319 " following prevents tree listing buffer from being marked "modified" 8828 6320 -" call Decho("(NetrwListStyle) setl nomod") 8829 - setl nomod 6321 +" call Decho("setl nomod") 6322 setl nomod 8830 6323 -" call Decho("(NetrwListStyle) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 8831 8832 - " refresh the listing 6324 +" call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 6325 6326 " refresh the listing 8833 6327 -" call Decho("(NetrwListStyle) refresh the listing") 8834 6328 - let svpos= netrw#NetrwSavePosn() 8835 - keepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) 6329 +" call Decho("refresh the listing") 6330 keepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) 8836 6331 - keepj call netrw#NetrwRestorePosn(svpos) 8837 - keepj call s:NetrwCursor() 8838 + " use buffer-oriented WinVars if buffer variables exist but associated window variables don't {{{3 8839 + call s:UseBufWinVars() 6332 keepj call s:NetrwCursor() 8840 6333 8841 6334 - " keep cursor on the filename … … 8846 6339 - exe "sil! keepj ".w:netrw_bannercnt 8847 6340 - endif 8848 - let @@= ykeep 8849 + " set up some variables {{{3 8850 + let b:netrw_browser_active = 1 8851 + let dirname = dirname 8852 + let s:last_sort_by = g:netrw_sort_by 8853 8854 -" call Dret("NetrwListStyle".(exists("w:netrw_liststyle")? ' : w:netrw_liststyle='.w:netrw_liststyle : "")) 8855 -endfun 8856 + " set up menu {{{3 8857 + keepj call s:NetrwMenu(1) 8858 8859 -" --------------------------------------------------------------------- 8860 -" s:NetrwBannerCtrl: toggles the display of the banner {{{2 8861 -fun! s:NetrwBannerCtrl(islocal) 8862 -" call Dfunc("s:NetrwBannerCtrl(islocal=".a:islocal.") g:netrw_banner=".g:netrw_banner) 8863 - 8864 - let ykeep= @@ 8865 - " toggle the banner (enable/suppress) 8866 - let g:netrw_banner= !g:netrw_banner 8867 - 8868 - " refresh the listing 6341 + " restore position; keep cursor on the filename 6342 + keepj call netrw#RestorePosn(svpos) 6343 let @@= ykeep 6344 6345 " call Dret("NetrwListStyle".(exists("w:netrw_liststyle")? ' : w:netrw_liststyle='.w:netrw_liststyle : "")) 6346 @@ -4198,7 +4139,7 @@ 6347 let g:netrw_banner= !g:netrw_banner 6348 6349 " refresh the listing 8869 6350 - let svpos= netrw#NetrwSavePosn() 8870 - call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) 8871 - 8872 - " keep cursor on the filename 8873 - let fname= s:NetrwGetWord() 8874 - sil keepj $ 8875 - let result= search('\%(^\%(|\+\s\)\=\|\s\{2,}\)\zs'.escape(fname,'.\[]*$^').'\%(\s\{2,}\|$\)','bc') 8876 -" call Decho("search result=".result." w:netrw_bannercnt=".(exists("w:netrw_bannercnt")? w:netrw_bannercnt : 'N/A')) 8877 - if result <= 0 && exists("w:netrw_bannercnt") 8878 - exe "keepj ".w:netrw_bannercnt 8879 + " get/set-up buffer {{{3 8880 + let reusing= s:NetrwGetBuffer(a:islocal,dirname) 8881 + " maintain markfile highlighting 8882 + if exists("s:netrwmarkfilemtch_{bufnr('%')}") && s:netrwmarkfilemtch_{bufnr("%")} != "" 8883 +" call Decho("bufnr(%)=".bufnr('%')) 8884 +" call Decho("exe 2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/") 8885 + exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/" 8886 + else 8887 +" call Decho("2match none") 8888 + 2match none 8889 endif 8890 - let @@= ykeep 8891 -" call Dret("s:NetrwBannerCtrl : g:netrw_banner=".g:netrw_banner) 8892 -endfun 8893 - 8894 -" --------------------------------------------------------------------- 8895 -" s:NetrwBookmarkMenu: Uses menu priorities {{{2 8896 -" .2.[cnt] for bookmarks, and 8897 -" .3.[cnt] for history 8898 -" (see s:NetrwMenu()) 8899 -fun! s:NetrwBookmarkMenu() 8900 - if !exists("s:netrw_menucnt") 8901 + if reusing && line("$") > 1 8902 + call s:NetrwOptionRestore("w:") 8903 +" call Decho("setl noma nomod nowrap") 8904 + setl noma nomod nowrap 8905 +" call Decho("(set noma nomod nowrap) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 8906 +" call Dret("s:NetrwBrowse : re-using buffer") 8907 return 8908 endif 8909 -" call Dfunc("NetrwBookmarkMenu() histcnt=".g:netrw_dirhist_cnt." menucnt=".s:netrw_menucnt) 8910 8911 - " the following test assures that gvim is running, has menus available, and has menus enabled. 8912 - if has("gui") && has("menu") && has("gui_running") && &go =~# 'm' && g:netrw_menu 8913 - if exists("g:NetrwTopLvlMenu") 8914 -" call Decho("removing ".g:NetrwTopLvlMenu."Bookmarks menu item(s)") 8915 - exe 'sil! unmenu '.g:NetrwTopLvlMenu.'Bookmarks' 8916 - exe 'sil! unmenu '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Bookmark\ Delete' 8917 - endif 8918 - if !exists("s:netrw_initbookhist") 8919 - call s:NetrwBookHistRead() 8920 + " set b:netrw_curdir to the new directory name {{{3 8921 +" call Decho("set b:netrw_curdir to the new directory name<".dirname."> (buf#".bufnr("%").")") 8922 + let b:netrw_curdir= dirname 8923 + if b:netrw_curdir =~ '[/\\]$' 8924 + let b:netrw_curdir= substitute(b:netrw_curdir,'[/\\]$','','e') 8925 + endif 8926 + if b:netrw_curdir =~ '\a:$' && (has("win32") || has("win95") || has("win64") || has("win16")) 8927 + let b:netrw_curdir= b:netrw_curdir."/" 8928 + endif 8929 + if b:netrw_curdir == '' 8930 + if has("amiga") 8931 + " On the Amiga, the empty string connotes the current directory 8932 + let b:netrw_curdir= getcwd() 8933 + else 8934 + " under unix, when the root directory is encountered, the result 8935 + " from the preceding substitute is an empty string. 8936 + let b:netrw_curdir= '/' 8937 endif 8938 + endif 8939 + if !a:islocal && b:netrw_curdir !~ '/$' 8940 + let b:netrw_curdir= b:netrw_curdir.'/' 8941 + endif 8942 +" call Decho("b:netrw_curdir<".b:netrw_curdir.">") 8943 8944 - " show bookmarked places 8945 - if exists("g:netrw_bookmarklist") && g:netrw_bookmarklist != [] && g:netrw_dirhistmax > 0 8946 - let cnt= 1 8947 - for bmd in g:netrw_bookmarklist 6351 + let svpos= netrw#SavePosn() 6352 call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) 6353 6354 " keep cursor on the filename 6355 @@ -4239,14 +4180,14 @@ 6356 if exists("g:netrw_bookmarklist") && g:netrw_bookmarklist != [] && g:netrw_dirhistmax > 0 6357 let cnt= 1 6358 for bmd in g:netrw_bookmarklist 8948 6359 - let ebmd= escape(bmd,g:netrw_menu_escape) 8949 6360 -" call Decho('sil! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmark.'.ebmd.' :e '.bmd) 8950 + " ------------ 8951 + " (local only) {{{3 8952 + " ------------ 8953 + if a:islocal 8954 +" call Decho("local only:") 8955 8956 - " show bookmarks for goto menu 6361 +" call Decho('sil! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmark.'.bmd.' :e '.bmd) 6362 + let bmd= escape(bmd,g:netrw_menu_escape) 6363 6364 " show bookmarks for goto menu 8957 6365 - exe 'sil! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmarks.'.ebmd.' :e '.bmd."\<cr>" 8958 + " Set up ShellCmdPost handling. Append current buffer to browselist 8959 + call s:LocalFastBrowser() 8960 8961 - " show bookmarks for deletion menu 6366 + exe 'sil! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmarks.'.bmd.' :e '.bmd."\<cr>" 6367 6368 " show bookmarks for deletion menu 8962 6369 - exe 'sil! menu '.g:NetrwMenuPriority.".8.2.".cnt." ".g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Bookmark\ Delete.'.ebmd.' '.cnt."mB" 8963 - let cnt= cnt + 1 8964 - endfor 8965 + " handle g:netrw_keepdir: set vim's current directory to netrw's notion of the current directory {{{3 8966 + if !g:netrw_keepdir 8967 +" call Decho("handle g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd) 8968 +" call Decho("l:acd".(exists("&l:acd")? "=".&l:acd : " doesn't exist")) 8969 + if !exists("&l:acd") || !&l:acd 8970 + call s:NetrwLcd(b:netrw_curdir) 8971 + endif 8972 + endif 8973 + 8974 + " -------------------------------- 8975 + " remote handling: {{{3 8976 + " -------------------------------- 8977 + else 8978 +" call Decho("remote only:") 8979 8980 + " analyze dirname and g:netrw_list_cmd {{{3 8981 +" call Decho("b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "doesn't exist")."> dirname<".dirname.">") 8982 + if dirname =~ "^NetrwTreeListing\>" 8983 + let dirname= b:netrw_curdir 8984 +" call Decho("(dirname was <NetrwTreeListing>) dirname<".dirname.">") 8985 + elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir") 8986 + let dirname= substitute(b:netrw_curdir,'\\','/','g') 8987 + if dirname !~ '/$' 8988 + let dirname= dirname.'/' 8989 + endif 8990 + let b:netrw_curdir = dirname 8991 +" call Decho("(liststyle is TREELIST) dirname<".dirname.">") 8992 + else 8993 + let dirname = substitute(dirname,'\\','/','g') 8994 +" call Decho("(normal) dirname<".dirname.">") 8995 endif 8996 8997 - " show directory browsing history 8998 - if g:netrw_dirhistmax > 0 8999 - let cnt = g:netrw_dirhist_cnt 9000 - let first = 1 9001 - let histcnt = 0 9002 - while ( first || cnt != g:netrw_dirhist_cnt ) 9003 - let histcnt = histcnt + 1 9004 - let priority = g:netrw_dirhist_cnt + histcnt 9005 - if exists("g:netrw_dirhist_{cnt}") 9006 - let histdir= escape(g:netrw_dirhist_{cnt},g:netrw_menu_escape) 9007 -" call Decho('sil! menu '.g:NetrwMenuPriority.".3.".priority." ".g:NetrwTopLvlMenu.'History.'.histdir.' :e '.histdir) 9008 - exe 'sil! menu '.g:NetrwMenuPriority.".3.".priority." ".g:NetrwTopLvlMenu.'History.'.histdir.' :e '.histdir."\<cr>" 9009 - endif 9010 - let first = 0 9011 - let cnt = ( cnt - 1 ) % g:netrw_dirhistmax 9012 - if cnt < 0 9013 - let cnt= cnt + g:netrw_dirhistmax 9014 - endif 9015 - endwhile 9016 + let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/]\+\)/\(.*\)$' 9017 + if dirname !~ dirpat 9018 + if !exists("g:netrw_quiet") 9019 + keepj call netrw#ErrorMsg(s:ERROR,"netrw doesn't understand your dirname<".dirname.">",20) 9020 + endif 9021 + keepj call s:NetrwOptionRestore("w:") 9022 +" call Decho("setl noma nomod nowrap") 9023 + setl noma nomod nowrap 9024 +" call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 9025 +" call Dret("s:NetrwBrowse : badly formatted dirname<".dirname.">") 9026 + return 9027 endif 9028 + let b:netrw_curdir= dirname 9029 +" call Decho("b:netrw_curdir<".b:netrw_curdir."> (remote)") 9030 + endif " (additional remote handling) 9031 9032 + " ----------------------- 9033 + " Directory Listing: {{{3 9034 + " ----------------------- 9035 + keepj call s:NetrwMaps(a:islocal) 9036 + keepj call s:NetrwCommands(a:islocal) 9037 + keepj call s:PerformListing(a:islocal) 9038 + if v:version >= 700 && has("balloon_eval") && &beval == 0 && &l:bexpr == "" && !exists("g:netrw_nobeval") 9039 + let &l:bexpr= "netrw#BalloonHelp()" 9040 +" call Decho("set up balloon help: l:bexpr=".&l:bexpr) 9041 + setl beval 9042 endif 9043 -" call Dret("NetrwBookmarkMenu") 9044 + call s:NetrwOptionRestore("w:") 9045 + 9046 + " The s:LocalBrowseRefresh() function is called by an autocmd 9047 + " installed by s:LocalFastBrowser() when g:netrw_fastbrowse <= 1 (ie. slow, medium speed). 9048 + " However, s:NetrwBrowse() causes the FocusGained event to fire the firstt time. 9049 + 9050 +" call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)") 9051 +" call Dret("s:NetrwBrowse : did PerformListing ft<".&ft.">") 9052 + return 9053 endfun 9054 9055 " --------------------------------------------------------------------- 9056 -" s:NetrwBrowseChgDir: constructs a new directory based on the current {{{2 9057 -" directory and a new directory name. Also, if the 9058 -" "new directory name" is actually a file, 9059 -" NetrwBrowseChgDir() edits the file. 9060 -fun! s:NetrwBrowseChgDir(islocal,newdir,...) 9061 -" call Dfunc("s:NetrwBrowseChgDir(islocal=".a:islocal."> newdir<".a:newdir.">) a:0=".a:0." curpos<".string(getpos("."))."> b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "").">") 9062 - 9063 +" s:NetrwFileInfo: supports qf (query for file information) {{{2 9064 +fun! s:NetrwFileInfo(islocal,fname) 9065 +" call Dfunc("s:NetrwFileInfo(islocal=".a:islocal." fname<".a:fname.">) b:netrw_curdir<".b:netrw_curdir.">") 6370 + exe 'sil! menu '.g:NetrwMenuPriority.".8.2.".cnt." ".g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Bookmark\ Delete.'.bmd.' '.cnt."mB" 6371 let cnt= cnt + 1 6372 endfor 6373 6374 @@ -4284,78 +4225,109 @@ 6375 " NetrwBrowseChgDir() edits the file. 6376 fun! s:NetrwBrowseChgDir(islocal,newdir,...) 6377 " call Dfunc("s:NetrwBrowseChgDir(islocal=".a:islocal."> newdir<".a:newdir.">) a:0=".a:0." curpos<".string(getpos("."))."> b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "").">") 6378 +" call Decho("win#".winnr()) 6379 9066 6380 let ykeep= @@ 9067 -if !exists("b:netrw_curdir")9068 -" Don't try to change-directory: this can happen, for example, when netrw#ErrorMsg has been called9069 -" and the current window is the NetrwMessage window.9070 -let @@= ykeep6381 if !exists("b:netrw_curdir") 6382 " Don't try to change-directory: this can happen, for example, when netrw#ErrorMsg has been called 6383 " and the current window is the NetrwMessage window. 6384 let @@= ykeep 9071 6385 -" call Decho("(NetrwBrowseChgDir) b:netrw_curdir doesn't exist!") 9072 6386 -" call Decho("(NetrwBrowseChgDir) getcwd<".getcwd().">") 9073 -" call Dret("s:NetrwBrowseChgDir")9074 - return9075 - endif9076 + if a:islocal9077 + if (has("unix") || has("macunix")) && executable("/bin/ls")9078 9079 - " NetrwBrowseChgDir: save options and initialize {{{39080 - keepj call s:NetrwOptionSave("s:")9081 - keepj call s:NetrwSafeOptions()9082 - let nbcd_curpos = netrw#NetrwSavePosn()9083 - let s:nbcd_curpos_{bufnr('%')} = nbcd_curpos9084 -" call Decho("(NetrwBrowseChgDir) setting s:nbcd_curpos_".bufnr('%')." to SavePosn")9085 - if (has("win32") || has("win95") || has("win64") || has("win16"))9086 - let dirname = substitute(b:netrw_curdir,'\\','/','ge')9087 - else9088 - let dirname= b:netrw_curdir9089 - endif9090 - let newdir = a:newdir9091 - let dolockout = 09092 + if getline(".") == "../"9093 + echo system("/bin/ls -lsad ".shellescape(".."))9094 +" call Decho("#1: echo system(/bin/ls -lsad ".shellescape(..).")")9095 +9096 + elseif w:netrw_liststyle == s:TREELIST && getline(".") !~ '^'.s:treedepthstring9097 + echo system("/bin/ls -lsad ".shellescape(b:netrw_curdir))9098 +" call Decho("#2: echo system(/bin/ls -lsad ".shellescape(b:netrw_curdir).")")9099 9100 - " set up o/s-dependent directory recognition pattern9101 - if has("amiga")9102 - let dirpat= '[\/:]$'9103 + elseif exists("b:netrw_curdir")9104 + if b:netrw_curdir =~ '/$'9105 + echo system("/bin/ls -lsad ".shellescape(b:netrw_curdir.a:fname))9106 +" call Decho("#3: echo system(/bin/ls -lsad ".shellescape(b:netrw_curdir.a:fname).")")9107 +9108 + else9109 + echo system("/bin/ls -lsad ".shellescape(b:netrw_curdir."/".a:fname))9110 +" call Decho("#4: echo system(/bin/ls -lsad ".shellescape(b:netrw_curdir."/".a:fname).")")9111 + endif9112 +9113 + else9114 +" call Decho('using ls '.a:fname." using cwd<".getcwd().">")9115 + echo system("/bin/ls -lsad ".shellescape(a:fname))9116 +" call Decho("#5: echo system(/bin/ls -lsad ".shellescape(a:fname).")")9117 + endif9118 + else9119 + " use vim functions to return information about file below cursor9120 +" call Decho("using vim functions to query for file info")9121 + if !isdirectory(a:fname) && !filereadable(a:fname) && a:fname =~ '[*@/]'9122 + let fname= substitute(a:fname,".$","","")9123 + else9124 + let fname= a:fname9125 + endif9126 + let t = getftime(fname)9127 + let sz = getfsize(fname)9128 + echo a:fname.": ".sz." ".strftime(g:netrw_timefmt,getftime(fname))9129 +" call Decho("fname.": ".sz." ".strftime(g:netrw_timefmt,getftime(fname)))9130 + endif9131 else9132 - let dirpat= '[\/]$'9133 + echo "sorry, \"qf\" not supported yet for remote files"9134 endif9135 -" call Decho("(NetrwBrowseChgDir) dirname<".dirname."> dirpat<".dirpat.">")9136 + let @@= ykeep9137 +" call Dret("s:NetrwFileInfo")9138 +endfun9139 9140 - if dirname !~ dirpat9141 - " apparently vim is "recognizing" that it is in a directory and9142 - " is removing the trailing "/". Bad idea, so let's put it back.9143 - let dirname= dirname.'/'9144 -" call Decho("(NetrwBrowseChgDir) adjusting dirname<".dirname.">")9145 - endif9146 +" ---------------------------------------------------------------------9147 +" s:NetrwGetBuffer: {{{29148 +" returns 0=cleared buffer9149 +" 1=re-used buffer9150 +fun! s:NetrwGetBuffer(islocal,dirname)9151 +" call Dfunc("s:NetrwGetBuffer(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".g:netrw_liststyle)9152 +" call Decho("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)9153 + let dirname= a:dirname9154 9155 - if newdir !~ dirpat9156 - " ------------------------------9157 - " NetrwBrowseChgDir: edit a file {{{39158 - " ------------------------------9159 -" call Decho('(NetrwBrowseChgDir:edit-a-file) case "handling a file": newdir<'.newdir.'> !~ dirpat<'.dirpat.">")9160 + " re-use buffer if possible {{{39161 +" call Decho("--re-use a buffer if possible--")9162 + if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST9163 + " find NetrwTreeList buffer if there is one9164 +" call Decho("case liststyle=treelist: find NetrwTreeList buffer if there is one")9165 + if exists("w:netrw_treebufnr") && w:netrw_treebufnr > 09166 +" call Decho(" re-using w:netrw_treebufnr=".w:netrw_treebufnr)9167 + let eikeep= &ei9168 + setl ei=all9169 + exe "sil! keepalt b ".w:netrw_treebufnr9170 + let &ei= eikeep9171 + setl ma9172 + sil! keepj %d9173 +" call Decho("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)9174 +" call Dret("s:NetrwGetBuffer 0<buffer cleared> : bufnum#".w:netrw_treebufnr."<NetrwTreeListing>")9175 + return 09176 + endif9177 + let bufnum= -19178 +" call Decho(" liststyle=TREE but w:netrw_treebufnr doesn't exist")9179 9180 - " save position for benefit of Rexplore9181 - let s:rexposn_{bufnr("%")}= netrw#NetrwSavePosn()9182 + else9183 + " find buffer number of buffer named precisely the same as dirname {{{39184 +" call Decho("case listtyle not treelist: find buffer numnber of buffer named precisely the same as dirname--")9185 +" call Dredir("(NetrwGetBuffer) ls!","ls!")9186 9187 -" call Decho("(NetrwBrowseChgDir:edit-a-file) setting s:rexposn_".bufnr("%")." to SavePosn")9188 - if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") && newdir !~ '^\(/\|\a:\)'9189 - let dirname= s:NetrwTreeDir()9190 - if dirname =~ '/$'9191 - let dirname= dirname.newdir9192 - else9193 - let dirname= s:NetrwTreeDir()."/".newdir9194 + " get dirname and associated buffer number9195 + let bufnum = bufnr(escape(dirname,'\'))9196 +" call Decho(" find buffer<".dirname.">'s number ")9197 +" call Decho(" bufnr(dirname<".escape(dirname,'\').">)=".bufnum)9198 +9199 + if bufnum < 0 && dirname !~ '/$'9200 + " try appending a trailing /9201 +" call Decho(" try appending a trailing / to dirname<".dirname.">")9202 + let bufnum= bufnr(escape(dirname.'/','\'))9203 + if bufnum > 09204 + let dirname= dirname.'/'9205 endif9206 -" call Decho("(NetrwBrowseChgDir:edit-a-file) dirname<".dirname.">")9207 -" call Decho("(NetrwBrowseChgDir:edit-a-file) tree listing")9208 - elseif newdir =~ '^\(/\|\a:\)'9209 - let dirname= newdir9210 - else9211 - let dirname= s:ComposePath(dirname,newdir)9212 endif9213 -" call Decho("(NetrwBrowseChgDir:edit-a-file) handling a file: dirname<".dirname."> (a:0=".a:0.")")9214 - " this lets NetrwBrowseX avoid the edit9215 - if a:0 < 19216 -" call Decho("(NetrwBrowseChgDir:edit-a-file) set up windows for editing<".fnameescape(dirname)."> didsplit=".(exists("s:didsplit")? s:didsplit : "doesn't exist"))9217 - keepj call s:NetrwOptionRestore("s:")9218 - if !exists("s:didsplit")9219 -" call Decho("(NetrwBrowseChgDir:edit-a-file) s:didsplit does not exist; g:netrw_browse_split=".g:netrw_browse_split." win#".winnr())9220 - if g:netrw_browse_split == 19221 - " horizontally splitting the window first9222 - keepalt new9223 - if !&ea9224 - keepalt wincmd _9225 - endif9226 - elseif g:netrw_browse_split == 29227 - " vertically splitting the window first9228 - keepalt rightb vert new9229 - if !&ea9230 - keepalt wincmd |9231 - endif9232 - elseif g:netrw_browse_split == 39233 - " open file in new tab9234 - keepalt tabnew9235 - elseif g:netrw_browse_split == 49236 - " act like "P" (ie. open previous window)9237 - if s:NetrwPrevWinOpen(2) == 39238 - let @@= ykeep9239 -" call Dret("s:NetrwBrowseChgDir")9240 - return9241 - endif9242 - else9243 - " handling a file, didn't split, so remove menu9244 -" call Decho("(NetrwBrowseChgDir:edit-a-file) handling a file+didn't split, so remove menu")9245 - call s:NetrwMenu(0)9246 - " optional change to window9247 - if g:netrw_chgwin >= 19248 - exe "keepj keepalt ".g:netrw_chgwin."wincmd w"9249 - endif9250 - endif9251 - endif9252 9253 - " the point where netrw actually edits the (local) file9254 - " if its local only: LocalBrowseCheck() doesn't edit a file, but NetrwBrowse() will9255 - if a:islocal9256 -" call Decho("(NetrwBrowseChgDir:edit-a-file) edit local file: exe e! ".fnameescape(dirname))9257 - exe "keepj keepalt e! ".fnameescape(dirname)9258 - call s:NetrwCursor()9259 - else9260 -" call Decho("(NetrwBrowseChgDir:edit-a-file) remote file: NetrwBrowse will edit it")9261 + if bufnum < 0 && dirname =~ '/$'9262 + " try removing a trailing /9263 +" call Decho(" try removing a trailing / from dirname<".dirname.">")9264 + let bufnum= bufnr(escape(substitute(dirname,'/$','',''),'\'))9265 + if bufnum > 09266 + let dirname= substitute(dirname,'/$','','')9267 endif9268 - let dolockout= 19269 + endif9270 9271 - " handle g:Netrw_funcref -- call external-to-netrw functions9272 - " This code will handle g:Netrw_funcref as an individual function reference9273 - " or as a list of function references. It will ignore anything that's not9274 - " a function reference. See :help Funcref for information about function references.9275 - if exists("g:Netrw_funcref")9276 -" call Decho("(NetrwBrowseChgDir:edit-a-file) handle optional Funcrefs")9277 - if type(g:Netrw_funcref) == 29278 -" call Decho("(NetrwBrowseChgDir:edit-a-file) handling a g:Netrw_funcref")9279 - keepj call g:Netrw_funcref()9280 - elseif type(g:Netrw_funcref) == 39281 -" call Decho("(NetrwBrowseChgDir:edit-a-file) handling a list of g:Netrw_funcrefs")9282 - for Fncref in g:Netrw_funcref9283 - if type(FncRef) == 29284 - keepj call FncRef()9285 - endif9286 - endfor9287 +" call Decho(" findbuf1: bufnum=bufnr('".dirname."')=".bufnum." bufname(".bufnum.")<".bufname(bufnum)."> (initial)")9288 + " note: !~ was used just below, but that means using ../ to go back would match (ie. abc/def/ and abc/ matches)9289 + if bufnum > 0 && bufname(bufnum) != dirname && bufname(bufnum) != '.'9290 + " handle approximate matches9291 +" call Decho(" handling approx match: bufnum#".bufnum.">0 AND bufname<".bufname(bufnum).">!=dirname<".dirname."> AND bufname(".bufnum.")!='.'")9292 + let ibuf = 19293 + let buflast = bufnr("$")9294 +" call Decho(" findbuf2: buflast=bufnr($)=".buflast)9295 + while ibuf <= buflast9296 + let bname= substitute(bufname(ibuf),'\\','/','g')9297 + let bname= substitute(bname,'.\zs/$','','')9298 +" call Decho(" findbuf3: while [ibuf=",ibuf."]<=[buflast=".buflast."]: dirname<".dirname."> bname=bufname(".ibuf.")<".bname.">")9299 + if bname != '' && dirname =~ '/'.bname.'/\=$' && dirname !~ '^/'9300 + " bname is not empty9301 + " dirname ends with bname,9302 + " dirname doesn't start with /, so its not a absolute path9303 +" call Decho(" findbuf3a: passes test 1 : dirname<".dirname.'> =~ /'.bname.'/\=$ && dirname !~ ^/')9304 + break9305 + endif9306 + if bname =~ '^'.dirname.'/\=$'9307 + " bname begins with dirname9308 +" call Decho(' findbuf3b: passes test 2 : bname<'.bname.'>=~^'.dirname.'/\=$')9309 + break9310 + endif9311 + if dirname =~ '^'.bname.'/$'9312 +" call Decho(' findbuf3c: passes test 3 : dirname<'.dirname.'>=~^'.bname.'/$')9313 + break9314 + endif9315 + if bname != '' && dirname =~ '/'.bname.'$' && bname == bufname("%") && line("$") == 19316 +" call Decho(' findbuf3d: passes test 4 : dirname<'.dirname.'>=~ /'.bname.'$')9317 + break9318 endif9319 + let ibuf= ibuf + 19320 + endwhile9321 + if ibuf > buflast9322 + let bufnum= -19323 + else9324 + let bufnum= ibuf9325 endif9326 +" call Decho(" findbuf4: bufnum=".bufnum." (ibuf=".ibuf." buflast=".buflast.")")9327 endif9328 + endif9329 9330 - elseif newdir =~ '^/'9331 - " ----------------------------------------------------9332 - " NetrwBrowseChgDir: just go to the new directory spec {{{39333 - " ----------------------------------------------------9334 -" call Decho('(NetrwBrowseChgDir:goto-newdir) case "just go to new directory spec": newdir<'.newdir.'>')9335 - let dirname = newdir9336 - keepj call s:SetRexDir(a:islocal,dirname)9337 - keepj call s:NetrwOptionRestore("s:")9338 -9339 - elseif newdir == './'9340 - " ---------------------------------------------9341 - " NetrwBrowseChgDir: refresh the directory list {{{39342 - " ---------------------------------------------9343 -" call Decho('(NetrwBrowseChgDir:refresh-dirlist) case "refresh directory listing": newdir == "./"')9344 - keepj call s:SetRexDir(a:islocal,dirname)9345 -9346 - elseif newdir == '../'9347 - " --------------------------------------9348 - " NetrwBrowseChgDir: go up one directory {{{39349 - " --------------------------------------9350 -" call Decho('(NetrwBrowseChgDir:go-up) case "go up one directory": newdir == "../"')9351 -9352 - if w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict")9353 - " force a refresh9354 -" call Decho("(NetrwBrowseChgDir:go-up) clear buffer<".expand("%")."> with :%d")9355 -" call Decho("(NetrwBrowseChgDir:go-up) setl noro ma")9356 - setl noro ma9357 - keepj %d9358 - endif9359 -9360 - if has("amiga")9361 - " amiga9362 -" call Decho('(NetrwBrowseChgDir:go-up) case "go up one directory": newdir == "../" and amiga')9363 - if a:islocal9364 - let dirname= substitute(dirname,'^\(.*[/:]\)\([^/]\+$\)','\1','')9365 - let dirname= substitute(dirname,'/$','','')9366 + " get enew buffer and name it -or- re-use buffer {{{39367 +" call Decho(" get enew buffer and name it OR re-use buffer")9368 + sil! keepj keepalt mark '9369 + if bufnum < 0 || !bufexists(bufnum)9370 +" call Decho("--get enew buffer and name it (bufnum#".bufnum."<0 OR bufexists(".bufnum.")=".bufexists(bufnum)."==0)")9371 + call s:NetrwEnew(dirname)9372 +" call Decho(" got enew buffer#".bufnr("%")." (altbuf<".expand("#").">)")9373 + " name the buffer9374 + if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST9375 + " Got enew buffer; transform into a NetrwTreeListing9376 +" call Decho("--transform enew buffer#".bufnr("%")." into a NetrwTreeListing --")9377 + if !exists("s:netrw_treelistnum")9378 + let s:netrw_treelistnum= 19379 else9380 - let dirname= substitute(dirname,'^\(.*[/:]\)\([^/]\+/$\)','\1','')9381 + let s:netrw_treelistnum= s:netrw_treelistnum + 19382 endif9383 -" call Decho("(NetrwBrowseChgDir:go-up) amiga: dirname<".dirname."> (go up one dir)")9384 -9385 + let w:netrw_treebufnr= bufnr("%")9386 +" call Decho(" exe sil! keepalt file NetrwTreeListing ".fnameescape(s:netrw_treelistnum))9387 + exe 'sil! keepalt file NetrwTreeListing\ '.fnameescape(s:netrw_treelistnum)9388 + setl bt=nofile noswf9389 + nnoremap <silent> <buffer> [ :sil call <SID>TreeListMove('[')<cr>9390 + nnoremap <silent> <buffer> ] :sil call <SID>TreeListMove(']')<cr>9391 + nnoremap <silent> <buffer> [[ :sil call <SID>TreeListMove('[')<cr>9392 + nnoremap <silent> <buffer> ]] :sil call <SID>TreeListMove(']')<cr>9393 +" call Decho(" tree listing#".s:netrw_treelistnum." bufnr=".w:netrw_treebufnr)9394 else9395 - " unix or cygwin9396 -" call Decho('(NetrwBrowseChgDir:go-up) case "go up one directory": newdir == "../" and unix or cygwin')9397 - if a:islocal9398 - let dirname= substitute(dirname,'^\(.*\)/\([^/]\+\)/$','\1','')9399 - if dirname == ""9400 - let dirname= '/'9401 - endif9402 - else9403 - let dirname= substitute(dirname,'^\(\a\+://.\{-}/\{1,2}\)\(.\{-}\)\([^/]\+\)/$','\1\2','')9404 - endif9405 -" call Decho("(NetrwBrowseChgDir:go-up) unix: dirname<".dirname."> (go up one dir)")9406 - endif9407 - keepj call s:SetRexDir(a:islocal,dirname)9408 -9409 - elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict")9410 - " --------------------------------------9411 - " NetrwBrowseChgDir: Handle Tree Listing {{{39412 - " --------------------------------------9413 -" call Decho('(NetrwBrowseChgDir:tree-list) case liststyle is TREELIST and w:netrw_treedict exists')9414 - " force a refresh (for TREELIST, wait for NetrwTreeDir() to force the refresh)9415 -" call Decho("(NetrwBrowseChgDir) (treelist) setl noro ma")9416 - setl noro ma9417 - if !(exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir"))9418 -" call Decho("(NetrwBrowseChgDir) clear buffer<".expand("%")."> with :%d")9419 - keepj %d9420 +" let v:errmsg= "" " Decho9421 + let escdirname= fnameescape(dirname)9422 +" call Decho(" errmsg<".v:errmsg."> bufnr(escdirname<".escdirname.">)=".bufnr(escdirname)." bufname()<".bufname(bufnr(escdirname)).">")9423 +" call Decho(' exe sil! keepalt file '.escdirname)9424 +" let v:errmsg= "" " Decho9425 + exe 'sil! keepalt file '.escdirname9426 +" call Decho(" errmsg<".v:errmsg."> bufnr(".escdirname.")=".bufnr(escdirname)."<".bufname(bufnr(escdirname)).">")9427 endif9428 - let treedir = s:NetrwTreeDir()9429 - let s:treecurpos = nbcd_curpos9430 - let haskey= 09431 -" call Decho("(NetrwBrowseChgDir:tree-list) w:netrw_treedict<".string(w:netrw_treedict).">")9432 +" call Decho(" named enew buffer#".bufnr("%")."<".bufname("%").">")9433 9434 - " search treedict for tree dir as-is9435 - if has_key(w:netrw_treedict,treedir)9436 -" call Decho('(NetrwBrowseChgDir:tree-list) ....searched for treedir<'.treedir.'> : found it!')9437 - let haskey= 19438 + else " Re-use the buffer9439 +" call Decho("--re-use buffer#".bufnum." (bufnum#".bufnum.">=0 AND bufexists(".bufnum.")=".bufexists(bufnum)."!=0)")9440 + let eikeep= &ei9441 + setl ei=all9442 + if getline(2) =~ '^" Netrw Directory Listing'9443 +" call Decho(" getline(2)<".getline(2).'> matches "Netrw Directory Listing" : using keepalt b '.bufnum)9444 + exe "sil! keepalt b ".bufnum9445 else9446 -" call Decho('(NetrwBrowseChgDir:tree-list) ....searched for treedir<'.treedir.'> : not found')9447 - endif9448 -9449 - " search treedict for treedir with a / appended9450 - if !haskey && treedir !~ '/$'9451 - if has_key(w:netrw_treedict,treedir."/")9452 - let treedir= treedir."/"9453 -" call Decho('(NetrwBrowseChgDir:tree-list) ....searched.for treedir<'.treedir.'> found it!')9454 - let haskey = 19455 - else9456 -" call Decho('(NetrwBrowseChgDir:tree-list) ....searched for treedir<'.treedir.'/> : not found')9457 - endif9458 +" call Decho(" getline(2)<".getline(2).'> does not match "Netrw Directory Listing" : using b '.bufnum)9459 + exe "sil! keepalt b ".bufnum9460 endif9461 -9462 - " search treedict for treedir with any trailing / elided9463 - if !haskey && treedir =~ '/$'9464 - let treedir= substitute(treedir,'/$','','')9465 - if has_key(w:netrw_treedict,treedir)9466 -" call Decho('(NetrwBrowseChgDir:tree-list) ....searched.for treedir<'.treedir.'> found it!')9467 - let haskey = 19468 - else9469 -" call Decho('(NetrwBrowseChgDir:tree-list) ....searched for treedir<'.treedir.'> : not found')9470 - endif9471 + if bufname("%") == '.'9472 +" call Decho("exe sil! keepalt file ".fnameescape(getcwd()))9473 + exe "sil! keepalt file ".fnameescape(getcwd())9474 endif9475 -9476 - if haskey9477 - " close tree listing for selected subdirectory9478 -" call Decho("(NetrwBrowseChgDir:tree-list) closing selected subdirectory<".dirname.">")9479 - call remove(w:netrw_treedict,treedir)9480 -" call Decho("(NetrwBrowseChgDir) removed entry<".treedir."> from treedict")9481 -" call Decho("(NetrwBrowseChgDir) yielding treedict<".string(w:netrw_treedict).">")9482 - let dirname= w:netrw_treetop9483 + let &ei= eikeep9484 + if line("$") <= 19485 + keepj call s:NetrwListSettings(a:islocal)9486 +" call Decho("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)9487 +" call Dret("s:NetrwGetBuffer 0<buffer empty> : re-using buffer#".bufnr("%").", but its empty, so refresh it")9488 + return 09489 + elseif g:netrw_fastbrowse == 0 || (a:islocal && g:netrw_fastbrowse == 1)9490 + keepj call s:NetrwListSettings(a:islocal)9491 + sil keepj %d9492 +" call Decho("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)9493 +" call Dret("s:NetrwGetBuffer 0<cleared buffer> : re-using buffer#".bufnr("%").", but refreshing due to g:netrw_fastbrowse=".g:netrw_fastbrowse)9494 + return 09495 + elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST9496 +" call Decho("--re-use tree listing--")9497 +" call Decho(" clear buffer<".expand("%")."> with :%d")9498 + sil keepj %d9499 + keepj call s:NetrwListSettings(a:islocal)9500 +" call Decho("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)9501 +" call Dret("s:NetrwGetBuffer 0<cleared buffer> : re-using buffer#".bufnr("%").", but treelist mode always needs a refresh")9502 + return 09503 else9504 - " go down one directory9505 - let dirname= substitute(treedir,'/*$','/','')9506 -" call Decho("(NetrwBrowseChgDir:tree-list) go down one dir: treedir<".treedir.">")9507 +" call Decho("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)9508 +" call Dret("s:NetrwGetBuffer 1<buffer not cleared> : buf#".bufnr("%"))9509 + return 19510 endif9511 - keepj call s:SetRexDir(a:islocal,dirname)9512 - let s:treeforceredraw = 19513 -9514 - else9515 - " ----------------------------------------9516 - " NetrwBrowseChgDir: Go down one directory {{{39517 - " ----------------------------------------9518 - let dirname = s:ComposePath(dirname,newdir)9519 -" call Decho("(NetrwBrowseChgDir:go-down) go down one dir: dirname<".dirname."> newdir<".newdir.">")9520 - keepj call s:SetRexDir(a:islocal,dirname)9521 endif9522 9523 - " --------------------------------------9524 - " NetrwBrowseChgDir: Restore and Cleanup {{{39525 - " --------------------------------------9526 - keepj call s:NetrwOptionRestore("s:")9527 - if dolockout9528 -" call Decho("(NetrwBrowseChgDir:restore) filewritable(dirname<".dirname.">)=".filewritable(dirname))9529 - if filewritable(dirname)9530 -" call Decho("(NetrwBrowseChgDir:restore) doing modification lockout settings: ma nomod noro")9531 -" call Decho("(NetrwBrowseChgDir:restore) setl ma nomod noro")9532 - setl ma nomod noro9533 -" call Decho("(NetrwBrowseChgDir:restore) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")9534 - else9535 -" call Decho("(NetrwBrowseChgDir:restore) doing modification lockout settings: ma nomod ro")9536 -" call Decho("(NetrwBrowseChgDir:restore) setl ma nomod noro")9537 - setl ma nomod ro9538 -" call Decho("(NetrwBrowseChgDir:restore) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)")9539 - endif9540 - endif9541 - let @@= ykeep9542 + " do netrw settings: make this buffer not-a-file, modifiable, not line-numbered, etc {{{39543 + " fastbrowse Local Remote Hiding a buffer implies it may be re-used (fast)9544 + " slow 0 D D Deleting a buffer implies it will not be re-used (slow)9545 + " med 1 D H9546 + " fast 2 H H9547 +" call Decho("--do netrw settings: make this buffer#".bufnr("%")." not-a-file, modifiable, not line-numbered, etc--")9548 + let fname= expand("%")9549 + keepj call s:NetrwListSettings(a:islocal)9550 +" call Decho("exe sil! keepalt file ".fnameescape(fname))9551 + exe "sil! keepj keepalt file ".fnameescape(fname)9552 9553 -" call Dret("s:NetrwBrowseChgDir <".dirname."> : curpos<".string(getpos(".")).">")9554 - return dirname9555 + " delete all lines from buffer {{{39556 +" call Decho("--delete all lines from buffer--")9557 +" call Decho(" clear buffer<".expand("%")."> with :%d")9558 + sil! keepalt keepj %d9559 +9560 +" call Decho("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)9561 +" call Dret("s:NetrwGetBuffer 0<cleared buffer> : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%"))9562 + return 09563 endfun9564 9565 " ---------------------------------------------------------------------9566 -" s:NetrwBrowseX: (implements "x") executes a special "viewer" script or program for the {{{29567 -" given filename; typically this means given their extension.9568 -" 0=local, 1=remote9569 -fun! netrw#NetrwBrowseX(fname,remote)9570 -" call Dfunc("NetrwBrowseX(fname<".a:fname."> remote=".a:remote.")")9571 -9572 - let ykeep = @@9573 - let screenposn = netrw#NetrwSavePosn()9574 -9575 - " special core