1 " netrw.vim: Handles file transfer and remote directory listing across
5 " Maintainer: Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>
6 " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
7 " Copyright: Copyright (C) 1999-2007 Charles E. Campbell, Jr. {{{1
8 " Permission is hereby granted to use and distribute this code,
9 " with or without modifications, provided that this copyright
10 " notice is copied with it. Like anything else that's free,
11 " netrw.vim, netrwPlugin.vim, and netrwSettings.vim are provided
12 " *as is* and comes with no warranty of any kind, either
13 " expressed or implied. By using this plugin, you agree that
14 " in no event will the copyright holder be liable for any damages
15 " resulting from the use of this software.
17 " COMBAK: worked with tmpfile s:GetTempname() in NetRead() NetWrite()
18 " !!NEEDS DEBUGGING && TESTING!!!
19 "redraw!|call inputsave()|call input("Press <cr> to continue")|call inputrestore()
21 " But be doers of the Word, and not only hearers, deluding your own selves {{{1
23 " =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
25 if &cp || exists("g:loaded_netrw")
33 let g:loaded_netrw = "v109"
35 call netrw#ErrorMsg(s:WARNING,"you need vim version 7.0 or later for version ".g:loaded_netrw." of netrw",1)
41 "call Decho("doing autoload/netrw.vim version ".g:loaded_netrw)
43 " ======================
44 " Netrw Variables: {{{1
45 " ======================
47 " ---------------------------------------------------------------------
48 " Netrw Constants: {{{2
49 if !exists("g:NETRW_BOOKMARKMAX")
50 let g:NETRW_BOOKMARKMAX= 0
52 if !exists("g:NETRW_DIRHIST_CNT")
53 let g:NETRW_DIRHIST_CNT= 0
55 if !exists("s:LONGLIST")
63 " ---------------------------------------------------------------------
64 " Default values for netrw's global protocol variables {{{2
65 if !exists("g:netrw_dav_cmd")
66 let g:netrw_dav_cmd = "cadaver"
68 if !exists("g:netrw_fetch_cmd")
69 if executable("fetch")
70 let g:netrw_fetch_cmd = "fetch -o"
72 let g:netrw_fetch_cmd = ""
75 if !exists("g:netrw_ftp_cmd")
76 let g:netrw_ftp_cmd = "ftp"
78 if !exists("g:netrw_http_cmd")
80 let g:netrw_http_cmd = "curl -o"
81 elseif executable("wget")
82 let g:netrw_http_cmd = "wget -q -O"
83 elseif executable("fetch")
84 let g:netrw_http_cmd = "fetch -o"
86 let g:netrw_http_cmd = ""
89 if !exists("g:netrw_rcp_cmd")
90 let g:netrw_rcp_cmd = "rcp"
92 if !exists("g:netrw_rsync_cmd")
93 let g:netrw_rsync_cmd = "rsync"
95 if !exists("g:netrw_scp_cmd")
96 let g:netrw_scp_cmd = "scp -q"
98 if !exists("g:netrw_sftp_cmd")
99 let g:netrw_sftp_cmd = "sftp"
101 if !exists("g:netrw_ssh_cmd")
102 let g:netrw_ssh_cmd= "ssh"
105 if (has("win32") || has("win95") || has("win64") || has("win16"))
106 \ && exists("g:netrw_use_nt_rcp")
107 \ && g:netrw_use_nt_rcp
108 \ && executable( $SystemRoot .'/system32/rcp.exe')
109 let s:netrw_has_nt_rcp = 1
110 let s:netrw_rcpmode = '-b'
112 let s:netrw_has_nt_rcp = 0
113 let s:netrw_rcpmode = ''
116 " ---------------------------------------------------------------------
117 " Default values for netrw's global variables {{{2
118 " Default values - a-c ---------- {{{3
119 if !exists("g:netrw_alto")
120 let g:netrw_alto= &sb
122 if !exists("g:netrw_altv")
123 let g:netrw_altv= &spr
125 if !exists("g:netrw_browse_split")
126 let g:netrw_browse_split= 0
128 if !exists("g:netrw_chgwin")
129 let g:netrw_chgwin = -1
131 if !exists("g:netrw_cygwin")
132 if has("win32") || has("win95") || has("win64") || has("win16")
133 if &shell =~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$'
134 let g:netrw_cygwin= 1
136 let g:netrw_cygwin= 0
139 let g:netrw_cygwin= 0
142 let g:netrw_cygwin= 0
144 " Default values - d-f ---------- {{{3
145 if !exists("g:NETRW_DIRHIST_CNT")
146 let g:NETRW_DIRHIST_CNT= 0
148 if !exists("g:netrw_dirhistmax")
149 let g:netrw_dirhistmax= 10
151 if !exists("g:netrw_ftp_browse_reject")
152 let g:netrw_ftp_browse_reject='^total\s\+\d\+$\|^Trying\s\+\d\+.*$\|^KERBEROS_V\d rejected\|^Security extensions not\|No such file\|: connect to address [0-9a-fA-F:]*: No route to host$'
154 if !exists("g:netrw_ftp_list_cmd")
155 if has("unix") || (exists("g:netrw_cygwin") && g:netrw_cygwin)
156 let g:netrw_ftp_list_cmd = "ls -lF"
157 let g:netrw_ftp_timelist_cmd = "ls -tlF"
158 let g:netrw_ftp_sizelist_cmd = "ls -slF"
160 let g:netrw_ftp_list_cmd = "dir"
161 let g:netrw_ftp_timelist_cmd = "dir"
162 let g:netrw_ftp_sizelist_cmd = "dir"
165 if !exists("g:netrw_ftpmode")
166 let g:netrw_ftpmode= "binary"
168 " Default values - h-lh ---------- {{{3
169 if !exists("g:netrw_hide")
172 if !exists("g:netrw_ignorenetrc")
173 if &shell =~ '\c\<\%(cmd\|4nt\)\.exe$'
174 let g:netrw_ignorenetrc= 1
176 let g:netrw_ignorenetrc= 0
179 if !exists("g:netrw_keepdir")
180 let g:netrw_keepdir= 1
182 if !exists("g:netrw_list_cmd")
183 if g:netrw_scp_cmd =~ '^pscp' && executable("pscp")
184 " provide a 'pscp' listing command
185 if (has("win32") || has("win95") || has("win64") || has("win16")) && filereadable("c:\\private.ppk")
186 let g:netrw_scp_cmd ="pscp -i C:\\private.ppk"
188 let g:netrw_list_cmd= g:netrw_scp_cmd." -ls USEPORT HOSTNAME:"
189 elseif executable(g:netrw_ssh_cmd)
190 " provide a default listing command
191 let g:netrw_list_cmd= g:netrw_ssh_cmd." USEPORT HOSTNAME ls -FLa"
193 " call Decho(g:netrw_ssh_cmd." is not executable")
194 let g:netrw_list_cmd= ""
197 if !exists("g:netrw_list_hide")
198 let g:netrw_list_hide= ""
200 " Default values - lh-lz ---------- {{{3
201 if !exists("g:netrw_local_mkdir")
202 let g:netrw_local_mkdir= "mkdir"
204 if !exists("g:netrw_local_rmdir")
205 let g:netrw_local_rmdir= "rmdir"
207 if !exists("g:netrw_liststyle")
208 let g:netrw_liststyle= s:THINLIST
210 if g:netrw_liststyle < 0 || g:netrw_liststyle >= s:MAXLIST
212 let g:netrw_liststyle= s:THINLIST
214 if g:netrw_liststyle == s:LONGLIST && g:netrw_scp_cmd !~ '^pscp'
215 let g:netrw_list_cmd= g:netrw_list_cmd." -l"
217 " Default values - m-r ---------- {{{3
218 if !exists("g:netrw_maxfilenamelen")
219 let g:netrw_maxfilenamelen= 32
221 if !exists("g:netrw_menu")
224 if !exists("g:netrw_mkdir_cmd")
225 let g:netrw_mkdir_cmd= g:netrw_ssh_cmd." USEPORT HOSTNAME mkdir"
227 if !exists("g:netrw_scpport")
228 let g:netrw_scpport= "-P"
230 if !exists("g:netrw_sshport")
231 let g:netrw_sshport= "-p"
233 if !exists("g:netrw_rename_cmd")
234 let g:netrw_rename_cmd= g:netrw_ssh_cmd." USEPORT HOSTNAME mv"
236 if !exists("g:netrw_rm_cmd")
237 let g:netrw_rm_cmd = g:netrw_ssh_cmd." USEPORT HOSTNAME rm"
239 if !exists("g:netrw_rmdir_cmd")
240 let g:netrw_rmdir_cmd = g:netrw_ssh_cmd." USEPORT HOSTNAME rmdir"
242 if !exists("g:netrw_rmf_cmd")
243 let g:netrw_rmf_cmd = g:netrw_ssh_cmd." USEPORT HOSTNAME rm -f"
245 " Default values - s ---------- {{{3
246 if exists("g:netrw_silent") && g:netrw_silent != 0
247 let g:netrw_silentxfer= "silent "
249 let g:netrw_silentxfer= ""
251 if !exists("g:netrw_fastbrowse")
252 let g:netrw_fastbrowse= 1
254 if !exists("g:netrw_shq")
255 if exists("&shq") && &shq != ""
256 let g:netrw_shq= &shq
257 elseif has("win32") || has("win95") || has("win64") || has("win16")
266 " call Decho("g:netrw_shq<".g:netrw_shq.">")
268 if !exists("g:netrw_sort_by")
269 " alternatives: date size
270 let g:netrw_sort_by= "name"
272 if !exists("g:netrw_sort_direction")
273 " alternative: reverse (z y x ...)
274 let g:netrw_sort_direction= "normal"
276 if !exists("g:netrw_sort_sequence")
277 let g:netrw_sort_sequence= '[\/]$,\.h$,\.c$,\.cpp$,\.[a-np-z]$,*,\.info$,\.swp$,\.o$\.obj$,\.bak$'
279 if !exists("g:netrw_ssh_browse_reject")
280 let g:netrw_ssh_browse_reject='^total\s\+\d\+$'
283 if !exists("g:netrw_use_noswf")
284 let g:netrw_use_noswf= 1
287 let g:netrw_use_noswf= 0
289 " Default values - t-w ---------- {{{3
290 if !exists("g:netrw_timefmt")
291 let g:netrw_timefmt= "%c"
293 if !exists("g:NetrwTopLvlMenu")
294 let g:NetrwTopLvlMenu= "Netrw."
296 if !exists("g:netrw_use_errorwindow")
297 let g:netrw_use_errorwindow= 1
299 if !exists("g:netrw_win95ftp")
300 let g:netrw_win95ftp= 1
302 if !exists("g:netrw_winsize")
303 let g:netrw_winsize= ""
305 " ---------------------------------------------------------------------
306 " Default values for netrw's script variables: {{{2
307 if !exists("s:netrw_cd_escape")
308 let s:netrw_cd_escape="[]#*$%'\" ?`!&();<>\\"
310 if !exists("g:netrw_fname_escape")
311 let g:netrw_fname_escape= ' ?&;'
313 if !exists("g:netrw_tmpfile_escape")
314 let g:netrw_tmpfile_escape= ' ?&;'
316 if !exists("s:netrw_glob_escape")
317 let s:netrw_glob_escape= '[]*?`{~$'
320 " BufEnter event ignored by decho when following variable is true
321 " Has a side effect that doau BufReadPost doesn't work, so
322 " files read by network transfer aren't appropriately highlighted.
323 "let g:decho_bufenter = 1 "Decho
325 " ==============================
326 " Netrw Utility Functions: {{{1
327 " ==============================
329 " ------------------------------------------------------------------------
330 " NetSavePosn: saves position of cursor on screen {{{2
331 fun! netrw#NetSavePosn()
332 " call Dfunc("netrw#NetSavePosn()")
333 " Save current line and column
334 let w:netrw_winnr= winnr()
335 let w:netrw_line = line(".")
336 let w:netrw_col = virtcol(".")
338 " Save top-of-screen line
340 let w:netrw_hline= line(".")
342 call netrw#NetRestorePosn()
343 " call Dret("netrw#NetSavePosn : winnr=".w:netrw_winnr." line=".w:netrw_line." col=".w:netrw_col." hline=".w:netrw_hline)
346 " ------------------------------------------------------------------------
347 " NetRestorePosn: restores the cursor and file position as saved by NetSavePosn() {{{2
348 fun! netrw#NetRestorePosn()
349 " call Dfunc("netrw#NetRestorePosn() winnr=".(exists("w:netrw_winnr")? w:netrw_winnr : -1)." line=".(exists("w:netrw_line")? w:netrw_line : -1)." col=".(exists("w:netrw_col")? w:netrw_col : -1)." hline=".(exists("w:netrw_hline")? w:netrw_hline : -1))
352 if expand("%") == "NetrwMessage"
353 exe s:winBeforeErr."wincmd w"
357 if exists("w:netrw_winnr")
358 " call Decho("restore window: exe silent! ".w:netrw_winnr."wincmd w")
359 exe "silent! ".w:netrw_winnr."wincmd w"
361 if v:shell_error == 0
362 " as suggested by Bram M: redraw on no error
363 " allows protocol error messages to remain visible
367 " restore top-of-screen line
368 if exists("w:netrw_hline")
369 " call Decho("restore topofscreen: exe norm! ".w:netrw_hline."G0z")
370 exe "norm! ".w:netrw_hline."G0z\<CR>"
374 if exists("w:netrw_line") && exists("w:netrw_col")
375 " call Decho("restore posn: exe norm! ".w:netrw_line."G0".w:netrw_col."|")
376 exe "norm! ".w:netrw_line."G0".w:netrw_col."\<bar>"
380 " call Dret("netrw#NetRestorePosn")
383 " ===============================
384 " NetOptionSave: save options and set to "standard" form {{{2
386 fun! s:NetOptionSave()
387 " call Dfunc("s:NetOptionSave() win#".winnr()." buf#".bufnr("."))
388 if !exists("w:netrw_optionsave")
389 let w:netrw_optionsave= 1
391 " call Dret("s:NetOptionSave : netoptionsave=".w:netrw_optionsave)
395 " Save current settings and current directory
398 let w:netrw_acdkeep = &l:acd
400 let w:netrw_aikeep = &l:ai
401 let w:netrw_awkeep = &l:aw
402 let w:netrw_cikeep = &l:ci
403 let w:netrw_cinkeep = &l:cin
404 let w:netrw_cinokeep = &l:cino
405 let w:netrw_comkeep = &l:com
406 let w:netrw_cpokeep = &l:cpo
408 let w:netrw_dirkeep = getcwd()
410 let w:netrw_fokeep = &l:fo " formatoptions
411 let w:netrw_gdkeep = &l:gd " gdefault
412 let w:netrw_hidkeep = &l:hidden
413 let w:netrw_magickeep = &l:magic
414 let w:netrw_repkeep = &l:report
415 let w:netrw_spellkeep = &l:spell
416 let w:netrw_twkeep = &l:tw " textwidth
417 let w:netrw_wigkeep = &l:wig " wildignore
418 if has("win32") && !has("win95")
419 let w:netrw_swfkeep= &l:swf " swapfile
421 call s:NetrwSafeOptions()
422 if &go =~ 'a' | silent! let w:netrw_regstar = @* | endif
423 silent! let w:netrw_regslash= @/
425 " call Dret("s:NetOptionSave")
426 " call Dret("s:NetOptionSave : win#".winnr()." buf#".bufnr("."))
429 " ------------------------------------------------------------------------
430 " NetOptionRestore: restore options {{{2
431 fun! s:NetOptionRestore()
432 " call Dfunc("s:NetOptionRestore() win#".winnr()." buf#".bufnr("."))
433 if !exists("w:netrw_optionsave")
434 " call Dret("s:NetOptionRestore : w:netrw_optionsave doesn't exist")
437 unlet w:netrw_optionsave
440 if exists("w:netrw_acdkeep") |let &l:acd = w:netrw_acdkeep |unlet w:netrw_acdkeep |endif
442 if exists("w:netrw_aikeep") |let &l:ai = w:netrw_aikeep |unlet w:netrw_aikeep |endif
443 if exists("w:netrw_awkeep") |let &l:aw = w:netrw_awkeep |unlet w:netrw_awkeep |endif
444 if exists("w:netrw_cikeep") |let &l:ci = w:netrw_cikeep |unlet w:netrw_cikeep |endif
445 if exists("w:netrw_cinkeep") |let &l:cin = w:netrw_cinkeep |unlet w:netrw_cinkeep |endif
446 if exists("w:netrw_cinokeep") |let &l:cino = w:netrw_cinokeep |unlet w:netrw_cinokeep |endif
447 if exists("w:netrw_comkeep") |let &l:com = w:netrw_comkeep |unlet w:netrw_comkeep |endif
448 if exists("w:netrw_cpokeep") |let &l:cpo = w:netrw_cpokeep |unlet w:netrw_cpokeep |endif
449 if exists("w:netrw_dirkeep") |exe "lcd ".w:netrw_dirkeep |unlet w:netrw_dirkeep |endif
450 if exists("w:netrw_fokeep") |let &l:fo = w:netrw_fokeep |unlet w:netrw_fokeep |endif
451 if exists("w:netrw_gdkeep") |let &l:gd = w:netrw_gdkeep |unlet w:netrw_gdkeep |endif
452 if exists("w:netrw_hidkeep") |let &l:hidden = w:netrw_hidkeep |unlet w:netrw_hidkeep |endif
453 if exists("w:netrw_magic") |let &l:magic = w:netrw_magic |unlet w:netrw_magic |endif
454 if exists("w:netrw_repkeep") |let &l:report = w:netrw_repkeep |unlet w:netrw_repkeep |endif
455 if exists("w:netrw_spellkeep")|let &l:spell = w:netrw_spellkeep |unlet w:netrw_spellkeep|endif
456 if exists("w:netrw_twkeep") |let &l:tw = w:netrw_twkeep |unlet w:netrw_twkeep |endif
457 if exists("w:netrw_wigkeep") |let &l:wig = w:netrw_wigkeep |unlet w:netrw_wigkeep |endif
458 if exists("s:yykeep") |let @@ = s:yykeep |unlet s:yykeep |endif
459 if exists("w:netrw_swfkeep")
461 " user hasn't specified a swapfile directory;
462 " netrw will temporarily set the swapfile directory
463 " to the current directory as returned by getcwd().
464 let &l:directory = getcwd()
465 silent! let &l:swf = w:netrw_swfkeep
467 unlet w:netrw_swfkeep
468 elseif &l:swf != w:netrw_swfkeep
469 " following line causes a Press ENTER in windows -- can't seem to work around it!!! (COMBAK)
470 silent! let &l:swf= w:netrw_swfkeep
471 unlet w:netrw_swfkeep
474 if exists("w:netrw_regstar") |silent! let @*= w:netrw_regstar |unlet w:netrw_regstar |endif
475 if exists("w:netrw_regslash")|silent! let @/= w:netrw_regslash|unlet w:netrw_regslash|endif
477 " call Dret("s:NetOptionRestore : win#".winnr()." buf#".bufnr("."))
480 " ---------------------------------------------------------------------
481 " NetrwSafeOptions: sets options to help netrw do its job {{{2
482 fun! s:NetrwSafeOptions()
483 " call Dfunc("s:NetrwSafeOptions()")
488 setlocal noacd nocin noai noci magic nospell nohid wig= noaw
491 setlocal nocin noai noci magic nospell nohid wig= noaw
495 setlocal report=10000
496 if g:netrw_use_noswf && has("win32") && !has("win95")
499 " call Dret("s:NetrwSafeOptions")
502 " ------------------------------------------------------------------------
503 " Netrw Transfer Functions: {{{1
504 " ===============================
506 " ------------------------------------------------------------------------
507 " NetRead: responsible for reading a file over the net {{{2
508 " mode: =0 read remote file and insert before current line
509 " =1 read remote file and insert after current line
510 " =2 replace with remote file
511 " =3 obtain file, but leave in temporary format
512 fun! netrw#NetRead(mode,...)
513 " call Dfunc("netrw#NetRead(mode=".a:mode.",...) a:0=".a:0." ".g:loaded_netrw)
516 call s:NetOptionSave()
518 " interpret mode into a readcmd {{{3
519 if a:mode == 0 " read remote file before current line
521 elseif a:mode == 1 " read file after current line
523 elseif a:mode == 2 " replace with remote file
525 elseif a:mode == 3 " skip read of file (leave as temporary)
531 let ichoice = (a:0 == 0)? 0 : 1
532 " call Decho("readcmd<".readcmd."> ichoice=".ichoice)
534 " Get Temporary Filename {{{3
535 let tmpfile= s:GetTempfile("")
537 " call Dret("netrw#NetRead : unable to get a tempfile!")
543 " attempt to repeat with previous host-file-etc
544 if exists("b:netrw_lastfile") && a:0 == 0
545 " call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">")
546 let choice = b:netrw_lastfile
547 let ichoice= ichoice + 1
550 exe "let choice= a:" . ichoice
551 " call Decho("no lastfile: choice<" . choice . ">")
553 if match(choice,"?") == 0
555 echomsg 'NetRead Usage:'
556 echomsg ':Nread machine:path uses rcp'
557 echomsg ':Nread "machine path" uses ftp with <.netrc>'
558 echomsg ':Nread "machine id password path" uses ftp'
559 echomsg ':Nread dav://machine[:port]/path uses cadaver'
560 echomsg ':Nread fetch://machine/path uses fetch'
561 echomsg ':Nread ftp://[user@]machine[:port]/path uses ftp autodetects <.netrc>'
562 echomsg ':Nread http://[user@]machine/path uses http wget'
563 echomsg ':Nread rcp://[user@]machine/path uses rcp'
564 echomsg ':Nread rsync://machine[:port]/path uses rsync'
565 echomsg ':Nread scp://[user@]machine[[:#]port]/path uses scp'
566 echomsg ':Nread sftp://[user@]machine[[:#]port]/path uses sftp'
570 elseif match(choice,'^"') != -1
571 " Reconstruct Choice if choice starts with '"'
572 " call Decho("reconstructing choice")
573 if match(choice,'"$') != -1
575 let choice=strpart(choice,1,strlen(choice)-2)
578 let choice = strpart(choice,1,strlen(choice)-1)
581 while match(choice,'"$') == -1
582 let wholechoice = wholechoice . " " . choice
583 let ichoice = ichoice + 1
585 if !exists("g:netrw_quiet")
586 call netrw#ErrorMsg(s:ERROR,"Unbalanced string in filename '". wholechoice ."'",3)
588 " call Dret("netrw#NetRead :2 getcwd<".getcwd().">")
591 let choice= a:{ichoice}
593 let choice= strpart(wholechoice,1,strlen(wholechoice)-1) . " " . strpart(choice,0,strlen(choice)-1)
598 " call Decho("choice<" . choice . ">")
599 let ichoice= ichoice + 1
601 " Determine method of read (ftp, rcp, etc) {{{3
602 call s:NetMethod(choice)
603 let tmpfile= s:GetTempfile(b:netrw_fname) " apply correct suffix
605 " Check if NetBrowse() should be handling this request
606 " call Decho("checking if NetBrowse() should handle choice<".choice."> with netrw_list_cmd<".g:netrw_list_cmd.">")
607 if choice =~ "^.*[\/]$" && b:netrw_method != 5 && choice !~ '^http://'
608 " call Decho("yes, choice matches '^.*[\/]$'")
609 keepjumps call s:NetBrowse(0,choice)
610 " call Dret("netrw#NetRead :3 getcwd<".getcwd().">")
615 " Perform Protocol-Based Read {{{3
616 " ===========================
617 if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1
618 echo "(netrw) Processing your read request..."
621 ".........................................
622 " rcp: NetRead Method #1 {{{3
623 if b:netrw_method == 1 " read with rcp
624 " call Decho("read via rcp (method #1)")
625 " ER: nothing done with g:netrw_uid yet?
626 " ER: on Win2K" rcp machine[.user]:file tmpfile
627 " ER: if machine contains '.' adding .user is required (use $USERNAME)
628 " ER: the tmpfile is full path: rcp sees C:\... as host C
629 if s:netrw_has_nt_rcp == 1
630 if exists("g:netrw_uid") && ( g:netrw_uid != "" )
631 let uid_machine = g:netrw_machine .'.'. g:netrw_uid
633 " Any way needed it machine contains a '.'
634 let uid_machine = g:netrw_machine .'.'. $USERNAME
637 if exists("g:netrw_uid") && ( g:netrw_uid != "" )
638 let uid_machine = g:netrw_uid .'@'. g:netrw_machine
640 let uid_machine = g:netrw_machine
643 " call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".uid_machine.":".escape(b:netrw_fname,' ?&;')." ".tmpfile)
644 exe g:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".uid_machine.":".escape(b:netrw_fname,' ?&;')." ".tmpfile
645 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
646 let b:netrw_lastfile = choice
648 ".........................................
649 " ftp + <.netrc>: NetRead Method #2 {{{3
650 elseif b:netrw_method == 2 " read with ftp + <.netrc>
651 " call Decho("read via ftp+.netrc (method #2)")
652 let netrw_fname= b:netrw_fname
655 exe "put ='".g:netrw_ftpmode."'"
656 " call Decho("filter input: ".getline("."))
657 if exists("g:netrw_ftpextracmd")
658 exe "put ='".g:netrw_ftpextracmd."'"
659 " call Decho("filter input: ".getline("."))
661 exe "put ='".'get \"'.netrw_fname.'\" '.tmpfile."'"
662 " call Decho("filter input: ".getline("."))
663 if exists("g:netrw_port") && g:netrw_port != ""
664 " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port)
665 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port
667 " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine)
668 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine
670 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
671 if getline(1) !~ "^$" && !exists("g:netrw_quiet") && getline(1) !~ '^Trying '
672 let debugkeep= &debug
674 call netrw#ErrorMsg(s:ERROR,getline(1),4)
675 let &debug= debugkeep
678 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
679 let b:netrw_lastfile = choice
681 ".........................................
682 " ftp + machine,id,passwd,filename: NetRead Method #3 {{{3
683 elseif b:netrw_method == 3 " read with ftp + machine, id, passwd, and fname
684 " Construct execution string (four lines) which will be passed through filter
685 " call Decho("read via ftp+mipf (method #3)")
686 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
689 if exists("g:netrw_port") && g:netrw_port != ""
690 put ='open '.g:netrw_machine.' '.g:netrw_port
691 " call Decho("filter input: ".getline("."))
693 put ='open '.g:netrw_machine
694 " call Decho("filter input: ".getline("."))
697 if exists("g:netrw_ftp") && g:netrw_ftp == 1
699 " call Decho("filter input: ".getline("."))
700 put ='\"'.g:netrw_passwd.'\"'
701 " call Decho("filter input: ".getline("."))
703 put ='user \"'.g:netrw_uid.'\" \"'.g:netrw_passwd.'\"'
704 " call Decho("filter input: ".getline("."))
707 if exists("g:netrw_ftpmode") && g:netrw_ftpmode != ""
709 " call Decho("filter input: ".getline("."))
711 if exists("g:netrw_ftpextracmd")
712 exe "put ='".g:netrw_ftpextracmd."'"
713 " call Decho("filter input: ".getline("."))
715 put ='get \"'.netrw_fname.'\" '.tmpfile
716 " call Decho("filter input: ".getline("."))
719 " -i : turns off interactive prompting from ftp
720 " -n unix : DON'T use <.netrc>, even though it exists
721 " -n win32: quit being obnoxious about password
723 " call Decho("executing: %!".g:netrw_ftp_cmd." -i -n")
724 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n"
725 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
726 if getline(1) !~ "^$"
727 " call Decho("error<".getline(1).">")
728 if !exists("g:netrw_quiet")
729 call netrw#ErrorMsg(s:ERROR,getline(1),5)
733 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
734 let b:netrw_lastfile = choice
736 ".........................................
737 " scp: NetRead Method #4 {{{3
738 elseif b:netrw_method == 4 " read with scp
739 " call Decho("read via scp (method #4)")
740 if exists("g:netrw_port") && g:netrw_port != ""
741 let useport= " ".g:netrw_scpport." ".g:netrw_port
745 " call Decho("executing: !".g:netrw_scp_cmd.useport." '".g:netrw_machine.":".escape(b:netrw_fname,g:netrw_fname_escape)."' ".tmpfile)
746 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_shq.g:netrw_machine.":".escape(b:netrw_fname,g:netrw_fname_escape).g:netrw_shq." ".tmpfile
747 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
748 let b:netrw_lastfile = choice
750 ".........................................
751 " http: NetRead Method #5 (wget) {{{3
752 elseif b:netrw_method == 5
753 " call Decho("read via http (method #5)")
754 if g:netrw_http_cmd == ""
755 if !exists("g:netrw_quiet")
756 call netrw#ErrorMsg(s:ERROR,"neither the wget nor the fetch command is available",6)
758 " call Dret("netrw#NetRead :4 getcwd<".getcwd().">")
762 if match(b:netrw_fname,"#") == -1
764 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
765 " call Decho("executing: !".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_fname)
766 exe g:netrw_silentxfer."!".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_fname
767 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
770 " wget plus a jump to an in-page marker (ie. http://abc/def.html#aMarker)
771 let netrw_html= substitute(netrw_fname,"#.*$","","")
772 let netrw_tag = substitute(netrw_fname,"^.*#","","")
773 " call Decho("netrw_html<".netrw_html.">")
774 " call Decho("netrw_tag <".netrw_tag.">")
775 " call Decho("executing: !".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_html)
776 exe g:netrw_silentxfer."!".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_html
777 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
778 " call Decho('<\s*a\s*name=\s*"'.netrw_tag.'"/')
779 exe 'norm! 1G/<\s*a\s*name=\s*"'.netrw_tag.'"/'."\<CR>"
781 let b:netrw_lastfile = choice
784 ".........................................
785 " cadaver: NetRead Method #6 {{{3
786 elseif b:netrw_method == 6
787 " call Decho("read via cadaver (method #6)")
789 " Construct execution string (four lines) which will be passed through filter
790 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
793 if exists("g:netrw_port") && g:netrw_port != ""
794 put ='open '.g:netrw_machine.' '.g:netrw_port
796 put ='open '.g:netrw_machine
798 put ='user '.g:netrw_uid.' '.g:netrw_passwd
799 put ='get '.netrw_fname.' '.tmpfile
802 " perform cadaver operation:
804 " call Decho("executing: %!".g:netrw_dav_cmd)
805 exe g:netrw_silentxfer."%!".g:netrw_dav_cmd
807 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
808 let b:netrw_lastfile = choice
810 ".........................................
811 " rsync: NetRead Method #7 {{{3
812 elseif b:netrw_method == 7
813 " call Decho("read via rsync (method #7)")
814 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
815 " call Decho("executing: !".g:netrw_rsync_cmd." ".g:netrw_machine.":".netrw_fname." ".tmpfile)
816 exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".g:netrw_machine.":".netrw_fname." ".tmpfile
817 let result = s:NetGetFile(readcmd,tmpfile, b:netrw_method)
818 let b:netrw_lastfile = choice
820 ".........................................
821 " fetch: NetRead Method #8 {{{3
822 " fetch://[user@]host[:http]/path
823 elseif b:netrw_method == 8
824 " call Decho("read via fetch (method #8)")
825 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
826 if g:netrw_fetch_cmd == ""
827 if !exists("g:netrw_quiet")
828 call netrw#ErrorMsg(s:ERROR,"fetch command not available",7)
830 " call Dret("NetRead")
832 if exists("g:netrw_option") && g:netrw_option == ":http"
833 let netrw_option= "http"
835 let netrw_option= "ftp"
837 " call Decho("read via fetch for ".netrw_option)
839 if exists("g:netrw_uid") && g:netrw_uid != "" && exists("g:netrw_passwd") && g:netrw_passwd != ""
840 " call Decho("executing: !".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_uid.':'.g:netrw_passwd.'@'.g:netrw_machine."/".netrw_fname)
841 exe g:netrw_silentxfer."!".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_uid.':'.g:netrw_passwd.'@'.g:netrw_machine."/".netrw_fname
843 " call Decho("executing: !".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_machine."/".netrw_fname)
844 exe g:netrw_silentxfer."!".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_machine."/".netrw_fname
847 let result = s:NetGetFile(readcmd,tmpfile, b:netrw_method)
848 let b:netrw_lastfile = choice
851 ".........................................
852 " sftp: NetRead Method #9 {{{3
853 elseif b:netrw_method == 9
854 " call Decho("read via sftp (method #9)")
855 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
856 " call Decho("executing: !".g:netrw_sftp_cmd." ".g:netrw_machine.":".netrw_fname." ".tmpfile)
857 exe g:netrw_silentxfer."!".g:netrw_sftp_cmd." ".g:netrw_machine.":".netrw_fname." ".tmpfile
858 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
859 let b:netrw_lastfile = choice
861 ".........................................
864 call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . choice . ">",8)
869 if exists("b:netrw_method")
870 " call Decho("cleanup b:netrw_method and b:netrw_fname")
874 if s:FileReadable(tmpfile) && tmpfile !~ '.tar.bz2$' && tmpfile !~ '.tar.gz$' && tmpfile !~ '.zip' && tmpfile !~ '.tar' && readcmd != 't'
875 " call Decho("cleanup by deleting tmpfile<".tmpfile.">")
876 call s:System("delete",tmpfile)
878 call s:NetOptionRestore()
880 " call Dret("netrw#NetRead :5 getcwd<".getcwd().">")
883 " ------------------------------------------------------------------------
884 " NetWrite: responsible for writing a file over the net {{{2
885 fun! netrw#NetWrite(...) range
886 " call Dfunc("netrw#NetWrite(a:0=".a:0.") ".g:loaded_netrw)
890 call s:NetOptionSave()
892 " Get Temporary Filename {{{3
893 let tmpfile= s:GetTempfile("")
895 " call Dret("netrw#NetWrite : unable to get a tempfile!")
905 let curbufname= expand("%")
906 " call Decho("curbufname<".curbufname.">")
908 " For binary writes, always write entire file.
909 " (line numbers don't really make sense for that).
910 " Also supports the writing of tar and zip files.
911 " call Decho("(write entire file) silent exe w! ".v:cmdarg." ".tmpfile)
912 silent exe "w! ".v:cmdarg." ".tmpfile
913 elseif g:netrw_cygwin
914 " write (selected portion of) file to temporary
915 let cygtmpfile= substitute(tmpfile,'/cygdrive/\(.\)','\1:','')
916 " call Decho("(write selected portion) silent exe ".a:firstline."," . a:lastline . "w! ".v:cmdarg." ".cygtmpfile)
917 silent exe a:firstline."," . a:lastline . "w! ".v:cmdarg." ".cygtmpfile
919 " write (selected portion of) file to temporary
920 " call Decho("(write selected portion) silent exe ".a:firstline."," . a:lastline . "w! ".v:cmdarg." ".tmpfile)
921 silent exe a:firstline."," . a:lastline . "w! ".v:cmdarg." ".tmpfile
925 " if the file is [No Name], and one attempts to Nwrite it, the buffer takes
926 " on the temporary file's name. Deletion of the temporary file during
927 " cleanup then causes an error message.
931 " While choice loop: {{{3
934 " Process arguments: {{{4
935 " attempt to repeat with previous host-file-etc
936 if exists("b:netrw_lastfile") && a:0 == 0
937 " call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">")
938 let choice = b:netrw_lastfile
939 let ichoice= ichoice + 1
941 exe "let choice= a:" . ichoice
943 " Reconstruct Choice if choice starts with '"'
944 if match(choice,"?") == 0
945 echomsg 'NetWrite Usage:"'
946 echomsg ':Nwrite machine:path uses rcp'
947 echomsg ':Nwrite "machine path" uses ftp with <.netrc>'
948 echomsg ':Nwrite "machine id password path" uses ftp'
949 echomsg ':Nwrite dav://[user@]machine/path uses cadaver'
950 echomsg ':Nwrite fetch://[user@]machine/path uses fetch'
951 echomsg ':Nwrite ftp://machine[#port]/path uses ftp (autodetects <.netrc>)'
952 echomsg ':Nwrite rcp://machine/path uses rcp'
953 echomsg ':Nwrite rsync://[user@]machine/path uses rsync'
954 echomsg ':Nwrite scp://[user@]machine[[:#]port]/path uses scp'
955 echomsg ':Nwrite sftp://[user@]machine/path uses sftp'
959 elseif match(choice,"^\"") != -1
960 if match(choice,"\"$") != -1
962 let choice=strpart(choice,1,strlen(choice)-2)
965 let choice = strpart(choice,1,strlen(choice)-1)
968 while match(choice,"\"$") == -1
969 let wholechoice= wholechoice . " " . choice
970 let ichoice = ichoice + 1
972 if !exists("g:netrw_quiet")
973 call netrw#ErrorMsg(s:ERROR,"Unbalanced string in filename '". wholechoice ."'",13)
975 " call Dret("netrw#NetWrite")
978 let choice= a:{ichoice}
980 let choice= strpart(wholechoice,1,strlen(wholechoice)-1) . " " . strpart(choice,0,strlen(choice)-1)
984 let ichoice= ichoice + 1
985 " call Decho("choice<" . choice . "> ichoice=".ichoice)
987 " Determine method of write (ftp, rcp, etc) {{{4
988 call s:NetMethod(choice)
991 " Perform Protocol-Based Write {{{4
992 " ============================
993 if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1
994 echo "(netrw) Processing your write request..."
997 ".........................................
998 " rcp: NetWrite Method #1 {{{4
999 if b:netrw_method == 1
1000 " call Decho("write via rcp (method #1)")
1001 if s:netrw_has_nt_rcp == 1
1002 if exists("g:netrw_uid") && ( g:netrw_uid != "" )
1003 let uid_machine = g:netrw_machine .'.'. g:netrw_uid
1005 let uid_machine = g:netrw_machine .'.'. $USERNAME
1008 if exists("g:netrw_uid") && ( g:netrw_uid != "" )
1009 let uid_machine = g:netrw_uid .'@'. g:netrw_machine
1011 let uid_machine = g:netrw_machine
1014 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
1015 " call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".g:netrw_shq.tmpfile.g:netrw_shq." ".uid_machine.":".netrw_fname)
1016 exe g:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".g:netrw_shq.tmpfile.g:netrw_shq." ".uid_machine.":".netrw_fname
1017 let b:netrw_lastfile = choice
1019 ".........................................
1020 " ftp + <.netrc>: NetWrite Method #2 {{{4
1021 elseif b:netrw_method == 2
1022 " call Decho("write via ftp+.netrc (method #2)")
1023 let netrw_fname= b:netrw_fname
1026 exe "put ='".g:netrw_ftpmode."'"
1027 " call Decho(" filter input: ".getline("."))
1028 if exists("g:netrw_ftpextracmd")
1029 exe "put ='".g:netrw_ftpextracmd."'"
1030 " call Decho("filter input: ".getline("."))
1032 exe "put ='".'put \"'.tmpfile.'\" \"'.netrw_fname.'\"'."'"
1033 " call Decho(" filter input: ".getline("."))
1034 if exists("g:netrw_port") && g:netrw_port != ""
1035 " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port)
1036 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port
1038 " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine)
1039 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine
1041 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
1042 if getline(1) !~ "^$"
1043 if !exists("g:netrw_quiet")
1044 call netrw#ErrorMsg(s:ERROR,getline(1),14)
1049 let b:netrw_lastfile = choice
1051 ".........................................
1052 " ftp + machine, id, passwd, filename: NetWrite Method #3 {{{4
1053 elseif b:netrw_method == 3
1054 " Construct execution string (four lines) which will be passed through filter
1055 " call Decho("read via ftp+mipf (method #3)")
1056 let netrw_fname= b:netrw_fname
1059 if exists("g:netrw_port") && g:netrw_port != ""
1060 put ='open '.g:netrw_machine.' '.g:netrw_port
1061 " call Decho("filter input: ".getline("."))
1063 put ='open '.g:netrw_machine
1064 " call Decho("filter input: ".getline("."))
1066 if exists("g:netrw_ftp") && g:netrw_ftp == 1
1068 " call Decho("filter input: ".getline("."))
1069 put ='\"'.g:netrw_passwd.'\"'
1070 " call Decho("filter input: ".getline("."))
1072 put ='user \"'.g:netrw_uid.'\" \"'.g:netrw_passwd.'\"'
1073 " call Decho("filter input: ".getline("."))
1075 put ='put \"'.tmpfile.'\" \"'.netrw_fname.'\"'
1076 " call Decho("filter input: ".getline("."))
1077 " save choice/id/password for future use
1078 let b:netrw_lastfile = choice
1081 " -i : turns off interactive prompting from ftp
1082 " -n unix : DON'T use <.netrc>, even though it exists
1083 " -n win32: quit being obnoxious about password
1085 " call Decho("executing: %!".g:netrw_ftp_cmd." -i -n")
1086 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n"
1087 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
1088 if getline(1) !~ "^$"
1089 if !exists("g:netrw_quiet")
1090 call netrw#ErrorMsg(s:ERROR,getline(1),15)
1096 ".........................................
1097 " scp: NetWrite Method #4 {{{4
1098 elseif b:netrw_method == 4
1099 " call Decho("write via scp (method #4)")
1100 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
1101 if exists("g:netrw_port") && g:netrw_port != ""
1102 let useport= " ".g:netrw_scpport." ".g:netrw_port
1106 " call Decho("exe ".g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_shq.tmpfile.g:netrw_shq." ".g:netrw_shq.g:netrw_machine.":".netrw_fname.g:netrw_shq)
1107 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_shq.tmpfile.g:netrw_shq." ".g:netrw_shq.g:netrw_machine.":".netrw_fname.g:netrw_shq
1108 let b:netrw_lastfile = choice
1110 ".........................................
1111 " http: NetWrite Method #5 {{{4
1112 elseif b:netrw_method == 5
1113 " call Decho("write via http (method #5)")
1114 if !exists("g:netrw_quiet")
1115 call netrw#ErrorMsg(s:ERROR,"currently <netrw.vim> does not support writing using http:",16)
1118 ".........................................
1119 " dav: NetWrite Method #6 (cadaver) {{{4
1120 elseif b:netrw_method == 6
1121 " call Decho("write via cadaver (method #6)")
1123 " Construct execution string (four lines) which will be passed through filter
1124 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
1127 if exists("g:netrw_port") && g:netrw_port != ""
1128 put ='open '.g:netrw_machine.' '.g:netrw_port
1130 put ='open '.g:netrw_machine
1132 put ='user '.g:netrw_uid.' '.g:netrw_passwd
1133 put ='put '.tmpfile.' '.netrw_fname
1135 " perform cadaver operation:
1137 " call Decho("executing: %!".g:netrw_dav_cmd)
1138 exe g:netrw_silentxfer."%!".g:netrw_dav_cmd
1140 let b:netrw_lastfile = choice
1142 ".........................................
1143 " rsync: NetWrite Method #7 {{{4
1144 elseif b:netrw_method == 7
1145 " call Decho("write via rsync (method #7)")
1146 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
1147 " call Decho("executing: !".g:netrw_rsync_cmd." ".tmpfile." ".g:netrw_machine.":".netrw_fname)
1148 exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".tmpfile." ".g:netrw_machine.":".netrw_fname
1149 let b:netrw_lastfile = choice
1151 ".........................................
1152 " sftp: NetWrite Method #9 {{{4
1153 elseif b:netrw_method == 9
1154 " call Decho("read via sftp (method #9)")
1155 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
1156 if exists("g:netrw_uid") && ( g:netrw_uid != "" )
1157 let uid_machine = g:netrw_uid .'@'. g:netrw_machine
1159 let uid_machine = g:netrw_machine
1163 put ='put \"'.escape(tmpfile,'\').'\" '.netrw_fname
1164 " call Decho("filter input: ".getline("."))
1166 " call Decho("executing: %!".g:netrw_sftp_cmd.' '.uid_machine)
1167 exe g:netrw_silentxfer."%!".g:netrw_sftp_cmd.' '.uid_machine
1169 let b:netrw_lastfile= choice
1171 ".........................................
1174 call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . choice . ">",17)
1179 " call Decho("cleanup")
1180 if s:FileReadable(tmpfile)
1181 " call Decho("tmpfile<".tmpfile."> readable, will now delete it")
1182 call s:System("delete",tmpfile)
1184 call s:NetOptionRestore()
1186 if a:firstline == 1 && a:lastline == line("$")
1187 " restore modifiability; usually equivalent to set nomod
1191 " call Dret("netrw#NetWrite")
1194 " ---------------------------------------------------------------------
1195 " NetSource: source a remotely hosted vim script {{{2
1196 " uses NetRead to get a copy of the file into a temporarily file,
1197 " then sources that file,
1198 " then removes that file.
1199 fun! netrw#NetSource(...)
1200 " call Dfunc("netrw#NetSource() a:0=".a:0)
1201 if a:0 > 0 && a:1 == '?'
1203 echomsg 'NetSource Usage:'
1204 echomsg ':Nsource dav://machine[:port]/path uses cadaver'
1205 echomsg ':Nsource fetch://machine/path uses fetch'
1206 echomsg ':Nsource ftp://[user@]machine[:port]/path uses ftp autodetects <.netrc>'
1207 echomsg ':Nsource http://[user@]machine/path uses http wget'
1208 echomsg ':Nsource rcp://[user@]machine/path uses rcp'
1209 echomsg ':Nsource rsync://machine[:port]/path uses rsync'
1210 echomsg ':Nsource scp://[user@]machine[[:#]port]/path uses scp'
1211 echomsg ':Nsource sftp://[user@]machine[[:#]port]/path uses sftp'
1216 call netrw#NetRead(3,a:{i})
1217 " call Decho("s:netread_tmpfile<".s:netrw_tmpfile.">")
1218 if s:FileReadable(s:netrw_tmpfile)
1219 " call Decho("exe so ".s:netrw_tmpfile)
1220 exe "so ".s:netrw_tmpfile
1221 call delete(s:netrw_tmpfile)
1222 unlet s:netrw_tmpfile
1224 call netrw#ErrorMsg(s:ERROR,"unable to source <".a:{i}.">!",48)
1229 " call Dret("netrw#NetSource")
1232 " ===========================================
1233 " NetGetFile: Function to read temporary file "tfile" with command "readcmd". {{{2
1234 " readcmd == %r : replace buffer with newly read file
1235 " == 0r : read file at top of buffer
1236 " == r : read file after current line
1237 " == t : leave file in temporary form (ie. don't read into buffer)
1238 fun! s:NetGetFile(readcmd, tfile, method)
1239 " call Dfunc("NetGetFile(readcmd<".a:readcmd.">,tfile<".a:tfile."> method<".a:method.">)")
1241 " readcmd=='t': simply do nothing
1243 " call Dret("NetGetFile : skip read of <".a:tfile.">")
1247 " get name of remote filename (ie. url and all)
1248 let rfile= bufname("%")
1249 " call Decho("rfile<".rfile.">")
1251 if exists("*NetReadFixup")
1252 " for the use of NetReadFixup (not otherwise used internally)
1253 let line2= line("$")
1256 if a:readcmd[0] == '%'
1257 " get file into buffer
1258 " call Decho("get file into buffer")
1260 " rename the current buffer to the temp file (ie. tfile)
1262 let tfile= substitute(a:tfile,'/cygdrive/\(.\)','\1:','')
1266 " call Decho("keepalt exe file ".tfile)
1267 keepalt exe "silent! keepalt file ".tfile
1269 " edit temporary file (ie. read the temporary file in)
1270 if rfile =~ '\.zip$'
1271 " call Decho("handling remote zip file with zip#Browse(tfile<".tfile.">)")
1272 call zip#Browse(tfile)
1273 elseif rfile =~ '\.tar$'
1274 " call Decho("handling remote tar file with tar#Browse(tfile<".tfile.">)")
1275 call tar#Browse(tfile)
1276 elseif rfile =~ '\.tar\.gz'
1277 " call Decho("handling remote gzip-compressed tar file")
1278 call tar#Browse(tfile)
1279 elseif rfile =~ '\.tar\.bz2'
1280 " call Decho("handling remote bz2-compressed tar file")
1281 call tar#Browse(tfile)
1283 " call Decho("edit temporary file")
1287 " rename buffer back to remote filename
1288 exe "silent! keepalt file ".escape(rfile,' ')
1290 " call Dredir("renamed buffer back to remote filename<".rfile."> : expand(%)<".expand("%").">","ls!")
1292 let line2 = line("$")
1294 elseif s:FileReadable(a:tfile)
1295 " read file after current line
1296 " call Decho("read file<".a:tfile."> after current line")
1297 let curline = line(".")
1298 let lastline= line("$")
1299 " call Decho("exe<".a:readcmd." ".v:cmdarg." ".a:tfile."> line#".curline)
1300 exe a:readcmd." ".v:cmdarg." ".a:tfile
1301 let line1= curline + 1
1302 let line2= line("$") - lastline + 1
1306 " call Decho("tfile<".a:tfile."> not readable")
1307 call netrw#ErrorMsg(s:WARNING,"file <".a:tfile."> not readable",9)
1308 " call Dret("NetGetFile : tfile<".a:tfile."> not readable")
1312 " User-provided (ie. optional) fix-it-up command
1313 if exists("*NetReadFixup")
1314 " call Decho("calling NetReadFixup(method<".a:method."> line1=".line1." line2=".line2.")")
1315 call NetReadFixup(a:method, line1, line2)
1317 " call Decho("NetReadFixup() not called, doesn't exist (line1=".line1." line2=".line2.")")
1320 " update the Buffers menu
1321 if has("gui") && has("gui_running")
1322 silent! emenu Buffers.Refresh\ menu
1325 " call Decho("readcmd<".a:readcmd."> cmdarg<".v:cmdarg."> tfile<".a:tfile."> readable=".s:FileReadable(a:tfile))
1327 " make sure file is being displayed
1329 " call Dret("NetGetFile")
1332 " ------------------------------------------------------------------------
1333 " NetMethod: determine method of transfer {{{2
1336 " 3: ftp + machine, id, password, and [path]filename
1343 fun! s:NetMethod(choice) " globals: method machine id passwd fname
1344 " call Dfunc("NetMethod(a:choice<".a:choice.">)")
1347 let b:netrw_method = 0
1348 let g:netrw_machine = ""
1349 let b:netrw_fname = ""
1350 let g:netrw_port = ""
1351 let g:netrw_choice = a:choice
1354 " mipf : a:machine a:id password filename Use ftp
1355 " mf : a:machine filename Use ftp + <.netrc> or g:netrw_uid g:netrw_passwd
1356 " ftpurm : ftp://[user@]host[[#:]port]/filename Use ftp + <.netrc> or g:netrw_uid g:netrw_passwd
1357 " rcpurm : rcp://[user@]host/filename Use rcp
1358 " rcphf : [user@]host:filename Use rcp
1359 " scpurm : scp://[user@]host[[#:]port]/filename Use scp
1360 " httpurm : http://[user@]host/filename Use wget
1361 " davurm : [s]dav://host[:port]/path Use cadaver
1362 " rsyncurm : rsync://host[:port]/path Use rsync
1363 " fetchurm : fetch://[user@]host[:http]/filename Use fetch (defaults to ftp, override for http)
1364 " sftpurm : sftp://[user@]host/filename Use scp
1365 let mipf = '^\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)$'
1366 let mf = '^\(\S\+\)\s\+\(\S\+\)$'
1367 let ftpurm = '^ftp://\(\([^/@]\{-}\)@\)\=\([^/#:]\{-}\)\([#:]\d\+\)\=/\(.*\)$'
1368 let rcpurm = '^rcp://\%(\([^/@]\{-}\)@\)\=\([^/]\{-}\)/\(.*\)$'
1369 let rcphf = '^\(\(\h\w*\)@\)\=\(\h\w*\):\([^@]\+\)$'
1370 let scpurm = '^scp://\([^/#:]\+\)\%([#:]\(\d\+\)\)\=/\(.*\)$'
1371 let httpurm = '^http://\([^/]\{-}\)\(/.*\)\=$'
1372 let davurm = '^s\=dav://\([^/]\+\)/\(.*/\)\([-_.~[:alnum:]]\+\)$'
1373 let rsyncurm = '^rsync://\([^/]\{-}\)/\(.*\)\=$'
1374 let fetchurm = '^fetch://\(\([^/@]\{-}\)@\)\=\([^/#:]\{-}\)\(:http\)\=/\(.*\)$'
1375 let sftpurm = '^sftp://\([^/]\{-}\)/\(.*\)\=$'
1377 " call Decho("determine method:")
1379 " rcp://user@hostname/...path-to-file
1380 if match(a:choice,rcpurm) == 0
1381 " call Decho("rcp://...")
1382 let b:netrw_method = 1
1383 let userid = substitute(a:choice,rcpurm,'\1',"")
1384 let g:netrw_machine = substitute(a:choice,rcpurm,'\2',"")
1385 let b:netrw_fname = substitute(a:choice,rcpurm,'\3',"")
1387 let g:netrw_uid= userid
1390 " scp://user@hostname/...path-to-file
1391 elseif match(a:choice,scpurm) == 0
1392 " call Decho("scp://...")
1393 let b:netrw_method = 4
1394 let g:netrw_machine = substitute(a:choice,scpurm,'\1',"")
1395 let g:netrw_port = substitute(a:choice,scpurm,'\2',"")
1396 let b:netrw_fname = substitute(a:choice,scpurm,'\3',"")
1398 " http://user@hostname/...path-to-file
1399 elseif match(a:choice,httpurm) == 0
1400 " call Decho("http://...")
1401 let b:netrw_method = 5
1402 let g:netrw_machine= substitute(a:choice,httpurm,'\1',"")
1403 let b:netrw_fname = substitute(a:choice,httpurm,'\2',"")
1405 " dav://hostname[:port]/..path-to-file..
1406 elseif match(a:choice,davurm) == 0
1407 " call Decho("dav://...")
1408 let b:netrw_method= 6
1410 let g:netrw_machine= 'https://'.substitute(a:choice,davurm,'\1/\2',"")
1412 let g:netrw_machine= 'http://'.substitute(a:choice,davurm,'\1/\2',"")
1414 let b:netrw_fname = substitute(a:choice,davurm,'\3',"")
1416 " rsync://user@hostname/...path-to-file
1417 elseif match(a:choice,rsyncurm) == 0
1418 " call Decho("rsync://...")
1419 let b:netrw_method = 7
1420 let g:netrw_machine= substitute(a:choice,rsyncurm,'\1',"")
1421 let b:netrw_fname = substitute(a:choice,rsyncurm,'\2',"")
1423 " ftp://[user@]hostname[[:#]port]/...path-to-file
1424 elseif match(a:choice,ftpurm) == 0
1425 " call Decho("ftp://...")
1426 let userid = substitute(a:choice,ftpurm,'\2',"")
1427 let g:netrw_machine= substitute(a:choice,ftpurm,'\3',"")
1428 let g:netrw_port = substitute(a:choice,ftpurm,'\4',"")
1429 let b:netrw_fname = substitute(a:choice,ftpurm,'\5',"")
1431 let g:netrw_uid= userid
1433 if exists("g:netrw_uid") && exists("g:netrw_passwd")
1434 let b:netrw_method = 3
1436 if s:FileReadable(expand("$HOME/.netrc")) && !g:netrw_ignorenetrc
1437 let b:netrw_method= 2
1439 if !exists("g:netrw_uid") || g:netrw_uid == ""
1441 elseif !exists("g:netrw_passwd") || g:netrw_passwd == ""
1442 call NetUserPass(g:netrw_uid)
1443 " else just use current g:netrw_uid and g:netrw_passwd
1445 let b:netrw_method= 3
1449 elseif match(a:choice,fetchurm) == 0
1450 " call Decho("fetch://...")
1451 let b:netrw_method = 8
1452 let g:netrw_userid = substitute(a:choice,fetchurm,'\2',"")
1453 let g:netrw_machine= substitute(a:choice,fetchurm,'\3',"")
1454 let b:netrw_option = substitute(a:choice,fetchurm,'\4',"")
1455 let b:netrw_fname = substitute(a:choice,fetchurm,'\5',"")
1457 " Issue an ftp : "machine id password [path/]filename"
1458 elseif match(a:choice,mipf) == 0
1459 " call Decho("(ftp) host id pass file")
1460 let b:netrw_method = 3
1461 let g:netrw_machine = substitute(a:choice,mipf,'\1',"")
1462 let g:netrw_uid = substitute(a:choice,mipf,'\2',"")
1463 let g:netrw_passwd = substitute(a:choice,mipf,'\3',"")
1464 let b:netrw_fname = substitute(a:choice,mipf,'\4',"")
1466 " Issue an ftp: "hostname [path/]filename"
1467 elseif match(a:choice,mf) == 0
1468 " call Decho("(ftp) host file")
1469 if exists("g:netrw_uid") && exists("g:netrw_passwd")
1470 let b:netrw_method = 3
1471 let g:netrw_machine = substitute(a:choice,mf,'\1',"")
1472 let b:netrw_fname = substitute(a:choice,mf,'\2',"")
1474 elseif s:FileReadable(expand("$HOME/.netrc"))
1475 let b:netrw_method = 2
1476 let g:netrw_machine = substitute(a:choice,mf,'\1',"")
1477 let b:netrw_fname = substitute(a:choice,mf,'\2',"")
1480 " sftp://user@hostname/...path-to-file
1481 elseif match(a:choice,sftpurm) == 0
1482 " call Decho("sftp://...")
1483 let b:netrw_method = 9
1484 let g:netrw_machine= substitute(a:choice,sftpurm,'\1',"")
1485 let b:netrw_fname = substitute(a:choice,sftpurm,'\2',"")
1487 " Issue an rcp: hostname:filename" (this one should be last)
1488 elseif match(a:choice,rcphf) == 0
1489 " call Decho("(rcp) [user@]host:file) rcphf<".rcphf.">")
1490 let b:netrw_method = 1
1491 let userid = substitute(a:choice,rcphf,'\2',"")
1492 let g:netrw_machine= substitute(a:choice,rcphf,'\3',"")
1493 let b:netrw_fname = substitute(a:choice,rcphf,'\4',"")
1494 " call Decho('\1<'.substitute(a:choice,rcphf,'\1',"").">")
1495 " call Decho('\2<'.substitute(a:choice,rcphf,'\2',"").">")
1496 " call Decho('\3<'.substitute(a:choice,rcphf,'\3',"").">")
1497 " call Decho('\4<'.substitute(a:choice,rcphf,'\4',"").">")
1499 let g:netrw_uid= userid
1503 if !exists("g:netrw_quiet")
1504 call netrw#ErrorMsg(s:WARNING,"cannot determine method",45)
1506 let b:netrw_method = -1
1509 " remove any leading [:#] from port number
1510 if g:netrw_port != ""
1511 let g:netrw_port = substitute(g:netrw_port,'[#:]\+','','')
1514 " call Decho("a:choice <".a:choice.">")
1515 " call Decho("b:netrw_method <".b:netrw_method.">")
1516 " call Decho("g:netrw_machine<".g:netrw_machine.">")
1517 " call Decho("g:netrw_port <".g:netrw_port.">")
1518 " if exists("g:netrw_uid") "Decho
1519 " call Decho("g:netrw_uid <".g:netrw_uid.">")
1521 " if exists("g:netrw_passwd") "Decho
1522 " call Decho("g:netrw_passwd <".g:netrw_passwd.">")
1524 " call Decho("b:netrw_fname <".b:netrw_fname.">")
1525 " call Dret("NetMethod : b:netrw_method=".b:netrw_method)
1528 " ------------------------------------------------------------------------
1529 " NetReadFixup: this sort of function is typically written by the user {{{2
1530 " to handle extra junk that their system's ftp dumps
1531 " into the transfer. This function is provided as an
1532 " example and as a fix for a Windows 95 problem: in my
1533 " experience, win95's ftp always dumped four blank lines
1534 " at the end of the transfer.
1535 if has("win95") && exists("g:netrw_win95ftp") && g:netrw_win95ftp
1536 fun! NetReadFixup(method, line1, line2)
1537 " call Dfunc("NetReadFixup(method<".a:method."> line1=".a:line1." line2=".a:line2.")")
1538 if method == 3 " ftp (no <.netrc>)
1539 let fourblanklines= line2 - 3
1540 silent fourblanklines.",".line2."g/^\s*/d"
1542 " call Dret("NetReadFixup")
1546 " ---------------------------------------------------------------------
1547 " NetUserPass: set username and password for subsequent ftp transfer {{{2
1548 " Usage: :call NetUserPass() -- will prompt for userid and password
1549 " :call NetUserPass("uid") -- will prompt for password
1550 " :call NetUserPass("uid","password") -- sets global userid and password
1551 fun! NetUserPass(...)
1555 " call Dfunc("NetUserPass(a:0<".a:0.">)")
1556 if !exists("g:netrw_uid") || g:netrw_uid == ""
1558 let g:netrw_uid= input('Enter username: ')
1560 else " from command line
1561 " call Dfunc("NetUserPass(a:1<".a:1.">) {")
1562 let g:netrw_uid= a:1
1566 if a:0 <= 1 " via prompt
1567 " call Decho("a:0=".a:0." case <=1:")
1568 let g:netrw_passwd= inputsecret("Enter Password: ")
1569 else " from command line
1570 " call Decho("a:0=".a:0." case >1: a:2<".a:2.">")
1571 let g:netrw_passwd=a:2
1574 " call Dret("NetUserPass")
1577 " ===========================================
1578 " Shared Browsing Support: {{{1
1579 " ===========================================
1581 " ---------------------------------------------------------------------
1582 " s:BrowserMaps: {{{2
1583 fun! s:BrowserMaps(islocal)
1584 " call Dfunc("s:BrowserMaps(islocal=".a:islocal.") b:netrw_curdir<".b:netrw_curdir.">")
1586 nnoremap <buffer> <silent> <cr> :call netrw#LocalBrowseCheck(<SID>NetBrowseChgDir(1,<SID>NetGetWord()))<cr>
1587 nnoremap <buffer> <silent> <leftmouse> <leftmouse>:call netrw#LocalBrowseCheck(<SID>NetBrowseChgDir(1,<SID>NetGetWord()))<cr>
1588 nnoremap <buffer> <silent> <c-l> :call <SID>NetRefresh(1,<SID>NetBrowseChgDir(1,'./'))<cr>
1589 nnoremap <buffer> <silent> - :exe "norm! 0"<bar>call netrw#LocalBrowseCheck(<SID>NetBrowseChgDir(1,'../'))<cr>
1590 nnoremap <buffer> <silent> a :call <SID>NetHide(1)<cr>
1591 nnoremap <buffer> <silent> mb :<c-u>call <SID>NetBookmarkDir(0,b:netrw_curdir)<cr>
1592 nnoremap <buffer> <silent> gb :<c-u>call <SID>NetBookmarkDir(1,b:netrw_curdir)<cr>
1593 nnoremap <buffer> <silent> c :exe "cd ".b:netrw_curdir<cr>
1594 nnoremap <buffer> <silent> C :let g:netrw_chgwin= winnr()<cr>
1595 nnoremap <buffer> <silent> d :call <SID>NetMakeDir("")<cr>
1596 nnoremap <buffer> <silent> <c-h> :call <SID>NetHideEdit(1)<cr>
1597 nnoremap <buffer> <silent> i :call <SID>NetListStyle(1)<cr>
1598 nnoremap <buffer> <silent> o :call <SID>NetSplit(3)<cr>
1599 nnoremap <buffer> <silent> O :call <SID>LocalObtain()<cr>
1600 nnoremap <buffer> <silent> p :call <SID>NetPreview(<SID>NetBrowseChgDir(1,<SID>NetGetWord(),1))<cr>
1601 nnoremap <buffer> <silent> P :call <SID>NetPrevWinOpen(1)<cr>
1602 nnoremap <buffer> <silent> q :<c-u>call <SID>NetBookmarkDir(2,b:netrw_curdir)<cr>
1603 nnoremap <buffer> <silent> r :let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetRefresh(1,<SID>NetBrowseChgDir(1,'./'))<cr>
1604 nnoremap <buffer> <silent> s :call <SID>NetSortStyle(1)<cr>
1605 nnoremap <buffer> <silent> S :call <SID>NetSortSequence(1)<cr>
1606 nnoremap <buffer> <silent> t :call <SID>NetSplit(4)<cr>
1607 nnoremap <buffer> <silent> u :<c-u>call <SID>NetBookmarkDir(4,expand("%"))<cr>
1608 nnoremap <buffer> <silent> U :<c-u>call <SID>NetBookmarkDir(5,expand("%"))<cr>
1609 nnoremap <buffer> <silent> v :call <SID>NetSplit(5)<cr>
1610 nnoremap <buffer> <silent> x :call netrw#NetBrowseX(<SID>NetBrowseChgDir(1,<SID>NetGetWord(),0),0)"<cr>
1611 if s:didstarstar || !mapcheck("<s-down>","n")
1612 nnoremap <buffer> <silent> <s-down> :Nexplore<cr>
1614 if s:didstarstar || !mapcheck("<s-up>","n")
1615 nnoremap <buffer> <silent> <s-up> :Pexplore<cr>
1617 exe 'nnoremap <buffer> <silent> <del> :call <SID>LocalBrowseRm("'.b:netrw_curdir.'")<cr>'
1618 exe 'vnoremap <buffer> <silent> <del> :call <SID>LocalBrowseRm("'.b:netrw_curdir.'")<cr>'
1619 exe 'nnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>LocalBrowseRm("'.b:netrw_curdir.'")<cr>'
1620 exe 'vnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>LocalBrowseRm("'.b:netrw_curdir.'")<cr>'
1621 exe 'nnoremap <buffer> <silent> D :call <SID>LocalBrowseRm("'.b:netrw_curdir.'")<cr>'
1622 exe 'vnoremap <buffer> <silent> D :call <SID>LocalBrowseRm("'.b:netrw_curdir.'")<cr>'
1623 exe 'nnoremap <buffer> <silent> R :call <SID>LocalBrowseRename("'.b:netrw_curdir.'")<cr>'
1624 exe 'vnoremap <buffer> <silent> R :call <SID>LocalBrowseRename("'.b:netrw_curdir.'")<cr>'
1625 exe 'nnoremap <buffer> <silent> <Leader>m :call <SID>NetMakeDir("")<cr>'
1626 nnoremap <buffer> <F1> :he netrw-dir<cr>
1629 call s:RemotePathAnalysis(b:netrw_curdir)
1630 nnoremap <buffer> <silent> <cr> :call <SID>NetBrowse(0,<SID>NetBrowseChgDir(0,<SID>NetGetWord()))<cr>
1631 nnoremap <buffer> <silent> <leftmouse> <leftmouse>:call <SID>NetBrowse(0,<SID>NetBrowseChgDir(0,<SID>NetGetWord()))<cr>
1632 nnoremap <buffer> <silent> <c-l> :call <SID>NetRefresh(0,<SID>NetBrowseChgDir(0,'./'))<cr>
1633 nnoremap <buffer> <silent> - :exe "norm! 0"<bar>call <SID>NetBrowse(0,<SID>NetBrowseChgDir(0,'../'))<cr>
1634 nnoremap <buffer> <silent> a :call <SID>NetHide(0)<cr>
1635 nnoremap <buffer> <silent> mb :<c-u>call <SID>NetBookmarkDir(0,b:netrw_curdir)<cr>
1636 nnoremap <buffer> <silent> gb :<c-u>call <SID>NetBookmarkDir(1,b:netrw_cur)<cr>
1637 nnoremap <buffer> <silent> C :let g:netrw_chgwin= winnr()<cr>
1638 nnoremap <buffer> <silent> <c-h> :call <SID>NetHideEdit(0)<cr>
1639 nnoremap <buffer> <silent> i :call <SID>NetListStyle(0)<cr>
1640 nnoremap <buffer> <silent> o :call <SID>NetSplit(0)<cr>
1641 nnoremap <buffer> <silent> O :call netrw#NetObtain(0)<cr>
1642 vnoremap <buffer> <silent> O :call netrw#NetObtain(1)<cr>
1643 nnoremap <buffer> <silent> p :call <SID>NetPreview(<SID>NetBrowseChgDir(1,<SID>NetGetWord(),1))<cr>
1644 nnoremap <buffer> <silent> P :call <SID>NetPrevWinOpen(0)<cr>
1645 nnoremap <buffer> <silent> q :<c-u>call <SID>NetBookmarkDir(2,b:netrw_curdir)<cr>
1646 nnoremap <buffer> <silent> r :let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetBrowse(0,<SID>NetBrowseChgDir(0,'./'))<cr>
1647 nnoremap <buffer> <silent> s :call <SID>NetSortStyle(0)<cr>
1648 nnoremap <buffer> <silent> S :call <SID>NetSortSequence(0)<cr>
1649 nnoremap <buffer> <silent> t :call <SID>NetSplit(1)<cr>
1650 nnoremap <buffer> <silent> u :<c-u>call <SID>NetBookmarkDir(4,b:netrw_curdir)<cr>
1651 nnoremap <buffer> <silent> U :<c-u>call <SID>NetBookmarkDir(5,b:netrw_curdir)<cr>
1652 nnoremap <buffer> <silent> v :call <SID>NetSplit(2)<cr>
1653 nnoremap <buffer> <silent> x :call netrw#NetBrowseX(<SID>NetBrowseChgDir(0,<SID>NetGetWord()),1)<cr>
1654 exe 'nnoremap <buffer> <silent> <del> :call <SID>NetBrowseRm("'.s:user.s:machine.'","'.s:path.'")<cr>'
1655 exe 'vnoremap <buffer> <silent> <del> :call <SID>NetBrowseRm("'.s:user.s:machine.'","'.s:path.'")<cr>'
1656 exe 'nnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetBrowseRm("'.s:user.s:machine.'","'.s:path.'")<cr>'
1657 exe 'vnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetBrowseRm("'.s:user.s:machine.'","'.s:path.'")<cr>'
1658 exe 'nnoremap <buffer> <silent> d :call <SID>NetMakeDir("'.s:user.s:machine.'")<cr>'
1659 exe 'nnoremap <buffer> <silent> D :call <SID>NetBrowseRm("'.s:user.s:machine.'","'.s:path.'")<cr>'
1660 exe 'vnoremap <buffer> <silent> D :call <SID>NetBrowseRm("'.s:user.s:machine.'","'.s:path.'")<cr>'
1661 exe 'nnoremap <buffer> <silent> R :call <SID>NetBrowseRename("'.s:user.s:machine.'","'.s:path.'")<cr>'
1662 exe 'vnoremap <buffer> <silent> R :call <SID>NetBrowseRename("'.s:user.s:machine.'","'.s:path.'")<cr>'
1663 nnoremap <buffer> <F1> :he netrw-browse-cmds<cr>
1665 " call Dret("s:BrowserMaps")
1668 " ---------------------------------------------------------------------
1669 " s:NetBrowse: This function uses the command in g:netrw_list_cmd to get a list {{{2
1670 " of the contents of a remote directory. It is assumed that the
1671 " g:netrw_list_cmd has a string, USEPORT HOSTNAME, that needs to be substituted
1672 " with the requested remote hostname first.
1673 fun! s:NetBrowse(islocal,dirname)
1674 if !exists("w:netrw_liststyle")|let w:netrw_liststyle= g:netrw_liststyle|endif
1675 " call Dfunc("NetBrowse(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".w:netrw_liststyle." ".g:loaded_netrw." buf#".bufnr("%")."<".bufname("%").">")
1676 " call Dredir("ls!")
1678 if exists("s:netrw_skipbrowse")
1679 unlet s:netrw_skipbrowse
1680 " call Dret("NetBrowse : s:netrw_skipbrowse=".s:netrw_skipbrowse)
1684 call s:NetOptionSave()
1686 if a:islocal && exists("w:netrw_acdkeep") && w:netrw_acdkeep
1687 " call Decho("handle w:netrw_acdkeep:")
1688 " call Decho("cd ".escape(a:dirname,s:netrw_cd_escape)." (due to 'acd')")
1689 exe 'cd '.escape(a:dirname,s:netrw_cd_escape)
1690 " call Decho("getcwd<".getcwd().">")
1692 elseif !a:islocal && a:dirname !~ '[\/]$' && a:dirname !~ '^"'
1693 " looks like a regular file, attempt transfer
1694 " call Decho("attempt transfer as regular file<".a:dirname.">")
1696 " remove any filetype indicator from end of dirname, except for the {{{3
1697 " "this is a directory" indicator (/).
1698 " There shouldn't be one of those here, anyway.
1699 let path= substitute(a:dirname,'[*=@|]\r\=$','','e')
1700 " call Decho("new path<".path.">")
1701 call s:RemotePathAnalysis(a:dirname)
1703 " remote-read the requested file into current buffer {{{3
1705 call s:NetrwEnew(a:dirname)
1706 let b:netrw_curdir= a:dirname
1707 call s:NetrwSafeOptions()
1709 " call Decho("exe silent! keepalt file ".s:method."://".s:user.s:machine."/".escape(s:path,s:netrw_cd_escape)." (bt=".&bt.")")
1710 exe "silent! keepalt file ".s:method."://".s:user.s:machine."/".escape(s:path,s:netrw_cd_escape)
1711 exe "silent keepalt doau BufReadPre ".s:fname
1712 silent call netrw#NetRead(2,s:method."://".s:user.s:machine."/".s:path)
1713 exe "silent keepalt doau BufReadPost ".s:fname
1715 " save certain window-oriented variables into buffer-oriented variables {{{3
1716 call s:SetBufWinVars()
1717 call s:NetOptionRestore()
1718 setlocal nomod nowrap
1720 " call Dret("NetBrowse : file<".s:fname.">")
1724 " use buffer-oriented WinVars if buffer ones exist but window ones don't {{{3
1725 call s:UseBufWinVars()
1727 " set up some variables {{{3
1728 let b:netrw_browser_active = 1
1729 let dirname = a:dirname
1730 let s:last_sort_by = g:netrw_sort_by
1732 call s:NetMenu(1) " set up menu {{{3
1733 if s:NetGetBuffer(a:islocal,dirname) " set up buffer {{{3
1734 " call Dret("NetBrowse : re-using buffer")
1738 " set b:netrw_curdir to the new directory name {{{3
1739 " call Decho("set b:netrw_curdir to the new directory name:")
1740 let b:netrw_curdir= dirname
1741 if b:netrw_curdir =~ '[/\\]$'
1742 let b:netrw_curdir= substitute(b:netrw_curdir,'[/\\]$','','e')
1744 if b:netrw_curdir == ''
1746 " On the Amiga, the empty string connotes the current directory
1747 let b:netrw_curdir= getcwd()
1749 " under unix, when the root directory is encountered, the result
1750 " from the preceding substitute is an empty string.
1751 let b:netrw_curdir= '/'
1754 if !a:islocal && b:netrw_curdir !~ '/$'
1755 let b:netrw_curdir= b:netrw_curdir.'/'
1757 " call Decho("b:netrw_curdir<".b:netrw_curdir.">")
1763 " call Decho("local only:")
1765 " Set up ShellCmdPost handling. Append current buffer to browselist
1766 call s:LocalFastBrowser()
1768 " handle g:netrw_keepdir: set vim's current directory to netrw's notion of the current directory {{{3
1770 " call Decho("handle keepdir: (g:netrw_keepdir=".g:netrw_keepdir.")")
1771 " call Decho('exe cd '.escape(b:netrw_curdir,s:netrw_cd_escape))
1773 exe 'cd '.escape(b:netrw_curdir,s:netrw_cd_escape)
1774 catch /^Vim\%((\a\+)\)\=:E472/
1775 call netrw#ErrorMsg(s:ERROR,"unable to change directory to <".b:netrw_curdir."> (permissions?)",33)
1776 if exists("w:netrw_prvdir")
1777 let b:netrw_curdir= w:netrw_prvdir
1779 call s:NetOptionRestore()
1780 let b:netrw_curdir= dirname
1781 " call Dret("NetBrowse : reusing buffer#".(exists("bufnum")? bufnum : 'N/A')."<".dirname."> getcwd<".getcwd().">")
1787 " --------------------------------
1788 " remote handling: {{{3
1789 " --------------------------------
1791 " call Decho("remote only:")
1793 " analyze a:dirname and g:netrw_list_cmd {{{4
1794 " call Decho("b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "doesn't exist")."> a:dirname<".a:dirname.">")
1795 if a:dirname == "NetrwTreeListing"
1796 let dirname= b:netrw_curdir
1797 " call Decho("(dirname was NetrwTreeListing) dirname<".dirname.">")
1798 elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir")
1799 let dirname= substitute(b:netrw_curdir,'\\','/','g')
1801 let dirname= dirname.'/'
1803 let b:netrw_curdir = dirname
1804 " call Decho("(liststyle is TREELIST) dirname<".dirname.">")
1806 let dirname = substitute(a:dirname,'\\','/','g')
1807 " call Decho("(normal) dirname<".dirname.">")
1810 let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/]\+\)/\(.*\)$'
1811 if dirname !~ dirpat
1812 if !exists("g:netrw_quiet")
1813 call netrw#ErrorMsg(s:ERROR,"netrw doesn't understand your dirname<".dirname.">",20)
1815 call s:NetOptionRestore()
1816 " call Dret("NetBrowse : badly formatted dirname<".dirname.">")
1819 let b:netrw_curdir= dirname
1820 " call Decho("b:netrw_curdir<".b:netrw_curdir."> (remote)")
1821 endif " (additional remote handling)
1823 " -----------------------
1824 " Directory Listing: {{{3
1825 " -----------------------
1827 call s:BrowserMaps(a:islocal)
1828 call s:PerformListing(a:islocal)
1830 " call Dret("NetBrowse")
1834 " ---------------------------------------------------------------------
1835 " s:NetGetBuffer: {{{2
1836 " returns 0=cleared buffer
1838 fun! s:NetGetBuffer(islocal,dirname)
1839 " call Dfunc("s:NetGetBuffer(islocal=".a:islocal." dirname<".a:dirname.">)")
1841 " re-use buffer if possible {{{3
1842 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST
1843 " find NetrwTreeList buffer if there is one
1844 let dirname= "NetrwTreeListing"
1845 let bufnum = bufnr('\<NetrwTreeListing\>')
1847 " call Dret("s:NetGetBuffer : bufnum#".bufnum."<NetrwTreeListing>")
1852 " find buffer number of buffer named precisely the same as dirname {{{3
1853 " call Dredir("ls!")
1854 let dirname= a:dirname
1855 " call Decho("find buffer<".dirname.">'s number ")
1856 let bufnum= bufnr(escape(dirname,'\'))
1857 " call Decho("findbuf1: bufnum=bufnr('".escape(dirname,'\')."')=".bufnum." (initial)")
1859 if bufnum > 0 && bufname(bufnum) != dirname
1860 let buflast = bufnr("$")
1861 " call Decho("findbuf2: buflast=".buflast)
1862 while ibuf <= buflast
1863 let bname= bufname(ibuf)
1864 " call Decho("findbuf3: dirname<".dirname."> bufname(".ibuf.")<".bname.">")
1865 if bname != '' && bname !~ '/' && dirname =~ '/'.bname.'$' | break | endif
1866 if bname =~ '^'.dirname.'\=$' | break | endif
1874 " call Decho("findbuf4: bufnum=".bufnum)
1878 " get enew buffer and name it -or- re-use buffer {{{3
1880 if bufnum < 0 || !bufexists(bufnum)
1881 " call Decho("get enew buffer")
1882 call s:NetrwEnew(dirname)
1883 call s:NetrwSafeOptions()
1885 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST
1886 " call Decho('silent! keepalt file NetrwTreeListing')
1887 silent! keepalt file NetrwTreeListing
1889 " call Decho('exe silent! keepalt file '.escape(dirname,s:netrw_cd_escape))
1890 " let v:errmsg= "" " Decho
1891 let escdirname= escape(dirname,s:netrw_cd_escape)
1892 exe 'silent! keepalt file '.escdirname
1893 " call Decho("errmsg<".v:errmsg."> bufnr(".escdirname.")=".bufnr(escdirname)."<".bufname(bufnr(escdirname)).">")
1895 " call Decho("named enew buffer#".bufnr("%")."<".bufname("%").">")
1897 else " Re-use the buffer
1899 " call Decho("re-use buffer:")
1902 if getline(2) =~ '^" Netrw Directory Listing'
1903 " call Decho("re-use buffer#".bufnum."<".((bufnum > 0)? bufname(bufnum) : "")."> using: keepalt b ".bufnum)
1904 exe "keepalt b ".bufnum
1906 " call Decho("reusing buffer#".bufnum."<".((bufnum > 0)? bufname(bufnum) : "")."> using: b ".bufnum)
1911 call s:NetrwListSettings(a:islocal)
1912 " call Dret("s:NetGetBuffer 0 : re-using buffer#".bufnr("%").", but its empty, so refresh it")
1914 elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST
1915 " call Decho("clear buffer<".expand("%")."> with :%d")
1917 call s:NetrwListSettings(a:islocal)
1918 " call Dret("s:NetGetBuffer 0 : re-using buffer#".bufnr("%").", but treelist mode always needs a refresh")
1921 " call Dret("s:NetGetBuffer 1 : buf#".bufnr("%"))
1926 " do netrw settings: make this buffer not-a-file, modifiable, not line-numbered, etc {{{3
1927 " fastbrowse Local Remote Hiding a buffer implies it may be re-used (fast)
1928 " slow 0 D D Deleting a buffer implies it will not be re-used (slow)
1931 let fname= expand("%")
1932 call s:NetrwListSettings(a:islocal)
1933 exe "file ".escape(fname,' ')
1935 " delete all lines from buffer {{{3
1936 " call Decho("clear buffer<".expand("%")."> with :%d")
1939 " call Dret("s:NetGetBuffer 0 : buf#".bufnr("%"))
1943 " ---------------------------------------------------------------------
1944 " s:NetrwListSettings: {{{2
1945 fun! s:NetrwListSettings(islocal)
1946 " call Dfunc("s:NetrwListSettings(islocal=".a:islocal.")")
1947 let fname= bufname("%")
1948 setlocal bt=nofile nobl ma nonu nowrap noro
1949 exe "file ".escape(fname,' ')
1950 if g:netrw_use_noswf
1953 " call Dredir("ls!")
1954 " call Decho("exe setlocal ts=".g:netrw_maxfilenamelen)
1955 exe "setlocal ts=".g:netrw_maxfilenamelen
1956 if g:netrw_fastbrowse > a:islocal
1961 " call Dret("s:NetrwListSettings")
1964 " ---------------------------------------------------------------------
1965 " s:PerformListing: {{{2
1966 fun! s:PerformListing(islocal)
1967 " call Dfunc("s:PerformListing(islocal=".a:islocal.") buf(%)=".bufnr("%")."<".bufname("%").">")
1969 " if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1 " Decho
1970 " call Decho("(netrw) Processing your browsing request...")
1973 " call Decho('w:netrw_liststyle='.(exists("w:netrw_liststyle")? w:netrw_liststyle : 'n/a'))
1974 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict")
1975 " force a refresh for tree listings
1976 " call Decho("force refresh for treelisting: clear buffer<".expand("%")."> with :%d")
1981 " save current directory on directory history list
1982 call s:NetBookmarkDir(3,b:netrw_curdir)
1984 " Set up the banner {{{3
1985 " call Decho("set up banner")
1986 keepjumps put ='\" ============================================================================'
1987 keepjumps put ='\" Netrw Directory Listing (netrw '.g:loaded_netrw.')'
1988 keepjumps put ='\" '.b:netrw_curdir
1990 let w:netrw_bannercnt= 3
1991 exe w:netrw_bannercnt
1993 let sortby= g:netrw_sort_by
1994 if g:netrw_sort_direction =~ "^r"
1995 let sortby= sortby." reversed"
1999 " call Decho("handle specified sorting: g:netrw_sort_by<".g:netrw_sort_by.">")
2000 if g:netrw_sort_by =~ "^n"
2001 " call Decho("directories will be sorted by name")
2003 keepjumps put ='\" Sorted by '.sortby
2004 keepjumps put ='\" Sort sequence: '.g:netrw_sort_sequence
2005 let w:netrw_bannercnt= w:netrw_bannercnt + 2
2007 " call Decho("directories will be sorted by size or time")
2008 " sorted by size or date
2009 keepjumps put ='\" Sorted by '.sortby
2010 let w:netrw_bannercnt= w:netrw_bannercnt + 1
2012 exe w:netrw_bannercnt
2014 " Hiding... -or- Showing... {{{3
2015 " call Decho("handle hiding/showing (g:netrw_hide=".g:netrw_list_hide." g:netrw_list_hide<".g:netrw_list_hide.">)")
2016 if g:netrw_list_hide != "" && g:netrw_hide
2017 if g:netrw_hide == 1
2018 keepjumps put ='\" Hiding: '.g:netrw_list_hide
2020 keepjumps put ='\" Showing: '.g:netrw_list_hide
2022 let w:netrw_bannercnt= w:netrw_bannercnt + 1
2024 exe w:netrw_bannercnt
2025 keepjumps put ='\" Quick Help: <F1>:help -:go up dir D:delete R:rename s:sort-by x:exec'
2026 keepjumps put ='\" ============================================================================'
2027 let w:netrw_bannercnt= w:netrw_bannercnt + 2
2029 " bannercnt should index the line just after the banner
2030 let w:netrw_bannercnt= w:netrw_bannercnt + 1
2031 exe w:netrw_bannercnt
2032 " call Decho("bannercnt=".w:netrw_bannercnt." (should index line just after banner) line($)=".line("$"))
2034 " set up syntax highlighting {{{3
2035 " call Decho("set up syntax highlighting")
2038 if !exists("g:syntax_on") || !g:syntax_on
2045 call s:LocalListing()
2047 call s:RemoteListing()
2049 " call Decho("w:netrw_bannercnt=".w:netrw_bannercnt." (banner complete)")
2051 " manipulate the directory listing (hide, sort) {{{3
2052 if line("$") >= w:netrw_bannercnt
2053 " call Decho("manipulate directory listing (hide)")
2054 " call Decho("g:netrw_hide=".g:netrw_hide." g:netrw_list_hide<".g:netrw_list_hide.">")
2055 if g:netrw_hide && g:netrw_list_hide != ""
2056 call s:NetListHide()
2058 if line("$") >= w:netrw_bannercnt
2059 " call Decho("manipulate directory listing (sort) : g:netrw_sort_by<".g:netrw_sort_by.">")
2061 if g:netrw_sort_by =~ "^n"
2065 if w:netrw_bannercnt < line("$")
2066 " call Decho("g:netrw_sort_direction=".g:netrw_sort_direction." (bannercnt=".w:netrw_bannercnt.")")
2067 if g:netrw_sort_direction =~ 'n'
2068 " normal direction sorting
2069 exe 'silent keepjumps '.w:netrw_bannercnt.',$sort'
2071 " reverse direction sorting
2072 exe 'silent keepjumps '.w:netrw_bannercnt.',$sort!'
2075 " remove priority pattern prefix
2076 " call Decho("remove priority pattern prefix")
2077 exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\d\{3}\///e'
2080 if w:netrw_bannercnt < line("$")
2081 " call Decho("g:netrw_sort_direction=".g:netrw_sort_direction)
2082 if g:netrw_sort_direction =~ 'n'
2083 " call Decho('exe silent keepjumps '.w:netrw_bannercnt.',$sort')
2084 exe 'silent keepjumps '.w:netrw_bannercnt.',$sort'
2086 " call Decho('exe silent keepjumps '.w:netrw_bannercnt.',$sort!')
2087 exe 'silent keepjumps '.w:netrw_bannercnt.',$sort!'
2090 exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\d\{-}\///e'
2093 elseif g:netrw_sort_direction =~ 'r'
2094 " call Decho('reverse the sorted listing')
2095 exe 'silent keepjumps '.w:netrw_bannercnt.'g/^/m '.w:netrw_bannercnt
2099 " convert to wide/tree listing {{{3
2100 " call Decho("modify display if wide/tree listing style")
2101 call s:NetWideListing()
2102 call s:NetTreeListing(b:netrw_curdir)
2104 if exists("w:netrw_bannercnt") && line("$") > w:netrw_bannercnt
2105 " place cursor on the top-left corner of the file listing
2106 " call Decho("place cursor on top-left corner of file listing")
2107 exe 'silent '.w:netrw_bannercnt
2111 " record previous current directory
2112 let w:netrw_prvdir= b:netrw_curdir
2113 " call Decho("record netrw_prvdir<".w:netrw_prvdir.">")
2115 " save certain window-oriented variables into buffer-oriented variables {{{3
2116 call s:SetBufWinVars()
2117 call s:NetOptionRestore()
2119 " set display to netrw display settings
2120 " call Decho("set display to netrw display settings (noma nomod etc)")
2121 setlocal noma nomod nonu nobl nowrap ro
2122 if exists("s:treecurpos")
2123 call setpos('.',s:treecurpos)
2127 " call Dret("s:PerformListing : curpos<".string(getpos(".")).">")
2130 " ---------------------------------------------------------------------
2131 " s:NetBrowseChgDir: constructs a new directory based on the current {{{2
2132 " directory and a new directory name
2133 fun! s:NetBrowseChgDir(islocal,newdir,...)
2134 " call Dfunc("s:NetBrowseChgDir(islocal=".a:islocal."> newdir<".a:newdir.">) a:0=".a:0." curpos<".string(getpos("."))."> b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "").">")
2136 if !exists("b:netrw_curdir")
2137 " call Decho("(NetBrowseChgDir) b:netrw_curdir doesn't exist!")
2138 echoerr "(NetBrowseChgDir) b:netrw_curdir doesn't exist!"
2139 " call Dret("s:NetBrowseChgDir")
2143 call netrw#NetSavePosn()
2144 let nbcd_curpos = getpos('.')
2145 let dirname = substitute(b:netrw_curdir,'\\','/','ge')
2146 let newdir = a:newdir
2148 " set up o/s-dependent directory recognition pattern
2150 let dirpat= '[\/:]$'
2154 " call Decho("dirname<".dirname."> dirpat<".dirpat.">")
2156 if dirname !~ dirpat
2157 " apparently vim is "recognizing" that it is in a directory and
2158 " is removing the trailing "/". Bad idea, so I have to put it back.
2159 let dirname= dirname.'/'
2160 " call Decho("adjusting dirname<".dirname.">")
2165 " call Decho('case "handling a file": newdir<'.newdir.'> !~ dirpat<'.dirpat.">")
2166 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") && newdir !~ '^\(/\|\a:\)'
2167 let dirname= s:NetTreeDir().newdir
2168 " call Decho("tree listing")
2169 elseif newdir =~ '^\(/\|\a:\)'
2172 let dirname= s:ComposePath(dirname,newdir)
2174 " call Decho("handling a file: dirname<".dirname."> (a:0=".a:0.")")
2175 " this lets NetBrowseX avoid the edit
2177 " call Decho("dirname<".dirname."> netrw_cd_escape<".s:netrw_cd_escape."> browse_split=".g:netrw_browse_split)
2178 " call Decho("about to edit<".escape(dirname,s:netrw_cd_escape)."> didsplit=".(exists("s:didsplit")? s:didsplit : "doesn't exist"))
2179 if !exists("s:didsplit")
2180 if g:netrw_browse_split == 1
2183 elseif g:netrw_browse_split == 2
2186 elseif g:netrw_browse_split == 3
2189 " handling a file, didn't split, so remove menu
2190 " call Decho("handling a file+didn't split, so remove menu")
2192 " optional change to window
2193 if g:netrw_chgwin >= 1
2194 exe g:netrw_chgwin."wincmd w"
2199 " its local only: LocalBrowseCheck() doesn't edit a file, but NetBrowse() will
2201 " call Decho("edit file: exe e! ".escape(dirname,s:netrw_cd_escape))
2202 exe "e! ".escape(dirname,s:netrw_cd_escape)
2204 setlocal ma nomod noro
2207 elseif newdir =~ '^/'
2208 " just go to the new directory spec
2209 " call Decho('case "just go to new directory spec": newdir<'.newdir.'>')
2212 elseif newdir == './'
2213 " refresh the directory list
2214 " call Decho('case "refresh directory listing": newdir == "./"')
2216 elseif newdir == '../'
2217 " go up one directory
2218 " call Decho('case "go up one directory": newdir == "../"')
2220 if w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict")
2222 " call Decho("clear buffer<".expand("%")."> with :%d")
2229 " call Decho('case "go up one directory": newdir == "../" and amiga')
2231 let dirname= substitute(dirname,'^\(.*[/:]\)\([^/]\+$\)','\1','')
2232 let dirname= substitute(dirname,'/$','','')
2234 let dirname= substitute(dirname,'^\(.*[/:]\)\([^/]\+/$\)','\1','')
2236 " call Decho("amiga: dirname<".dirname."> (go up one dir)")
2240 " call Decho('case "go up one directory": newdir == "../" and unix or cygwin')
2242 let dirname= substitute(dirname,'^\(.*\)/\([^/]\+\)/$','\1','')
2247 let dirname= substitute(dirname,'^\(\a\+://.\{-}/\{1,2}\)\(.\{-}\)\([^/]\+\)/$','\1\2','')
2249 " call Decho("unix: dirname<".dirname."> (go up one dir)")
2252 elseif w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict")
2253 " call Decho('case liststyle is TREELIST and w:netrw_treedict exists')
2254 " force a refresh (for TREELIST, wait for NetTreeDir() to force the refresh)
2256 if !(exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir"))
2257 " call Decho("clear buffer<".expand("%")."> with :%d")
2260 let treedir = s:NetTreeDir()
2261 let s:treecurpos = nbcd_curpos
2263 " call Decho("w:netrw_treedict<".string(w:netrw_treedict).">")
2265 " search treedict for tree dir as-is
2266 if has_key(w:netrw_treedict,treedir)
2267 " call Decho('....searched for treedir<'.treedir.'> : found it!')
2270 " call Decho('....searched for treedir<'.treedir.'> : not found')
2273 " search treedict for treedir with a / appended
2274 if !haskey && treedir !~ '/$'
2275 if has_key(w:netrw_treedict,treedir."/")
2276 let treedir= treedir."/"
2277 " call Decho('....searched.for treedir<'.treedir.'> found it!')
2280 " call Decho('....searched for treedir<'.treedir.'/> : not found')
2284 " search treedict for treedir with any trailing / elided
2285 if !haskey && treedir =~ '/$'
2286 let treedir= substitute(treedir,'/$','','')
2287 if has_key(w:netrw_treedict,treedir)
2288 " call Decho('....searched.for treedir<'.treedir.'> found it!')
2291 " call Decho('....searched for treedir<'.treedir.'> : not found')
2296 " close tree listing for selected subdirectory
2297 " call Decho("closing selected subdirectory<".dirname.">")
2298 call remove(w:netrw_treedict,treedir)
2299 " call Decho("removed entry<".dirname."> from treedict")
2300 " call Decho("yielding treedict<".string(w:netrw_treedict).">")
2301 let dirname= w:netrw_treetop
2303 " go down one directory
2304 let dirname= substitute(treedir,'/*$','/','')
2305 " call Decho("go down one dir: treedir<".treedir.">")
2309 " go down one directory
2310 let dirname= s:ComposePath(dirname,newdir)
2311 " call Decho("go down one dir: dirname<".dirname."> newdir<".newdir.">")
2314 " call Dret("s:NetBrowseChgDir <".dirname."> : curpos<".string(getpos(".")).">")
2318 " ---------------------------------------------------------------------
2319 " s:NetHide: this function is invoked by the "a" map for browsing {{{2
2320 " and switches the hiding mode
2321 fun! s:NetHide(islocal)
2322 " call Dfunc("NetHide(islocal=".a:islocal.")")
2323 let g:netrw_hide=(g:netrw_hide+1)%3
2325 if g:netrw_hide && g:netrw_list_hide == ""
2326 call netrw#ErrorMsg(s:WARNING,"your hiding list is empty!",49)
2327 " call Dret("NetHide")
2330 call netrw#NetSavePosn()
2331 call s:NetRefresh(a:islocal,s:NetBrowseChgDir(a:islocal,'./'))
2332 " call Dret("NetHide")
2335 " ---------------------------------------------------------------------
2337 " ===========================================
2338 " s:NetPreview: {{{2
2339 fun! s:NetPreview(path) range
2340 " call Dfunc("NetPreview(path<".a:path.">)")
2342 if !isdirectory(a:path)
2343 exe "pedit ".escape(a:path,g:netrw_fname_escape)
2344 elseif !exists("g:netrw_quiet")
2345 call netrw#ErrorMsg(s:WARNING,"sorry, cannot preview a directory such as <".a:path.">",38)
2347 elseif !exists("g:netrw_quiet")
2348 call netrw#ErrorMsg(s:WARNING,"sorry, to preview your vim needs the quickfix feature compiled in",39)
2350 " call Dret("NetPreview")
2353 " ---------------------------------------------------------------------
2354 " s:NetSortStyle: change sorting style (name - time - size) and refresh display {{{2
2355 fun! s:NetSortStyle(islocal)
2356 " call Dfunc("s:NetSortStyle(islocal=".a:islocal.") netrw_sort_by<".g:netrw_sort_by.">")
2357 call s:NetSaveWordPosn()
2359 let g:netrw_sort_by= (g:netrw_sort_by =~ 'n')? 'time' : (g:netrw_sort_by =~ 't')? 'size' : 'name'
2361 call netrw#NetSavePosn()
2362 call s:NetRefresh(a:islocal,s:NetBrowseChgDir(a:islocal,'./'))
2364 " call Dret("s:NetSortStyle : netrw_sort_by<".g:netrw_sort_by.">")
2367 " ---------------------------------------------------------------------
2368 " Remote Directory Browsing Support: {{{1
2369 " ===========================================
2371 " ---------------------------------------------------------------------
2372 " s:RemoteListing: {{{2
2373 fun! s:RemoteListing()
2374 " call Dfunc("s:RemoteListing() b:netrw_curdir<".b:netrw_curdir.">)")
2376 call s:RemotePathAnalysis(b:netrw_curdir)
2379 if exists("b:netrw_method") && b:netrw_method =~ '[235]'
2380 " call Decho("b:netrw_method=".b:netrw_method)
2381 if !executable("ftp")
2382 if !exists("g:netrw_quiet")
2383 call netrw#ErrorMsg(s:ERROR,"this system doesn't support remote directory listing via ftp",18)
2385 call s:NetOptionRestore()
2386 " call Dret("s:RemoteListing")
2390 elseif !exists("g:netrw_list_cmd") || g:netrw_list_cmd == ''
2391 if !exists("g:netrw_quiet")
2392 if g:netrw_list_cmd == ""
2393 call netrw#ErrorMsg(s:ERROR,g:netrw_ssh_cmd." is not executable on your system",47)
2395 call netrw#ErrorMsg(s:ERROR,"this system doesn't support remote directory listing via ".g:netrw_list_cmd,19)
2399 call s:NetOptionRestore()
2400 " call Dret("s:RemoteListing")
2402 endif " (remote handling sanity check)
2404 if exists("b:netrw_method")
2405 " call Decho("setting w:netrw_method<".b:netrw_method.">")
2406 let w:netrw_method= b:netrw_method
2409 if s:method == "ftp"
2410 " use ftp to get remote file listing
2411 " call Decho("use ftp to get remote file listing")
2412 let s:method = "ftp"
2413 let listcmd = g:netrw_ftp_list_cmd
2414 if g:netrw_sort_by =~ '^t'
2415 let listcmd= g:netrw_ftp_timelist_cmd
2416 elseif g:netrw_sort_by =~ '^s'
2417 let listcmd= g:netrw_ftp_sizelist_cmd
2419 " call Decho("listcmd<".listcmd."> (using g:netrw_ftp_list_cmd)")
2420 call s:NetBrowseFtpCmd(s:path,listcmd)
2421 " exe "keepjumps ".w:netrw_bannercnt.',$g/^./call Decho("raw listing: ".getline("."))'
2423 if w:netrw_liststyle == s:THINLIST || w:netrw_liststyle == s:WIDELIST || w:netrw_liststyle == s:TREELIST
2424 " shorten the listing
2425 " call Decho("generate short listing")
2426 exe "keepjumps ".w:netrw_bannercnt
2429 if g:netrw_ftp_browse_reject != ""
2430 exe "silent! g/".g:netrw_ftp_browse_reject."/keepjumps d"
2432 silent! keepjumps %s/\r$//e
2434 " if there's no ../ listed, then put ./ and ../ in
2435 let line1= line(".")
2436 exe "keepjumps ".w:netrw_bannercnt
2437 let line2= search('^\.\.\/\%(\s\|$\)','cnW')
2439 " call Decho("netrw is putting ./ and ../ into listing")
2443 exe "keepjumps ".line1
2446 " call Decho("line1=".line1." line2=".line2." line(.)=".line("."))
2447 if search('^\d\{2}-\d\{2}-\d\{2}\s','n') " M$ ftp site cleanup
2448 " call Decho("M$ ftp cleanup")
2449 exe 'silent! keepjumps '.w:netrw_bannercnt.',$s/^\d\{2}-\d\{2}-\d\{2}\s\+\d\+:\d\+[AaPp][Mm]\s\+\%(<DIR>\|\d\+\)\s\+//'
2450 else " normal ftp cleanup
2451 " call Decho("normal ftp cleanup")
2452 exe 'silent! keepjumps '.w:netrw_bannercnt.',$s/^\(\%(\S\+\s\+\)\{7}\S\+\)\s\+\(\S.*\)$/\2/e'
2453 exe "silent! keepjumps ".w:netrw_bannercnt.',$g/ -> /s# -> .*/$#/#e'
2454 exe "silent! keepjumps ".w:netrw_bannercnt.',$g/ -> /s# -> .*$#/#e'
2459 " use ssh to get remote file listing {{{3
2460 " call Decho("use ssh to get remote file listing: s:netrw_shq<".g:netrw_shq."> s:path<".s:path."> s:netrw_cd_escape<".s:netrw_cd_escape.">")
2461 let listcmd= s:MakeSshCmd(g:netrw_list_cmd)
2462 " call Decho("listcmd<".listcmd."> (using g:netrw_list_cmd)")
2463 if g:netrw_scp_cmd =~ '^pscp'
2464 " call Decho("1: exe silent r! ".listcmd.g:netrw_shq.s:path.g:netrw_shq)
2465 exe "silent r! ".listcmd.g:netrw_shq.s:path.g:netrw_shq
2466 " remove rubbish and adjust listing format of 'pscp' to 'ssh ls -FLa' like
2467 g/^Listing directory/d
2468 g/^d[-rwx][-rwx][-rwx]/s+$+/+e
2469 silent g/^l[-rwx][-rwx][-rwx]/s+$+@+e
2470 if g:netrw_liststyle != s:LONGLIST
2471 g/^[dlsp-][-rwx][-rwx][-rwx]/s/^.*\s\(\S\+\)$/\1/e
2475 " call Decho("2: exe silent r! ".listcmd)
2476 exe "silent r! ".listcmd
2478 " call Decho("3: exe silent r! ".listcmd." ".g:netrw_shq.s:path.g:netrw_shq)
2479 exe "silent r! ".listcmd." ".g:netrw_shq.s:path.g:netrw_shq
2484 if g:netrw_ftp_browse_reject != ""
2485 " call Decho("(cleanup) exe silent! g/".g:netrw_ssh_browse_reject."/keepjumps d")
2486 exe "silent! g/".g:netrw_ssh_browse_reject."/keepjumps d"
2490 if w:netrw_liststyle == s:LONGLIST
2491 " do a long listing; these substitutions need to be done prior to sorting {{{3
2492 " call Decho("fix long listing:")
2494 if s:method == "ftp"
2496 exe "keepjumps ".w:netrw_bannercnt
2497 while getline(".") =~ g:netrw_ftp_browse_reject
2500 " if there's no ../ listed, then put ./ and ../ in
2501 let line1= line(".")
2503 silent keepjumps call search('^\.\.\/\%(\s\|$\)','W')
2504 let line2= line(".")
2506 exe 'keepjumps '.w:netrw_bannercnt."put='./'"
2507 if b:netrw_curdir != '/'
2508 exe 'keepjumps '.w:netrw_bannercnt."put='../'"
2511 exe "keepjumps ".line1
2515 if search('^\d\{2}-\d\{2}-\d\{2}\s','n') " M$ ftp site cleanup
2516 " call Decho("M$ ftp site listing cleanup")
2517 exe 'silent! keepjumps '.w:netrw_bannercnt.',$s/^\(\d\{2}-\d\{2}-\d\{2}\s\+\d\+:\d\+[AaPp][Mm]\s\+\%(<DIR>\|\d\+\)\s\+\)\(\w.*\)$/\2\t\1/'
2518 elseif exists("w:netrw_bannercnt") && w:netrw_bannercnt <= line("$")
2519 " call Decho("normal ftp site listing cleanup: bannercnt=".w:netrw_bannercnt." line($)=".line("$"))
2520 exe 'silent keepjumps '.w:netrw_bannercnt.',$s/ -> .*$//e'
2521 exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\(\%(\S\+\s\+\)\{7}\S\+\)\s\+\(\S.*\)$/\2\t\1/e'
2522 exe 'silent keepjumps '.w:netrw_bannercnt
2526 " if exists("w:netrw_bannercnt") && w:netrw_bannercnt <= line("$") " Decho
2527 " exe "keepjumps ".w:netrw_bannercnt.',$g/^./call Decho("listing: ".getline("."))'
2529 " call Dret("s:RemoteListing")
2532 " ---------------------------------------------------------------------
2533 " NetGetWord: it gets the directory named under the cursor {{{2
2535 " call Dfunc("NetGetWord() line#".line(".")." liststyle=".g:netrw_liststyle." virtcol=".virtcol("."))
2536 call s:UseBufWinVars()
2538 " insure that w:netrw_liststyle is set up
2539 if !exists("w:netrw_liststyle")
2540 if exists("g:netrw_liststyle")
2541 let w:netrw_liststyle= g:netrw_liststyle
2543 let w:netrw_liststyle= s:THINLIST
2545 " call Decho("w:netrw_liststyle=".w:netrw_liststyle)
2548 if exists("w:netrw_bannercnt") && line(".") < w:netrw_bannercnt
2549 " Active Banner support
2550 " call Decho("active banner handling")
2553 let curline= getline(".")
2555 if curline =~ '"\s*Sorted by\s'
2557 let s:netrw_skipbrowse= 1
2558 echo 'Pressing "s" also works'
2560 elseif curline =~ '"\s*Sort sequence:'
2561 let s:netrw_skipbrowse= 1
2562 echo 'Press "S" to edit sorting sequence'
2564 elseif curline =~ '"\s*Quick Help:'
2566 let s:netrw_skipbrowse= 1
2567 echo 'Pressing "?" also works'
2569 elseif curline =~ '"\s*\%(Hiding\|Showing\):'
2571 let s:netrw_skipbrowse= 1
2572 echo 'Pressing "a" also works'
2574 elseif line("$") > w:netrw_bannercnt
2575 exe 'silent keepjumps '.w:netrw_bannercnt
2578 elseif w:netrw_liststyle == s:THINLIST
2579 " call Decho("thin column handling")
2581 let dirname= getline(".")
2583 elseif w:netrw_liststyle == s:LONGLIST
2584 " call Decho("long column handling")
2586 let dirname= substitute(getline("."),'^\(\%(\S\+ \)*\S\+\).\{-}$','\1','e')
2588 elseif w:netrw_liststyle == s:TREELIST
2589 " call Decho("treelist handling")
2590 let dirname= substitute(getline("."),'^\(| \)*','','e')
2593 " call Decho("obtain word from wide listing")
2594 let dirname= getline(".")
2596 if !exists("b:netrw_cpf")
2598 exe 'silent keepjumps '.w:netrw_bannercnt.',$g/^./if virtcol("$") > b:netrw_cpf|let b:netrw_cpf= virtcol("$")|endif'
2599 " call Decho("computed cpf")
2602 " call Decho("buf#".bufnr("%")."<".bufname("%").">")
2603 let filestart = (virtcol(".")/b:netrw_cpf)*b:netrw_cpf
2604 " call Decho("filestart= ([virtcol=".virtcol(".")."]/[b:netrw_cpf=".b:netrw_cpf."])*b:netrw_cpf=".filestart." bannercnt=".w:netrw_bannercnt)
2605 " call Decho("1: dirname<".dirname.">")
2606 if filestart > 0|let dirname= substitute(dirname,'^.\{'.filestart.'}','','')|endif
2607 " call Decho("2: dirname<".dirname.">")
2608 let dirname = substitute(dirname,'^\(.\{'.b:netrw_cpf.'}\).*$','\1','e')
2609 " call Decho("3: dirname<".dirname.">")
2610 let dirname = substitute(dirname,'\s\+$','','e')
2611 " call Decho("4: dirname<".dirname.">")
2614 " call Dret("NetGetWord <".dirname.">")
2618 " ---------------------------------------------------------------------
2619 " NetBrowseRm: remove/delete a remote file or directory {{{2
2620 fun! s:NetBrowseRm(usrhost,path) range
2621 " call Dfunc("NetBrowseRm(usrhost<".a:usrhost."> path<".a:path.">) virtcol=".virtcol("."))
2622 " call Decho("firstline=".a:firstline." lastline=".a:lastline)
2624 " preparation for removing multiple files/directories
2625 let ctr= a:firstline
2628 " remove multiple files and directories
2629 while ctr <= a:lastline
2632 let rmfile= s:NetGetWord()
2633 " call Decho("rmfile<".rmfile.">")
2635 if rmfile !~ '^"' && (rmfile =~ '@$' || rmfile !~ '[\/]$')
2636 " attempt to remove file
2637 " call Decho("attempt to remove file")
2641 let ok= input("Confirm deletion of file<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ")
2647 let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e')
2653 if all || ok =~ 'y\%[es]' || ok == ""
2654 if exists("w:netrw_method") && (w:netrw_method == 2 || w:netrw_method == 3)
2655 silent! keepjumps .,$d
2656 call s:NetBrowseFtpCmd(a:path,"delete ".rmfile)
2658 let netrw_rm_cmd= s:MakeSshCmd(g:netrw_rm_cmd)
2659 " call Decho("attempt to remove file: system(".netrw_rm_cmd.")")
2660 let ret= s:System("system",netrw_rm_cmd)
2661 " call Decho("returned=".ret." errcode=".v:shell_error)
2663 elseif ok =~ 'q\%[uit]'
2668 " attempt to remove directory
2669 " call Decho("attempt to remove directory")
2672 let ok= input("Confirm deletion of directory<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ")
2677 let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e')
2683 if all || ok =~ 'y\%[es]' || ok == ""
2684 if exists("w:netrw_method") && (w:netrw_method == 2 || w:netrw_method == 3)
2685 call s:NetBrowseFtpCmd(a:path,"rmdir ".rmfile)
2687 let rmfile = substitute(a:path.rmfile,'/$','','')
2688 let netrw_rmdir_cmd = s:MakeSshCmd(g:netrw_rmdir_cmd).' '.rmfile
2689 " call Decho("attempt to remove dir: system(".netrw_rmdir_cmd.")")
2690 let ret= s:System("system",netrw_rmdir_cmd)
2691 " call Decho("returned=".ret." errcode=".v:shell_error)
2693 if v:shell_error != 0
2694 " call Decho("v:shell_error not 0")
2695 let netrw_rmf_cmd= s:MakeSshCmd(g:netrw_rmf_cmd).' '.substitute(rmfile,'[\/]$','','e')
2696 " call Decho("2nd attempt to remove dir: system(".netrw_rmf_cmd.")")
2697 let ret= s:System("system",netrw_rmf_cmd)
2698 " call Decho("returned=".ret." errcode=".v:shell_error)
2700 if v:shell_error != 0 && !exists("g:netrw_quiet")
2701 call netrw#ErrorMsg(s:ERROR,"unable to remove directory<".rmfile."> -- is it empty?",22)
2706 elseif ok =~ 'q\%[uit]'
2714 " refresh the (remote) directory listing
2715 " call Decho("refresh remote directory listing")
2716 call netrw#NetSavePosn()
2717 call s:NetRefresh(0,s:NetBrowseChgDir(0,'./'))
2719 " call Dret("NetBrowseRm")
2722 " ---------------------------------------------------------------------
2723 " NetBrowseRename: rename a remote file or directory {{{2
2724 fun! s:NetBrowseRename(usrhost,path) range
2725 " call Dfunc("NetBrowseRename(usrhost<".a:usrhost."> path<".a:path.">)")
2727 " preparation for removing multiple files/directories
2728 let ctr = a:firstline
2729 let rename_cmd = s:MakeSshCmd(g:netrw_rename_cmd)
2731 " attempt to rename files/directories
2732 while ctr <= a:lastline
2733 exe "keepjumps ".ctr
2736 let oldname= s:NetGetWord()
2737 " call Decho("oldname<".oldname.">")
2740 let newname= input("Moving ".oldname." to : ",oldname)
2743 if exists("w:netrw_method") && (w:netrw_method == 2 || w:netrw_method == 3)
2744 call s:NetBrowseFtpCmd(a:path,"rename ".oldname." ".newname)
2746 let oldname= a:path.oldname
2747 let newname= a:path.newname
2748 " call Decho("system(rename_cmd".' "'.escape(oldname," ").'" "'.escape(newname,s:netrw_cd_escape).'"')
2749 let ret= s:System("system",rename_cmd.' "'.escape(oldname,s:netrw_cd_escape).'" "'.escape(newname,s:netrw_cd_escape).'"')
2755 " refresh the directory
2756 let curline= line(".")
2757 call s:NetBrowse(0,s:NetBrowseChgDir(0,'./'))
2758 exe "keepjumps ".curline
2759 " call Dret("NetBrowseRename")
2762 " ---------------------------------------------------------------------
2764 fun! s:NetRefresh(islocal,dirname)
2765 " call Dfunc("NetRefresh(islocal<".a:islocal.">,dirname=".a:dirname.") hide=".g:netrw_hide." sortdir=".g:netrw_sort_direction)
2766 " at the current time (Mar 19, 2007) all calls to NetRefresh() call NetBrowseChgDir() first.
2767 " NetBrowseChgDir() may clear the display; hence a NetSavePosn() may not work if its placed here.
2768 " Also, NetBrowseChgDir() now does a NetSavePosn() itself.
2770 " call Decho("clear buffer<".expand("%")."> with :%d")
2773 call netrw#LocalBrowseCheck(a:dirname)
2775 call s:NetBrowse(a:islocal,a:dirname)
2777 call netrw#NetRestorePosn()
2779 " call Dret("NetRefresh")
2782 " ---------------------------------------------------------------------
2783 " NetSplit: mode {{{2
2790 fun! s:NetSplit(mode)
2791 " call Dfunc("NetSplit(mode=".a:mode.") alto=".g:netrw_alto." altv=".g:netrw_altv)
2793 call s:SaveWinVars()
2797 exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s"
2799 call s:RestoreWinVars()
2800 call s:NetBrowse(0,s:NetBrowseChgDir(0,s:NetGetWord()))
2805 let cursorword = s:NetGetWord()
2808 call s:RestoreWinVars()
2809 call s:NetBrowse(0,s:NetBrowseChgDir(0,cursorword))
2814 exe (g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v"
2816 call s:RestoreWinVars()
2817 call s:NetBrowse(0,s:NetBrowseChgDir(0,s:NetGetWord()))
2822 exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s"
2824 call s:RestoreWinVars()
2825 call netrw#LocalBrowseCheck(s:NetBrowseChgDir(1,s:NetGetWord()))
2830 let netrw_curdir= b:netrw_curdir
2831 let cursorword = s:NetGetWord()
2833 let b:netrw_curdir= netrw_curdir
2835 call s:RestoreWinVars()
2836 call netrw#LocalBrowseCheck(s:NetBrowseChgDir(1,cursorword))
2841 exe (g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v"
2843 call s:RestoreWinVars()
2844 call netrw#LocalBrowseCheck(s:NetBrowseChgDir(1,s:NetGetWord()))
2848 call netrw#ErrorMsg(s:ERROR,"(NetSplit) unsupported mode=".a:mode,45)
2851 " call Dret("NetSplit")
2854 " ---------------------------------------------------------------------
2855 " NetBrowseX: allows users to write custom functions to operate on {{{2
2856 " files given their extension. Passes 0=local, 1=remote
2857 fun! netrw#NetBrowseX(fname,remote)
2858 " call Dfunc("NetBrowseX(fname<".a:fname."> remote=".a:remote.")")
2860 " set up the filename
2861 " (lower case the extension, make a local copy of a remote file)
2862 let exten= substitute(a:fname,'.*\.\(.\{-}\)','\1','e')
2863 if has("win32") || has("win95") || has("win64") || has("win16")
2864 let exten= substitute(exten,'^.*$','\L&\E','')
2866 let fname= escape(a:fname,"%#")
2867 " call Decho("fname<".fname."> after escape()")
2869 " seems kde systems often have gnome-open due to dependencies, even though
2870 " gnome-open's subsidiary display tools are largely absent. Kde systems
2871 " usually have "kdeinit" running, though... (tnx Mikolaj Machowski)
2872 if !exists("s:haskdeinit")
2874 let s:haskdeinit= s:System("system",'ps -e') =~ 'kdeinit'
2876 let s:haskdeinit = 0
2881 " call Decho("setting s:haskdeinit=".s:haskdeinit)
2885 " create a local copy
2886 let fname= fnamemodify(tempname(),":t:r").".".exten
2887 " call Decho("a:remote=".a:remote.": create a local copy of <".a:fname."> as <".fname.">")
2888 exe "silent keepjumps bot 1new ".a:fname
2890 " call Decho("exe w! ".fname)
2894 " call Decho("exten<".exten."> "."netrwFileHandlers#NFH_".exten."():exists=".exists("*netrwFileHandlers#NFH_".exten))
2896 " set up redirection
2898 let redir= substitute(&srr,"%s","/dev/null","")
2900 let redir= &srr . "/dev/null"
2902 " call Decho("redir{".redir."} srr{".&srr."}")
2904 " execute the file handler
2905 if exists("g:netrw_browsex_viewer") && g:netrw_browsex_viewer == '-'
2906 " call Decho("g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">")
2907 let ret= netrwFileHandlers#Invoke(exten,fname)
2909 elseif exists("g:netrw_browsex_viewer") && executable(g:netrw_browsex_viewer)
2910 " call Decho("g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">")
2911 " call Decho("exe silent !".g:netrw_browsex_viewer." '".escape(fname,'%#')."' ".redir)
2912 exe "silent !".g:netrw_browsex_viewer." '".escape(fname,'%#')."'".redir
2913 let ret= v:shell_error
2915 elseif has("win32") || has("win64")
2916 " call Decho('exe silent !start rundll32 url.dll,FileProtocolHandler "'.escape(fname, '%#').'"')
2917 exe 'silent !start rundll32 url.dll,FileProtocolHandler "'.escape(fname, '%#').'"'
2918 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
2919 let ret= v:shell_error
2921 elseif has("unix") && executable("gnome-open") && !s:haskdeinit
2922 " call Decho("exe silent !gnome-open '".escape(fname,'%#')."' ".redir)
2923 exe "silent !gnome-open '".escape(fname,'%#')."'".redir
2924 let ret= v:shell_error
2926 elseif has("unix") && executable("kfmclient") && s:haskdeinit
2927 " call Decho("exe silent !kfmclient exec '".escape(fname,'%#')."' ".redir)
2928 exe "silent !kfmclient exec '".escape(fname,'%#')."' ".redir
2929 let ret= v:shell_error
2932 " netrwFileHandlers#Invoke() always returns 0
2933 let ret= netrwFileHandlers#Invoke(exten,fname)
2936 " if unsuccessful, attempt netrwFileHandlers#Invoke()
2938 let ret= netrwFileHandlers#Invoke(exten,fname)
2943 " cleanup: remove temporary file,
2944 " delete current buffer if success with handler,
2945 " return to prior buffer (directory listing)
2946 if a:remote == 1 && fname != a:fname
2947 " call Decho("deleting temporary file<".fname.">")
2948 call s:System("delete",fname)
2952 setlocal bh=delete bt=nofile
2953 if g:netrw_use_noswf
2960 " call Dret("NetBrowseX")
2963 " ---------------------------------------------------------------------
2964 " NetBrowseFtpCmd: unfortunately, not all ftp servers honor options for ls {{{2
2965 " This function assumes that a long listing will be received. Size, time,
2966 " and reverse sorts will be requested of the server but not otherwise
2968 fun! s:NetBrowseFtpCmd(path,listcmd)
2969 " call Dfunc("NetBrowseFtpCmd(path<".a:path."> listcmd<".a:listcmd.">) netrw_method=".w:netrw_method)
2970 " call Decho("line($)=".line("$")." bannercnt=".w:netrw_bannercnt)
2972 " because WinXX ftp uses unix style input
2974 setlocal ma ff=unix noro
2976 " clear off any older non-banner lines
2977 " note that w:netrw_bannercnt indexes the line after the banner
2978 " call Decho('exe silent! keepjumps '.w:netrw_bannercnt.",$d (clear off old non-banner lines)")
2979 exe "silent! keepjumps ".w:netrw_bannercnt.",$d"
2981 ".........................................
2982 if w:netrw_method == 2 || w:netrw_method == 5
2983 " ftp + <.netrc>: Method #2
2985 put ='cd \"'.a:path.'\"'
2987 if exists("g:netrw_ftpextracmd")
2988 exe "put ='".g:netrw_ftpextracmd."'"
2989 " call Decho("filter input: ".getline("."))
2991 exe "put ='".a:listcmd."'"
2992 " exe w:netrw_bannercnt.',$g/^./call Decho("ftp#".line(".").": ".getline("."))'
2993 if exists("g:netrw_port") && g:netrw_port != ""
2994 " call Decho("exe ".g:netrw_silentxfer.w:netrw_bannercnt.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port)
2995 exe g:netrw_silentxfer.w:netrw_bannercnt.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port
2997 " call Decho("exe ".g:netrw_silentxfer.w:netrw_bannercnt.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine)
2998 exe g:netrw_silentxfer.w:netrw_bannercnt.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine
3001 ".........................................
3002 elseif w:netrw_method == 3
3003 " ftp + machine,id,passwd,filename: Method #3
3005 if exists("g:netrw_port") && g:netrw_port != ""
3006 put ='open '.g:netrw_machine.' '.g:netrw_port
3008 put ='open '.g:netrw_machine
3011 if exists("g:netrw_ftp") && g:netrw_ftp == 1
3013 put ='\"'.g:netrw_passwd.'\"'
3015 put ='user \"'.g:netrw_uid.'\" \"'.g:netrw_passwd.'\"'
3019 put ='cd \"'.a:path.'\"'
3021 if exists("g:netrw_ftpextracmd")
3022 exe "put ='".g:netrw_ftpextracmd."'"
3023 " call Decho("filter input: ".getline("."))
3025 exe "put ='".a:listcmd."'"
3028 " -i : turns off interactive prompting from ftp
3029 " -n unix : DON'T use <.netrc>, even though it exists
3030 " -n win32: quit being obnoxious about password
3031 " exe w:netrw_bannercnt.',$g/^./call Decho("ftp#".line(".").": ".getline("."))'
3032 " call Decho("exe ".g:netrw_silentxfer.w:netrw_bannercnt.",$!".g:netrw_ftp_cmd." -i -n")
3033 exe g:netrw_silentxfer.w:netrw_bannercnt.",$!".g:netrw_ftp_cmd." -i -n"
3035 ".........................................
3037 call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . choice . ">",23)
3040 " cleanup for Windows
3041 if has("win32") || has("win95") || has("win64") || has("win16")
3042 silent! keepjumps %s/\r$//e
3044 if a:listcmd == "dir"
3045 " infer directory/link based on the file permission string
3046 silent! keepjumps g/d\%([-r][-w][-x]\)\{3}/s@$@/@
3047 silent! keepjumps g/l\%([-r][-w][-x]\)\{3}/s/$/@/
3048 if w:netrw_liststyle == s:THINLIST || w:netrw_liststyle == s:WIDELIST || w:netrw_liststyle == s:TREELIST
3049 exe "silent! keepjumps ".w:netrw_bannercnt.',$s/^\%(\S\+\s\+\)\{8}//e'
3053 " ftp's listing doesn't seem to include ./ or ../
3054 if !search('^\.\/$\|\s\.\/$','wn')
3055 exe 'keepjumps '.w:netrw_bannercnt
3058 if !search('^\.\.\/$\|\s\.\.\/$','wn')
3059 exe 'keepjumps '.w:netrw_bannercnt
3065 " call Dret("NetBrowseFtpCmd")
3068 " ---------------------------------------------------------------------
3069 " NetListHide: uses [range]g~...~d to delete files that match comma {{{2
3070 " separated patterns given in g:netrw_list_hide
3071 fun! s:NetListHide()
3072 " call Dfunc("NetListHide() hide=".g:netrw_hide." listhide<".g:netrw_list_hide.">")
3074 " find a character not in the "hide" string to use as a separator for :g and :v commands
3075 " How-it-works: take the hiding command, convert it into a range. Duplicate
3076 " characters don't matter. Remove all such characters from the '/~...90'
3077 " string. Use the first character left as a separator character.
3078 let listhide= g:netrw_list_hide
3079 let sep = strpart(substitute('/~@#$%^&*{};:,<.>?|1234567890','['.escape(listhide,'-]^\').']','','ge'),1,1)
3080 " call Decho("sep=".sep)
3082 while listhide != ""
3084 let hide = substitute(listhide,',.*$','','e')
3085 let listhide = substitute(listhide,'^.\{-},\(.*\)$','\1','e')
3091 " Prune the list by hiding any files which match
3092 if g:netrw_hide == 1
3093 " call Decho("hiding<".hide."> listhide<".listhide.">")
3094 exe 'silent keepjumps '.w:netrw_bannercnt.',$g'.sep.hide.sep.'d'
3095 elseif g:netrw_hide == 2
3096 " call Decho("showing<".hide."> listhide<".listhide.">")
3097 exe 'silent keepjumps '.w:netrw_bannercnt.',$g'.sep.hide.sep.'s@^@ /-KEEP-/ @'
3100 if g:netrw_hide == 2
3101 exe 'silent keepjumps '.w:netrw_bannercnt.',$v@^ /-KEEP-/ @d'
3102 exe 'silent keepjumps '.w:netrw_bannercnt.',$s@^\%( /-KEEP-/ \)\+@@e'
3105 " call Dret("NetListHide")
3108 " ---------------------------------------------------------------------
3109 " NetHideEdit: allows user to edit the file/directory hiding list
3110 fun! s:NetHideEdit(islocal)
3111 " call Dfunc("NetHideEdit(islocal=".a:islocal.")")
3113 " save current cursor position
3114 let s:nhe_curpos= getpos(".")
3116 " get new hiding list from user
3118 let newhide= input("Edit Hiding List: ",g:netrw_list_hide)
3120 let g:netrw_list_hide= newhide
3121 " call Decho("new g:netrw_list_hide<".g:netrw_list_hide.">")
3123 " refresh the listing
3124 silent call s:NetRefresh(a:islocal,s:NetBrowseChgDir(a:islocal,"./"))
3126 " restore cursor position
3127 call setpos('.',s:nhe_curpos)
3130 " call Dret("NetHideEdit")
3133 " ---------------------------------------------------------------------
3134 " NetSortSequence: allows user to edit the sorting sequence
3135 fun! s:NetSortSequence(islocal)
3136 " call Dfunc("NetSortSequence(islocal=".a:islocal.")")
3139 let newsortseq= input("Edit Sorting Sequence: ",g:netrw_sort_sequence)
3142 " refresh the listing
3143 let g:netrw_sort_sequence= newsortseq
3144 call netrw#NetSavePosn()
3145 call s:NetRefresh(a:islocal,s:NetBrowseChgDir(a:islocal,'./'))
3147 " call Dret("NetSortSequence")
3150 " ---------------------------------------------------------------------
3151 " NetListStyle: {{{2
3152 " islocal=0: remote browsing
3153 " =1: local browsing
3154 fun! s:NetListStyle(islocal)
3155 " call Dfunc("NetListStyle(islocal=".a:islocal.") w:netrw_liststyle=".w:netrw_liststyle)
3156 let fname = s:NetGetWord()
3157 if !exists("w:netrw_liststyle")|let w:netrw_liststyle= g:netrw_liststyle|endif
3158 let w:netrw_liststyle = (w:netrw_liststyle + 1) % s:MAXLIST
3159 " call Decho("fname<".fname.">")
3160 " call Decho("chgd w:netrw_liststyle to ".w:netrw_liststyle)
3161 " call Decho("b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "doesn't exist").">")
3163 if w:netrw_liststyle == s:THINLIST
3164 " use one column listing
3165 " call Decho("use one column list")
3166 let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge')
3168 elseif w:netrw_liststyle == s:LONGLIST
3170 " call Decho("use long list")
3171 let g:netrw_list_cmd = g:netrw_list_cmd." -l"
3173 elseif w:netrw_liststyle == s:WIDELIST
3175 " call Decho("use wide list")
3176 let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge')
3178 elseif w:netrw_liststyle == s:TREELIST
3179 " call Decho("use tree list")
3180 let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge')
3183 call netrw#ErrorMsg(s:WARNING,"bad value for g:netrw_liststyle (=".w:netrw_liststyle.")",46)
3184 let g:netrw_liststyle = s:THINLIST
3185 let w:netrw_liststyle = g:netrw_liststyle
3186 let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge')
3190 " clear buffer - this will cause NetBrowse/LocalBrowseCheck to do a refresh
3191 " call Decho("clear buffer<".expand("%")."> with :%d")
3194 " refresh the listing
3195 call netrw#NetSavePosn()
3196 call s:NetRefresh(a:islocal,s:NetBrowseChgDir(a:islocal,'./'))
3198 " keep cursor on the filename
3200 let result= search('\%(^\%(|\+\s\)\=\|\s\{2,}\)\zs'.escape(fname,'.\[]*$^').'\%(\s\{2,}\|$\)','bc')
3201 " call Decho("search result=".result." w:netrw_bannercnt=".(exists("w:netrw_bannercnt")? w:netrw_bannercnt : 'N/A'))
3202 if result <= 0 && exists("w:netrw_bannercnt")
3203 exe w:netrw_bannercnt
3206 " call Dret("NetListStyle".(exists("w:netrw_liststyle")? ' : w:netrw_liststyle='.w:netrw_liststyle : ""))
3209 " ---------------------------------------------------------------------
3210 " NetWideListing: {{{2
3211 fun! s:NetWideListing()
3213 if w:netrw_liststyle == s:WIDELIST
3214 " call Dfunc("NetWideListing() w:netrw_liststyle=".w:netrw_liststyle.' fo='.&fo.' l:fo='.&l:fo)
3215 " look for longest filename (cpf=characters per filename)
3216 " cpf: characters per file
3217 " fpl: files per line
3218 " fpc: files per column
3221 if line("$") >= w:netrw_bannercnt
3222 exe 'silent keepjumps '.w:netrw_bannercnt.',$g/^./if virtcol("$") > b:netrw_cpf|let b:netrw_cpf= virtcol("$")|endif'
3224 " call Dret("NetWideListing")
3227 " call Decho("max file strlen+1=".b:netrw_cpf)
3228 let b:netrw_cpf= b:netrw_cpf + 1
3230 " determine qty files per line (fpl)
3231 let w:netrw_fpl= winwidth(0)/b:netrw_cpf
3235 " call Decho("fpl= ".winwidth(0)."/[b:netrw_cpf=".b:netrw_cpf.']='.w:netrw_fpl)
3238 exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^.*$/\=escape(printf("%-'.b:netrw_cpf.'s",submatch(0)),"\\")/'
3239 let fpc = (line("$") - w:netrw_bannercnt + w:netrw_fpl)/w:netrw_fpl
3240 let newcolstart = w:netrw_bannercnt + fpc
3241 let newcolend = newcolstart + fpc - 1
3242 " call Decho("bannercnt=".w:netrw_bannercnt." fpl=".w:netrw_fpl." fpc=".fpc." newcol[".newcolstart.",".newcolend."]")
3243 silent! let keepregstar = @*
3244 while line("$") >= newcolstart
3245 if newcolend > line("$") | let newcolend= line("$") | endif
3246 let newcolqty= newcolend - newcolstart
3249 exe "silent keepjumps norm! 0\<c-v>$hx".w:netrw_bannercnt."G$p"
3251 exe "silent keepjumps norm! 0\<c-v>".newcolqty.'j$hx'.w:netrw_bannercnt.'G$p'
3253 exe "silent keepjumps ".newcolstart.','.newcolend.'d'
3254 exe 'silent keepjumps '.w:netrw_bannercnt
3256 silent! let @*= keepregstar
3257 exe "silent keepjumps ".w:netrw_bannercnt.',$s/\s\+$//e'
3258 setlocal noma nomod ro
3259 " call Dret("NetWideListing")
3264 " ---------------------------------------------------------------------
3265 " NetTreeDir: determine tree directory given current cursor position {{{2
3266 " (full path directory with trailing slash returned)
3268 " call Dfunc("NetTreeDir() curline#".line(".")."<".getline(".")."> b:netrw_curdir<".b:netrw_curdir."> tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%").">")
3270 let treedir= b:netrw_curdir
3271 " call Decho("set initial treedir<".treedir.">")
3272 let s:treecurpos= getpos(".")
3274 if w:netrw_liststyle == s:TREELIST
3275 " call Decho("w:netrrw_liststyle is TREELIST:")
3276 " call Decho("line#".line(".")." getline(.)<".getline('.')."> treecurpos<".string(s:treecurpos).">")
3277 if getline('.') =~ '/$'
3278 let treedir= substitute(getline('.'),'^\%(| \)*\([^|].\{-}\)$','\1','e')
3283 " call Decho("treedir<".treedir.">")
3285 " detect user attempting to close treeroot
3286 if getline('.') !~ '|' && getline('.') != '..'
3287 " call Decho("user attempted to close treeroot")
3288 " now force a refresh
3289 " call Decho("clear buffer<".expand("%")."> with :%d")
3291 " call Dret("NetTreeDir <".treedir."> : (side effect) s:treecurpos<".string(s:treecurpos).">")
3292 return b:netrw_curdir
3295 " elide all non-depth information
3296 let depth = substitute(getline('.'),'^\(\%(| \)*\)[^|].\{-}$','\1','e')
3297 " call Decho("depth<".depth."> 1st subst")
3300 let depth = substitute(depth,'^| ','','')
3301 " call Decho("depth<".depth."> 2nd subst")
3303 " construct treedir by searching backwards at correct depth
3304 " call Decho("constructing treedir<".treedir."> depth<".depth.">")
3305 while depth != "" && search('^'.depth.'[^|].\{-}/$','bW')
3306 let dirname= substitute(getline("."),'^\(| \)*','','e')
3307 let treedir= dirname.treedir
3308 let depth = substitute(depth,'^| ','','')
3309 " call Decho("constructing treedir<".treedir.">: dirname<".dirname."> while depth<".depth.">")
3311 if w:netrw_treetop =~ '/$'
3312 let treedir= w:netrw_treetop.treedir
3314 let treedir= w:netrw_treetop.'/'.treedir
3316 " call Decho("bufnr(.)=".bufnr(".")." line($)=".line("$")." line(.)=".line("."))
3318 let treedir= substitute(treedir,'//$','/','')
3320 " " now force a refresh
3321 " call Decho("clear buffer<".expand("%")."> with :%d")
3325 " call Dret("NetTreeDir <".treedir."> : (side effect) s:treecurpos<".string(s:treecurpos).">")
3329 " ---------------------------------------------------------------------
3330 " NetTreeDisplay: recursive tree display {{{2
3331 fun! s:NetTreeDisplay(dir,depth)
3332 " call Dfunc("NetTreeDisplay(dir<".a:dir."> depth<".a:depth.">)")
3334 " insure that there are no folds
3337 " install ../ and shortdir
3339 call setline(line("$")+1,'../')
3340 " call Decho("setline#".line("$")." ../ (depth is zero)")
3342 if a:dir =~ '^\a\+://'
3343 if a:dir == w:netrw_treetop
3346 let shortdir= substitute(a:dir,'^.*/\([^/]\+\)/$','\1/','e')
3348 call setline(line("$")+1,a:depth.shortdir)
3350 let shortdir= substitute(a:dir,'^.*/','','e')
3351 call setline(line("$")+1,a:depth.shortdir.'/')
3353 " call Decho("setline#".line("$")." shortdir<".a:depth.shortdir.">")
3355 " append a / to dir if its missing one
3361 " display subtrees (if any)
3362 let depth= "| ".a:depth
3363 " call Decho("display subtrees with depth<".depth."> and current leaves")
3364 for entry in w:netrw_treedict[a:dir]
3365 let direntry= substitute(dir.entry,'/$','','e')
3366 " call Decho("dir<".dir."> entry<".entry."> direntry<".direntry.">")
3367 if entry =~ '/$' && has_key(w:netrw_treedict,direntry)
3368 " call Decho("<".direntry."> is a key in treedict - display subtree for it")
3369 call s:NetTreeDisplay(direntry,depth)
3370 elseif entry =~ '/$' && has_key(w:netrw_treedict,direntry.'/')
3371 " call Decho("<".direntry."/> is a key in treedict - display subtree for it")
3372 call s:NetTreeDisplay(direntry.'/',depth)
3374 " call Decho("<".entry."> is not a key in treedict (no subtree)")
3375 call setline(line("$")+1,depth.entry)
3378 " call Dret("NetTreeDisplay")
3381 " ---------------------------------------------------------------------
3382 " NetTreeListing: displays tree listing from treetop on down, using NetTreeDisplay() {{{2
3383 fun! s:NetTreeListing(dirname)
3384 if w:netrw_liststyle == s:TREELIST
3385 " call Dfunc("NetTreeListing() bufname<".expand("%").">")
3386 " call Decho("curdir<".a:dirname.">")
3388 " update the treetop
3389 " call Decho("update the treetop")
3390 if !exists("w:netrw_treetop")
3391 let w:netrw_treetop= a:dirname
3392 " call Decho("w:netrw_treetop<".w:netrw_treetop."> (reusing)")
3393 elseif (w:netrw_treetop =~ ('^'.a:dirname) && strlen(a:dirname) < strlen(w:netrw_treetop)) || a:dirname !~ ('^'.w:netrw_treetop)
3394 let w:netrw_treetop= a:dirname
3395 " call Decho("w:netrw_treetop<".w:netrw_treetop."> (went up)")
3398 " insure that we have at least an empty treedict
3399 if !exists("w:netrw_treedict")
3400 let w:netrw_treedict= {}
3403 " update the directory listing for the current directory
3404 " call Decho("updating dictionary with ".a:dirname.":[..directory listing..]")
3405 " call Decho("bannercnt=".w:netrw_bannercnt." line($)=".line("$"))
3406 exe "silent! keepjumps ".w:netrw_bannercnt.',$g@^\.\.\=/$@d'
3407 let w:netrw_treedict[a:dirname]= getline(w:netrw_bannercnt,line("$"))
3408 " call Decho("treedict=".string(w:netrw_treedict))
3409 exe "silent! keepjumps ".w:netrw_bannercnt.",$d"
3411 " if past banner, record word
3412 if exists("w:netrw_bannercnt") && line(".") > w:netrw_bannercnt
3413 let fname= expand("<cword>")
3418 " display from treetop on down
3419 call s:NetTreeDisplay(w:netrw_treetop,"")
3422 if !exists("s:nbcd_curpos")
3424 " call Decho("(NetTreeListing) place cursor <".fname.">")
3425 call search('\<'.fname.'\>','cw')
3426 elseif exists("w:netrw_bannercnt")
3427 exe (w:netrw_bannercnt+1)
3428 " call Decho("(NetTreeListing) place cursor line#".(w:netrw_bannercnt+1))
3432 " call Dret("NetTreeListing : bufname<".expand("%").">")
3436 " ---------------------------------------------------------------------
3437 " NetSaveWordPosn: used by the "s" command in both remote and local {{{2
3438 " browsing. Along with NetRestoreWordPosn(), it keeps the cursor on
3439 " the same word even though the sorting has changed its order of appearance.
3440 fun! s:NetSaveWordPosn()
3441 " call Dfunc("NetSaveWordPosn()")
3442 let s:netrw_saveword= '^'.escape(getline("."),s:netrw_cd_escape).'$'
3443 " call Dret("NetSaveWordPosn : saveword<".s:netrw_saveword.">")
3446 " ---------------------------------------------------------------------
3447 " NetRestoreWordPosn: used by the "s" command; see NetSaveWordPosn() above {{{2
3448 fun! s:NetRestoreWordPosn()
3449 " call Dfunc("NetRestoreWordPosn()")
3450 silent! call search(s:netrw_saveword,'w')
3451 " call Dret("NetRestoreWordPosn")
3454 " ---------------------------------------------------------------------
3455 " NetMakeDir: this function makes a directory (both local and remote) {{{2
3456 fun! s:NetMakeDir(usrhost)
3457 " call Dfunc("NetMakeDir(usrhost<".a:usrhost.">)")
3459 " get name of new directory from user. A bare <CR> will skip.
3460 " if its currently a directory, also request will be skipped, but with
3463 let newdirname= input("Please give directory name: ")
3465 " call Decho("newdirname<".newdirname.">")
3468 " call Dret("NetMakeDir : user aborted with bare <cr>")
3476 let fullnewdir= b:netrw_curdir.'/'.newdirname
3477 " call Decho("fullnewdir<".fullnewdir.">")
3478 if isdirectory(fullnewdir)
3479 if !exists("g:netrw_quiet")
3480 call netrw#ErrorMsg(s:WARNING,"<".newdirname."> is already a directory!",24)
3482 " call Dret("NetMakeDir : directory<".newdirname."> exists previously")
3485 if s:FileReadable(fullnewdir)
3486 if !exists("g:netrw_quiet")
3487 call netrw#ErrorMsg(s:WARNING,"<".newdirname."> is already a file!",25)
3489 " call Dret("NetMakeDir : file<".newdirname."> exists previously")
3493 " requested new local directory is neither a pre-existing file or
3494 " directory, so make it!
3496 call mkdir(fullnewdir,"p")
3498 let netrw_origdir= s:NetGetcwd(1)
3499 exe 'keepjumps cd '.b:netrw_curdir
3500 " call Decho("netrw_origdir<".netrw_origdir.">: cd b:netrw_curdir<".b:netrw_curdir.">")
3501 " call Decho("exe silent! !".g:netrw_local_mkdir.' '.g:netrw_shq.newdirname.g:netrw_shq)
3502 exe "silent! !".g:netrw_local_mkdir.' '.g:netrw_shq.newdirname.g:netrw_shq
3503 if !g:netrw_keepdir | exe 'keepjumps cd '.netrw_origdir | endif
3505 exe 'keepjumps cd '.netrw_origdir
3506 " call Decho("netrw_keepdir=".g:netrw_keepdir.": cd ".netrw_origdir)
3510 if v:shell_error == 0
3512 " call Decho("refresh listing")
3513 call netrw#NetSavePosn()
3514 call s:NetRefresh(1,s:NetBrowseChgDir(1,'./'))
3515 elseif !exists("g:netrw_quiet")
3516 call netrw#ErrorMsg(s:ERROR,"unable to make directory<".newdirname.">",26)
3522 let mkdircmd = s:MakeSshCmd(g:netrw_mkdir_cmd)
3523 let newdirname= substitute(b:netrw_curdir,'^\%(.\{-}/\)\{3}\(.*\)$','\1','').newdirname
3524 " call Decho("exe silent! !".mkdircmd." ".g:netrw_shq.newdirname.g:netrw_shq)
3525 exe "silent! !".mkdircmd." ".g:netrw_shq.newdirname.g:netrw_shq
3526 if v:shell_error == 0
3528 call netrw#NetSavePosn()
3529 call s:NetRefresh(0,s:NetBrowseChgDir(0,'./'))
3530 elseif !exists("g:netrw_quiet")
3531 call netrw#ErrorMsg(s:ERROR,"unable to make directory<".newdirname.">",27)
3536 " call Dret("NetMakeDir")
3539 " ---------------------------------------------------------------------
3540 " NetBookmarkDir: {{{2
3541 " 0: (user: <b>) bookmark current directory
3542 " 1: (user: <B>) change to the bookmarked directory
3543 " 2: (user: <q>) list bookmarks
3544 " 3: (browsing) record current directory history
3545 " 4: (user: <u>) go up (previous) bookmark
3546 " 5: (user: <U>) go down (next) bookmark
3547 fun! s:NetBookmarkDir(chg,curdir)
3548 " call Dfunc("NetBookmarkDir(chg=".a:chg." curdir<".a:curdir.">) cnt=".v:count." bookmarkcnt=".g:NETRW_BOOKMARKMAX." histcnt=".g:NETRW_DIRHIST_CNT." bookmax=".g:NETRW_BOOKMARKMAX." histmax=".g:netrw_dirhistmax)
3551 " bookmark the current directory
3552 " call Decho("(user: <b>) bookmark the current directory")
3554 " handle bookmark# specified via the count
3555 let g:NETRW_BOOKMARKDIR_{v:count}= a:curdir
3556 if !exists("g:NETRW_BOOKMARKMAX")
3557 let g:NETRW_BOOKMARKMAX= v:count
3558 elseif v:count > g:NETRW_BOOKMARKMAX
3559 let g:NETRW_BOOKMARKMAX= v:count
3562 " handle no count specified
3563 let g:NETRW_BOOKMARKMAX = g:NETRW_BOOKMARKMAX + 1
3564 let g:NETRW_BOOKMARKDIR_{g:NETRW_BOOKMARKMAX} = a:curdir
3566 echo "bookmarked the current directory"
3569 " change to the bookmarked directory
3570 " call Decho("(user: <B>) change to the bookmarked directory")
3571 if exists("g:NETRW_BOOKMARKDIR_{v:count}")
3572 exe "e ".g:NETRW_BOOKMARKDIR_{v:count}
3574 echomsg "Sorry, bookmark#".v:count." doesn't exist!"
3580 " list user's bookmarks
3581 " call Decho("(user: <q>) list user's bookmarks")
3582 if exists("g:NETRW_BOOKMARKMAX")
3583 " call Decho("list bookmarks [0,".g:NETRW_BOOKMARKMAX."]")
3585 while cnt <= g:NETRW_BOOKMARKMAX
3586 if exists("g:NETRW_BOOKMARKDIR_{cnt}")
3587 " call Decho("Netrw Bookmark#".cnt.": ".g:NETRW_BOOKMARKDIR_{cnt})
3588 echo "Netrw Bookmark#".cnt.": ".g:NETRW_BOOKMARKDIR_{cnt}
3595 " list directory history
3596 let cnt = g:NETRW_DIRHIST_CNT
3599 while ( first || cnt != g:NETRW_DIRHIST_CNT )
3600 " call Decho("first=".first." cnt=".cnt." dirhist_cnt=".g:NETRW_DIRHIST_CNT)
3601 let histcnt= histcnt + 1
3602 if exists("g:NETRW_DIRHIST_{cnt}")
3603 " call Decho("Netrw History#".histcnt.": ".g:NETRW_DIRHIST_{cnt})
3604 echo "Netrw History#".histcnt.": ".g:NETRW_DIRHIST_{cnt}
3608 let cnt = ( cnt - 1 ) % g:netrw_dirhistmax
3610 let cnt= cnt + g:netrw_dirhistmax
3614 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
3618 " saves most recently visited directories (when they differ)
3619 " call Decho("(browsing) record curdir history")
3620 if !exists("g:NETRW_DIRHIST_0") || g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT} != a:curdir
3621 let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT + 1 ) % g:netrw_dirhistmax
3622 " let g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}= substitute(a:curdir,'[/\\]$','','e')
3623 let g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}= a:curdir
3624 " call Decho("save dirhist#".g:NETRW_DIRHIST_CNT."<".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}.">")
3628 " u: change to the previous directory stored on the history list
3629 " call Decho("(user: <u>) chg to prev dir from history")
3630 let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT - 1 ) % g:netrw_dirhistmax
3631 if g:NETRW_DIRHIST_CNT < 0
3632 let g:NETRW_DIRHIST_CNT= g:NETRW_DIRHIST_CNT + g:netrw_dirhistmax
3634 if exists("g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}")
3635 " call Decho("changedir u#".g:NETRW_DIRHIST_CNT."<".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}.">")
3636 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir")
3641 " call Decho("exe e! ".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT})
3642 exe "e! ".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}
3644 let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT + 1 ) % g:netrw_dirhistmax
3645 echo "Sorry, no predecessor directory exists yet"
3649 " U: change to the subsequent directory stored on the history list
3650 " call Decho("(user: <U>) chg to next dir from history")
3651 let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT + 1 ) % g:netrw_dirhistmax
3652 if exists("g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}")
3653 " call Decho("changedir U#".g:NETRW_DIRHIST_CNT."<".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}.">")
3654 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir")
3659 " call Decho("exe e! ".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT})
3660 exe "e! ".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}
3662 let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT - 1 ) % g:netrw_dirhistmax
3663 if g:NETRW_DIRHIST_CNT < 0
3664 let g:NETRW_DIRHIST_CNT= g:NETRW_DIRHIST_CNT + g:netrw_dirhistmax
3666 echo "Sorry, no successor directory exists yet"
3669 call s:NetBookmarkMenu()
3670 " call Dret("NetBookmarkDir")
3673 " ---------------------------------------------------------------------
3674 " NetBookmarkMenu: {{{2
3675 fun! s:NetBookmarkMenu()
3676 if !exists("s:netrw_menucnt")
3679 " call Dfunc("NetBookmarkMenu() bookmarkcnt=".g:NETRW_BOOKMARKMAX." histcnt=".g:NETRW_DIRHIST_CNT." menucnt=".s:netrw_menucnt)
3680 if has("menu") && has("gui_running") && &go =~ 'm'
3681 if exists("g:NetrwTopLvlMenu")
3682 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Bookmark'
3685 " show bookmarked places
3687 while cnt <= g:NETRW_BOOKMARKMAX
3688 if exists("g:NETRW_BOOKMARKDIR_{cnt}")
3689 let bmdir= escape(g:NETRW_BOOKMARKDIR_{cnt},'.')
3690 " call Decho('silent! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmark.'.bmdir.' :e '.g:NETRW_BOOKMARKDIR_{cnt})
3691 exe 'silent! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmarks.'.bmdir.' :e '.g:NETRW_BOOKMARKDIR_{cnt}."\<cr>"
3696 " show directory browsing history
3697 let cnt = g:NETRW_DIRHIST_CNT
3700 while ( first || cnt != g:NETRW_DIRHIST_CNT )
3701 let histcnt = histcnt + 1
3702 let priority = g:NETRW_DIRHIST_CNT + histcnt
3703 if exists("g:NETRW_DIRHIST_{cnt}")
3704 let bmdir= escape(g:NETRW_DIRHIST_{cnt},'.')
3705 " call Decho('silent! menu '.g:NetrwMenuPriority.".3.".priority." ".g:NetrwTopLvlMenu.'History.'.bmdir.' :e '.g:NETRW_DIRHIST_{cnt})
3706 exe 'silent! menu '.g:NetrwMenuPriority.".3.".priority." ".g:NetrwTopLvlMenu.'History.'.bmdir.' :e '.g:NETRW_DIRHIST_{cnt}."\<cr>"
3709 let cnt = ( cnt - 1 ) % g:netrw_dirhistmax
3711 let cnt= cnt + g:netrw_dirhistmax
3715 " call Dret("NetBookmarkMenu")
3718 " ---------------------------------------------------------------------
3719 " NetObtain: obtain file under cursor (for remote browsing support) {{{2
3720 fun! netrw#NetObtain(vismode,...) range
3721 " call Dfunc("NetObtain(vismode=".a:vismode.") a:0=".a:0)
3725 let fname= expand("<cWORD>")
3726 " call Decho("no arguments, use <".fname.">")
3727 elseif a:vismode == 1
3731 if g:netrw_liststyle == s:THINLIST
3733 let filelist= split(@a,'\n')
3734 elseif g:netrw_liststyle == s:LONGLIST
3736 let filelist= split(substitute(@a,'\t.\{-}\n','\n','g'),'\n')
3739 let filelist = split(substitute(@a,'\s\{2,}','\n','g'),'\n')
3740 let filelist = map(filelist,'substitute(v:val,"^\\s\\+","","")')
3741 let filelist = map(filelist,'substitute(v:val,"\\s\\+$","","")')
3743 " call Decho("filelist<".string(filelist).">")
3747 call netrw#NetObtain(2,f)
3750 " call Dret("NetObtain : visual mode handler")
3752 elseif a:vismode == 2
3753 " multiple file mode
3755 " call Decho("visual mode handling: <".fname.">")
3758 " NetrwStatusLine support - for obtaining support
3759 call s:SetupNetrwStatusLine('%f %h%m%r%=%9*Obtaining '.fname)
3761 if exists("w:netrw_method") && w:netrw_method =~ '[235]'
3762 " call Decho("method=".w:netrw_method)
3763 if executable("ftp")
3764 " call Decho("ftp is executable, method=".w:netrw_method)
3765 let curdir = b:netrw_curdir
3766 let path = substitute(curdir,'ftp://[^/]\+/','','e')
3767 let curline= line(".")
3768 let endline= line("$")+1
3771 " call Decho("getcwd<".getcwd().">")
3772 " call Decho("curdir<".curdir.">")
3773 " call Decho("path<".path.">")
3774 " call Decho("curline=".curline)
3775 " call Decho("endline=".endline)
3777 ".........................................
3778 if w:netrw_method == 2
3779 " ftp + <.netrc>: Method #2
3783 " call Decho("ftp: cd ".path)
3786 " call Decho("ftp: get ".fname)
3788 " call Decho("ftp: quit")
3789 if exists("g:netrw_port") && g:netrw_port != ""
3790 " call Decho("exe ".g:netrw_silentxfer.endline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port)
3791 exe g:netrw_silentxfer.endline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port
3793 " call Decho("exe ".g:netrw_silentxfer.endline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine)
3794 exe g:netrw_silentxfer.endline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine
3797 ".........................................
3798 elseif w:netrw_method == 3
3799 " ftp + machine,id,passwd,filename: Method #3
3801 if exists("g:netrw_port") && g:netrw_port != ""
3802 put ='open '.g:netrw_machine.' '.g:netrw_port
3803 " call Decho('ftp: open '.g:netrw_machine.' '.g:netrw_port)
3805 put ='open '.g:netrw_machine
3806 " call Decho('ftp: open '.g:netrw_machine)
3809 if exists("g:netrw_ftp") && g:netrw_ftp == 1
3811 put ='\"'.g:netrw_passwd.'\"'
3812 " call Decho('ftp: g:netrw_uid')
3813 " call Decho('ftp: g:netrw_passwd')
3815 put ='user \"'.g:netrw_uid.'\" \"'.g:netrw_passwd.'\"'
3816 " call Decho('user '.g:netrw_uid.' '.g:netrw_passwd)
3821 " call Decho('cd '.a:path)
3824 " call Decho("ftp: get ".fname)
3826 " call Decho("ftp: quit")
3829 " -i : turns off interactive prompting from ftp
3830 " -n unix : DON'T use <.netrc>, even though it exists
3831 " -n win32: quit being obnoxious about password
3832 " call Decho("exe ".g:netrw_silentxfer.curline.",$!".g:netrw_ftp_cmd." -i -n")
3833 exe g:netrw_silentxfer.endline.",$!".g:netrw_ftp_cmd." -i -n"
3835 ".........................................
3837 call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . choice . ">",28)
3840 exe "silent! ".endline.",$d"
3841 exe "keepjumps ".curline
3842 setlocal noma nomod ro
3844 " call Decho("ftp not executable")
3845 if !exists("g:netrw_quiet")
3846 call netrw#ErrorMsg(s:ERROR,"this system doesn't support ftp",29)
3848 " restore status line
3849 let &stl = s:netrw_users_stl
3850 let &laststatus = s:netrw_users_ls
3852 if exists("keep_netrw_method")
3853 call s:NetMethod(keep_netrw_choice)
3854 let w:netrw_method = keep_netrw_wmethod
3856 " call Dret("NetObtain")
3860 ".........................................
3863 " call Decho("using scp")
3864 let curdir = b:netrw_curdir
3865 let path = substitute(curdir,'scp://[^/]\+/','','e')
3866 " call Decho("path<".path.">")
3867 if exists("g:netrw_port") && g:netrw_port != ""
3868 let useport= " ".g:netrw_scpport." ".g:netrw_port
3872 " call Decho("executing: !".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".path.escape(fname,' ?&')." .")
3873 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".path.escape(fname,' ?&')." ."
3877 " restore status line
3878 let &stl = s:netrw_users_stl
3879 let &laststatus = s:netrw_users_ls
3883 if exists("keep_netrw_method")
3884 call s:NetMethod(keep_netrw_choice)
3885 let w:netrw_method = keep_netrw_wmethod
3888 " call Dret("NetObtain")
3891 " ---------------------------------------------------------------------
3892 " NetPrevWinOpen: open file/directory in previous window. {{{2
3893 " If there's only one window, then the window will first be split.
3894 fun! s:NetPrevWinOpen(islocal)
3895 " call Dfunc("NetPrevWinOpen(islocal=".a:islocal.")")
3897 " get last window number and the word currently under the cursor
3898 let lastwinnr = winnr("$")
3899 let curword = s:NetGetWord()
3900 " call Decho("lastwinnr=".lastwinnr." curword<".curword.">")
3904 " if only one window, open a new one first
3905 " call Decho("only one window, so open a new one (g:netrw_alto=".g:netrw_alto.")")
3906 exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s"
3911 " if the previous window's buffer has been changed (is modified),
3912 " and it doesn't appear in any other extant window, then ask the
3913 " user if s/he wants to abandon modifications therein.
3914 let bnr = winbufnr(0)
3917 windo if winbufnr(0) == bnr | let bnrcnt=bnrcnt+1 | endif
3918 " call Decho("bnr=".bnr." bnrcnt=".bnrcnt)
3920 let bufname= bufname(winbufnr(winnr()))
3921 let choice= confirm("Save modified file<".bufname.">?","&Yes\n&No\n&Cancel")
3924 " Yes -- write file & then browse
3928 call netrw#ErrorMsg(s:ERROR,"unable to write <".bufname.">!",30)
3934 " call Dret("NetPrevWinOpen : unable to write <".bufname.">")
3939 " No -- don't worry about changed file, just browse anyway
3941 call netrw#ErrorMsg(s:WARNING,bufname." changes abandoned",31)
3944 " Cancel -- don't do this
3950 " call Dret("NetPrevWinOpen : cancelled")
3958 call netrw#LocalBrowseCheck(s:NetBrowseChgDir(a:islocal,curword))
3960 call s:NetBrowse(a:islocal,s:NetBrowseChgDir(a:islocal,curword))
3962 " call Dret("NetPrevWinOpen")
3965 " ---------------------------------------------------------------------
3966 " NetMenu: generates the menu for gvim and netrw {{{2
3967 fun! s:NetMenu(domenu)
3969 if !exists("g:NetrwMenuPriority")
3970 let g:NetrwMenuPriority= 80
3973 if has("menu") && has("gui_running") && &go =~ 'm' && g:netrw_menu
3974 " call Dfunc("NetMenu(domenu=".a:domenu.")")
3976 if !exists("s:netrw_menu_enabled") && a:domenu
3977 " call Decho("initialize menu")
3978 let s:netrw_menu_enabled= 1
3979 exe 'silent! menu '.g:NetrwMenuPriority.'.1 '.g:NetrwTopLvlMenu.'Help<tab><F1> <F1>'
3980 call s:NetBookmarkMenu() " provide some history!
3981 exe 'silent! menu '.g:NetrwMenuPriority.'.4 '.g:NetrwTopLvlMenu.'Go\ Up\ Directory<tab>- -'
3982 exe 'silent! menu '.g:NetrwMenuPriority.'.5 '.g:NetrwTopLvlMenu.'Apply\ Special\ Viewer<tab>x x'
3983 exe 'silent! menu '.g:NetrwMenuPriority.'.6 '.g:NetrwTopLvlMenu.'Bookmark\ Current\ Directory<tab>mb mb'
3984 exe 'silent! menu '.g:NetrwMenuPriority.'.7 '.g:NetrwTopLvlMenu.'Goto\ Bookmarked\ Directory<tab>gb gb'
3985 exe 'silent! menu '.g:NetrwMenuPriority.'.8 '.g:NetrwTopLvlMenu.'Change\ To\ Recently\ Used\ Directory<tab>u u'
3986 exe 'silent! menu '.g:NetrwMenuPriority.'.9 '.g:NetrwTopLvlMenu.'Change\ To\ Subsequently\ Used\ Directory<tab>U U'
3987 exe 'silent! menu '.g:NetrwMenuPriority.'.10 '.g:NetrwTopLvlMenu.'Delete\ File/Directory<tab>D D'
3988 exe 'silent! menu '.g:NetrwMenuPriority.'.11 '.g:NetrwTopLvlMenu.'Edit\ File\ Hiding\ List<tab>'."<ctrl-h> \<c-h>"
3989 exe 'silent! menu '.g:NetrwMenuPriority.'.12 '.g:NetrwTopLvlMenu.'Edit\ File/Directory<tab><cr> '."\<cr>"
3990 exe 'silent! menu '.g:NetrwMenuPriority.'.13 '.g:NetrwTopLvlMenu.'Edit\ File/Directory,\ New\ Window<tab>o o'
3991 exe 'silent! menu '.g:NetrwMenuPriority.'.14 '.g:NetrwTopLvlMenu.'Edit\ File/Directory,\ New\ Vertical\ Window<tab>v v'
3992 exe 'silent! menu '.g:NetrwMenuPriority.'.15 '.g:NetrwTopLvlMenu.'List\ Bookmarks\ and\ History<tab>q q'
3993 exe 'silent! menu '.g:NetrwMenuPriority.'.16 '.g:NetrwTopLvlMenu.'Listing\ Style\ (thin-long-wide)<tab>i i'
3994 exe 'silent! menu '.g:NetrwMenuPriority.'.17 '.g:NetrwTopLvlMenu.'Make\ Subdirectory<tab>d d'
3995 exe 'silent! menu '.g:NetrwMenuPriority.'.18 '.g:NetrwTopLvlMenu.'Normal-Hide-Show<tab>a a'
3996 exe 'silent! menu '.g:NetrwMenuPriority.'.19 '.g:NetrwTopLvlMenu.'Obtain\ File<tab>O O'
3997 exe 'silent! menu '.g:NetrwMenuPriority.'.20 '.g:NetrwTopLvlMenu.'Preview\ File/Directory<tab>p p'
3998 exe 'silent! menu '.g:NetrwMenuPriority.'.21 '.g:NetrwTopLvlMenu.'Previous\ Window\ Browser<tab>P P'
3999 exe 'silent! menu '.g:NetrwMenuPriority.'.22 '.g:NetrwTopLvlMenu.'Refresh\ Listing<tab>'."<ctrl-l> \<c-l>"
4000 exe 'silent! menu '.g:NetrwMenuPriority.'.23 '.g:NetrwTopLvlMenu.'Rename\ File/Directory<tab>R R'
4001 exe 'silent! menu '.g:NetrwMenuPriority.'.24 '.g:NetrwTopLvlMenu.'Reverse\ Sorting\ Order<tab>'."r r"
4002 exe 'silent! menu '.g:NetrwMenuPriority.'.25 '.g:NetrwTopLvlMenu.'Select\ Sorting\ Style<tab>s s'
4003 exe 'silent! menu '.g:NetrwMenuPriority.'.26 '.g:NetrwTopLvlMenu.'Sorting\ Sequence\ Edit<tab>S S'
4004 exe 'silent! menu '.g:NetrwMenuPriority.'.27 '.g:NetrwTopLvlMenu.'Set\ Current\ Directory<tab>c c'
4005 exe 'silent! menu '.g:NetrwMenuPriority.'.28 '.g:NetrwTopLvlMenu.'Settings/Options<tab>:NetrwSettings '.":NetrwSettings\<cr>"
4006 let s:netrw_menucnt= 28
4010 let curwin = winnr()
4011 windo if getline(2) =~ "Netrw" | let s:netrwcnt= s:netrwcnt + 1 | endif
4012 exe curwin."wincmd w"
4015 " call Decho("clear menus")
4016 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Help'
4017 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Apply\ Special\ Viewer'
4018 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Bookmark\ Current\ Directory'
4019 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Go\ Up\ Directory'
4020 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Goto\ Bookmarked\ Directory'
4021 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Change\ To\ Recently\ Used\ Directory'
4022 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Change\ To\ Subsequently\ Used\ Directory'
4023 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Delete\ File/Directory'
4024 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Edit\ File/Directory'
4025 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Edit\ File/Directory,\ New\ Window'
4026 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Edit\ File/Directory,\ New\ Vertical\ Window'
4027 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Edit\ File\ Hiding\ List'
4028 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Edit\ File'
4029 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Enter\ File/Directory'
4030 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Enter\ File/Directory\ (vertical\ split)'
4031 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'List\ Bookmarks\ and\ History'
4032 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Listing\ Style\ (thin-long-wide)'
4033 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Make\ Subdirectory'
4034 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Normal-Hide-Show'
4035 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Obtain\ File'
4036 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Preview\ File/Directory'
4037 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Previous\ Window\ Browser'
4038 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Refresh\ Listing'
4039 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Rename\ File/Directory'
4040 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Reverse\ Sorting\ Order'
4041 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Select\ Sorting\ Style'
4042 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Sorting\ Sequence\ Edit'
4043 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Set\ Current\ Directory'
4044 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Settings/Options'
4045 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Bookmarks'
4046 silent! unlet s:netrw_menu_enabled
4049 " call Dret("NetMenu")
4054 " ==========================================
4055 " Local Directory Browsing Support: {{{1
4056 " ==========================================
4058 " ---------------------------------------------------------------------
4059 " LocalBrowseCheck: {{{2
4060 fun! netrw#LocalBrowseCheck(dirname)
4061 " unfortunate interaction -- split window debugging can't be
4062 " " used here, must use DechoRemOn or DechoTabOn -- the BufEnter
4063 " event triggers another call to LocalBrowseCheck() when attempts
4064 " to write to the DBG buffer are made.
4065 " call Dfunc("LocalBrowseCheck(dirname<".a:dirname.">")
4066 if isdirectory(a:dirname)
4067 silent! call s:NetBrowse(1,a:dirname)
4069 " call Dret("LocalBrowseCheck")
4070 " not a directory, ignore it
4073 " ---------------------------------------------------------------------
4074 " LocalListing: does the job of "ls" for local directories {{{2
4075 fun! s:LocalListing()
4076 " call Dfunc("LocalListing() &ma=".&ma." &mod=".&mod." &ro=".&ro." buf(%)=".buf("%"))
4077 " if exists("b:netrw_curdir") |call Decho('b:netrw_curdir<'.b:netrw_curdir.">") |else|call Decho("b:netrw_curdir doesn't exist") |endif
4078 " if exists("g:netrw_sort_by")|call Decho('g:netrw_sort_by<'.g:netrw_sort_by.">")|else|call Decho("g:netrw_sort_by doesn't exist")|endif
4080 " get the list of files contained in the current directory
4081 let dirname = escape(b:netrw_curdir,s:netrw_glob_escape)
4082 let dirnamelen = strlen(b:netrw_curdir)
4083 let filelist = glob(s:ComposePath(dirname,"*"))
4084 " call Decho("glob(dirname<".dirname."/*>)=".filelist)
4086 let filelist= filelist."\n"
4088 let filelist= filelist.glob(s:ComposePath(dirname,".*"))
4089 " call Decho("glob(dirname<".dirname."/.*>)=".glob(dirname.".*"))
4091 " if the directory name includes a "$", and possibly other characters,
4092 " the glob() doesn't include "." and ".." entries.
4093 if filelist !~ '[\\/]\.[\\/]\=\(\n\|$\)'
4094 " call Decho("forcibly tacking on .")
4096 let filelist= s:ComposePath(dirname,"./")
4098 let filelist= filelist."\n".s:ComposePath(b:netrw_curdir,"./")
4100 " call Decho("filelist<".filelist.">")
4102 if filelist !~ '[\\/]\.\.[\\/]\=\(\n\|$\)'
4103 " call Decho("forcibly tacking on ..")
4104 let filelist= filelist."\n".s:ComposePath(b:netrw_curdir,"../")
4105 " call Decho("filelist<".filelist.">")
4107 if b:netrw_curdir == '/'
4108 " remove .. from filelist when current directory is root directory
4109 let filelist= substitute(filelist,'/\.\.\n','','')
4110 " call Decho("remove .. from filelist")
4112 let filelist= substitute(filelist,'\n\{2,}','\n','ge')
4113 if (has("win32") || has("win95") || has("win64") || has("win16"))
4114 let filelist= substitute(filelist,'\','/','ge')
4116 let filelist= substitute(filelist,'\','\\','ge')
4119 " call Decho("dirname<".dirname.">")
4120 " call Decho("dirnamelen<".dirnamelen.">")
4121 " call Decho("filelist<".filelist.">")
4123 while filelist != ""
4125 let filename = substitute(filelist,'\n.*$','','e')
4126 let filelist = substitute(filelist,'^.\{-}\n\(.*\)$','\1','e')
4128 let filename = filelist
4132 if isdirectory(filename)
4133 let pfile= filename."/"
4136 let pfile= substitute(pfile,'//$','/','e')
4138 let pfile= strpart(pfile,dirnamelen)
4139 let pfile= substitute(pfile,'^[/\\]','','e')
4141 " call Decho("filename<".filename.">")
4142 " call Decho("pfile <".pfile.">")
4144 if w:netrw_liststyle == s:LONGLIST
4145 let sz = getfsize(filename)
4146 let fsz = strpart(" ",1,15-strlen(sz)).sz
4147 let pfile= pfile."\t".fsz." ".strftime(g:netrw_timefmt,getftime(filename))
4148 " call Decho("sz=".sz." fsz=".fsz)
4151 if g:netrw_sort_by =~ "^t"
4152 " sort by time (handles time up to 1 quintillion seconds, US)
4153 " call Decho("getftime(".filename.")=".getftime(filename))
4154 let t = getftime(filename)
4155 let ft = strpart("000000000000000000",1,18-strlen(t)).t
4156 " call Decho("exe keepjumps put ='".ft.'/'.filename."'")
4157 let ftpfile= ft.'/'.pfile
4158 keepjumps silent! put=ftpfile
4160 elseif g:netrw_sort_by =~ "^s"
4161 " sort by size (handles file sizes up to 1 quintillion bytes, US)
4162 " call Decho("getfsize(".filename.")=".getfsize(filename))
4163 let sz = getfsize(filename)
4164 let fsz = strpart("000000000000000000",1,18-strlen(sz)).sz
4165 " call Decho("exe keepjumps put ='".fsz.'/'.filename."'")
4166 let fszpfile= fsz.'/'.pfile
4167 keepjumps silent! put =fszpfile
4171 " call Decho("exe keepjumps put ='".pfile."'")
4172 keepjumps silent! put=pfile
4176 " cleanup any windows mess at end-of-line
4177 silent! keepjumps %s/\r$//e
4179 " call Decho("setlocal ts=32")
4181 " call Dret("LocalListing")
4184 " ---------------------------------------------------------------------
4185 " LocalBrowseShellCmdRefresh: this function is called after a user has {{{2
4186 " performed any shell command. The idea is to cause all local-browsing
4187 " buffers to be refreshed after a user has executed some shell command,
4188 " on the chance that s/he removed/created a file/directory with it.
4189 fun! s:LocalBrowseShellCmdRefresh()
4190 " call Dfunc("LocalBrowseShellCmdRefresh() browselist=".string(s:netrw_browselist))
4191 " determine which buffers currently reside in a tab
4194 while itab <= tabpagenr("$")
4195 let buftablist= buftablist + tabpagebuflist()
4199 " call Decho("buftablist".string(buftablist))
4200 " GO through all buffers on netrw_browselist (ie. just local-netrw buffers):
4201 " | refresh any netrw window
4202 " | wipe out any non-displaying netrw buffer
4203 let curwin = winnr()
4205 for ibuf in s:netrw_browselist
4206 " call Decho("bufwinnr(".ibuf.") index(buftablist,".ibuf.")=".index(buftablist,ibuf))
4207 if bufwinnr(ibuf) == -1 && index(buftablist,ibuf) == -1
4208 " call Decho("wiping buf#".ibuf,"<".bufname(ibuf).">")
4209 exe "silent! bw ".ibuf
4210 call remove(s:netrw_browselist,ibl)
4211 " call Decho("browselist=".string(s:netrw_browselist))
4213 elseif index(tabpagebuflist(),ibuf) != -1
4214 " call Decho("refresh buf#".ibuf.'-> win#'.bufwinnr(ibuf))
4215 exe bufwinnr(ibuf)."wincmd w"
4216 call s:NetRefresh(1,s:NetBrowseChgDir(1,'./'))
4220 exe curwin."wincmd w"
4222 " call Dret("LocalBrowseShellCmdRefresh")
4225 " ---------------------------------------------------------------------
4226 " LocalBrowseRm: {{{2
4227 fun! s:LocalBrowseRm(path) range
4228 " call Dfunc("LocalBrowseRm(path<".a:path.">)")
4229 " call Decho("firstline=".a:firstline." lastline=".a:lastline)
4231 " preparation for removing multiple files/directories
4232 let ctr = a:firstline
4236 " remove multiple files and directories
4237 while ctr <= a:lastline
4238 exe "keepjumps ".ctr
4241 if line(".") < w:netrw_bannercnt
4245 let curword= s:NetGetWord()
4246 if curword == "./" || curword == "../"
4252 let rmfile= s:ComposePath(a:path,curword)
4253 " call Decho("rmfile<".rmfile.">")
4255 if rmfile !~ '^"' && (rmfile =~ '@$' || rmfile !~ '[\/]$')
4256 " attempt to remove file
4260 let ok= input("Confirm deletion of file<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ")
4266 " call Decho("response: ok<".ok.">")
4267 let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e')
4268 " call Decho("response: ok<".ok."> (after sub)")
4274 if all || ok =~ 'y\%[es]' || ok == ""
4275 let ret= s:System("delete",rmfile)
4276 " call Decho("errcode=".v:shell_error." ret=".ret)
4277 elseif ok =~ 'q\%[uit]'
4282 " attempt to remove directory
4286 let ok= input("Confirm deletion of directory<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ")
4288 let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e')
4296 let rmfile= substitute(rmfile,'[\/]$','','e')
4298 if all || ok =~ 'y\%[es]' || ok == ""
4299 " call Decho("1st attempt: system(".g:netrw_local_rmdir.' "'.rmfile.'")')
4300 call s:System("system",g:netrw_local_rmdir.' "'.rmfile.'"')
4301 " call Decho("v:shell_error=".v:shell_error)
4303 if v:shell_error != 0
4304 " call Decho("2nd attempt to remove directory<".rmfile.">")
4305 let errcode= s:System("delete",rmfile)
4306 " call Decho("errcode=".errcode)
4310 " call Decho("3rd attempt to remove directory<".rmfile.">")
4311 call s:System("system","rm ".rmfile)
4312 if v:shell_error != 0 && !exists("g:netrw_quiet")
4313 call netrw#ErrorMsg(s:ERROR,"unable to remove directory<".rmfile."> -- is it empty?",34)
4315 elseif !exists("g:netrw_quiet")
4316 call netrw#ErrorMsg(s:ERROR,"unable to remove directory<".rmfile."> -- is it empty?",35)
4321 elseif ok =~ 'q\%[uit]'
4329 " refresh the directory
4330 let curline= line(".")
4331 " call Decho("refresh the directory")
4332 call s:NetRefresh(1,s:NetBrowseChgDir(1,'./'))
4335 " call Dret("LocalBrowseRm")
4338 " ---------------------------------------------------------------------
4339 " LocalBrowseRename: rename a remote file or directory {{{2
4340 fun! s:LocalBrowseRename(path) range
4341 " call Dfunc("LocalBrowseRename(path<".a:path.">)")
4343 " preparation for removing multiple files/directories
4344 let ctr= a:firstline
4346 " attempt to rename files/directories
4347 while ctr <= a:lastline
4348 exe "keepjumps ".ctr
4351 if line(".") < w:netrw_bannercnt
4355 let curword= s:NetGetWord()
4356 if curword == "./" || curword == "../"
4362 let oldname= s:ComposePath(a:path,curword)
4363 " call Decho("oldname<".oldname.">")
4366 let newname= input("Moving ".oldname." to : ",substitute(oldname,'/*$','','e'))
4369 let ret= rename(oldname,newname)
4370 " call Decho("renaming <".oldname."> to <".newname.">")
4375 " refresh the directory
4376 " call Decho("refresh the directory listing")
4377 call netrw#NetSavePosn()
4378 call s:NetRefresh(1,s:NetBrowseChgDir(1,'./'))
4379 " call Dret("LocalBrowseRename")
4382 " ---------------------------------------------------------------------
4383 " LocalFastBrowser: handles setting up/taking down fast browsing for the {{{2
4385 " fastbrowse Local Remote Hiding a buffer implies it may be re-used (fast)
4386 " slow 0 D D Deleting a buffer implies it will not be re-used (slow)
4389 fun! s:LocalFastBrowser()
4390 " call Dfunc("LocalFastBrowser() g:netrw_fastbrowse=".g:netrw_fastbrowse)
4392 " initialize browselist, a list of buffer numbers that the local browser has used
4393 if !exists("s:netrw_browselist")
4394 " call Decho("initialize s:netrw_browselist")
4395 let s:netrw_browselist= []
4398 " append current buffer to fastbrowse list
4399 if g:netrw_fastbrowse <= 1 && (empty(s:netrw_browselist) || bufnr("%") > s:netrw_browselist[-1])
4400 " call Decho("appendng current buffer to browselist")
4401 call add(s:netrw_browselist,bufnr("%"))
4402 " call Decho("browselist=".string(s:netrw_browselist))
4405 " enable autocmd events to handle refreshing/removing local browser buffers
4406 " If local browse buffer is currently showing: refresh it
4407 " If local browse buffer is currently hidden : wipe it
4408 if !exists("s:netrw_browser_shellcmd") && g:netrw_fastbrowse <= 1
4409 " call Decho("setting up local-browser shell command refresh")
4410 let s:netrw_browser_shellcmd= 1
4411 augroup AuNetrwShellCmd
4413 if (has("win32") || has("win95") || has("win64") || has("win16"))
4414 au ShellCmdPost * call s:LocalBrowseShellCmdRefresh()
4416 au ShellCmdPost,FocusGained * call s:LocalBrowseShellCmdRefresh()
4421 " user must have changed fastbrowse to its fast setting, so remove
4422 " the associated autocmd events
4423 if g:netrw_fastbrowse > 1 && exists("s:netrw_browser_shellcmd")
4424 " call Decho("remove AuNetrwShellCmd autcmd group")
4425 unlet s:netrw_browser_shellcmd
4426 augroup AuNetrwShellCmd
4429 augroup! AuNetrwShellCmd
4432 " call Dret("LocalFastBrowser")
4435 " ---------------------------------------------------------------------
4436 " LocalObtain: copy selected file to current working directory {{{2
4437 fun! s:LocalObtain()
4438 " call Dfunc("LocalObtain()")
4439 if exists("b:netrw_curdir") && getcwd() != b:netrw_curdir
4440 let fname= expand("<cWORD>")
4441 let fcopy= readfile(b:netrw_curdir."/".fname,"b")
4442 call writefile(fcopy,getcwd()."/".fname,"b")
4443 elseif !exists("b:netrw_curdir")
4444 call netrw#ErrorMsg(s:ERROR,"local browsing directory doesn't exist!",36)
4446 call netrw#ErrorMsg(s:ERROR,"local browsing directory and current directory are identical",37)
4448 " call Dret("LocalObtain")
4451 " ---------------------------------------------------------------------
4452 " netrw#Explore: launch the local browser in the directory of the current file {{{2
4453 " dosplit==0: the window will be split iff the current file has
4455 " dosplit==1: the window will be split before running the local
4457 fun! netrw#Explore(indx,dosplit,style,...)
4458 " call Dfunc("netrw#Explore(indx=".a:indx." dosplit=".a:dosplit." style=".a:style.",a:1<".a:1.">) &modified=".&modified." a:0=".a:0)
4459 if !exists("b:netrw_curdir")
4460 let b:netrw_curdir= getcwd()
4461 " call Decho("set b:netrw_curdir<".b:netrw_curdir."> (used getcwd)")
4463 let curfile= b:netrw_curdir
4464 " call Decho("curfile<".curfile.">")
4467 silent! let keepregstar = @*
4468 silent! let keepregplus = @+
4469 silent! let keepregslash= @/
4471 " if dosplit or file has been modified
4472 if a:dosplit || &modified || a:style == 6
4473 " call Decho("case: dosplit=".a:dosplit." modified=".&modified." a:style=".a:style)
4474 call s:SaveWinVars()
4476 if a:style == 0 " Explore, Sexplore
4477 " call Decho("style=0: Explore or Sexplore")
4478 exe g:netrw_winsize."wincmd s"
4480 elseif a:style == 1 "Explore!, Sexplore!
4481 " call Decho("style=1: Explore! or Sexplore!")
4482 exe g:netrw_winsize."wincmd v"
4484 elseif a:style == 2 " Hexplore
4485 " call Decho("style=2: Hexplore")
4486 exe "bel ".g:netrw_winsize."wincmd s"
4488 elseif a:style == 3 " Hexplore!
4489 " call Decho("style=3: Hexplore!")
4490 exe "abo ".g:netrw_winsize."wincmd s"
4492 elseif a:style == 4 " Vexplore
4493 " call Decho("style=4: Vexplore")
4494 exe "lefta ".g:netrw_winsize."wincmd v"
4496 elseif a:style == 5 " Vexplore!
4497 " call Decho("style=5: Vexplore!")
4498 exe "rightb ".g:netrw_winsize."wincmd v"
4500 elseif a:style == 6 " Texplore
4501 call s:SaveBufVars()
4502 " call Decho("style = 6: Texplore")
4504 call s:RestoreBufVars()
4506 call s:RestoreWinVars()
4511 " call Decho("a:1<".a:1.">")
4512 if a:1 =~ '^\~' && (has("unix") || (exists("g:netrw_cygwin") && g:netrw_cygwin))
4513 let dirname= substitute(a:1,'\~',expand("$HOME"),'')
4514 " call Decho("using dirname<".dirname."> (case: ~ && unix||cygwin)")
4516 let dirname= exists("b:netrw_curdir")? b:netrw_curdir : getcwd()
4518 let dirname= dirname."/"
4520 " call Decho("using dirname<".dirname."> (case: ".(exists("b:netrw_curdir")? "b:netrw_curdir" : "getcwd()").")")
4522 let dirname= expand(a:1)
4525 " call Decho("using dirname<".dirname.">")
4529 if dirname =~ '^\*/'
4531 " call Decho("case Explore */pattern")
4532 let pattern= substitute(dirname,'^\*/\(.*\)$','\1','')
4533 " call Decho("Explore */pat: dirname<".dirname."> -> pattern<".pattern.">")
4534 if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif
4535 elseif dirname =~ '^\*\*//'
4536 " Explore **//pattern
4537 " call Decho("case Explore **//pattern")
4538 let pattern = substitute(dirname,'^\*\*//','','')
4540 " call Decho("Explore **//pat: dirname<".dirname."> -> pattern<".pattern.">")
4543 if dirname == "" && a:indx >= 0
4544 " Explore Hexplore Vexplore Sexplore
4545 " call Decho("case Explore Hexplore Vexplore Sexplore")
4546 let newdir= substitute(expand("%:p"),'^\(.*[/\\]\)[^/\\]*$','\1','e')
4547 if newdir =~ '^scp:' || newdir =~ '^ftp:'
4548 " call Decho("calling NetBrowse(0,newdir<".newdir.">)")
4549 call s:NetBrowse(0,newdir)
4551 if newdir == ""|let newdir= getcwd()|endif
4552 " call Decho("calling LocalBrowseCheck(newdir<".newdir.">)")
4553 call netrw#LocalBrowseCheck(newdir)
4555 call search('\<'.substitute(curfile,'^.*/','','e').'\>','cW')
4557 elseif dirname =~ '^\*\*/' || a:indx < 0 || dirname =~ '^\*/'
4558 " Nexplore, Pexplore, Explore **/... , or Explore */pattern
4559 " call Decho("case Nexplore, Pexplore, <s-down>, <s-up>, Explore dirname<".dirname.">")
4560 if !mapcheck("<s-up>","n") && !mapcheck("<s-down>","n") && exists("b:netrw_curdir")
4561 " call Decho("set up <s-up> and <s-down> maps")
4562 let s:didstarstar= 1
4563 nnoremap <buffer> <silent> <s-up> :Pexplore<cr>
4564 nnoremap <buffer> <silent> <s-down> :Nexplore<cr>
4567 if has("path_extra")
4568 " call Decho("has path_extra")
4569 if !exists("w:netrw_explore_indx")
4570 let w:netrw_explore_indx= 0
4573 " call Decho("set indx= [a:indx=".indx."]")
4577 " call Decho("case Nexplore: (indx=".indx.")")
4578 if !exists("w:netrw_explore_list") " sanity check
4579 call netrw#ErrorMsg(s:WARNING,"using Nexplore or <s-down> improperly; see help for netrw-starstar",40)
4580 silent! let @* = keepregstar
4581 silent! let @+ = keepregstar
4582 silent! let @/ = keepregslash
4583 " call Dret("netrw#Explore")
4586 let indx= w:netrw_explore_indx
4587 if indx < 0 | let indx= 0 | endif
4588 if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif
4589 let curfile= w:netrw_explore_list[indx]
4590 " call Decho("indx=".indx." curfile<".curfile.">")
4591 while indx < w:netrw_explore_listlen && curfile == w:netrw_explore_list[indx]
4593 " call Decho("indx=".indx." (Nexplore while loop)")
4595 if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif
4596 " call Decho("Nexplore: indx= [w:netrw_explore_indx=".w:netrw_explore_indx."]=".indx)
4600 " call Decho("case Pexplore: (indx=".indx.")")
4601 if !exists("w:netrw_explore_list") " sanity check
4602 call netrw#ErrorMsg(s:WARNING,"using Pexplore or <s-up> improperly; see help for netrw-starstar",41)
4603 silent! let @* = keepregstar
4604 silent! let @+ = keepregstar
4605 silent! let @/ = keepregslash
4606 " call Dret("netrw#Explore")
4609 let indx= w:netrw_explore_indx
4610 if indx < 0 | let indx= 0 | endif
4611 if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif
4612 let curfile= w:netrw_explore_list[indx]
4613 " call Decho("indx=".indx." curfile<".curfile.">")
4614 while indx >= 0 && curfile == w:netrw_explore_list[indx]
4616 " call Decho("indx=".indx." (Pexplore while loop)")
4618 if indx < 0 | let indx= 0 | endif
4619 " call Decho("Pexplore: indx= [w:netrw_explore_indx=".w:netrw_explore_indx."]=".indx)
4622 " Explore -- initialize
4623 " build list of files to Explore with Nexplore/Pexplore
4624 " call Decho("case Explore: initialize (indx=".indx.")")
4625 let w:netrw_explore_indx= 0
4626 if !exists("b:netrw_curdir")
4627 let b:netrw_curdir= getcwd()
4629 " call Decho("b:netrw_curdir<".b:netrw_curdir.">")
4631 if exists("pattern")
4632 " call Decho("pattern exists: building list pattern<".pattern."> cwd<".getcwd().">")
4633 if exists("starstarpat")
4634 " call Decho("starstarpat<".starstarpat.">")
4636 exe "silent vimgrep /".pattern."/gj "."**/*"
4637 catch /^Vim\%((\a\+)\)\=:E480/
4638 call netrw#ErrorMsg(s:WARNING,'no files matched pattern<'.pattern.'>',45)
4639 if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif
4640 silent! let @* = keepregstar
4641 silent! let @+ = keepregstar
4642 silent! let @/ = keepregslash
4643 " call Dret("netrw#Explore : no files matched pattern")
4646 let s:netrw_curdir = b:netrw_curdir
4647 let w:netrw_explore_list = getqflist()
4648 let w:netrw_explore_list = map(w:netrw_explore_list,'s:netrw_curdir."/".bufname(v:val.bufnr)')
4650 " call Decho("no starstarpat")
4651 exe "vimgrep /".pattern."/gj ".b:netrw_curdir."/*"
4652 let w:netrw_explore_list = map(getqflist(),'bufname(v:val.bufnr)')
4653 if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif
4656 " call Decho("no pattern: building list based on ".b:netrw_curdir."/".dirname)
4657 let w:netrw_explore_list= split(expand(b:netrw_curdir."/".dirname),'\n')
4658 if &hls | let keepregslash= s:ExplorePatHls(dirname) | endif
4661 let w:netrw_explore_listlen = len(w:netrw_explore_list)
4662 " call Decho("w:netrw_explore_list<".string(w:netrw_explore_list)."> listlen=".w:netrw_explore_listlen)
4664 if w:netrw_explore_listlen == 0 || (w:netrw_explore_listlen == 1 && w:netrw_explore_list[0] =~ '\*\*\/')
4665 call netrw#ErrorMsg(s:WARNING,"no files matched",42)
4666 silent! let @* = keepregstar
4667 silent! let @+ = keepregstar
4668 silent! let @/ = keepregslash
4669 " call Dret("netrw#Explore : no files matched")
4674 " NetrwStatusLine support - for exploring support
4675 let w:netrw_explore_indx= indx
4676 " call Decho("explorelist<".join(w:netrw_explore_list,',')."> len=".w:netrw_explore_listlen)
4678 " wrap the indx around, but issue a note
4679 if indx >= w:netrw_explore_listlen || indx < 0
4680 " call Decho("wrap indx (indx=".indx." listlen=".w:netrw_explore_listlen.")")
4681 let indx = (indx < 0)? ( w:netrw_explore_listlen - 1 ) : 0
4682 let w:netrw_explore_indx= indx
4683 call netrw#ErrorMsg(s:NOTE,"no more files match Explore pattern",43)
4687 exe "let dirfile= w:netrw_explore_list[".indx."]"
4688 " call Decho("dirfile=w:netrw_explore_list[indx=".indx."]= <".dirfile.">")
4689 let newdir= substitute(dirfile,'/[^/]*$','','e')
4690 " call Decho("newdir<".newdir.">")
4692 " call Decho("calling LocalBrowseCheck(newdir<".newdir.">)")
4693 call netrw#LocalBrowseCheck(newdir)
4694 if !exists("w:netrw_liststyle")
4695 let w:netrw_liststyle= g:netrw_liststyle
4697 if w:netrw_liststyle == s:THINLIST || w:netrw_liststyle == s:LONGLIST
4698 call search('^'.substitute(dirfile,"^.*/","","").'\>',"W")
4700 call search('\<'.substitute(dirfile,"^.*/","","").'\>',"w")
4702 let w:netrw_explore_mtchcnt = indx + 1
4703 let w:netrw_explore_bufnr = bufnr("%")
4704 let w:netrw_explore_line = line(".")
4705 call s:SetupNetrwStatusLine('%f %h%m%r%=%9*%{NetrwStatusLine()}')
4706 " call Decho("explore: mtchcnt=".w:netrw_explore_mtchcnt." bufnr=".w:netrw_explore_bufnr." line#".w:netrw_explore_line)
4709 " call Decho("vim does not have path_extra")
4710 if !exists("g:netrw_quiet")
4711 call netrw#ErrorMsg(s:WARNING,"your vim needs the +path_extra feature for Exploring with **!",44)
4713 silent! let @* = keepregstar
4714 silent! let @+ = keepregstar
4715 silent! let @/ = keepregslash
4716 " call Dret("netrw#Explore : missing +path_extra")
4721 " call Decho("case Explore newdir<".dirname.">")
4722 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && dirname =~ '/'
4723 silent! unlet w:netrw_treedict
4724 silent! unlet w:netrw_treetop
4727 if !exists("b:netrw_curdir")
4728 call netrw#LocalBrowseCheck(getcwd())
4730 call netrw#LocalBrowseCheck(s:NetBrowseChgDir(1,newdir))
4734 silent! let @* = keepregstar
4735 silent! let @+ = keepregstar
4736 silent! let @/ = keepregslash
4737 " call Dret("netrw#Explore : @/<".@/.">")
4740 " ---------------------------------------------------------------------
4741 " s:ExplorePatHls: converts an Explore pattern into a regular expression search pattern {{{2
4742 fun! s:ExplorePatHls(pattern)
4743 " call Dfunc("s:ExplorePatHls(pattern<".a:pattern.">)")
4744 let repat= substitute(a:pattern,'^**/\{1,2}','','')
4745 " call Decho("repat<".repat.">")
4746 let repat= escape(repat,'][.\')
4747 " call Decho("repat<".repat.">")
4748 let repat= '\<'.substitute(repat,'\*','\\(\\S\\+ \\)*\\S\\+','g').'\>'
4749 " call Dret("s:ExplorePatHls repat<".repat.">")
4753 " ---------------------------------------------------------------------
4754 " SetupNetrwStatusLine: {{{2
4755 fun! s:SetupNetrwStatusLine(statline)
4756 " call Dfunc("SetupNetrwStatusLine(statline<".a:statline.">)")
4758 if !exists("s:netrw_setup_statline")
4759 let s:netrw_setup_statline= 1
4760 " call Decho("do first-time status line setup")
4762 if !exists("s:netrw_users_stl")
4763 let s:netrw_users_stl= &stl
4765 if !exists("s:netrw_users_ls")
4766 let s:netrw_users_ls= &laststatus
4769 " set up User9 highlighting as needed
4774 catch /^Vim\%((\a\+)\)\=:E411/
4776 hi User9 ctermfg=yellow ctermbg=blue guifg=yellow guibg=blue
4778 hi User9 ctermbg=yellow ctermfg=blue guibg=yellow guifg=blue
4785 " set up status line (may use User9 highlighting)
4786 " insure that windows have a statusline
4787 " make sure statusline is displayed
4789 setlocal laststatus=2
4790 " call Decho("stl=".&stl)
4793 " call Dret("SetupNetrwStatusLine : stl=".&stl)
4796 " ---------------------------------------------------------------------
4797 " NetrwStatusLine: {{{2
4798 fun! NetrwStatusLine()
4800 " vvv NetrwStatusLine() debugging vvv
4802 " if !exists("w:netrw_explore_bufnr")
4803 " let g:stlmsg="!X<explore_bufnr>"
4804 " elseif w:netrw_explore_bufnr != bufnr("%")
4805 " let g:stlmsg="explore_bufnr!=".bufnr("%")
4807 " if !exists("w:netrw_explore_line")
4808 " let g:stlmsg=" !X<explore_line>"
4809 " elseif w:netrw_explore_line != line(".")
4810 " let g:stlmsg=" explore_line!={line(.)<".line(".").">"
4812 " if !exists("w:netrw_explore_list")
4813 " let g:stlmsg=" !X<explore_list>"
4815 " ^^^ NetrwStatusLine() debugging ^^^
4817 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")
4818 " restore user's status line
4819 let &stl = s:netrw_users_stl
4820 let &laststatus = s:netrw_users_ls
4821 if exists("w:netrw_explore_bufnr")|unlet w:netrw_explore_bufnr|endif
4822 if exists("w:netrw_explore_line")|unlet w:netrw_explore_line|endif
4825 return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen
4829 " ---------------------------------------------------------------------
4830 " NetGetcwd: get the current directory. {{{2
4831 " Change backslashes to forward slashes, if any.
4832 " If doesc is true, escape certain troublesome characters
4833 fun! s:NetGetcwd(doesc)
4834 " call Dfunc("NetGetcwd(doesc=".a:doesc.")")
4835 let curdir= substitute(getcwd(),'\\','/','ge')
4836 if curdir !~ '[\/]$'
4837 let curdir= curdir.'/'
4840 let curdir= escape(curdir,s:netrw_cd_escape)
4842 " call Dret("NetGetcwd <".curdir.">")
4846 " ---------------------------------------------------------------------
4847 " SetSort: sets up the sort based on the g:netrw_sort_sequence {{{2
4848 " What this function does is to compute a priority for the patterns
4849 " in the g:netrw_sort_sequence. It applies a substitute to any
4850 " "files" that satisfy each pattern, putting the priority / in
4851 " front. An "*" pattern handles the default priority.
4853 " call Dfunc("SetSort() bannercnt=".w:netrw_bannercnt)
4854 if w:netrw_liststyle == s:LONGLIST
4855 let seqlist = substitute(g:netrw_sort_sequence,'\$','\\%(\t\\|\$\\)','ge')
4857 let seqlist = g:netrw_sort_sequence
4859 " sanity check -- insure that * appears somewhere
4862 elseif seqlist !~ '\*'
4863 let seqlist= seqlist.',*'
4868 let seq = substitute(seqlist,',.*$','','e')
4869 let seqlist = substitute(seqlist,'^.\{-},\(.*\)$','\1','e')
4874 let eseq= escape(seq,'/')
4876 let spriority= "00".priority.'\/'
4877 elseif priority < 100
4878 let spriority= "0".priority.'\/'
4880 let spriority= priority.'\/'
4882 " call Decho("priority=".priority." spriority<".spriority."> seq<".seq."> seqlist<".seqlist.">")
4885 if w:netrw_bannercnt > line("$")
4886 " apparently no files were left after a Hiding pattern was used
4887 " call Dret("SetSort : no files left after hiding")
4891 exe 'silent keepjumps '.w:netrw_bannercnt.',$v/^\d\{3}\//s/^/'.spriority.'/'
4893 exe 'silent keepjumps '.w:netrw_bannercnt.',$g/'.eseq.'/s/^/'.spriority.'/'
4895 let priority = priority + 1
4898 " Following line associated with priority -- items that satisfy a priority
4899 " pattern get prefixed by ###/ which permits easy sorting by priority.
4900 " Sometimes files can satisfy multiple priority patterns -- only the latest
4901 " priority pattern needs to be retained. So, at this point, these excess
4902 " priority prefixes need to be removed, but not directories that happen to
4903 " be just digits themselves.
4904 exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\(\d\{3}\/\)\%(\d\{3}\/\)\+\ze./\1/e'
4906 " call Dret("SetSort")
4909 " =====================================================================
4910 " Support Functions: {{{1
4912 " ---------------------------------------------------------------------
4913 " ComposePath: Appends a new part to a path taking different systems into consideration {{{2
4914 fun! s:ComposePath(base,subdir)
4915 " call Dfunc("s:ComposePath(base<".a:base."> subdir<".a:subdir.">)")
4917 let ec = a:base[strlen(a:base)-1]
4918 if ec != '/' && ec != ':'
4919 let ret = a:base . "/" . a:subdir
4921 let ret = a:base . a:subdir
4923 elseif a:base =~ '^\a\+://'
4924 let urlbase = substitute(a:base,'^\(\a\+://.\{-}/\)\(.*\)$','\1','')
4925 let curpath = substitute(a:base,'^\(\a\+://.\{-}/\)\(.*\)$','\2','')
4926 let ret = urlbase.curpath.a:subdir
4927 " call Decho("urlbase<".urlbase.">")
4928 " call Decho("curpath<".curpath.">")
4929 " call Decho("ret<".ret.">")
4931 let ret = substitute(a:base."/".a:subdir,"//","/","g")
4933 " call Dret("s:ComposePath ".ret)
4937 " ---------------------------------------------------------------------
4938 " netrw#ErrorMsg: {{{2
4940 " 1=warning = s:WARNING
4942 " Mar 19, 2007 : max errnum currently is 49
4943 fun! netrw#ErrorMsg(level,msg,errnum)
4944 " call Dfunc("netrw#ErrorMsg(level=".a:level." msg<".a:msg."> errnum=".a:errnum.") g:netrw_use_errorwindow=".g:netrw_use_errorwindow)
4947 let level= "**warning** (netrw) "
4949 let level= "**error** (netrw) "
4951 let level= "**note** (netrw) "
4954 if g:netrw_use_errorwindow
4955 " (default) netrw creates a one-line window to show error/warning
4956 " messages (reliably displayed)
4958 " record current window number for NetRestorePosn()'s benefit
4959 let s:winBeforeErr= winnr()
4961 " getting messages out reliably is just plain difficult!
4962 " This attempt splits the current window, creating a one line window.
4963 if bufexists("NetrwMessage") && bufwinnr("NetrwMessage") > 0
4964 exe bufwinnr("NetrwMessage")."wincmd w"
4966 call setline(line("$")+1,level.a:msg)
4973 call setline(line("$"),level.a:msg)
4977 syn match netrwMesgNote "^\*\*note\*\*"
4978 syn match netrwMesgWarning "^\*\*warning\*\*"
4979 syn match netrwMesgError "^\*\*error\*\*"
4980 hi link netrwMesgWarning WarningMsg
4981 hi link netrwMesgError Error
4983 setlocal noma ro bh=wipe
4986 " (optional) netrw will show messages using echomsg. Even if the
4987 " message doesn't appear, at least it'll be recallable via :messages
4989 if a:level == s:WARNING
4991 elseif a:level == s:ERROR
4995 " call Decho("echomsg ***netrw*** ".a:msg)
4999 " call Dret("netrw#ErrorMsg")
5002 " ---------------------------------------------------------------------
5003 " netrw#RFC2396: converts %xx into characters {{{2
5004 fun! netrw#RFC2396(fname)
5005 " call Dfunc("netrw#RFC2396(fname<".a:fname.">)")
5006 let fname = escape(substitute(a:fname,'%\(\x\x\)','\=nr2char("0x".submatch(1))','ge')," \t")
5007 " call Dret("netrw#RFC2396 ".fname)
5011 " ---------------------------------------------------------------------
5012 " s:FileReadable: o/s independent filereadable {{{2
5013 fun! s:FileReadable(fname)
5014 " call Dfunc("s:FileReadable(fname<".a:fname.">)")
5017 let ret= filereadable(substitute(a:fname,'/cygdrive/\(.\)','\1:/',''))
5019 let ret= filereadable(a:fname)
5022 " call Dret("s:FileReadable ".ret)
5026 " ---------------------------------------------------------------------
5027 " s:GetTempfile: gets a tempname that'll work for various o/s's {{{2
5028 " Places correct suffix on end of temporary filename,
5029 " using the suffix provided with fname
5030 fun! s:GetTempfile(fname)
5031 " call Dfunc("s:GetTempfile(fname<".a:fname.">)")
5033 if !exists("b:netrw_tmpfile")
5034 " get a brand new temporary filename
5035 let tmpfile= tempname()
5036 " call Decho("tmpfile<".tmpfile."> : from tempname()")
5038 let tmpfile= escape(substitute(tmpfile,'\','/','ge'),g:netrw_tmpfile_escape)
5039 " call Decho("tmpfile<".tmpfile."> : chgd any \\ -> /")
5041 " sanity check -- does the temporary file's directory exist?
5042 if !isdirectory(substitute(tmpfile,'[^/]\+$','','e'))
5043 call netrw#ErrorMsg(s:ERROR,"your <".substitute(tmpfile,'[^/]\+$','','e')."> directory is missing!",2)
5044 " call Dret("s:GetTempfile getcwd<".getcwd().">")
5048 " let netrw#NetSource() know about the tmpfile
5049 let s:netrw_tmpfile= tmpfile " used by netrw#NetSource()
5050 " call Decho("tmpfile<".tmpfile."> s:netrw_tmpfile<".s:netrw_tmpfile.">")
5053 if g:netrw_cygwin == 1
5054 let tmpfile = substitute(tmpfile,'^\(\a\):','/cygdrive/\1','e')
5055 elseif has("win32") || has("win95") || has("win64") || has("win16")
5056 let tmpfile = substitute(tmpfile,'/','\\','g')
5058 let tmpfile = tmpfile
5060 let b:netrw_tmpfile= tmpfile
5061 " call Decho("o/s dependent fixed tempname<".tmpfile.">")
5063 " re-use temporary filename
5064 let tmpfile= b:netrw_tmpfile
5065 " call Decho("tmpfile<".tmpfile."> re-using")
5068 " use fname's suffix for the temporary file
5070 if a:fname =~ '\.[^./]\+$'
5071 " call Decho("using fname<".a:fname.">'s suffix")
5072 if a:fname =~ '.tar.gz' || a:fname =~ '.tar.bz2'
5073 let suffix = ".tar".substitute(a:fname,'^.*\(\.[^./]\+\)$','\1','e')
5075 let suffix = substitute(a:fname,'^.*\(\.[^./]\+\)$','\1','e')
5077 let suffix = escape(suffix,g:netrw_tmpfile_escape)
5078 " call Decho("suffix<".suffix.">")
5079 let tmpfile= substitute(tmpfile,'\.tmp$','','e')
5080 " call Decho("chgd tmpfile<".tmpfile."> (removed any .tmp suffix)")
5081 let tmpfile .= suffix
5082 " call Decho("chgd tmpfile<".tmpfile."> (added ".suffix." suffix) netrw_fname<".b:netrw_fname.">")
5083 let s:netrw_tmpfile= tmpfile " supports netrw#NetSource()
5087 " call Dret("s:GetTempfile <".tmpfile.">")
5091 " ---------------------------------------------------------------------
5092 " s:MakeSshCmd: transforms input command using USEPORT HOSTNAME into {{{2
5094 fun! s:MakeSshCmd(sshcmd)
5095 " call Dfunc("s:MakeSshCmd(sshcmd<".a:sshcmd.">)")
5096 let sshcmd = substitute(a:sshcmd,'\<HOSTNAME\>',s:user.s:machine,'')
5097 if exists("g:netrw_port") && g:netrw_port != ""
5098 let sshcmd= substitute(sshcmd,"USEPORT",g:netrw_sshport.' '.g:netrw_port,'')
5099 elseif exists("s:port") && s:port != ""
5100 let sshcmd= substitute(sshcmd,"USEPORT",g:netrw_sshport.' '.s:port,'')
5102 let sshcmd= substitute(sshcmd,"USEPORT ",'','')
5104 " call Dret("s:MakeSshCmd <".sshcmd.">")
5108 " ---------------------------------------------------------------------
5109 " s:NetrwEnew: opens a new buffer, passes netrw buffer variables through {{{2
5110 fun! s:NetrwEnew(curdir)
5111 " call Dfunc("s:NetrwEnew(curdir<".a:curdir.">) buf#".bufnr("%")."<".bufname("%").">")
5113 " grab a function-local copy of buffer variables
5114 if exists("b:netrw_bannercnt") |let netrw_bannercnt = b:netrw_bannercnt |endif
5115 if exists("b:netrw_browser_active") |let netrw_browser_active = b:netrw_browser_active |endif
5116 if exists("b:netrw_cpf") |let netrw_cpf = b:netrw_cpf |endif
5117 if exists("b:netrw_curdir") |let netrw_curdir = b:netrw_curdir |endif
5118 if exists("b:netrw_explore_bufnr") |let netrw_explore_bufnr = b:netrw_explore_bufnr |endif
5119 if exists("b:netrw_explore_indx") |let netrw_explore_indx = b:netrw_explore_indx |endif
5120 if exists("b:netrw_explore_line") |let netrw_explore_line = b:netrw_explore_line |endif
5121 if exists("b:netrw_explore_list") |let netrw_explore_list = b:netrw_explore_list |endif
5122 if exists("b:netrw_explore_listlen")|let netrw_explore_listlen = b:netrw_explore_listlen|endif
5123 if exists("b:netrw_explore_mtchcnt")|let netrw_explore_mtchcnt = b:netrw_explore_mtchcnt|endif
5124 if exists("b:netrw_fname") |let netrw_fname = b:netrw_fname |endif
5125 if exists("b:netrw_lastfile") |let netrw_lastfile = b:netrw_lastfile |endif
5126 if exists("b:netrw_liststyle") |let netrw_liststyle = b:netrw_liststyle |endif
5127 if exists("b:netrw_method") |let netrw_method = b:netrw_method |endif
5128 if exists("b:netrw_option") |let netrw_option = b:netrw_option |endif
5129 if exists("b:netrw_prvdir") |let netrw_prvdir = b:netrw_prvdir |endif
5131 if getline(2) =~ '^" Netrw Directory Listing'
5132 " call Decho("generate a buffer with keepjumps keepalt enew! (1)")
5133 keepjumps keepalt enew!
5135 " call Decho("generate a buffer with keepjumps enew! (2)")
5139 " copy function-local variables to buffer variable equivalents
5140 if exists("netrw_bannercnt") |let b:netrw_bannercnt = netrw_bannercnt |endif
5141 if exists("netrw_browser_active") |let b:netrw_browser_active = netrw_browser_active |endif
5142 if exists("netrw_cpf") |let b:netrw_cpf = netrw_cpf |endif
5143 if exists("netrw_curdir") |let b:netrw_curdir = netrw_curdir |endif
5144 if exists("netrw_explore_bufnr") |let b:netrw_explore_bufnr = netrw_explore_bufnr |endif
5145 if exists("netrw_explore_indx") |let b:netrw_explore_indx = netrw_explore_indx |endif
5146 if exists("netrw_explore_line") |let b:netrw_explore_line = netrw_explore_line |endif
5147 if exists("netrw_explore_list") |let b:netrw_explore_list = netrw_explore_list |endif
5148 if exists("netrw_explore_listlen")|let b:netrw_explore_listlen = netrw_explore_listlen|endif
5149 if exists("netrw_explore_mtchcnt")|let b:netrw_explore_mtchcnt = netrw_explore_mtchcnt|endif
5150 if exists("netrw_fname") |let b:netrw_fname = netrw_fname |endif
5151 if exists("netrw_lastfile") |let b:netrw_lastfile = netrw_lastfile |endif
5152 if exists("netrw_liststyle") |let b:netrw_liststyle = netrw_liststyle |endif
5153 if exists("netrw_method") |let b:netrw_method = netrw_method |endif
5154 if exists("netrw_option") |let b:netrw_option = netrw_option |endif
5155 if exists("netrw_prvdir") |let b:netrw_prvdir = netrw_prvdir |endif
5157 let b:netrw_curdir= a:curdir
5158 if b:netrw_curdir =~ '/$'
5159 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST
5160 file NetrwTreeListing
5162 exe "silent! file ".b:netrw_curdir
5166 " call Dret("s:NetrwEnew : buf#".bufnr("%")."<".bufname("%").">")
5169 " ------------------------------------------------------------------------
5170 " s:RemotePathAnalysis: {{{2
5171 fun! s:RemotePathAnalysis(dirname)
5172 " call Dfunc("s:RemotePathAnalysis()")
5174 let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/:#]\+\)\%([:#]\(\d\+\)\)\=/\(.*\)$'
5175 let s:method = substitute(a:dirname,dirpat,'\1','')
5176 let s:user = substitute(a:dirname,dirpat,'\2','')
5177 let s:machine = substitute(a:dirname,dirpat,'\3','')
5178 let s:port = substitute(a:dirname,dirpat,'\4','')
5179 let s:path = substitute(a:dirname,dirpat,'\5','')
5180 let s:fname = substitute(a:dirname,'^.*/\ze.','','')
5182 " call Decho("set up s:method <".s:method .">")
5183 " call Decho("set up s:user <".s:user .">")
5184 " call Decho("set up s:machine<".s:machine.">")
5185 " call Decho("set up s:port <".s:port.">")
5186 " call Decho("set up s:path <".s:path .">")
5187 " call Decho("set up s:fname <".s:fname .">")
5189 " call Dret("s:RemotePathAnalysis")
5192 " ---------------------------------------------------------------------
5193 " s:RestoreBufVars: {{{2
5194 fun! s:RestoreBufVars()
5195 " call Dfunc("s:RestoreBufVars()")
5197 if exists("s:netrw_curdir") |let b:netrw_curdir = s:netrw_curdir |endif
5198 if exists("s:netrw_lastfile") |let b:netrw_lastfile = s:netrw_lastfile |endif
5199 if exists("s:netrw_method") |let b:netrw_method = s:netrw_method |endif
5200 if exists("s:netrw_fname") |let b:netrw_fname = s:netrw_fname |endif
5201 if exists("s:netrw_machine") |let b:netrw_machine = s:netrw_machine |endif
5202 if exists("s:netrw_browser_active")|let b:netrw_browser_active = s:netrw_browser_active|endif
5204 " call Dret("s:RestoreBufVars")
5207 " ---------------------------------------------------------------------
5208 " s:RestoreWinVars: (used by Explore() and NetSplit()) {{{2
5209 fun! s:RestoreWinVars()
5210 " call Dfunc("s:RestoreWinVars()")
5211 if exists("s:bannercnt") |let w:netrw_bannercnt = s:bannercnt |unlet s:bannercnt |endif
5212 if exists("s:col") |let w:netrw_col = s:col |unlet s:col |endif
5213 if exists("s:curdir") |let w:netrw_curdir = s:curdir |unlet s:curdir |endif
5214 if exists("s:explore_bufnr") |let w:netrw_explore_bufnr = s:explore_bufnr |unlet s:explore_bufnr |endif
5215 if exists("s:explore_indx") |let w:netrw_explore_indx = s:explore_indx |unlet s:explore_indx |endif
5216 if exists("s:explore_line") |let w:netrw_explore_line = s:explore_line |unlet s:explore_line |endif
5217 if exists("s:explore_listlen")|let w:netrw_explore_listlen = s:explore_listlen|unlet s:explore_listlen|endif
5218 if exists("s:explore_list") |let w:netrw_explore_list = s:explore_list |unlet s:explore_list |endif
5219 if exists("s:explore_mtchcnt")|let w:netrw_explore_mtchcnt = s:explore_mtchcnt|unlet s:explore_mtchcnt|endif
5220 if exists("s:fpl") |let w:netrw_fpl = s:fpl |unlet s:fpl |endif
5221 if exists("s:hline") |let w:netrw_hline = s:hline |unlet s:hline |endif
5222 if exists("s:line") |let w:netrw_line = s:line |unlet s:line |endif
5223 if exists("s:liststyle") |let w:netrw_liststyle = s:liststyle |unlet s:liststyle |endif
5224 if exists("s:method") |let w:netrw_method = s:method |unlet s:method |endif
5225 if exists("s:prvdir") |let w:netrw_prvdir = s:prvdir |unlet s:prvdir |endif
5226 if exists("s:treedict") |let w:netrw_treedict = s:treedict |unlet s:treedict |endif
5227 if exists("s:treetop") |let w:netrw_treetop = s:treetop |unlet s:treetop |endif
5228 if exists("s:winnr") |let w:netrw_winnr = s:winnr |unlet s:winnr |endif
5229 " call Dret("s:RestoreWinVars")
5232 " ---------------------------------------------------------------------
5233 " s:SaveBufVars: {{{2
5234 fun! s:SaveBufVars()
5235 " call Dfunc("s:SaveBufVars()")
5237 if exists("b:netrw_curdir") |let s:netrw_curdir = b:netrw_curdir |endif
5238 if exists("b:netrw_lastfile") |let s:netrw_lastfile = b:netrw_lastfile |endif
5239 if exists("b:netrw_method") |let s:netrw_method = b:netrw_method |endif
5240 if exists("b:netrw_fname") |let s:netrw_fname = b:netrw_fname |endif
5241 if exists("b:netrw_machine") |let s:netrw_machine = b:netrw_machine |endif
5242 if exists("b:netrw_browser_active")|let s:netrw_browser_active = b:netrw_browser_active|endif
5244 " call Dret("s:SaveBufVars")
5247 " ---------------------------------------------------------------------
5248 " s:SaveWinVars: (used by Explore() and NetSplit()) {{{2
5249 fun! s:SaveWinVars()
5250 " call Dfunc("s:SaveWinVars()")
5251 if exists("w:netrw_bannercnt") |let s:bannercnt = w:netrw_bannercnt |endif
5252 if exists("w:netrw_col") |let s:col = w:netrw_col |endif
5253 if exists("w:netrw_curdir") |let s:curdir = w:netrw_curdir |endif
5254 if exists("w:netrw_explore_bufnr") |let s:explore_bufnr = w:netrw_explore_bufnr |endif
5255 if exists("w:netrw_explore_indx") |let s:explore_indx = w:netrw_explore_indx |endif
5256 if exists("w:netrw_explore_line") |let s:explore_line = w:netrw_explore_line |endif
5257 if exists("w:netrw_explore_listlen")|let s:explore_listlen = w:netrw_explore_listlen|endif
5258 if exists("w:netrw_explore_list") |let s:explore_list = w:netrw_explore_list |endif
5259 if exists("w:netrw_explore_mtchcnt")|let s:explore_mtchcnt = w:netrw_explore_mtchcnt|endif
5260 if exists("w:netrw_fpl") |let s:fpl = w:netrw_fpl |endif
5261 if exists("w:netrw_hline") |let s:hline = w:netrw_hline |endif
5262 if exists("w:netrw_line") |let s:line = w:netrw_line |endif
5263 if exists("w:netrw_liststyle") |let s:liststyle = w:netrw_liststyle |endif
5264 if exists("w:netrw_method") |let s:method = w:netrw_method |endif
5265 if exists("w:netrw_prvdir") |let s:prvdir = w:netrw_prvdir |endif
5266 if exists("w:netrw_treedict") |let s:treedict = w:netrw_treedict |endif
5267 if exists("w:netrw_treetop") |let s:treetop = w:netrw_treetop |endif
5268 if exists("w:netrw_winnr") |let s:winnr = w:netrw_winnr |endif
5269 " call Dret("s:SaveWinVars")
5272 " ---------------------------------------------------------------------
5273 " s:SetBufWinVars: (used by NetBrowse() and LocalBrowseCheck()) {{{2
5274 " To allow separate windows to have their own activities, such as
5275 " Explore **/pattern, several variables have been made window-oriented.
5276 " However, when the user splits a browser window (ex: ctrl-w s), these
5277 " variables are not inherited by the new window. SetBufWinVars() and
5278 " UseBufWinVars() get around that.
5279 fun! s:SetBufWinVars()
5280 " call Dfunc("s:SetBufWinVars()")
5281 if exists("w:netrw_liststyle") |let b:netrw_liststyle = w:netrw_liststyle |endif
5282 if exists("w:netrw_bannercnt") |let b:netrw_bannercnt = w:netrw_bannercnt |endif
5283 if exists("w:netrw_method") |let b:netrw_method = w:netrw_method |endif
5284 if exists("w:netrw_prvdir") |let b:netrw_prvdir = w:netrw_prvdir |endif
5285 if exists("w:netrw_explore_indx") |let b:netrw_explore_indx = w:netrw_explore_indx |endif
5286 if exists("w:netrw_explore_listlen")|let b:netrw_explore_listlen= w:netrw_explore_listlen|endif
5287 if exists("w:netrw_explore_mtchcnt")|let b:netrw_explore_mtchcnt= w:netrw_explore_mtchcnt|endif
5288 if exists("w:netrw_explore_bufnr") |let b:netrw_explore_bufnr = w:netrw_explore_bufnr |endif
5289 if exists("w:netrw_explore_line") |let b:netrw_explore_line = w:netrw_explore_line |endif
5290 if exists("w:netrw_explore_list") |let b:netrw_explore_list = w:netrw_explore_list |endif
5291 " call Dret("s:SetBufWinVars")
5294 " ---------------------------------------------------------------------
5295 " s:System: using Steve Hall's idea to insure that Windows paths stay {{{2
5296 " acceptable. No effect on Unix paths.
5297 " Examples of use: let result= s:System("system",path)
5298 " let result= s:System("delete",path)
5299 fun! s:System(cmd,path)
5300 " call Dfunc("s:System(cmd<".a:cmd."> path<".a:path.">)")
5303 if (has("win32") || has("win95") || has("win64") || has("win16"))
5305 " remove trailing slash (Win95)
5306 let path = substitute(path, '\(\\\|/\)$', '', 'g')
5307 " remove escaped spaces
5308 let path = substitute(path, '\ ', ' ', 'g')
5309 " convert slashes to backslashes
5310 let path = substitute(path, '/', '\', 'g')
5311 if exists("+shellslash")
5312 let sskeep= &shellslash
5313 setlocal noshellslash
5314 exe "let result= ".a:cmd."('".path."')"
5315 let &shellslash = sskeep
5317 exe "let result= ".a:cmd."(".g:netrw_shq.path.g:netrw_shq.")"
5320 exe "let result= ".a:cmd."('".path."')"
5323 " call Decho("result<".result.">")
5324 " call Dret("s:System")
5328 " ---------------------------------------------------------------------
5329 " s:UseBufWinVars: (used by NetBrowse() and LocalBrowseCheck() {{{2
5330 " Matching function to BufferWinVars()
5331 fun! s:UseBufWinVars()
5332 " call Dfunc("s:UseBufWinVars()")
5333 if exists("b:netrw_liststyle") && !exists("w:netrw_liststyle") |let w:netrw_liststyle = b:netrw_liststyle |endif
5334 if exists("b:netrw_bannercnt") && !exists("w:netrw_bannercnt") |let w:netrw_bannercnt = b:netrw_bannercnt |endif
5335 if exists("b:netrw_method") && !exists("w:netrw_method") |let w:netrw_method = b:netrw_method |endif
5336 if exists("b:netrw_prvdir") && !exists("w:netrw_prvdir") |let w:netrw_prvdir = b:netrw_prvdir |endif
5337 if exists("b:netrw_explore_indx") && !exists("w:netrw_explore_indx") |let w:netrw_explore_indx = b:netrw_explore_indx |endif
5338 if exists("b:netrw_explore_listlen") && !exists("w:netrw_explore_listlen")|let w:netrw_explore_listlen = b:netrw_explore_listlen|endif
5339 if exists("b:netrw_explore_mtchcnt") && !exists("w:netrw_explore_mtchcnt")|let w:netrw_explore_mtchcnt = b:netrw_explore_mtchcnt|endif
5340 if exists("b:netrw_explore_bufnr") && !exists("w:netrw_explore_bufnr") |let w:netrw_explore_bufnr = b:netrw_explore_bufnr |endif
5341 if exists("b:netrw_explore_line") && !exists("w:netrw_explore_line") |let w:netrw_explore_line = b:netrw_explore_line |endif
5342 if exists("b:netrw_explore_list") && !exists("w:netrw_explore_list") |let w:netrw_explore_list = b:netrw_explore_list |endif
5343 " call Dret("s:UseBufWinVars")
5346 " ---------------------------------------------------------------------
5347 " Settings Restoration: {{{2
5351 " ------------------------------------------------------------------------
5353 " vim:ts=8 fdm=marker