482
|
1 " netrw.vim: Handles file transfer and remote directory listing across a network
|
|
2 " AUTOLOAD PORTION
|
842
|
3 " Date: Apr 24, 2006
|
|
4 " Version: 93
|
482
|
5 " Maintainer: Charles E Campbell, Jr <drchipNOSPAM at campbellfamily dot biz>
|
|
6 " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
|
|
7 " Copyright: Copyright (C) 1999-2005 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,
|
559
|
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.
|
482
|
16 " of this software.
|
|
17 "
|
|
18 " But be doers of the Word, and not only hearers, deluding your own selves {{{1
|
|
19 " (James 1:22 RSV)
|
|
20 " =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
559
|
21
|
|
22 " Exception for &cp: {{{1
|
|
23 if &cp || exists("g:loaded_netrw")
|
|
24 finish
|
|
25 endif
|
842
|
26 let g:loaded_netrw = "v93"
|
519
|
27 if v:version < 700
|
|
28 echohl WarningMsg | echo "***netrw*** you need vim version 7.0 or later for version ".g:loaded_netrw." of netrw" | echohl None
|
|
29 finish
|
|
30 endif
|
559
|
31 let s:keepcpo= &cpo
|
|
32 set cpo&vim
|
|
33 " call Decho("doing autoload/netrw.vim")
|
482
|
34
|
650
|
35 " ======================
|
|
36 " Netrw Variables: {{{1
|
|
37 " ======================
|
|
38
|
482
|
39 " ---------------------------------------------------------------------
|
650
|
40 " Default values for netrw's global protocol variables {{{2
|
559
|
41 if !exists("g:netrw_dav_cmd")
|
|
42 let g:netrw_dav_cmd = "cadaver"
|
|
43 endif
|
|
44 if !exists("g:netrw_fetch_cmd")
|
|
45 if executable("fetch")
|
|
46 let g:netrw_fetch_cmd = "fetch -o"
|
|
47 else
|
|
48 let g:netrw_fetch_cmd = ""
|
|
49 endif
|
|
50 endif
|
|
51 if !exists("g:netrw_ftp_cmd")
|
|
52 let g:netrw_ftp_cmd = "ftp"
|
|
53 endif
|
|
54 if !exists("g:netrw_http_cmd")
|
|
55 if executable("wget")
|
|
56 let g:netrw_http_cmd = "wget -q -O"
|
|
57 elseif executable("fetch")
|
|
58 let g:netrw_http_cmd = "fetch -o"
|
|
59 else
|
|
60 let g:netrw_http_cmd = ""
|
|
61 endif
|
|
62 endif
|
|
63 if !exists("g:netrw_rcp_cmd")
|
|
64 let g:netrw_rcp_cmd = "rcp"
|
|
65 endif
|
|
66 if !exists("g:netrw_rsync_cmd")
|
|
67 let g:netrw_rsync_cmd = "rsync"
|
482
|
68 endif
|
559
|
69 if !exists("g:netrw_scp_cmd")
|
|
70 let g:netrw_scp_cmd = "scp -q"
|
|
71 endif
|
|
72 if !exists("g:netrw_sftp_cmd")
|
|
73 let g:netrw_sftp_cmd = "sftp"
|
|
74 endif
|
|
75 if !exists("g:netrw_ssh_cmd")
|
|
76 let g:netrw_ssh_cmd= "ssh"
|
|
77 endif
|
|
78
|
719
|
79 if (has("win32") || has("win95") || has("win64") || has("win16"))
|
559
|
80 \ && exists("g:netrw_use_nt_rcp")
|
|
81 \ && g:netrw_use_nt_rcp
|
|
82 \ && executable( $SystemRoot .'/system32/rcp.exe')
|
|
83 let s:netrw_has_nt_rcp = 1
|
|
84 let s:netrw_rcpmode = '-b'
|
|
85 else
|
|
86 let s:netrw_has_nt_rcp = 0
|
|
87 let s:netrw_rcpmode = ''
|
|
88 endif
|
|
89
|
|
90 " ---------------------------------------------------------------------
|
650
|
91 " Default values for netrw's global variables {{{2
|
|
92 " Default values - a-c ---------- {{{3
|
559
|
93 if !exists("g:netrw_alto")
|
|
94 let g:netrw_alto= 0
|
|
95 endif
|
|
96 if !exists("g:netrw_altv")
|
|
97 let g:netrw_altv= 0
|
482
|
98 endif
|
650
|
99 if !exists("g:netrw_browse_split")
|
|
100 let g:netrw_browse_split= 0
|
|
101 endif
|
482
|
102 if !exists("g:netrw_cygwin")
|
|
103 if has("win32") || has("win95") || has("win64") || has("win16")
|
|
104 if &shell == "bash"
|
|
105 let g:netrw_cygwin= 1
|
|
106 else
|
|
107 let g:netrw_cygwin= 0
|
|
108 endif
|
|
109 else
|
|
110 let g:netrw_cygwin= 0
|
|
111 endif
|
|
112 endif
|
650
|
113 " Default values - d-f ---------- {{{3
|
559
|
114 if !exists("g:NETRW_DIRHIST_CNT")
|
|
115 let g:NETRW_DIRHIST_CNT= 0
|
|
116 endif
|
|
117 if !exists("g:netrw_dirhistmax")
|
|
118 let g:netrw_dirhistmax= 10
|
|
119 endif
|
|
120 if !exists("g:netrw_ftp_browse_reject")
|
|
121 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$'
|
482
|
122 endif
|
|
123 if !exists("g:netrw_ftp_list_cmd")
|
|
124 if has("unix") || exists("g:netrw_cygwin")
|
|
125 let g:netrw_ftp_list_cmd= "ls -lF"
|
|
126 else
|
|
127 let g:netrw_ftp_list_cmd= "dir"
|
|
128 endif
|
|
129 endif
|
559
|
130 if !exists("g:netrw_ftpmode")
|
|
131 let g:netrw_ftpmode= "binary"
|
|
132 endif
|
650
|
133 " Default values - h-lh ---------- {{{3
|
559
|
134 if !exists("g:netrw_hide")
|
|
135 let g:netrw_hide= 1
|
|
136 endif
|
|
137 if !exists("g:netrw_keepdir")
|
|
138 let g:netrw_keepdir= 1
|
|
139 endif
|
|
140 if !exists("g:netrw_list_cmd")
|
|
141 if executable(g:netrw_ssh_cmd)
|
|
142 " provide a default listing command
|
|
143 let g:netrw_list_cmd= g:netrw_ssh_cmd." HOSTNAME ls -FLa"
|
|
144 else
|
|
145 " call Decho(g:netrw_ssh_cmd." is not executable, can't do remote directory exploring)
|
|
146 let g:netrw_list_cmd= ""
|
|
147 endif
|
|
148 endif
|
|
149 if !exists("g:netrw_list_hide")
|
|
150 let g:netrw_list_hide= ""
|
|
151 endif
|
650
|
152 " Default values - lh-lz ---------- {{{3
|
559
|
153 if !exists("g:netrw_local_mkdir")
|
|
154 let g:netrw_local_mkdir= "mkdir"
|
|
155 endif
|
|
156 if !exists("g:netrw_local_rmdir")
|
|
157 let g:netrw_local_rmdir= "rmdir"
|
|
158 endif
|
|
159 if !exists("g:netrw_longlist")
|
|
160 let g:netrw_longlist= 0
|
|
161 endif
|
|
162 if g:netrw_longlist < 0 || g:netrw_longlist > 2
|
|
163 " sanity check
|
|
164 let g:netrw_longlist= 0
|
|
165 endif
|
|
166 if g:netrw_longlist == 1
|
|
167 let g:netrw_list_cmd= g:netrw_list_cmd." -l"
|
|
168 endif
|
650
|
169 " Default values - m-r ---------- {{{3
|
559
|
170 if !exists("g:netrw_maxfilenamelen")
|
|
171 let g:netrw_maxfilenamelen= 32
|
|
172 endif
|
|
173 if !exists("g:netrw_mkdir_cmd")
|
|
174 let g:netrw_mkdir_cmd= g:netrw_ssh_cmd." HOSTNAME mkdir"
|
|
175 endif
|
|
176 if !exists("g:netrw_rename_cmd")
|
|
177 let g:netrw_rename_cmd= g:netrw_ssh_cmd." HOSTNAME mv"
|
|
178 endif
|
557
|
179 if !exists("g:netrw_rm_cmd")
|
559
|
180 let g:netrw_rm_cmd = g:netrw_ssh_cmd." HOSTNAME rm"
|
|
181 endif
|
|
182 if !exists("g:netrw_rmdir_cmd")
|
|
183 let g:netrw_rmdir_cmd = g:netrw_ssh_cmd." HOSTNAME rmdir"
|
554
|
184 endif
|
557
|
185 if !exists("g:netrw_rmf_cmd")
|
559
|
186 let g:netrw_rmf_cmd = g:netrw_ssh_cmd." HOSTNAME rm -f"
|
554
|
187 endif
|
650
|
188 " Default values - s ---------- {{{3
|
482
|
189 if exists("g:netrw_silent") && g:netrw_silent != 0
|
|
190 let g:netrw_silentxfer= "silent "
|
|
191 else
|
|
192 let g:netrw_silentxfer= ""
|
|
193 endif
|
719
|
194 if !exists("g:netrw_fastbrowse")
|
|
195 let g:netrw_fastbrowse= 1
|
|
196 endif
|
482
|
197 if !exists("g:netrw_sort_by")
|
|
198 " alternatives: date size
|
|
199 let g:netrw_sort_by= "name"
|
|
200 endif
|
|
201 if !exists("g:netrw_sort_direction")
|
|
202 " alternative: reverse (z y x ...)
|
|
203 let g:netrw_sort_direction= "normal"
|
|
204 endif
|
559
|
205 if !exists("g:netrw_sort_sequence")
|
|
206 let g:netrw_sort_sequence= '[\/]$,*,\.bak$,\.o$,\.h$,\.info$,\.swp$,\.obj$'
|
482
|
207 endif
|
|
208 if !exists("g:netrw_ssh_browse_reject")
|
|
209 let g:netrw_ssh_browse_reject='^total\s\+\d\+$'
|
|
210 endif
|
650
|
211 " Default values - t-w ---------- {{{3
|
559
|
212 if !exists("g:netrw_timefmt")
|
|
213 let g:netrw_timefmt= "%c"
|
482
|
214 endif
|
559
|
215 if !exists("g:netrw_win95ftp")
|
|
216 let g:netrw_win95ftp= 1
|
|
217 endif
|
|
218 if !exists("g:netrw_winsize")
|
|
219 let g:netrw_winsize= ""
|
|
220 endif
|
|
221 " ---------------------------------------------------------------------
|
650
|
222 " Default values for netrw's script variables: {{{2
|
482
|
223 if !exists("s:netrw_cd_escape")
|
|
224 if has("win32") || has("win95") || has("win64") || has("win16")
|
|
225 let s:netrw_cd_escape="#% "
|
|
226 else
|
|
227 let s:netrw_cd_escape="[]#*$%'\" ?`!&();<>\\"
|
|
228 endif
|
|
229 endif
|
719
|
230 if !exists("g:netrw_fname_escape")
|
|
231 let g:netrw_fname_escape= ' ?&;'
|
|
232 endif
|
|
233 if !exists("g:netrw_tmpfile_escape")
|
|
234 let g:netrw_tmpfile_escape= ' ?&;'
|
|
235 endif
|
482
|
236 if !exists("s:netrw_glob_escape")
|
|
237 if has("win32") || has("win95") || has("win64") || has("win16")
|
|
238 let s:netrw_glob_escape= ""
|
|
239 else
|
|
240 let s:netrw_glob_escape= '[]*?`{~$'
|
|
241 endif
|
|
242 endif
|
|
243
|
|
244 " BufEnter event ignored by decho when following variable is true
|
|
245 " Has a side effect that doau BufReadPost doesn't work, so
|
|
246 " files read by network transfer aren't appropriately highlighted.
|
|
247 "let g:decho_bufenter = 1 "Decho
|
|
248
|
650
|
249 " ==============================
|
|
250 " Netrw Utility Functions: {{{1
|
|
251 " ==============================
|
|
252
|
482
|
253 " ------------------------------------------------------------------------
|
650
|
254 " NetSavePosn: saves position of cursor on screen {{{2
|
482
|
255 fun! netrw#NetSavePosn()
|
|
256 " call Dfunc("NetSavePosn()")
|
|
257 " Save current line and column
|
|
258 let w:netrw_winnr= winnr()
|
|
259 let w:netrw_line = line(".")
|
|
260 let w:netrw_col = virtcol(".")
|
|
261
|
|
262 " Save top-of-screen line
|
|
263 norm! H0
|
|
264 let w:netrw_hline= line(".")
|
|
265
|
|
266 call netrw#NetRestorePosn()
|
|
267 " call Dret("NetSavePosn : winnr=".w:netrw_winnr." line=".w:netrw_line." col=".w:netrw_col." hline=".w:netrw_hline)
|
|
268 endfun
|
|
269
|
|
270 " ------------------------------------------------------------------------
|
650
|
271 " NetRestorePosn: restores the cursor and file position as saved by NetSavePosn() {{{2
|
482
|
272 fun! netrw#NetRestorePosn()
|
|
273 " call Dfunc("NetRestorePosn() winnr=".w:netrw_winnr." line=".w:netrw_line." col=".w:netrw_col." hline=".w:netrw_hline)
|
|
274 let eikeep= &ei
|
|
275 set ei=all
|
|
276
|
|
277 " restore window
|
|
278 " call Decho("restore window: exe silent! ".w:netrw_winnr."wincmd w")
|
|
279 exe "silent! ".w:netrw_winnr."wincmd w"
|
|
280 " if v:shell_error == 0
|
|
281 " " as suggested by Bram M: redraw on no error
|
|
282 " " allows protocol error messages to remain visible
|
|
283 " redraw!
|
|
284 " endif
|
|
285
|
|
286 " restore top-of-screen line
|
|
287 " call Decho("restore topofscreen: exe norm! ".w:netrw_hline."G0z")
|
|
288 exe "norm! ".w:netrw_hline."G0z\<CR>"
|
|
289
|
|
290 " restore position
|
|
291 " call Decho("restore posn: exe norm! ".w:netrw_line."G0".w:netrw_col."|")
|
|
292 exe "norm! ".w:netrw_line."G0".w:netrw_col."\<bar>"
|
|
293
|
|
294 let &ei= eikeep
|
|
295 " call Dret("NetRestorePosn")
|
|
296 endfun
|
|
297
|
650
|
298 " ===============================
|
|
299 " Netrw Transfer Functions: {{{1
|
|
300 " ===============================
|
|
301
|
482
|
302 " ------------------------------------------------------------------------
|
650
|
303 " NetRead: responsible for reading a file over the net {{{2
|
719
|
304 fun! netrw#NetRead(mode,...)
|
|
305 " call Dfunc("NetRead(mode=".a:mode.",...) a:0=".a:0)
|
|
306
|
482
|
307 " save options
|
|
308 call s:NetOptionSave()
|
719
|
309
|
|
310 if a:mode == 0 " read remote file before current line
|
482
|
311 let readcmd = "0r"
|
719
|
312 elseif a:mode == 1 " read file after current line
|
482
|
313 let readcmd = "r"
|
719
|
314 elseif a:mode == 2 " replace with remote file
|
|
315 let readcmd = "%r"
|
|
316 else
|
|
317 exe a:mode
|
|
318 let readcmd = "r"
|
482
|
319 endif
|
719
|
320 let ichoice = (a:0 == 0)? 0 : 1
|
|
321 " call Decho("readcmd<".readcmd."> ichoice=".ichoice)
|
|
322
|
650
|
323 " get name of a temporary file and set up shell-quoting character {{{3
|
482
|
324 let tmpfile= tempname()
|
719
|
325 let tmpfile= escape(substitute(tmpfile,'\','/','ge'),g:netrw_tmpfile_escape)
|
482
|
326 if !isdirectory(substitute(tmpfile,'[^/]\+$','','e'))
|
568
|
327 echohl Error | echo "***netrw*** your <".substitute(tmpfile,'[^/]\+$','','e')."> directory is missing!" | echohl None
|
482
|
328 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
329 " call Dret("NetRead")
|
|
330 return
|
|
331 endif
|
719
|
332 " call Decho("tmpfile<".tmpfile.">")
|
|
333
|
482
|
334 while ichoice <= a:0
|
719
|
335
|
482
|
336 " attempt to repeat with previous host-file-etc
|
|
337 if exists("b:netrw_lastfile") && a:0 == 0
|
|
338 " call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">")
|
|
339 let choice = b:netrw_lastfile
|
|
340 let ichoice= ichoice + 1
|
719
|
341
|
482
|
342 else
|
|
343 exe "let choice= a:" . ichoice
|
|
344 " call Decho("no lastfile: choice<" . choice . ">")
|
719
|
345
|
482
|
346 if match(choice,"?") == 0
|
|
347 " give help
|
|
348 echomsg 'NetRead Usage:'
|
|
349 echomsg ':Nread machine:path uses rcp'
|
|
350 echomsg ':Nread "machine path" uses ftp with <.netrc>'
|
|
351 echomsg ':Nread "machine id password path" uses ftp'
|
|
352 echomsg ':Nread dav://machine[:port]/path uses cadaver'
|
|
353 echomsg ':Nread fetch://machine/path uses fetch'
|
|
354 echomsg ':Nread ftp://[user@]machine[:port]/path uses ftp autodetects <.netrc>'
|
|
355 echomsg ':Nread http://[user@]machine/path uses http wget'
|
|
356 echomsg ':Nread rcp://[user@]machine/path uses rcp'
|
|
357 echomsg ':Nread rsync://machine[:port]/path uses rsync'
|
|
358 echomsg ':Nread scp://[user@]machine[[:#]port]/path uses scp'
|
|
359 echomsg ':Nread sftp://[user@]machine[[:#]port]/path uses sftp'
|
|
360 break
|
|
361
|
|
362 elseif match(choice,"^\"") != -1
|
|
363 " Reconstruct Choice if choice starts with '"'
|
|
364 " call Decho("reconstructing choice")
|
|
365 if match(choice,"\"$") != -1
|
|
366 " case "..."
|
|
367 let choice=strpart(choice,1,strlen(choice)-2)
|
|
368 else
|
|
369 " case "... ... ..."
|
|
370 let choice = strpart(choice,1,strlen(choice)-1)
|
|
371 let wholechoice = ""
|
719
|
372
|
482
|
373 while match(choice,"\"$") == -1
|
|
374 let wholechoice = wholechoice . " " . choice
|
|
375 let ichoice = ichoice + 1
|
|
376 if ichoice > a:0
|
|
377 if !exists("g:netrw_quiet")
|
|
378 echohl Error | echo "***netrw*** Unbalanced string in filename '". wholechoice ."'" | echohl None
|
|
379 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
380 endif
|
|
381 " call Dret("NetRead")
|
|
382 return
|
|
383 endif
|
|
384 let choice= a:{ichoice}
|
|
385 endwhile
|
|
386 let choice= strpart(wholechoice,1,strlen(wholechoice)-1) . " " . strpart(choice,0,strlen(choice)-1)
|
|
387 endif
|
|
388 endif
|
|
389 endif
|
|
390
|
|
391 " call Decho("choice<" . choice . ">")
|
|
392 let ichoice= ichoice + 1
|
719
|
393
|
482
|
394 " fix up windows urls
|
|
395 if has("win32") || has("win95") || has("win64") || has("win16")
|
|
396 let choice = substitute(choice,'\\','/','ge')
|
|
397 " call Decho("fixing up windows url to <".choice."> tmpfile<".tmpfile)
|
|
398
|
839
|
399 exe 'cd ' . fnamemodify(tmpfile,':h')
|
482
|
400 let tmpfile = fnamemodify(tmpfile,':t')
|
|
401 endif
|
719
|
402
|
650
|
403 " Determine method of read (ftp, rcp, etc) {{{3
|
482
|
404 call s:NetMethod(choice)
|
719
|
405
|
482
|
406 " Check if NetBrowse() should be handling this request
|
819
|
407 " call Decho("checking if NetBrowse() should handle choice<".choice."> with netrw_list_cmd<".g:netrw_list_cmd.">")
|
482
|
408 if choice =~ "^.*[\/]$"
|
819
|
409 " call Decho("yes, choice matches '^.*[\/]$'")
|
482
|
410 keepjumps call s:NetBrowse(choice)
|
|
411 " call Dret("NetRead")
|
|
412 return
|
|
413 endif
|
559
|
414
|
|
415 " use filename's suffix for the temporary file
|
650
|
416 if b:netrw_fname =~ '\.[^./]\+$'
|
|
417 let suffix = substitute(b:netrw_fname,'^.*\(\.[^./]\+\)$','\1','e')
|
559
|
418 let tmpfile= substitute(tmpfile,"$",suffix,'e')
|
650
|
419 " call Decho("chgd tmpfile<".tmpfile."> (added ".suffix." suffix) netrw_fname<".b:netrw_fname.">")
|
559
|
420 endif
|
719
|
421
|
482
|
422 " ============
|
650
|
423 " Perform Protocol-Based Read {{{3
|
|
424 " ===========================
|
559
|
425 if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1
|
|
426 echo "(netrw) Processing your read request..."
|
|
427 endif
|
719
|
428
|
482
|
429 ".........................................
|
650
|
430 " rcp: NetRead Method #1 {{{3
|
482
|
431 if b:netrw_method == 1 " read with rcp
|
|
432 " call Decho("read via rcp (method #1)")
|
|
433 " ER: noting done with g:netrw_uid yet?
|
|
434 " ER: on Win2K" rcp machine[.user]:file tmpfile
|
|
435 " ER: if machine contains '.' adding .user is required (use $USERNAME)
|
|
436 " ER: the tmpfile is full path: rcp sees C:\... as host C
|
|
437 if s:netrw_has_nt_rcp == 1
|
|
438 if exists("g:netrw_uid") && ( g:netrw_uid != "" )
|
|
439 let uid_machine = g:netrw_machine .'.'. g:netrw_uid
|
|
440 else
|
|
441 " Any way needed it machine contains a '.'
|
|
442 let uid_machine = g:netrw_machine .'.'. $USERNAME
|
|
443 endif
|
|
444 else
|
|
445 if exists("g:netrw_uid") && ( g:netrw_uid != "" )
|
|
446 let uid_machine = g:netrw_uid .'@'. g:netrw_machine
|
|
447 else
|
|
448 let uid_machine = g:netrw_machine
|
|
449 endif
|
|
450 endif
|
719
|
451 " call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".uid_machine.":".escape(b:netrw_fname,' ?&;')." ".tmpfile)
|
|
452 exe g:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".uid_machine.":".escape(b:netrw_fname,' ?&;')." ".tmpfile
|
482
|
453 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
|
|
454 let b:netrw_lastfile = choice
|
719
|
455
|
482
|
456 ".........................................
|
650
|
457 " ftp + <.netrc>: NetRead Method #2 {{{3
|
482
|
458 elseif b:netrw_method == 2 " read with ftp + <.netrc>
|
559
|
459 " call Decho("read via ftp+.netrc (method #2)")
|
820
|
460 let netrw_fname= b:netrw_fname
|
482
|
461 new
|
|
462 setlocal ff=unix
|
|
463 exe "put ='".g:netrw_ftpmode."'"
|
559
|
464 " call Decho("filter input: ".getline("."))
|
|
465 exe "put ='".'get \"'.netrw_fname.'\" '.tmpfile."'"
|
|
466 " call Decho("filter input: ".getline("."))
|
482
|
467 if exists("g:netrw_port") && g:netrw_port != ""
|
|
468 " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port)
|
|
469 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port
|
|
470 else
|
|
471 " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine)
|
|
472 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine
|
|
473 endif
|
|
474 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
|
|
475 if getline(1) !~ "^$" && !exists("g:netrw_quiet") && getline(1) !~ '^Trying '
|
|
476 let debugkeep= &debug
|
|
477 set debug=msg
|
|
478 echohl Error | echo "***netrw*** ".getline(1) | echohl None
|
|
479 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
480 let &debug= debugkeep
|
|
481 endif
|
|
482 bd!
|
559
|
483 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
|
482
|
484 let b:netrw_lastfile = choice
|
719
|
485
|
482
|
486 ".........................................
|
650
|
487 " ftp + machine,id,passwd,filename: NetRead Method #3 {{{3
|
482
|
488 elseif b:netrw_method == 3 " read with ftp + machine, id, passwd, and fname
|
|
489 " Construct execution string (four lines) which will be passed through filter
|
|
490 " call Decho("read via ftp+mipf (method #3)")
|
719
|
491 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
|
482
|
492 new
|
|
493 setlocal ff=unix
|
|
494 if exists("g:netrw_port") && g:netrw_port != ""
|
|
495 put ='open '.g:netrw_machine.' '.g:netrw_port
|
559
|
496 " call Decho("filter input: ".getline("."))
|
482
|
497 else
|
|
498 put ='open '.g:netrw_machine
|
559
|
499 " call Decho("filter input: ".getline("."))
|
482
|
500 endif
|
719
|
501
|
482
|
502 if exists("g:netrw_ftp") && g:netrw_ftp == 1
|
|
503 put =g:netrw_uid
|
559
|
504 " call Decho("filter input: ".getline("."))
|
|
505 put ='\"'.g:netrw_passwd.'\"'
|
|
506 " call Decho("filter input: ".getline("."))
|
482
|
507 else
|
559
|
508 put ='user \"'.g:netrw_uid.'\" \"'.g:netrw_passwd.'\"'
|
|
509 " call Decho("filter input: ".getline("."))
|
482
|
510 endif
|
719
|
511
|
482
|
512 if exists("g:netrw_ftpmode") && g:netrw_ftpmode != ""
|
|
513 put =g:netrw_ftpmode
|
559
|
514 " call Decho("filter input: ".getline("."))
|
482
|
515 endif
|
559
|
516 put ='get \"'.netrw_fname.'\" '.tmpfile
|
|
517 " call Decho("filter input: ".getline("."))
|
719
|
518
|
482
|
519 " perform ftp:
|
|
520 " -i : turns off interactive prompting from ftp
|
|
521 " -n unix : DON'T use <.netrc>, even though it exists
|
|
522 " -n win32: quit being obnoxious about password
|
|
523 norm! 1Gdd
|
|
524 " call Decho("executing: %!".g:netrw_ftp_cmd." -i -n")
|
|
525 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n"
|
|
526 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
|
|
527 if getline(1) !~ "^$"
|
|
528 " call Decho("error<".getline(1).">")
|
|
529 if !exists("g:netrw_quiet")
|
|
530 echohl Error | echo "***netrw*** ".getline(1) | echohl None
|
|
531 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
532 endif
|
|
533 endif
|
|
534 bd!
|
|
535 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
|
|
536 let b:netrw_lastfile = choice
|
719
|
537
|
482
|
538 ".........................................
|
650
|
539 " scp: NetRead Method #4 {{{3
|
482
|
540 elseif b:netrw_method == 4 " read with scp
|
|
541 " call Decho("read via scp (method #4)")
|
|
542 if exists("g:netrw_port") && g:netrw_port != ""
|
|
543 let useport= " -P ".g:netrw_port
|
|
544 else
|
|
545 let useport= ""
|
|
546 endif
|
|
547 if g:netrw_cygwin == 1
|
|
548 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
|
719
|
549 " call Decho("executing: !".g:netrw_scp_cmd.useport." '".g:netrw_machine.":".escape(b:netrw_fname,g:netrw_fname_escape)."' ".cygtmpfile)
|
|
550 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." '".g:netrw_machine.":".escape(b:netrw_fname,g:netrw_fname_escape)."' ".cygtmpfile
|
482
|
551 else
|
719
|
552 " call Decho("executing: !".g:netrw_scp_cmd.useport." '".g:netrw_machine.":".escape(b:netrw_fname,g:netrw_fname_escape)."' ".tmpfile)
|
|
553 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." '".g:netrw_machine.":".escape(b:netrw_fname,g:netrw_fname_escape)."' ".tmpfile
|
482
|
554 endif
|
559
|
555 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
|
482
|
556 let b:netrw_lastfile = choice
|
719
|
557
|
482
|
558 ".........................................
|
650
|
559 " http: NetRead Method #5 (wget) {{{3
|
|
560 elseif b:netrw_method == 5
|
482
|
561 " call Decho("read via http (method #5)")
|
|
562 if g:netrw_http_cmd == ""
|
|
563 if !exists("g:netrw_quiet")
|
|
564 echohl Error | echo "***netrw*** neither wget nor fetch command is available" | echohl None
|
|
565 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
566 endif
|
559
|
567 " call Dret("NetRead")
|
|
568 return
|
482
|
569 endif
|
719
|
570
|
482
|
571 if match(b:netrw_fname,"#") == -1
|
|
572 " simple wget
|
719
|
573 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
|
|
574 " call Decho("executing: !".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_fname)
|
|
575 exe g:netrw_silentxfer."!".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_fname
|
482
|
576 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
|
719
|
577
|
482
|
578 else
|
|
579 " wget plus a jump to an in-page marker (ie. http://abc/def.html#aMarker)
|
719
|
580 let netrw_html= substitute(netrw_fname,"#.*$","","")
|
|
581 let netrw_tag = substitute(netrw_fname,"^.*#","","")
|
482
|
582 " call Decho("netrw_html<".netrw_html.">")
|
|
583 " call Decho("netrw_tag <".netrw_tag.">")
|
|
584 " call Decho("executing: !".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_html)
|
|
585 exe g:netrw_silentxfer."!".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_html
|
|
586 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
|
|
587 " call Decho('<\s*a\s*name=\s*"'.netrw_tag.'"/')
|
|
588 exe 'norm! 1G/<\s*a\s*name=\s*"'.netrw_tag.'"/'."\<CR>"
|
|
589 endif
|
|
590 let b:netrw_lastfile = choice
|
719
|
591
|
482
|
592 ".........................................
|
650
|
593 " cadaver: NetRead Method #6 {{{3
|
|
594 elseif b:netrw_method == 6
|
482
|
595 " call Decho("read via cadaver (method #6)")
|
719
|
596
|
482
|
597 " Construct execution string (four lines) which will be passed through filter
|
719
|
598 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
|
482
|
599 new
|
|
600 setlocal ff=unix
|
|
601 if exists("g:netrw_port") && g:netrw_port != ""
|
|
602 put ='open '.g:netrw_machine.' '.g:netrw_port
|
|
603 else
|
|
604 put ='open '.g:netrw_machine
|
|
605 endif
|
|
606 put ='user '.g:netrw_uid.' '.g:netrw_passwd
|
719
|
607
|
482
|
608 if g:netrw_cygwin == 1
|
|
609 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
|
|
610 put ='get '.netrw_fname.' '.cygtmpfile
|
|
611 else
|
|
612 put ='get '.netrw_fname.' '.tmpfile
|
|
613 endif
|
|
614 put ='quit'
|
719
|
615
|
482
|
616 " perform cadaver operation:
|
|
617 norm! 1Gdd
|
|
618 " call Decho("executing: %!".g:netrw_dav_cmd)
|
|
619 exe g:netrw_silentxfer."%!".g:netrw_dav_cmd
|
|
620 bd!
|
|
621 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
|
|
622 let b:netrw_lastfile = choice
|
719
|
623
|
482
|
624 ".........................................
|
650
|
625 " rsync: NetRead Method #7 {{{3
|
|
626 elseif b:netrw_method == 7
|
482
|
627 " call Decho("read via rsync (method #7)")
|
719
|
628 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
|
482
|
629 if g:netrw_cygwin == 1
|
|
630 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
|
719
|
631 " call Decho("executing: !".g:netrw_rsync_cmd." ".g:netrw_machine.":".netrw_fname." ".cygtmpfile)
|
|
632 exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".g:netrw_machine.":".netrw_fname." ".cygtmpfile
|
482
|
633 else
|
719
|
634 " call Decho("executing: !".g:netrw_rsync_cmd." ".g:netrw_machine.":".netrw_fname." ".tmpfile)
|
|
635 exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".g:netrw_machine.":".netrw_fname." ".tmpfile
|
482
|
636 endif
|
|
637 let result = s:NetGetFile(readcmd,tmpfile, b:netrw_method)
|
|
638 let b:netrw_lastfile = choice
|
719
|
639
|
482
|
640 ".........................................
|
650
|
641 " fetch: NetRead Method #8 {{{3
|
482
|
642 " fetch://[user@]host[:http]/path
|
650
|
643 elseif b:netrw_method == 8
|
719
|
644 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
|
482
|
645 if g:netrw_fetch_cmd == ""
|
|
646 if !exists("g:netrw_quiet")
|
|
647 echohl Error | echo "***netrw*** fetch command not available" | echohl None
|
|
648 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
649 endif
|
559
|
650 " call Dret("NetRead")
|
482
|
651 endif
|
|
652 if exists("g:netrw_option") && g:netrw_option == ":http"
|
|
653 let netrw_option= "http"
|
|
654 else
|
|
655 let netrw_option= "ftp"
|
|
656 endif
|
|
657 " call Decho("read via fetch for ".netrw_option)
|
719
|
658
|
482
|
659 if exists("g:netrw_uid") && g:netrw_uid != "" && exists("g:netrw_passwd") && g:netrw_passwd != ""
|
719
|
660 " call Decho("executing: !".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_uid.':'.g:netrw_passwd.'@'.g:netrw_machine."/".netrw_fname)
|
|
661 exe g:netrw_silentxfer."!".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_uid.':'.g:netrw_passwd.'@'.g:netrw_machine."/".netrw_fname
|
482
|
662 else
|
719
|
663 " call Decho("executing: !".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_machine."/".netrw_fname)
|
|
664 exe g:netrw_silentxfer."!".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_machine."/".netrw_fname
|
482
|
665 endif
|
719
|
666
|
482
|
667 let result = s:NetGetFile(readcmd,tmpfile, b:netrw_method)
|
|
668 let b:netrw_lastfile = choice
|
719
|
669
|
482
|
670 ".........................................
|
650
|
671 " sftp: NetRead Method #9 {{{3
|
|
672 elseif b:netrw_method == 9
|
482
|
673 " call Decho("read via sftp (method #4)")
|
719
|
674 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
|
482
|
675 if g:netrw_cygwin == 1
|
|
676 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
|
719
|
677 " call Decho("!".g:netrw_sftp_cmd." ".g:netrw_machine.":".netrw_fname." ".cygtmpfile)
|
|
678 " call Decho("executing: !".g:netrw_sftp_cmd." ".g:netrw_machine.":".netrw_fname." ".cygtmpfile)
|
|
679 exe "!".g:netrw_sftp_cmd." ".g:netrw_machine.":".netrw_fname." ".cygtmpfile
|
482
|
680 else
|
719
|
681 " call Decho("executing: !".g:netrw_sftp_cmd." ".g:netrw_machine.":".netrw_fname." ".tmpfile)
|
|
682 exe g:netrw_silentxfer."!".g:netrw_sftp_cmd." ".g:netrw_machine.":".netrw_fname." ".tmpfile
|
482
|
683 endif
|
|
684 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
|
|
685 let b:netrw_lastfile = choice
|
719
|
686
|
482
|
687 ".........................................
|
650
|
688 " Complain {{{3
|
|
689 else
|
482
|
690 echo "***warning*** unable to comply with your request<" . choice . ">"
|
|
691 endif
|
|
692 endwhile
|
719
|
693
|
650
|
694 " cleanup {{{3
|
482
|
695 " call Decho("cleanup")
|
|
696 if exists("b:netrw_method")
|
|
697 unlet b:netrw_method
|
|
698 unlet b:netrw_fname
|
|
699 endif
|
|
700 call s:NetOptionRestore()
|
|
701
|
|
702 " call Dret("NetRead")
|
|
703 endfun
|
|
704
|
|
705 " ------------------------------------------------------------------------
|
650
|
706 " NetGetFile: Function to read temporary file "tfile" with command "readcmd". {{{2
|
719
|
707 " readcmd == %r : replace buffer with newly read file
|
|
708 " == 0r : read file at top of buffer
|
|
709 " == r : read file after current line
|
559
|
710 fun! s:NetGetFile(readcmd, tfile, method)
|
719
|
711 " call Dfunc("NetGetFile(readcmd<".a:readcmd.">,tfile<".a:tfile."> method<".a:method.">)")
|
559
|
712
|
|
713 " get name of remote filename (ie. url and all)
|
|
714 let rfile= bufname("%")
|
|
715 " call Decho("rfile<".rfile.">")
|
719
|
716
|
482
|
717 if exists("*NetReadFixup")
|
|
718 " for the use of NetReadFixup (not otherwise used internally)
|
|
719 let line2= line("$")
|
|
720 endif
|
719
|
721
|
482
|
722 " transform paths from / to \ for Windows (except for cygwin)
|
|
723 if &term == "win32"
|
|
724 if g:netrw_cygwin
|
559
|
725 let tfile= a:tfile
|
|
726 " call Decho("(win32 && cygwin) tfile<".tfile.">")
|
482
|
727 else
|
559
|
728 let tfile= substitute(a:tfile,'/','\\\\','ge')
|
|
729 " call Decho("(win32 && !cygwin) tfile<".tfile.">")
|
482
|
730 endif
|
|
731 else
|
559
|
732 let tfile= a:tfile
|
|
733 " call Decho("tfile=a:tfile<".tfile.">")
|
482
|
734 endif
|
719
|
735
|
|
736 if a:readcmd[0] == '%'
|
482
|
737 " get file into buffer
|
|
738
|
|
739 " call Dredir("ls!","starting buffer list")
|
|
740
|
559
|
741 " rename the current buffer to the temp file (ie. tfile)
|
|
742 keepalt exe "file ".tfile
|
|
743 " call Dredir("ls!","after renaming current buffer to <".tfile.">")
|
|
744
|
|
745 " edit temporary file (ie. read the temporary file in)
|
|
746 if rfile =~ '\.zip$'
|
|
747 call zip#Browse(tfile)
|
|
748 elseif rfile =~ '\.tar$'
|
|
749 call tar#Browse(tfile)
|
|
750 else
|
650
|
751 " call Decho("edit temporary file")
|
559
|
752 e
|
|
753 endif
|
482
|
754
|
|
755 " rename buffer back to remote filename
|
650
|
756 keepalt exe "file ".escape(rfile,' ')
|
559
|
757 filetype detect
|
650
|
758 " call Dredir("ls!","renamed buffer back to remote filename<".rfile."> : expand(%)<".expand("%").">")
|
482
|
759 let line1 = 1
|
|
760 let line2 = line("$")
|
|
761
|
559
|
762 elseif filereadable(tfile)
|
482
|
763 " read file after current line
|
|
764 let curline = line(".")
|
|
765 let lastline= line("$")
|
559
|
766 " call Decho("exe<".a:readcmd." ".v:cmdarg." ".tfile."> line#".curline)
|
|
767 exe a:readcmd." ".v:cmdarg." ".tfile
|
719
|
768 let line1= curline + 1
|
|
769 let line2= line("$") - lastline + 1
|
559
|
770
|
482
|
771 else
|
|
772 " not readable
|
559
|
773 echohl WarningMsg | echo "***netrw*** file <".tfile."> not readable"| echohl None
|
|
774 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
775 " call Dret("NetGetFile : tfile<".tfile."> not readable")
|
482
|
776 return
|
|
777 endif
|
719
|
778
|
482
|
779 " User-provided (ie. optional) fix-it-up command
|
|
780 if exists("*NetReadFixup")
|
|
781 " call Decho("calling NetReadFixup(method<".a:method."> line1=".line1." line2=".line2.")")
|
|
782 call NetReadFixup(a:method, line1, line2)
|
|
783 " else " Decho
|
819
|
784 " call Decho("NetReadFixup() not called, doesn't exist (line1=".line1." line2=".line2.")")
|
482
|
785 endif
|
|
786
|
|
787 " update the Buffers menu
|
|
788 if has("gui") && has("gui_running")
|
|
789 silent! emenu Buffers.Refresh\ menu
|
|
790 endif
|
719
|
791
|
559
|
792 " call Decho("readcmd<".a:readcmd."> cmdarg<".v:cmdarg."> tfile<".a:tfile."> readable=".filereadable(a:tfile))
|
719
|
793
|
559
|
794 " make sure file is being displayed
|
482
|
795 redraw!
|
|
796 " call Dret("NetGetFile")
|
|
797 endfun
|
|
798
|
|
799 " ------------------------------------------------------------------------
|
650
|
800 " NetWrite: responsible for writing a file over the net {{{2
|
482
|
801 fun! netrw#NetWrite(...) range
|
|
802 " call Dfunc("NetWrite(a:0=".a:0.")")
|
719
|
803
|
482
|
804 " option handling
|
|
805 let mod= 0
|
|
806 call s:NetOptionSave()
|
719
|
807
|
650
|
808 " Get Temporary Filename {{{3
|
719
|
809 let tmpfile= escape(tempname(),g:netrw_tmpfile_escape)
|
482
|
810 if !isdirectory(substitute(tmpfile,'[^/]\+$','','e'))
|
|
811 echohl Error | echo "***netrw*** your ".substitute(tmpfile,'[^/]\+$','','e')." directory is missing!"
|
|
812 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
559
|
813 " call Dret("NetWrite")
|
482
|
814 return
|
|
815 endif
|
719
|
816
|
482
|
817 if a:0 == 0
|
|
818 let ichoice = 0
|
|
819 else
|
|
820 let ichoice = 1
|
|
821 endif
|
719
|
822
|
559
|
823 if &binary
|
|
824 " for binary writes, write entire file. Line numbers don't really make sense.
|
|
825 " Supports the writing of tar and zip files.
|
|
826 " call Decho("silent exe w! ".v:cmdarg." ".tmpfile)
|
|
827 silent exe "w! ".v:cmdarg." ".tmpfile
|
|
828 else
|
|
829 " write (selected portion of) file to temporary
|
|
830 " call Decho("silent exe ".a:firstline."," . a:lastline . "w! ".v:cmdarg." ".tmpfile)
|
|
831 silent exe a:firstline."," . a:lastline . "w! ".v:cmdarg." ".tmpfile
|
|
832 endif
|
719
|
833
|
482
|
834 while ichoice <= a:0
|
719
|
835
|
650
|
836 " Process arguments: {{{3
|
482
|
837 " attempt to repeat with previous host-file-etc
|
|
838 if exists("b:netrw_lastfile") && a:0 == 0
|
|
839 " call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">")
|
|
840 let choice = b:netrw_lastfile
|
|
841 let ichoice= ichoice + 1
|
|
842 else
|
|
843 exe "let choice= a:" . ichoice
|
719
|
844
|
482
|
845 " Reconstruct Choice if choice starts with '"'
|
|
846 if match(choice,"?") == 0
|
|
847 echomsg 'NetWrite Usage:"'
|
|
848 echomsg ':Nwrite machine:path uses rcp'
|
|
849 echomsg ':Nwrite "machine path" uses ftp with <.netrc>'
|
|
850 echomsg ':Nwrite "machine id password path" uses ftp'
|
|
851 echomsg ':Nwrite dav://[user@]machine/path uses cadaver'
|
|
852 echomsg ':Nwrite fetch://[user@]machine/path uses fetch'
|
|
853 echomsg ':Nwrite ftp://machine[#port]/path uses ftp (autodetects <.netrc>)'
|
|
854 echomsg ':Nwrite rcp://machine/path uses rcp'
|
|
855 echomsg ':Nwrite rsync://[user@]machine/path uses rsync'
|
|
856 echomsg ':Nwrite scp://[user@]machine[[:#]port]/path uses scp'
|
|
857 echomsg ':Nwrite sftp://[user@]machine/path uses sftp'
|
|
858 break
|
719
|
859
|
482
|
860 elseif match(choice,"^\"") != -1
|
|
861 if match(choice,"\"$") != -1
|
|
862 " case "..."
|
|
863 let choice=strpart(choice,1,strlen(choice)-2)
|
|
864 else
|
|
865 " case "... ... ..."
|
|
866 let choice = strpart(choice,1,strlen(choice)-1)
|
|
867 let wholechoice = ""
|
719
|
868
|
482
|
869 while match(choice,"\"$") == -1
|
|
870 let wholechoice= wholechoice . " " . choice
|
|
871 let ichoice = ichoice + 1
|
|
872 if choice > a:0
|
|
873 if !exists("g:netrw_quiet")
|
|
874 echohl Error | echo "***netrw*** Unbalanced string in filename '". wholechoice ."'" | echohl None
|
|
875 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
876 endif
|
|
877 " call Dret("NetWrite")
|
|
878 return
|
|
879 endif
|
|
880 let choice= a:{ichoice}
|
|
881 endwhile
|
|
882 let choice= strpart(wholechoice,1,strlen(wholechoice)-1) . " " . strpart(choice,0,strlen(choice)-1)
|
|
883 endif
|
|
884 endif
|
|
885 endif
|
|
886 " call Decho("choice<" . choice . ">")
|
|
887 let ichoice= ichoice + 1
|
719
|
888
|
482
|
889 " fix up windows urls
|
|
890 if has("win32") || has("win95") || has("win64") || has("win16")
|
|
891 let choice= substitute(choice,'\\','/','ge')
|
|
892 "ER: see NetRead()
|
839
|
893 exe 'cd ' . fnamemodify(tmpfile,':h')
|
482
|
894 let tmpfile = fnamemodify(tmpfile,':t')
|
|
895 endif
|
719
|
896
|
650
|
897 " Determine method of read (ftp, rcp, etc) {{{3
|
482
|
898 call s:NetMethod(choice)
|
719
|
899
|
482
|
900 " =============
|
650
|
901 " Perform Protocol-Based Write {{{3
|
|
902 " ============================
|
559
|
903 if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1
|
|
904 echo "(netrw) Processing your write request..."
|
|
905 endif
|
719
|
906
|
482
|
907 ".........................................
|
650
|
908 " rcp: NetWrite Method #1 {{{3
|
|
909 if b:netrw_method == 1
|
559
|
910 " call Decho("write via rcp (method #1)")
|
482
|
911 if s:netrw_has_nt_rcp == 1
|
|
912 if exists("g:netrw_uid") && ( g:netrw_uid != "" )
|
|
913 let uid_machine = g:netrw_machine .'.'. g:netrw_uid
|
|
914 else
|
|
915 let uid_machine = g:netrw_machine .'.'. $USERNAME
|
|
916 endif
|
|
917 else
|
|
918 if exists("g:netrw_uid") && ( g:netrw_uid != "" )
|
|
919 let uid_machine = g:netrw_uid .'@'. g:netrw_machine
|
|
920 else
|
|
921 let uid_machine = g:netrw_machine
|
|
922 endif
|
|
923 endif
|
719
|
924 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
|
|
925 " call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".tmpfile." ".uid_machine.":".netrw_fname)
|
|
926 exe g:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".tmpfile." ".uid_machine.":".netrw_fname
|
482
|
927 let b:netrw_lastfile = choice
|
719
|
928
|
482
|
929 ".........................................
|
650
|
930 " ftp + <.netrc>: NetWrite Method #2 {{{3
|
|
931 elseif b:netrw_method == 2
|
829
|
932 let netrw_fname= b:netrw_fname
|
482
|
933 new
|
|
934 setlocal ff=unix
|
|
935 exe "put ='".g:netrw_ftpmode."'"
|
559
|
936 " call Decho(" filter input: ".getline("."))
|
|
937 exe "put ='"."put ".tmpfile.' \"'.netrw_fname.'\"'."'"
|
|
938 " call Decho(" filter input: ".getline("."))
|
482
|
939 if exists("g:netrw_port") && g:netrw_port != ""
|
|
940 " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port)
|
|
941 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port
|
|
942 else
|
|
943 " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine)
|
|
944 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine
|
|
945 endif
|
|
946 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
|
|
947 if getline(1) !~ "^$"
|
|
948 if !exists("g:netrw_quiet")
|
|
949 echohl Error | echo "***netrw*** ".getline(1) | echohl None
|
|
950 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
951 endif
|
|
952 let mod=1
|
|
953 endif
|
|
954 bd!
|
|
955 let b:netrw_lastfile = choice
|
719
|
956
|
482
|
957 ".........................................
|
650
|
958 " ftp + machine, id, passwd, filename: NetWrite Method #3 {{{3
|
|
959 elseif b:netrw_method == 3
|
829
|
960 let netrw_fname= b:netrw_fname
|
482
|
961 new
|
|
962 setlocal ff=unix
|
|
963 if exists("g:netrw_port") && g:netrw_port != ""
|
|
964 put ='open '.g:netrw_machine.' '.g:netrw_port
|
559
|
965 " call Decho("filter input: ".getline("."))
|
482
|
966 else
|
|
967 put ='open '.g:netrw_machine
|
559
|
968 " call Decho("filter input: ".getline("."))
|
482
|
969 endif
|
|
970 if exists("g:netrw_ftp") && g:netrw_ftp == 1
|
|
971 put =g:netrw_uid
|
559
|
972 " call Decho("filter input: ".getline("."))
|
|
973 put ='\"'.g:netrw_passwd.'\"'
|
|
974 " call Decho("filter input: ".getline("."))
|
482
|
975 else
|
559
|
976 put ='user \"'.g:netrw_uid.'\" \"'.g:netrw_passwd.'\"'
|
|
977 " call Decho("filter input: ".getline("."))
|
482
|
978 endif
|
559
|
979 put ='put '.tmpfile.' \"'.netrw_fname.'\"'
|
|
980 " call Decho("filter input: ".getline("."))
|
482
|
981 " save choice/id/password for future use
|
|
982 let b:netrw_lastfile = choice
|
719
|
983
|
482
|
984 " perform ftp:
|
|
985 " -i : turns off interactive prompting from ftp
|
|
986 " -n unix : DON'T use <.netrc>, even though it exists
|
|
987 " -n win32: quit being obnoxious about password
|
|
988 norm! 1Gdd
|
|
989 " call Decho("executing: %!".g:netrw_ftp_cmd." -i -n")
|
|
990 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n"
|
|
991 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
|
|
992 if getline(1) !~ "^$"
|
|
993 if !exists("g:netrw_quiet")
|
|
994 echohl Error | echo "***netrw*** ".getline(1) | echohl None
|
|
995 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
996 endif
|
|
997 let mod=1
|
|
998 endif
|
|
999 bd!
|
719
|
1000
|
482
|
1001 ".........................................
|
650
|
1002 " scp: NetWrite Method #4 {{{3
|
|
1003 elseif b:netrw_method == 4
|
719
|
1004 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
|
482
|
1005 if exists("g:netrw_port") && g:netrw_port != ""
|
|
1006 let useport= " -P ".g:netrw_port
|
|
1007 else
|
|
1008 let useport= ""
|
|
1009 endif
|
|
1010 if g:netrw_cygwin == 1
|
|
1011 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
|
719
|
1012 " call Decho("executing: !".g:netrw_scp_cmd.useport." ".cygtmpfile." '".g:netrw_machine.":".netrw_fname."'")
|
|
1013 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".cygtmpfile." '".g:netrw_machine.":".netrw_fname."'"
|
482
|
1014 else
|
719
|
1015 " call Decho("executing: !".g:netrw_scp_cmd.useport." ".tmpfile." '".g:netrw_machine.":".netrw_fname."'")
|
|
1016 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".tmpfile." '".g:netrw_machine.":".netrw_fname."'"
|
482
|
1017 endif
|
|
1018 let b:netrw_lastfile = choice
|
719
|
1019
|
482
|
1020 ".........................................
|
650
|
1021 " http: NetWrite Method #5 {{{3
|
482
|
1022 elseif b:netrw_method == 5
|
|
1023 if !exists("g:netrw_quiet")
|
|
1024 echohl Error | echo "***netrw*** currently <netrw.vim> does not support writing using http:" | echohl None
|
|
1025 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
1026 endif
|
719
|
1027
|
482
|
1028 ".........................................
|
650
|
1029 " dav: NetWrite Method #6 (cadaver) {{{3
|
|
1030 elseif b:netrw_method == 6
|
482
|
1031 " call Decho("write via cadaver (method #6)")
|
719
|
1032
|
482
|
1033 " Construct execution string (four lines) which will be passed through filter
|
719
|
1034 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
|
482
|
1035 new
|
|
1036 setlocal ff=unix
|
|
1037 if exists("g:netrw_port") && g:netrw_port != ""
|
|
1038 put ='open '.g:netrw_machine.' '.g:netrw_port
|
|
1039 else
|
|
1040 put ='open '.g:netrw_machine
|
|
1041 endif
|
|
1042 put ='user '.g:netrw_uid.' '.g:netrw_passwd
|
719
|
1043
|
482
|
1044 if g:netrw_cygwin == 1
|
|
1045 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
|
|
1046 put ='put '.cygtmpfile.' '.netrw_fname
|
|
1047 else
|
|
1048 put ='put '.tmpfile.' '.netrw_fname
|
|
1049 endif
|
719
|
1050
|
482
|
1051 " perform cadaver operation:
|
|
1052 norm! 1Gdd
|
|
1053 " call Decho("executing: %!".g:netrw_dav_cmd)
|
|
1054 exe g:netrw_silentxfer."%!".g:netrw_dav_cmd
|
|
1055 bd!
|
|
1056 let b:netrw_lastfile = choice
|
719
|
1057
|
482
|
1058 ".........................................
|
650
|
1059 " rsync: NetWrite Method #7 {{{3
|
|
1060 elseif b:netrw_method == 7
|
719
|
1061 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
|
482
|
1062 if g:netrw_cygwin == 1
|
|
1063 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
|
719
|
1064 " call Decho("executing: !".g:netrw_rsync_cmd." ".cygtmpfile." ".g:netrw_machine.":".netrw_fname)
|
|
1065 exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".cygtmpfile." ".g:netrw_machine.":".netrw_fname
|
482
|
1066 else
|
719
|
1067 " call Decho("executing: !".g:netrw_rsync_cmd." ".tmpfile." ".g:netrw_machine.":".netrw_fname)
|
|
1068 exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".tmpfile." ".g:netrw_machine.":".netrw_fname
|
482
|
1069 endif
|
|
1070 let b:netrw_lastfile = choice
|
719
|
1071
|
482
|
1072 ".........................................
|
650
|
1073 " sftp: NetWrite Method #9 {{{3
|
|
1074 elseif b:netrw_method == 9
|
719
|
1075 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
|
482
|
1076 if exists("g:netrw_uid") && ( g:netrw_uid != "" )
|
|
1077 let uid_machine = g:netrw_uid .'@'. g:netrw_machine
|
|
1078 else
|
|
1079 let uid_machine = g:netrw_machine
|
|
1080 endif
|
|
1081 new
|
|
1082 setlocal ff=unix
|
|
1083 put ='put '.tmpfile.' '.netrw_fname
|
|
1084 norm! 1Gdd
|
|
1085 " call Decho("executing: %!".g:netrw_sftp_cmd.' '.uid_machine)
|
|
1086 exe g:netrw_silentxfer."%!".g:netrw_sftp_cmd.' '.uid_machine
|
|
1087 bd!
|
|
1088 let b:netrw_lastfile= choice
|
719
|
1089
|
482
|
1090 ".........................................
|
650
|
1091 " Complain {{{3
|
|
1092 else
|
482
|
1093 echo "***warning*** unable to comply with your request<" . choice . ">"
|
|
1094 endif
|
|
1095 endwhile
|
719
|
1096
|
650
|
1097 " cleanup {{{3
|
482
|
1098 " call Decho("cleanup")
|
|
1099 let result=delete(tmpfile)
|
|
1100 call s:NetOptionRestore()
|
719
|
1101
|
482
|
1102 if a:firstline == 1 && a:lastline == line("$")
|
|
1103 let &mod= mod " usually equivalent to set nomod
|
|
1104 endif
|
719
|
1105
|
482
|
1106 " call Dret("NetWrite")
|
|
1107 endfun
|
|
1108
|
|
1109 " ===========================================
|
|
1110 " Remote Directory Browsing Support: {{{1
|
|
1111 " ===========================================
|
|
1112
|
650
|
1113 " ---------------------------------------------------------------------
|
482
|
1114 " NetBrowse: This function uses the command in g:netrw_list_cmd to get a list {{{2
|
|
1115 " of the contents of a remote directory. It is assumed that the
|
|
1116 " g:netrw_list_cmd has a string, HOSTNAME, that needs to be substituted
|
|
1117 " with the requested remote hostname first.
|
|
1118 fun! s:NetBrowse(dirname)
|
519
|
1119 if !exists("w:netrw_longlist")|let w:netrw_longlist= g:netrw_longlist|endif
|
|
1120 " call Dfunc("NetBrowse(dirname<".a:dirname.">) longlist=".w:netrw_longlist)
|
482
|
1121
|
|
1122 if exists("s:netrw_skipbrowse")
|
|
1123 unlet s:netrw_skipbrowse
|
|
1124 " call Dret("NetBrowse")
|
|
1125 return
|
|
1126 endif
|
|
1127
|
484
|
1128 call s:NetOptionSave()
|
|
1129
|
482
|
1130 " sanity check
|
|
1131 if exists("b:netrw_method") && b:netrw_method =~ '[235]'
|
|
1132 " call Decho("b:netrw_method=".b:netrw_method)
|
|
1133 if !executable("ftp")
|
|
1134 if !exists("g:netrw_quiet")
|
|
1135 echohl Error | echo "***netrw*** this system doesn't support remote directory listing via ftp" | echohl None
|
|
1136 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
1137 endif
|
484
|
1138 call s:NetOptionRestore()
|
482
|
1139 " call Dret("NetBrowse")
|
|
1140 return
|
|
1141 endif
|
|
1142 elseif !exists("g:netrw_list_cmd") || g:netrw_list_cmd == ''
|
|
1143 if !exists("g:netrw_quiet")
|
559
|
1144 echohl Error | echo "***netrw*** this system doesn't support remote directory listing via ".g:netrw_list_cmd | echohl None
|
482
|
1145 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
1146 endif
|
|
1147
|
484
|
1148 call s:NetOptionRestore()
|
482
|
1149 " call Dret("NetBrowse")
|
|
1150 return
|
|
1151 endif
|
|
1152
|
|
1153 " use buffer-oriented WinVars if buffer ones exist but window ones don't
|
|
1154 call s:UseBufWinVars()
|
|
1155
|
719
|
1156 " set up menus
|
|
1157 let b:netrw_browser_active= 1
|
828
|
1158 call s:NetMenu(1)
|
719
|
1159
|
482
|
1160 " make this buffer modifiable
|
|
1161 setlocal ma nonu nowrap
|
|
1162
|
|
1163 " analyze a:dirname and g:netrw_list_cmd
|
|
1164 let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/]\+\)/\(.*\)$'
|
|
1165 let dirname = substitute(a:dirname,'\\','/','ge')
|
559
|
1166 " call Decho("dirname<".dirname.">")
|
482
|
1167 if dirname !~ dirpat
|
|
1168 if !exists("g:netrw_quiet")
|
|
1169 echohl Error | echo "***netrw*** netrw doesn't understand your dirname<".dirname.">" | echohl None
|
|
1170 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
1171 endif
|
484
|
1172 call s:NetOptionRestore()
|
482
|
1173 " call Dret("NetBrowse : badly formatted dirname<".dirname.">")
|
|
1174 return
|
|
1175 endif
|
|
1176
|
|
1177 let method = substitute(dirname,dirpat,'\1','')
|
|
1178 let user = substitute(dirname,dirpat,'\2','')
|
|
1179 let machine = substitute(dirname,dirpat,'\3','')
|
|
1180 let path = substitute(dirname,dirpat,'\4','')
|
|
1181 let fname = substitute(dirname,'^.*/\ze.','','')
|
|
1182 " call Decho("set up method <".method .">")
|
|
1183 " call Decho("set up user <".user .">")
|
|
1184 " call Decho("set up machine<".machine.">")
|
|
1185 " call Decho("set up path <".path .">")
|
|
1186 " call Decho("set up fname <".fname .">")
|
|
1187
|
|
1188 if method == "ftp" || method == "http"
|
|
1189 let method = "ftp"
|
|
1190 let listcmd = g:netrw_ftp_list_cmd
|
|
1191 else
|
|
1192 let listcmd = substitute(g:netrw_list_cmd,'\<HOSTNAME\>',user.machine,'')
|
|
1193 endif
|
|
1194
|
|
1195 if exists("b:netrw_method")
|
|
1196 " call Decho("setting w:netrw_method<".b:netrw_method.">")
|
|
1197 let w:netrw_method= b:netrw_method
|
|
1198 endif
|
|
1199
|
|
1200 " optionally sort by time (-t) or by size (-S)
|
|
1201 if listcmd == "dir" && g:netrw_sort_by =~ "^[ts]"
|
|
1202 echohl WarningMsg | echo "***netrw*** windows' ftp doesn't support time/size sorts (get cygwin, set g:netrw_cygwin)" | echohl None
|
|
1203 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
1204 else
|
|
1205 if g:netrw_sort_by =~ "^t"
|
|
1206 let listcmd= listcmd."t"
|
|
1207 elseif g:netrw_sort_by =~ "^s"
|
|
1208 let listcmd= listcmd."S"
|
|
1209 endif
|
|
1210 " optionally sort in reverse
|
|
1211 if g:netrw_sort_direction =~ "^r" && listcmd == "dir"
|
|
1212 let listcmd= listcmd."r"
|
|
1213 endif
|
|
1214 endif
|
|
1215
|
|
1216 " call Decho("set up listcmd<".listcmd.">")
|
|
1217 if fname =~ '@$' && fname !~ '^"'
|
|
1218 " call Decho("attempt transfer of symlink as file")
|
|
1219 call s:NetBrowse(substitute(dirname,'@$','','e'))
|
|
1220 redraw!
|
484
|
1221 call s:NetOptionRestore()
|
482
|
1222 " call Dret("NetBrowse : symlink")
|
|
1223 return
|
|
1224
|
|
1225 elseif fname !~ '[\/]$' && fname !~ '^"'
|
|
1226 " looks like a regular file, attempt transfer
|
|
1227 " call Decho("attempt transfer as regular file<".dirname.">")
|
|
1228
|
|
1229 " remove any filetype indicator from end of dirname, except for the
|
|
1230 " "this is a directory" indicator (/). There shouldn't be one of those,
|
|
1231 " anyway.
|
484
|
1232 let path= substitute(path,'[*=@|]\r\=$','','e')
|
482
|
1233 " call Decho("new path<".path.">")
|
|
1234
|
|
1235 " remote-read the requested file into current buffer
|
839
|
1236 mark '
|
559
|
1237 keepjumps keepalt enew!
|
519
|
1238 set ma
|
559
|
1239 " call Decho("exe file ".method."://".user.machine."/".escape(path,s:netrw_cd_escape))
|
482
|
1240 exe "file ".method."://".user.machine."/".escape(path,s:netrw_cd_escape)
|
|
1241 exe "silent doau BufReadPre ".fname
|
719
|
1242 silent call netrw#NetRead(2,method."://".user.machine."/".path)
|
482
|
1243 exe "silent doau BufReadPost ".fname
|
|
1244
|
|
1245 " save certain window-oriented variables into buffer-oriented variables
|
559
|
1246 call s:SetBufWinVars()
|
484
|
1247 call s:NetOptionRestore()
|
719
|
1248 setlocal nomod nowrap
|
482
|
1249
|
|
1250 " call Dret("NetBrowse : file<".fname.">")
|
|
1251 return
|
|
1252 endif
|
|
1253
|
|
1254 " ---------------------------------------------------------------------
|
|
1255 " Perform Directory Listing:
|
|
1256 " call Decho("Perform directory listing...")
|
|
1257 " set up new buffer and map
|
|
1258 let bufname = method.'://'.user.machine.'/'.path
|
|
1259 let bufnamenr = bufnr(bufname.'$')
|
|
1260 " call Decho("bufname<".bufname."> bufnamenr=".bufnamenr)
|
839
|
1261 mark '
|
482
|
1262 if bufnamenr != -1
|
|
1263 " buffer already exists, switch to it!
|
|
1264 " call Decho("buffer already exists, switching to it")
|
|
1265 exe "b ".bufnamenr
|
|
1266 if line("$") >= 5
|
484
|
1267 call s:NetOptionRestore()
|
482
|
1268 " call Dret("NetBrowse")
|
|
1269 return
|
|
1270 endif
|
|
1271 else
|
|
1272 " call Decho("generate a new buffer")
|
559
|
1273 keepjumps keepalt enew!
|
482
|
1274 endif
|
|
1275
|
|
1276 " rename file to reflect where its from
|
|
1277 setlocal bt=nofile bh=wipe nobl noswf
|
|
1278 exe "setlocal ts=".g:netrw_maxfilenamelen
|
|
1279 " call Decho("exe file ".escape(bufname,s:netrw_cd_escape))
|
|
1280 exe 'file '.escape(bufname,s:netrw_cd_escape)
|
|
1281 " call Decho("renaming file to bufname<".bufname.">")
|
719
|
1282 setlocal bt=nofile nobl nonu noswf
|
|
1283 if g:netrw_fastbrowse >= 1
|
|
1284 setlocal bh=hide
|
799
|
1285 else
|
|
1286 setlocal bh=delete
|
719
|
1287 endif
|
482
|
1288
|
|
1289 " save current directory on directory history list
|
650
|
1290 call s:NetBookmarkDir(3,expand("%"))
|
482
|
1291
|
|
1292 " set up buffer-local mappings
|
|
1293 " call Decho("set up buffer-local mappings")
|
519
|
1294 nnoremap <buffer> <silent> <cr> :call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),<SID>NetGetWord()))<cr>
|
559
|
1295 nnoremap <buffer> <silent> <c-l> :call <SID>NetRefresh(<SID>NetBrowseChgDir(expand("%"),'./'),0)<cr>
|
482
|
1296 nnoremap <buffer> <silent> - :exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'../'))<cr>
|
|
1297 nnoremap <buffer> <silent> a :let g:netrw_hide=(g:netrw_hide+1)%3<bar>exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'./'))<cr>
|
519
|
1298 if w:netrw_longlist != 2
|
|
1299 nnoremap <buffer> <silent> b :<c-u>call <SID>NetBookmarkDir(0,expand("%"))<cr>
|
|
1300 nnoremap <buffer> <silent> B :<c-u>call <SID>NetBookmarkDir(1,expand("%"))<cr>
|
|
1301 endif
|
|
1302 nnoremap <buffer> <silent> Nb :<c-u>call <SID>NetBookmarkDir(0,expand("%"))<cr>
|
|
1303 nnoremap <buffer> <silent> NB :<c-u>call <SID>NetBookmarkDir(0,expand("%"))<cr>
|
482
|
1304 nnoremap <buffer> <silent> <c-h> :call <SID>NetHideEdit(0)<cr>
|
|
1305 nnoremap <buffer> <silent> i :call <SID>NetLongList(0)<cr>
|
|
1306 nnoremap <buffer> <silent> o :call <SID>NetSplit(0)<cr>
|
719
|
1307 nnoremap <buffer> <silent> O :call netrw#NetObtain()<cr>
|
650
|
1308 nnoremap <buffer> <silent> P :call <SID>NetPrevWinOpen(0)<cr>
|
482
|
1309 nnoremap <buffer> <silent> q :<c-u>call <SID>NetBookmarkDir(2,expand("%"))<cr>
|
|
1310 nnoremap <buffer> <silent> r :let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'./'))<cr>
|
|
1311 nnoremap <buffer> <silent> s :call <SID>NetSaveWordPosn()<bar>let g:netrw_sort_by= (g:netrw_sort_by =~ 'n')? 'time' : (g:netrw_sort_by =~ 't')? 'size' : 'name'<bar>exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'./'))<bar>call <SID>NetRestoreWordPosn()<cr>
|
|
1312 nnoremap <buffer> <silent> S :call <SID>NetSortSequence(0)<cr>
|
|
1313 nnoremap <buffer> <silent> u :<c-u>call <SID>NetBookmarkDir(4,expand("%"))<cr>
|
|
1314 nnoremap <buffer> <silent> U :<c-u>call <SID>NetBookmarkDir(5,expand("%"))<cr>
|
|
1315 nnoremap <buffer> <silent> v :call <SID>NetSplit(1)<cr>
|
650
|
1316 nnoremap <buffer> <silent> x :call netrw#NetBrowseX(<SID>NetBrowseChgDir(expand("%"),<SID>NetGetWord()),1)<cr>
|
559
|
1317 nnoremap <buffer> <silent> <2-leftmouse> :call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),<SID>NetGetWord()))<cr>
|
519
|
1318 exe 'nnoremap <buffer> <silent> <del> :call <SID>NetBrowseRm("'.user.machine.'","'.path.'")<cr>'
|
482
|
1319 exe 'vnoremap <buffer> <silent> <del> :call <SID>NetBrowseRm("'.user.machine.'","'.path.'")<cr>'
|
|
1320 exe 'nnoremap <buffer> <silent> d :call <SID>NetMakeDir("'.user.machine.'")<cr>'
|
519
|
1321 exe 'nnoremap <buffer> <silent> D :call <SID>NetBrowseRm("'.user.machine.'","'.path.'")<cr>'
|
482
|
1322 exe 'vnoremap <buffer> <silent> D :call <SID>NetBrowseRm("'.user.machine.'","'.path.'")<cr>'
|
519
|
1323 exe 'nnoremap <buffer> <silent> R :call <SID>NetBrowseRename("'.user.machine.'","'.path.'")<cr>'
|
482
|
1324 exe 'vnoremap <buffer> <silent> R :call <SID>NetBrowseRename("'.user.machine.'","'.path.'")<cr>'
|
794
|
1325 nnoremap <buffer> <F1> :he netrw-browse-cmds<cr>
|
482
|
1326 setlocal ma nonu nowrap
|
|
1327
|
|
1328 " Set up the banner
|
839
|
1329 " call Decho("set up the banner: sortby<".g:netrw_sort_by."> method<".method."> direction<".g:netrw_sort_direction.">")
|
482
|
1330 keepjumps put ='\" ==========================================================================='
|
519
|
1331 keepjumps put ='\" Netrw Remote Directory Listing (netrw '.g:loaded_netrw.')'
|
482
|
1332 keepjumps put ='\" '.bufname
|
|
1333 let w:netrw_bannercnt = 7
|
|
1334 let sortby = g:netrw_sort_by
|
|
1335 if g:netrw_sort_direction =~ "^r"
|
|
1336 let sortby = sortby." reversed"
|
|
1337 endif
|
|
1338
|
|
1339 if g:netrw_sort_by =~ "^n"
|
|
1340 " sorted by name
|
|
1341 let w:netrw_bannercnt= w:netrw_bannercnt + 1
|
|
1342 keepjumps put ='\" Sorted by '.sortby
|
|
1343 keepjumps put ='\" Sort sequence: '.g:netrw_sort_sequence
|
|
1344 else
|
|
1345 " sorted by size or date
|
|
1346 keepjumps put ='\" Sorted by '.sortby
|
|
1347 endif
|
|
1348 if g:netrw_list_hide != "" && g:netrw_hide
|
559
|
1349 " call Decho("g:netrw_hide=".g:netrw_hide)
|
482
|
1350 if g:netrw_hide == 1
|
|
1351 keepjumps put ='\" Hiding: '.g:netrw_list_hide
|
|
1352 else
|
|
1353 keepjumps put ='\" Showing: '.g:netrw_list_hide
|
|
1354 endif
|
|
1355 let w:netrw_bannercnt= w:netrw_bannercnt + 1
|
|
1356 endif
|
819
|
1357 keepjumps put ='\" Quick Help: <F1>:help -:go up dir D:delete R:rename s:sort-by x:exec'
|
482
|
1358 keepjumps put ='\" ==========================================================================='
|
|
1359
|
|
1360 " remote read the requested directory listing
|
|
1361 " Use ftp if that was the file-transfer method selected, otherwise use ssh
|
|
1362 " Note that not all ftp servers honor the options for ls
|
|
1363 if method == "ftp"
|
|
1364 " use ftp to get remote file listing
|
|
1365 " call Decho("use ftp to get remote file listing")
|
|
1366 call s:NetBrowseFtpCmd(path,listcmd)
|
|
1367 keepjumps 1d
|
|
1368
|
519
|
1369 if w:netrw_longlist == 0 || w:netrw_longlist == 2
|
482
|
1370 " shorten the listing
|
|
1371 " call Decho("generate short listing")
|
|
1372 exe "keepjumps ".w:netrw_bannercnt
|
|
1373
|
|
1374 " cleanup
|
|
1375 if g:netrw_ftp_browse_reject != ""
|
|
1376 exe "silent! g/".g:netrw_ftp_browse_reject."/keepjumps d"
|
|
1377 endif
|
559
|
1378 silent! keepjumps %s/\r$//e
|
482
|
1379
|
|
1380 " if there's no ../ listed, then put ./ and ../ in
|
|
1381 let line1= line(".")
|
|
1382 keepjumps 1
|
|
1383 silent keepjumps call search('^\.\.\/\%(\s\|$\)','W')
|
|
1384 let line2= line(".")
|
|
1385 if line2 == 0
|
|
1386 keepjumps put='../'
|
|
1387 keepjumps put='./'
|
|
1388 endif
|
|
1389 exe "keepjumps ".line1
|
|
1390 keepjumps norm! 0
|
|
1391
|
|
1392 " more cleanup
|
559
|
1393 exe 'silent! keepjumps '.w:netrw_bannercnt.',$s/^\(\%(\S\+\s\+\)\{7}\S\+\)\s\+\(\S.*\)$/\2/e'
|
|
1394 exe "silent! keepjumps ".w:netrw_bannercnt.',$g/ -> /s# -> .*/$#/#e'
|
|
1395 exe "silent! keepjumps ".w:netrw_bannercnt.',$g/ -> /s# -> .*$#/#e'
|
482
|
1396 endif
|
|
1397
|
|
1398 else
|
|
1399 " use ssh to get remote file listing
|
|
1400 " call Decho("use ssh to get remote file listing")
|
|
1401 let shq= &shq? &shq : ( &sxq? &sxq : "'")
|
|
1402 " call Decho("exe silent r! ".listcmd." '".shq.escape(path,s:netrw_cd_escape).shq."'")
|
|
1403 exe "silent r! ".listcmd." ".shq.escape(path,s:netrw_cd_escape).shq
|
|
1404 keepjumps 1d
|
|
1405 " cleanup
|
|
1406 if g:netrw_ftp_browse_reject != ""
|
|
1407 exe "silent! g/".g:netrw_ssh_browse_reject."/keepjumps d"
|
|
1408 endif
|
|
1409 endif
|
|
1410
|
|
1411 " set up syntax highlighting
|
|
1412 if has("syntax")
|
829
|
1413 setlocal ft=netrw
|
482
|
1414 if !exists("g:syntax_on") || !g:syntax_on
|
|
1415 setlocal ft=
|
|
1416 " Ugly workaround -- when syntax highlighting is off and laststatus==2,
|
|
1417 " sometimes the laststatus highlight bleeds into the entire display.
|
|
1418 " Only seems to happen with remote browsing. Weird.
|
|
1419 redraw
|
|
1420 endif
|
|
1421 endif
|
|
1422
|
|
1423 " manipulate the directory listing (hide, sort)
|
|
1424 if line("$") >= w:netrw_bannercnt
|
|
1425 if g:netrw_hide && g:netrw_list_hide != ""
|
|
1426 call s:NetrwListHide()
|
|
1427 endif
|
|
1428
|
519
|
1429 if w:netrw_longlist == 1
|
482
|
1430 " do a long listing; these substitutions need to be done prior to sorting
|
|
1431 " call Decho("manipulate long listing")
|
|
1432
|
|
1433 if method == "ftp"
|
|
1434 " cleanup
|
|
1435 exe "keepjumps ".w:netrw_bannercnt
|
|
1436 while getline(".") =~ g:netrw_ftp_browse_reject
|
|
1437 keepjumps d
|
|
1438 endwhile
|
|
1439 " if there's no ../ listed, then put ./ and ../ in
|
|
1440 let line1= line(".")
|
|
1441 keepjumps 1
|
|
1442 silent keepjumps call search('^\.\.\/\%(\s\|$\)','W')
|
|
1443 let line2= line(".")
|
|
1444 if line2 == 0
|
|
1445 exe 'keepjumps '.w:netrw_bannercnt."put='./'"
|
|
1446 exe 'keepjumps '.w:netrw_bannercnt."put='../'"
|
|
1447 endif
|
|
1448 exe "keepjumps ".line1
|
|
1449 keepjumps norm! 0
|
|
1450 endif
|
|
1451
|
559
|
1452 exe 'silent keepjumps '.w:netrw_bannercnt.',$s/ -> .*$//e'
|
|
1453 exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\(\%(\S\+\s\+\)\{7}\S\+\)\s\+\(\S.*\)$/\2\t\1/e'
|
|
1454 exe 'silent keepjumps '.w:netrw_bannercnt
|
482
|
1455 endif
|
|
1456
|
|
1457 if line("$") >= w:netrw_bannercnt
|
|
1458 if g:netrw_sort_by =~ "^n"
|
|
1459 call s:SetSort()
|
519
|
1460 if g:netrw_sort_direction =~ 'n'
|
559
|
1461 exe 'silent keepjumps '.w:netrw_bannercnt.',$sort'
|
482
|
1462 else
|
559
|
1463 exe 'silent keepjumps '.w:netrw_bannercnt.',$sort!'
|
482
|
1464 endif
|
828
|
1465 " remove priority pattern prefix
|
559
|
1466 exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\d\{3}\///e'
|
482
|
1467 endif
|
519
|
1468 if w:netrw_longlist == 1
|
|
1469 " shorten the list to keep its width <= winwidth characters
|
559
|
1470 exe "silent keepjumps ".w:netrw_bannercnt.',$s/\t[-dstrwx]\+/\t/e'
|
482
|
1471 endif
|
|
1472 endif
|
|
1473 endif
|
484
|
1474
|
519
|
1475 call s:NetrwWideListing()
|
|
1476 if line("$") >= w:netrw_bannercnt
|
559
|
1477 " place cursor on the top-left corner of the file listing
|
519
|
1478 exe "keepjumps ".w:netrw_bannercnt
|
559
|
1479 norm! 0
|
519
|
1480 endif
|
482
|
1481
|
484
|
1482 call s:NetOptionRestore()
|
482
|
1483 setlocal nomod noma nonu
|
|
1484
|
|
1485 " call Dret("NetBrowse")
|
|
1486 return
|
|
1487 endfun
|
|
1488
|
|
1489 " ---------------------------------------------------------------------
|
|
1490 " NetBrowseChgDir: {{{2
|
|
1491 fun! s:NetBrowseChgDir(dirname,newdir)
|
|
1492 " call Dfunc("NetBrowseChgDir(dirname<".a:dirname."> newdir<".a:newdir.">)")
|
|
1493
|
|
1494 let dirname= a:dirname
|
|
1495 let newdir = a:newdir
|
|
1496
|
|
1497 if newdir !~ '[\/]$'
|
|
1498 " handling a file
|
|
1499 let dirname= dirname.newdir
|
828
|
1500 let didfile= 0
|
650
|
1501 if g:netrw_browse_split == 1
|
|
1502 new
|
|
1503 wincmd _
|
|
1504 elseif g:netrw_browse_split == 2
|
|
1505 rightb vert new
|
|
1506 wincmd |
|
828
|
1507 else
|
|
1508 " handling a file, didn't split, so possibly remove menu
|
|
1509 call s:NetMenu(0)
|
650
|
1510 endif
|
482
|
1511 " call Decho("handling a file: dirname<".dirname.">")
|
|
1512
|
|
1513 elseif newdir == './'
|
|
1514 " refresh the directory list
|
|
1515 " call Decho("refresh directory listing")
|
719
|
1516 setlocal ma nobl
|
|
1517 if g:netrw_fastbrowse >= 1
|
|
1518 setlocal bh=hide
|
799
|
1519 else
|
|
1520 setlocal bh=delete
|
719
|
1521 endif
|
482
|
1522 %d
|
|
1523
|
|
1524 elseif newdir == '../'
|
|
1525 " go up one directory
|
|
1526 let trailer= substitute(a:dirname,'^\(\w\+://\%(\w\+@\)\=\w\+/\)\(.*\)$','\2','')
|
|
1527
|
|
1528 if trailer =~ '^\%(\.\./\)*$'
|
|
1529 " tack on a ../"
|
|
1530 let dirname= dirname.'../'
|
|
1531
|
|
1532 else
|
|
1533 " strip off a directory name from dirname
|
|
1534 let dirname= substitute(dirname,'^\(.*/\)[^/]\+/','\1','')
|
|
1535 endif
|
|
1536 " call Decho("go up one dir: dirname<".dirname."> trailer<".trailer.">")
|
|
1537
|
|
1538 else
|
|
1539 " go down one directory
|
|
1540 let dirname= dirname.newdir
|
|
1541 " call Decho("go down one dir: dirname<".dirname."> newdir<".newdir.">")
|
|
1542 endif
|
|
1543
|
|
1544 " call Dret("NetBrowseChgDir <".dirname.">")
|
|
1545 return dirname
|
|
1546 endfun
|
|
1547
|
|
1548 " ---------------------------------------------------------------------
|
650
|
1549 " NetGetWord: it gets the directory named under the cursor {{{2
|
482
|
1550 fun! s:NetGetWord()
|
799
|
1551 " call Dfunc("NetGetWord() line#".line(".")." longlist=".g:netrw_longlist." virtcol=".virtcol("."))
|
482
|
1552 call s:UseBufWinVars()
|
|
1553
|
519
|
1554 " insure that w:netrw_longlist is set up
|
|
1555 if !exists("w:netrw_longlist")
|
|
1556 if exists("g:netrw_longlist")
|
|
1557 let w:netrw_longlist= g:netrw_longlist
|
|
1558 else
|
|
1559 let w:netrw_longlist= 0
|
|
1560 endif
|
799
|
1561 " call Decho("w:netrw_longlist=".w:netrw_longlist)
|
519
|
1562 endif
|
|
1563
|
482
|
1564 if exists("w:netrw_bannercnt") && line(".") < w:netrw_bannercnt
|
519
|
1565 " Active Banner support
|
|
1566 " call Decho("active banner handling")
|
|
1567 norm! 0
|
482
|
1568 let dirname= "./"
|
|
1569 let curline= getline(".")
|
|
1570 if curline =~ '"\s*Sorted by\s'
|
|
1571 norm s
|
|
1572 let s:netrw_skipbrowse= 1
|
|
1573 echo 'Pressing "s" also works'
|
|
1574 elseif curline =~ '"\s*Sort sequence:'
|
|
1575 let s:netrw_skipbrowse= 1
|
|
1576 echo 'Press "S" to edit sorting sequence'
|
|
1577 elseif curline =~ '"\s*Quick Help:'
|
|
1578 norm ?
|
|
1579 let s:netrw_skipbrowse= 1
|
|
1580 echo 'Pressing "?" also works'
|
|
1581 elseif curline =~ '"\s*\%(Hiding\|Showing\):'
|
|
1582 norm a
|
|
1583 let s:netrw_skipbrowse= 1
|
|
1584 echo 'Pressing "a" also works'
|
|
1585 elseif line("$") > w:netrw_bannercnt
|
559
|
1586 exe 'silent keepjumps '.w:netrw_bannercnt
|
482
|
1587 endif
|
519
|
1588
|
|
1589 elseif w:netrw_longlist == 0
|
|
1590 " call Decho("thin column handling")
|
|
1591 norm! 0
|
|
1592 let dirname= getline(".")
|
|
1593
|
|
1594 elseif w:netrw_longlist == 1
|
|
1595 " call Decho("long column handling")
|
|
1596 norm! 0
|
|
1597 let dirname= substitute(getline("."),'^\(\%(\S\+\s\)*\S\+\).\{-}$','\1','e')
|
|
1598
|
482
|
1599 else
|
519
|
1600 " call Decho("obtain word from wide listing")
|
482
|
1601 let dirname= getline(".")
|
519
|
1602
|
|
1603 if !exists("b:netrw_cpf")
|
|
1604 let b:netrw_cpf= 0
|
|
1605 exe 'silent keepjumps '.w:netrw_bannercnt.',$g/^./if virtcol("$") > b:netrw_cpf|let b:netrw_cpf= virtcol("$")|endif'
|
|
1606 " call Decho("computed cpf")
|
482
|
1607 endif
|
519
|
1608
|
|
1609 let filestart = (virtcol(".")/b:netrw_cpf)*b:netrw_cpf
|
799
|
1610 " call Decho("filestart= ([virtcol=".virtcol(".")."]/[b:netrw_cpf=".b:netrw_cpf."])*b:netrw_cpf=".filestart." bannercnt=".w:netrw_bannercnt)
|
519
|
1611 " call Decho("1: dirname<".dirname.">")
|
|
1612 if filestart > 0|let dirname= substitute(dirname,'^.\{'.filestart.'}','','')|endif
|
|
1613 " call Decho("2: dirname<".dirname.">")
|
|
1614 let dirname = substitute(dirname,'^\(.\{'.b:netrw_cpf.'}\).*$','\1','e')
|
|
1615 " call Decho("3: dirname<".dirname.">")
|
|
1616 let dirname = substitute(dirname,'\s\+$','','e')
|
|
1617 " call Decho("4: dirname<".dirname.">")
|
482
|
1618 endif
|
519
|
1619
|
482
|
1620 " call Dret("NetGetWord <".dirname.">")
|
|
1621 return dirname
|
|
1622 endfun
|
|
1623
|
|
1624 " ---------------------------------------------------------------------
|
|
1625 " NetBrowseRm: remove/delete a remote file or directory {{{2
|
|
1626 fun! s:NetBrowseRm(usrhost,path) range
|
799
|
1627 " call Dfunc("NetBrowseRm(usrhost<".a:usrhost."> path<".a:path.">) virtcol=".virtcol("."))
|
482
|
1628 " call Decho("firstline=".a:firstline." lastline=".a:lastline)
|
|
1629
|
|
1630 " preparation for removing multiple files/directories
|
|
1631 let ctr= a:firstline
|
|
1632 let all= 0
|
|
1633
|
|
1634 " remove multiple files and directories
|
|
1635 while ctr <= a:lastline
|
|
1636 exe ctr
|
|
1637
|
|
1638 let rmfile= s:NetGetWord()
|
|
1639 " call Decho("rmfile<".rmfile.">")
|
|
1640
|
|
1641 if rmfile !~ '^"' && (rmfile =~ '@$' || rmfile !~ '[\/]$')
|
|
1642 " attempt to remove file
|
|
1643 if !all
|
|
1644 echohl Statement
|
|
1645 call inputsave()
|
|
1646 let ok= input("Confirm deletion of file<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ")
|
|
1647 call inputrestore()
|
|
1648 echohl NONE
|
559
|
1649 if ok == ""
|
|
1650 let ok="no"
|
|
1651 endif
|
482
|
1652 let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e')
|
|
1653 if ok =~ 'a\%[ll]'
|
|
1654 let all= 1
|
|
1655 endif
|
|
1656 endif
|
|
1657
|
|
1658 if all || ok =~ 'y\%[es]' || ok == ""
|
|
1659 if exists("w:netrw_method") && (w:netrw_method == 2 || w:netrw_method == 3)
|
|
1660 silent! keepjumps .,$d
|
|
1661 call s:NetBrowseFtpCmd(a:path,"delete ".rmfile)
|
|
1662 else
|
|
1663 let netrw_rm_cmd= substitute(g:netrw_rm_cmd,'HOSTNAME',a:usrhost,'').' "'.escape(a:path.rmfile,s:netrw_cd_escape).'"'
|
|
1664 " call Decho("attempt to remove file: system(".netrw_rm_cmd.")")
|
|
1665 let ret= system(netrw_rm_cmd)
|
|
1666 " call Decho("returned=".ret." errcode=".v:shell_error)
|
|
1667 endif
|
|
1668 elseif ok =~ 'q\%[uit]'
|
|
1669 break
|
|
1670 endif
|
719
|
1671
|
482
|
1672 else
|
|
1673 " attempt to remove directory
|
|
1674 if !all
|
|
1675 call inputsave()
|
|
1676 let ok= input("Confirm deletion of directory<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ")
|
|
1677 call inputrestore()
|
559
|
1678 if ok == ""
|
|
1679 let ok="no"
|
|
1680 endif
|
482
|
1681 let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e')
|
|
1682 if ok =~ 'a\%[ll]'
|
|
1683 let all= 1
|
|
1684 endif
|
|
1685 endif
|
|
1686
|
|
1687 if all || ok =~ 'y\%[es]' || ok == ""
|
|
1688 if exists("w:netrw_method") && (w:netrw_method == 2 || w:netrw_method == 3)
|
|
1689 call s:NetBrowseFtpCmd(a:path,"rmdir ".rmfile)
|
|
1690 else
|
|
1691 let rmfile = a:path.rmfile
|
|
1692 let netrw_rmdir_cmd= substitute(g:netrw_rmdir_cmd,'HOSTNAME',a:usrhost,'').' '."'".'"'.rmfile.'"'."'"
|
|
1693 " call Decho("attempt to remove dir: system(".netrw_rmdir_cmd.")")
|
|
1694 let ret= system(netrw_rmdir_cmd)
|
|
1695 " call Decho("returned=".ret." errcode=".v:shell_error)
|
|
1696
|
|
1697 if v:shell_error != 0
|
|
1698 let netrw_rmf_cmd= substitute(g:netrw_rmf_cmd,'HOSTNAME',a:usrhost,'').' '.substitute(rmfile,'[\/]$','','e')
|
|
1699 " call Decho("2nd attempt to remove dir: system(".netrw_rmf_cmd.")")
|
|
1700 let ret= system(netrw_rmf_cmd)
|
|
1701 " call Decho("returned=".ret." errcode=".v:shell_error)
|
719
|
1702
|
482
|
1703 if v:shell_error != 0 && !exists("g:netrw_quiet")
|
|
1704 echohl Error | echo "***netrw*** unable to remove directory<".rmfile."> -- is it empty?" | echohl None
|
|
1705 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
1706 endif
|
|
1707 endif
|
|
1708 endif
|
|
1709
|
|
1710 elseif ok =~ 'q\%[uit]'
|
|
1711 break
|
|
1712 endif
|
|
1713 endif
|
|
1714
|
|
1715 let ctr= ctr + 1
|
|
1716 endwhile
|
|
1717
|
|
1718 " refresh the directory
|
|
1719 let curline= line(".")-1
|
|
1720 " call Decho("refresh the directory")
|
650
|
1721 call s:NetBrowse(s:NetBrowseChgDir(expand("%"),'./'))
|
482
|
1722 exe curline
|
|
1723
|
|
1724 " call Dret("NetBrowseRm")
|
|
1725 endfun
|
|
1726
|
|
1727 " ---------------------------------------------------------------------
|
|
1728 " NetBrowseRename: rename a remote file or directory {{{2
|
|
1729 fun! s:NetBrowseRename(usrhost,path) range
|
|
1730 " call Dfunc("NetBrowseRename(usrhost<".a:usrhost."> path<".a:path.">)")
|
|
1731
|
|
1732 " preparation for removing multiple files/directories
|
|
1733 let ctr = a:firstline
|
|
1734 let rename_cmd = substitute(g:netrw_rename_cmd,'\<HOSTNAME\>',a:usrhost,'')
|
|
1735
|
|
1736 " attempt to rename files/directories
|
|
1737 while ctr <= a:lastline
|
|
1738 exe "keepjumps ".ctr
|
|
1739
|
|
1740 norm! 0
|
|
1741 let oldname= s:NetGetWord()
|
|
1742 " call Decho("oldname<".oldname.">")
|
|
1743
|
|
1744 call inputsave()
|
|
1745 let newname= input("Moving ".oldname." to : ",oldname)
|
|
1746 call inputrestore()
|
|
1747
|
|
1748 if exists("w:netrw_method") && (w:netrw_method == 2 || w:netrw_method == 3)
|
|
1749 call s:NetBrowseFtpCmd(a:path,"rename ".oldname." ".newname)
|
|
1750 else
|
|
1751 let oldname= a:path.oldname
|
|
1752 let newname= a:path.newname
|
|
1753 " call Decho("system(rename_cmd".' "'.escape(oldname," ").'" "'.escape(newname,s:netrw_cd_escape).'"')
|
|
1754 let ret= system(rename_cmd.' "'.escape(oldname,s:netrw_cd_escape).'" "'.escape(newname,s:netrw_cd_escape).'"')
|
|
1755 endif
|
|
1756
|
|
1757 let ctr= ctr + 1
|
|
1758 endwhile
|
|
1759
|
|
1760 " refresh the directory
|
|
1761 let curline= line(".")
|
650
|
1762 call s:NetBrowse(s:NetBrowseChgDir(expand("%"),'./'))
|
482
|
1763 exe "keepjumps ".curline
|
|
1764 " call Dret("NetBrowseRename")
|
|
1765 endfun
|
|
1766
|
|
1767 " ---------------------------------------------------------------------
|
|
1768 " NetRefresh: {{{2
|
559
|
1769 fun! s:NetRefresh(dirname,islocal)
|
|
1770 " call Dfunc("NetRefresh(dirname<".a:dirname.">,islocal=".a:islocal.")")
|
|
1771 call netrw#NetSavePosn()
|
482
|
1772 set ma
|
|
1773 %d
|
559
|
1774 if a:islocal
|
|
1775 call s:LocalBrowse(a:dirname)
|
|
1776 else
|
|
1777 call s:NetBrowse(a:dirname)
|
|
1778 endif
|
|
1779 call netrw#NetRestorePosn()
|
482
|
1780 redraw!
|
|
1781 " call Dret("NetRefresh")
|
|
1782 endfun
|
|
1783
|
|
1784 " ---------------------------------------------------------------------
|
|
1785 " NetSplit: mode {{{2
|
|
1786 " =0 : net and o
|
|
1787 " =1 : net and v
|
|
1788 " =2 : local and o
|
|
1789 " =3 : local and v
|
|
1790 fun! s:NetSplit(mode)
|
650
|
1791 " call Dfunc("NetSplit(mode=".a:mode.") alto=".g:netrw_alto." altv=".g:netrw_altv)
|
482
|
1792
|
|
1793 call s:SaveWinVars()
|
|
1794 if a:mode == 0
|
|
1795 exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s"
|
|
1796 call s:CopyWinVars()
|
|
1797 exe "norm! 0"
|
650
|
1798 call s:NetBrowse(s:NetBrowseChgDir(expand("%"),s:NetGetWord()))
|
482
|
1799 elseif a:mode ==1
|
|
1800 exe (g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v"
|
|
1801 call s:CopyWinVars()
|
|
1802 exe "norm! 0"
|
650
|
1803 call s:NetBrowse(s:NetBrowseChgDir(expand("%"),s:NetGetWord()))
|
482
|
1804 elseif a:mode ==2
|
|
1805 exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s"
|
|
1806 call s:CopyWinVars()
|
|
1807 exe "norm! 0"
|
650
|
1808 call s:LocalBrowse(s:LocalBrowseChgDir(b:netrw_curdir,s:NetGetWord()))
|
482
|
1809 else
|
|
1810 exe (g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v"
|
|
1811 call s:CopyWinVars()
|
|
1812 exe "norm! 0"
|
650
|
1813 call s:LocalBrowse(s:LocalBrowseChgDir(b:netrw_curdir,s:NetGetWord()))
|
482
|
1814 endif
|
|
1815
|
|
1816 " call Dret("NetSplit")
|
|
1817 endfun
|
|
1818
|
|
1819 " ---------------------------------------------------------------------
|
|
1820 " NetBrowseX: allows users to write custom functions to operate on {{{2
|
|
1821 " files given their extension. Passes 0=local, 1=remote
|
650
|
1822 fun! netrw#NetBrowseX(fname,remote)
|
|
1823 " call Dfunc("NetBrowseX(fname<".a:fname."> remote=".a:remote.")")
|
482
|
1824
|
|
1825 " set up the filename
|
|
1826 " (lower case the extension, make a local copy of a remote file)
|
|
1827 let exten= substitute(a:fname,'.*\.\(.\{-}\)','\1','e')
|
|
1828 if has("win32") || has("win95") || has("win64") || has("win16")
|
|
1829 let exten= substitute(exten,'^.*$','\L&\E','')
|
|
1830 endif
|
|
1831 let fname= escape(a:fname,"%#")
|
|
1832 " call Decho("fname<".fname."> after escape()")
|
|
1833
|
650
|
1834 " seems kde systems often have gnome-open due to dependencies, even though
|
|
1835 " gnome-open's subsidiary display tools are largely absent. Kde systems
|
719
|
1836 " usually have "kdeinit" running, though... (tnx Mikolaj Machowski)
|
|
1837 if !exists("s:haskdeinit")
|
650
|
1838 if has("unix")
|
719
|
1839 silent! let s:haskdeinit= system('ps -e') =~ 'kdeinit'
|
650
|
1840 if v:shell_error
|
719
|
1841 let s:haskdeinit = 0
|
650
|
1842 endif
|
|
1843 else
|
719
|
1844 let s:haskdeinit= 0
|
650
|
1845 endif
|
719
|
1846 " call Decho("setting s:haskdeinit=".s:haskdeinit)
|
650
|
1847 endif
|
|
1848
|
482
|
1849 if a:remote == 1
|
|
1850 " create a local copy
|
|
1851 let fname= tempname().".".exten
|
719
|
1852 " call Decho("a:remote==1: create a local copy of <".a:fname."> as <".fname.">")
|
559
|
1853 exe "silent keepjumps bot 1new ".a:fname
|
482
|
1854 set bh=delete
|
|
1855 exe "w! ".fname
|
|
1856 q
|
|
1857 endif
|
559
|
1858 " call Decho("exten<".exten."> "."netrwFileHandlers#NFH_".exten."():exists=".exists("*netrwFileHandlers#NFH_".exten))
|
482
|
1859
|
|
1860 " set up redirection
|
|
1861 if &srr =~ "%s"
|
615
|
1862 let redir= substitute(&srr,"%s","/dev/null","")
|
482
|
1863 else
|
|
1864 let redir= &srr . "/dev/null"
|
|
1865 endif
|
719
|
1866 " call Decho("redir{".redir."} srr{".&srr."}")
|
482
|
1867
|
650
|
1868 if exists("g:netrw_browsex_viewer") && executable(g:netrw_browsex_viewer)
|
719
|
1869 " call Decho("g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">")
|
650
|
1870 if g:netrw_browsex_viewer == '-'
|
719
|
1871 let ret= netrwFileHandlers#Invoke(exten,fname)
|
650
|
1872 else
|
|
1873 " call Decho("exe silent !".g:netrw_browsex_viewer." '".escape(fname,'%#')."' ".redir)
|
|
1874 exe "silent !".g:netrw_browsex_viewer." '".escape(fname,'%#')."'".redir
|
|
1875 let ret= v:shell_error
|
|
1876 endif
|
|
1877
|
482
|
1878 " execute the file handler
|
650
|
1879 elseif has("win32") || has("win64")
|
482
|
1880 " call Decho('exe silent !start rundll32 url.dll,FileProtocolHandler "'.escape(fname, '%#').'"')
|
|
1881 exe 'silent !start rundll32 url.dll,FileProtocolHandler "'.escape(fname, '%#').'"'
|
|
1882 let ret= v:shell_error
|
|
1883
|
719
|
1884 elseif has("unix") && executable("gnome-open") && !s:haskdeinit
|
559
|
1885 " call Decho("exe silent !gnome-open '".escape(fname,'%#')."' ".redir)
|
|
1886 exe "silent !gnome-open '".escape(fname,'%#')."'".redir
|
|
1887 let ret= v:shell_error
|
|
1888
|
719
|
1889 elseif has("unix") && executable("kfmclient") && s:haskdeinit
|
557
|
1890 " call Decho("exe silent !kfmclient exec '".escape(fname,'%#')."' ".redir)
|
|
1891 exe "silent !kfmclient exec '".escape(fname,'%#')."' ".redir
|
|
1892 let ret= v:shell_error
|
|
1893
|
559
|
1894 else
|
719
|
1895 " netrwFileHandlers#Invoke() always returns 0
|
|
1896 let ret= netrwFileHandlers#Invoke(exten,fname)
|
482
|
1897 endif
|
719
|
1898
|
|
1899 " if unsuccessful, attempt netrwFileHandlers#Invoke()
|
|
1900 if ret
|
|
1901 let ret= netrwFileHandlers#Invoke(exten,fname)
|
|
1902 endif
|
|
1903
|
482
|
1904 redraw!
|
|
1905
|
|
1906 " cleanup: remove temporary file,
|
|
1907 " delete current buffer if success with handler,
|
|
1908 " return to prior buffer (directory listing)
|
|
1909 if a:remote == 1 && fname != a:fname
|
|
1910 " call Decho("deleting temporary file<".fname.">")
|
|
1911 call delete(fname)
|
|
1912 endif
|
|
1913
|
|
1914 if a:remote == 1
|
|
1915 set bh=delete bt=nofile noswf
|
|
1916 exe "norm! \<c-o>"
|
|
1917 redraw!
|
|
1918 endif
|
|
1919
|
|
1920 " call Dret("NetBrowseX")
|
|
1921 endfun
|
|
1922
|
|
1923 " ---------------------------------------------------------------------
|
|
1924 " NetBrowseFtpCmd: unfortunately, not all ftp servers honor options for ls {{{2
|
|
1925 " This function assumes that a long listing will be received. Size, time,
|
|
1926 " and reverse sorts will be requested of the server but not otherwise
|
|
1927 " enforced here.
|
829
|
1928 fun! s:NetBrowseFtpCmd(path,listcmd)
|
|
1929 " call Dfunc("NetBrowseFtpCmd(path<".a:path."> listcmd<".a:listcmd.">) netrw_method=".w:netrw_method)
|
482
|
1930
|
|
1931 " because WinXX ftp uses unix style input
|
|
1932 " curline is one more than the bannercnt in order to account
|
|
1933 " for the unwanted first blank line (doing a :put to an empty
|
|
1934 " buffer yields a blank first line)
|
|
1935 let ffkeep= &ff
|
|
1936 setlocal ma ff=unix
|
|
1937 let curline= w:netrw_bannercnt+1
|
|
1938 exe "silent! keepjumps ".curline.",$d"
|
|
1939
|
519
|
1940 ".........................................
|
|
1941 if w:netrw_method == 2 || w:netrw_method == 5
|
482
|
1942 " ftp + <.netrc>: Method #2
|
|
1943 if a:path != ""
|
559
|
1944 put ='cd \"'.a:path.'\"'
|
|
1945 " call Decho('ftp: '.getline("."))
|
482
|
1946 endif
|
829
|
1947 exe "put ='".a:listcmd."'"
|
559
|
1948 " call Decho("ftp: ".getline("."))
|
482
|
1949 " redraw!|call inputsave()|call input("Pausing...")|call inputrestore()
|
|
1950 if exists("g:netrw_port") && g:netrw_port != ""
|
|
1951 " call Decho("exe ".g:netrw_silentxfer.curline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port)
|
|
1952 exe g:netrw_silentxfer.curline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port
|
|
1953 else
|
|
1954 " call Decho("exe ".g:netrw_silentxfer.curline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine)
|
|
1955 exe g:netrw_silentxfer.curline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine
|
|
1956 endif
|
|
1957
|
|
1958 ".........................................
|
|
1959 elseif w:netrw_method == 3
|
|
1960 " ftp + machine,id,passwd,filename: Method #3
|
|
1961 setlocal ff=unix
|
|
1962 if exists("g:netrw_port") && g:netrw_port != ""
|
|
1963 put ='open '.g:netrw_machine.' '.g:netrw_port
|
|
1964 else
|
|
1965 put ='open '.g:netrw_machine
|
|
1966 endif
|
719
|
1967
|
482
|
1968 if exists("g:netrw_ftp") && g:netrw_ftp == 1
|
|
1969 put =g:netrw_uid
|
559
|
1970 put ='\"'.g:netrw_passwd.'\"'
|
482
|
1971 else
|
559
|
1972 put ='user \"'.g:netrw_uid.'\" \"'.g:netrw_passwd.'\"'
|
482
|
1973 endif
|
719
|
1974
|
482
|
1975 if a:path != ""
|
559
|
1976 put ='cd \"'.a:path.'\"'
|
482
|
1977 endif
|
829
|
1978 exe "put ='".a:listcmd."'"
|
719
|
1979
|
482
|
1980 " perform ftp:
|
|
1981 " -i : turns off interactive prompting from ftp
|
|
1982 " -n unix : DON'T use <.netrc>, even though it exists
|
|
1983 " -n win32: quit being obnoxious about password
|
|
1984 " call Decho("exe ".g:netrw_silentxfer.curline.",$!".g:netrw_ftp_cmd." -i -n")
|
|
1985 exe g:netrw_silentxfer.curline.",$!".g:netrw_ftp_cmd." -i -n"
|
|
1986
|
|
1987 ".........................................
|
|
1988 else
|
|
1989 echo "***warning*** unable to comply with your request<" . choice . ">"
|
|
1990 endif
|
|
1991
|
|
1992 " cleanup for Windows
|
|
1993 if has("win32") || has("win95") || has("win64") || has("win16")
|
559
|
1994 silent! keepjumps! %s/\r$//e
|
482
|
1995 endif
|
829
|
1996 if a:listcmd == "dir"
|
482
|
1997 " infer directory/link based on the file permission string
|
559
|
1998 silent! keepjumps g/d\%([-r][-w][-x]\)\{3}/s@$@/@
|
|
1999 silent! keepjumps g/l\%([-r][-w][-x]\)\{3}/s/$/@/
|
519
|
2000 if w:netrw_longlist == 0 || w:netrw_longlist == 2
|
559
|
2001 exe "silent! keepjumps ".curline.',$s/^\%(\S\+\s\+\)\{8}//e'
|
482
|
2002 endif
|
|
2003 endif
|
|
2004
|
484
|
2005 " ftp's ls doesn't seem to include ./ or ../
|
|
2006 if !search('^\.\/$','wn')
|
|
2007 exe 'keepjumps '.curline
|
|
2008 if a:path !~ '^$'
|
|
2009 put ='../'
|
|
2010 endif
|
|
2011 put ='./'
|
|
2012 exe 'keepjumps '.curline
|
|
2013 endif
|
|
2014
|
482
|
2015 " restore settings
|
|
2016 let &ff= ffkeep
|
|
2017 " call Dret("NetBrowseFtpCmd")
|
|
2018 endfun
|
|
2019
|
|
2020 " ---------------------------------------------------------------------
|
|
2021 " NetrwListHide: uses [range]g~...~d to delete files that match comma {{{2
|
|
2022 " separated patterns given in g:netrw_list_hide
|
|
2023 fun! s:NetrwListHide()
|
559
|
2024 " call Dfunc("NetrwListHide() hide=".g:netrw_hide." listhide<".g:netrw_list_hide.">")
|
482
|
2025
|
|
2026 let listhide= g:netrw_list_hide
|
|
2027 while listhide != ""
|
|
2028 if listhide =~ ','
|
|
2029 let hide = substitute(listhide,',.*$','','e')
|
|
2030 let listhide = substitute(listhide,'^.\{-},\(.*\)$','\1','e')
|
|
2031 else
|
|
2032 let hide = listhide
|
|
2033 let listhide= ""
|
|
2034 endif
|
|
2035
|
|
2036 " Prune the list by hiding any files which match
|
|
2037 if g:netrw_hide == 1
|
559
|
2038 " call Decho("hiding<".hide."> listhide<".listhide.">")
|
|
2039 " call Decho('exe silent keepjumps '.w:netrw_bannercnt.',$g~'.hide.'~d')
|
|
2040 exe 'silent keepjumps '.w:netrw_bannercnt.',$g~'.hide.'~d'
|
482
|
2041 elseif g:netrw_hide == 2
|
559
|
2042 " call Decho("showing<".hide."> listhide<".listhide.">")
|
|
2043 " call Decho('exe silent keepjumps '.w:netrw_bannercnt.',$v~'.hide.'~d')
|
|
2044 exe 'silent keepjumps '.w:netrw_bannercnt.',$v~'.hide.'~d'
|
482
|
2045 endif
|
|
2046 endwhile
|
|
2047
|
|
2048 " call Dret("NetrwListHide")
|
|
2049 endfun
|
|
2050
|
|
2051 " ---------------------------------------------------------------------
|
|
2052 " NetHideEdit: allows user to edit the file/directory hiding list
|
559
|
2053 fun! s:NetHideEdit(islocal)
|
|
2054 " call Dfunc("NetHideEdit(islocal=".a:islocal.")")
|
|
2055
|
|
2056 " get new hiding list from user
|
482
|
2057 call inputsave()
|
|
2058 let newhide= input("Edit Hiding List: ",g:netrw_list_hide)
|
|
2059 call inputrestore()
|
559
|
2060 let g:netrw_list_hide= newhide
|
|
2061 " call Decho("new g:netrw_list_hide<".g:netrw_list_hide.">")
|
482
|
2062
|
|
2063 " refresh the listing
|
559
|
2064 if a:islocal == 0
|
482
|
2065 silent call s:NetBrowse(s:NetBrowseChgDir(expand("%"),'./'))
|
|
2066 else
|
650
|
2067 silent call s:NetRefresh(s:LocalBrowseChgDir(b:netrw_curdir,"./"),a:islocal)
|
482
|
2068 endif
|
|
2069
|
|
2070 " call Dret("NetHideEdit")
|
|
2071 endfun
|
|
2072
|
|
2073 " ---------------------------------------------------------------------
|
|
2074 " NetSortSequence: allows user to edit the sorting sequence
|
|
2075 fun! s:NetSortSequence(mode)
|
|
2076 " call Dfunc("NetSortSequence(mode=".a:mode.")")
|
|
2077
|
|
2078 call inputsave()
|
|
2079 let newsortseq= input("Edit Sorting Sequence: ",g:netrw_sort_sequence)
|
|
2080 call inputrestore()
|
|
2081
|
|
2082 " refresh the listing
|
|
2083 let g:netrw_sort_sequence= newsortseq
|
|
2084 if a:mode == 0
|
|
2085 silent call s:NetBrowse(s:NetBrowseChgDir(expand("%"),'./'))
|
|
2086 else
|
650
|
2087 silent call s:LocalBrowse(s:LocalBrowseChgDir(b:netrw_curdir,"./"))
|
482
|
2088 endif
|
|
2089
|
|
2090 " call Dret("NetSortSequence")
|
|
2091 endfun
|
|
2092
|
|
2093 " ---------------------------------------------------------------------
|
|
2094 " NetLongList: {{{2
|
|
2095 fun! s:NetLongList(mode)
|
519
|
2096 " call Dfunc("NetLongList(mode=".a:mode.") netrw_longlist=".w:netrw_longlist)
|
|
2097 let fname = s:NetGetWord()
|
|
2098 let w:netrw_longlist = (w:netrw_longlist + 1) % 3
|
|
2099 " call Decho("fname<".fname.">")
|
|
2100
|
|
2101 if w:netrw_longlist == 0
|
|
2102 " use one column listing
|
|
2103 " call Decho("use one column list")
|
482
|
2104 let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge')
|
|
2105
|
519
|
2106 elseif w:netrw_longlist == 1
|
|
2107 " use long list
|
|
2108 " call Decho("use long list")
|
|
2109 let g:netrw_list_cmd = g:netrw_list_cmd." -l"
|
|
2110
|
482
|
2111 else
|
519
|
2112 " give wide list
|
|
2113 " call Decho("use wide list")
|
|
2114 let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge')
|
482
|
2115 endif
|
|
2116 setlocal ma
|
|
2117
|
|
2118 " clear buffer - this will cause NetBrowse/LocalBrowse to do a refresh
|
|
2119 %d
|
|
2120
|
|
2121 " refresh the listing
|
|
2122 if a:mode == 0
|
650
|
2123 silent call s:NetBrowse(s:NetBrowseChgDir(expand("%"),"./"))
|
482
|
2124 else
|
650
|
2125 silent call s:LocalBrowse(s:LocalBrowseChgDir(b:netrw_curdir,"./"))
|
482
|
2126 endif
|
|
2127
|
519
|
2128 " keep cursor on the filename
|
|
2129 silent keepjumps $
|
|
2130 if fname =~ '/$'
|
|
2131 silent call search('\%(^\|\s\{2,}\)\zs'.escape(fname,'.\[]*$^').'\%(\s\{2,}\|$\)','bW')
|
|
2132 else
|
|
2133 silent call search('\%(^\|\s\{2,}\)\zs'.escape(fname,'.\[]*$^').'\%(\s\{2,}\|$\)','bW')
|
|
2134 endif
|
|
2135
|
|
2136 " call Dret("NetLongList : w:netrw_longlist=".w:netrw_longlist)
|
|
2137 endfun
|
|
2138
|
|
2139 " ---------------------------------------------------------------------
|
|
2140 " NetrwWideListing: {{{2
|
|
2141 fun! s:NetrwWideListing()
|
|
2142
|
|
2143 if w:netrw_longlist == 2
|
829
|
2144 " call Dfunc("NetrwWideListing() w:netrw_longlist=".w:netrw_longlist)
|
519
|
2145 " look for longest filename (cpf=characters per filename)
|
|
2146 " cpf: characters per file
|
|
2147 " fpl: files per line
|
|
2148 " fpc: files per column
|
|
2149 set ma
|
|
2150 let b:netrw_cpf= 0
|
|
2151 if line("$") >= w:netrw_bannercnt
|
|
2152 exe 'silent keepjumps '.w:netrw_bannercnt.',$g/^./if virtcol("$") > b:netrw_cpf|let b:netrw_cpf= virtcol("$")|endif'
|
839
|
2153 else
|
|
2154 " call Dret("NetrwWideListing")
|
|
2155 return
|
|
2156 endif
|
519
|
2157 " call Decho("max file strlen+1=".b:netrw_cpf)
|
|
2158 let b:netrw_cpf= b:netrw_cpf + 1
|
|
2159
|
|
2160 " determine qty files per line (fpl)
|
|
2161 let w:netrw_fpl= winwidth(0)/b:netrw_cpf
|
719
|
2162 if w:netrw_fpl <= 0
|
|
2163 let w:netrw_fpl= 1
|
|
2164 endif
|
519
|
2165 " call Decho("fpl= ".winwidth(0)."/[b:netrw_cpf=".b:netrw_cpf.']='.w:netrw_fpl)
|
|
2166
|
|
2167 " make wide display
|
839
|
2168 exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^.*$/\=printf("%-'.b:netrw_cpf.'s",escape(submatch(0),"\\"))/'
|
519
|
2169 let fpc = (line("$") - w:netrw_bannercnt + w:netrw_fpl)/w:netrw_fpl
|
|
2170 let newcolstart = w:netrw_bannercnt + fpc
|
|
2171 let newcolend = newcolstart + fpc - 1
|
|
2172 " call Decho("bannercnt=".w:netrw_bannercnt." fpl=".w:netrw_fpl." fpc=".fpc." newcol[".newcolstart.",".newcolend."]")
|
|
2173 while line("$") >= newcolstart
|
|
2174 if newcolend > line("$") | let newcolend= line("$") | endif
|
|
2175 let newcolqty= newcolend - newcolstart
|
|
2176 exe newcolstart
|
|
2177 if newcolqty == 0
|
|
2178 exe "silent keepjumps norm! 0\<c-v>$hx".w:netrw_bannercnt."G$p"
|
|
2179 else
|
|
2180 exe "silent keepjumps norm! 0\<c-v>".newcolqty.'j$hx'.w:netrw_bannercnt.'G$p'
|
|
2181 endif
|
|
2182 exe "silent keepjumps ".newcolstart.','.newcolend.'d'
|
559
|
2183 exe 'silent keepjumps '.w:netrw_bannercnt
|
519
|
2184 endwhile
|
|
2185 exe "silent keepjumps ".w:netrw_bannercnt.',$s/\s\+$//e'
|
559
|
2186 setlocal noma nomod
|
829
|
2187 " call Dret("NetrwWideListing")
|
519
|
2188 endif
|
|
2189
|
482
|
2190 endfun
|
|
2191
|
|
2192 " ---------------------------------------------------------------------
|
|
2193 " NetSaveWordPosn: used by the "s" command in both remote and local {{{2
|
|
2194 " browsing. Along with NetRestoreWordPosn(), it keeps the cursor on
|
|
2195 " the same word even though the sorting has changed its order of appearance.
|
|
2196 fun! s:NetSaveWordPosn()
|
|
2197 " call Dfunc("NetSaveWordPosn()")
|
|
2198 let s:netrw_saveword= '^'.escape(getline("."),s:netrw_cd_escape).'$'
|
|
2199 " call Dret("NetSaveWordPosn : saveword<".s:netrw_saveword.">")
|
|
2200 endfun
|
|
2201
|
|
2202 " ---------------------------------------------------------------------
|
|
2203 " NetRestoreWordPosn: used by the "s" command; see NetSaveWordPosn() above {{{2
|
|
2204 fun! s:NetRestoreWordPosn()
|
|
2205 " call Dfunc("NetRestoreWordPosn()")
|
|
2206 silent! call search(s:netrw_saveword,'w')
|
|
2207 " call Dret("NetRestoreWordPosn")
|
|
2208 endfun
|
|
2209
|
|
2210 " ---------------------------------------------------------------------
|
|
2211 " NetMakeDir: this function makes a directory (both local and remote) {{{2
|
|
2212 fun! s:NetMakeDir(usrhost)
|
|
2213 " call Dfunc("NetMakeDir(usrhost<".a:usrhost.">)")
|
|
2214
|
|
2215 " get name of new directory from user. A bare <CR> will skip.
|
|
2216 " if its currently a directory, also request will be skipped, but with
|
|
2217 " a message.
|
|
2218 call inputsave()
|
|
2219 let newdirname= input("Please give directory name: ")
|
|
2220 call inputrestore()
|
|
2221 " call Decho("newdirname<".newdirname.">")
|
|
2222
|
|
2223 if newdirname == ""
|
|
2224 " call Dret("NetMakeDir : user aborted with bare <cr>")
|
|
2225 return
|
|
2226 endif
|
|
2227
|
|
2228 if a:usrhost == ""
|
|
2229
|
|
2230 " Local mkdir:
|
|
2231 " sanity checks
|
|
2232 let fullnewdir= b:netrw_curdir.'/'.newdirname
|
|
2233 " call Decho("fullnewdir<".fullnewdir.">")
|
|
2234 if isdirectory(fullnewdir)
|
|
2235 if !exists("g:netrw_quiet")
|
|
2236 echohl WarningMsg | echo "***netrw*** <".newdirname."> is already a directory!" | echohl None
|
|
2237 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
2238 endif
|
|
2239 " call Dret("NetMakeDir : directory<".newdirname."> exists previously")
|
|
2240 return
|
|
2241 endif
|
|
2242 if filereadable(fullnewdir)
|
|
2243 if !exists("g:netrw_quiet")
|
|
2244 echohl WarningMsg | echo "***netrw*** <".newdirname."> is already a file!" | echohl None
|
|
2245 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
2246 endif
|
|
2247 " call Dret("NetMakeDir : file<".newdirname."> exists previously")
|
|
2248 return
|
|
2249 endif
|
|
2250
|
|
2251 " requested new local directory is neither a pre-existing file or
|
|
2252 " directory, so make it!
|
|
2253 if exists("*mkdir")
|
|
2254 call mkdir(fullnewdir,"p")
|
|
2255 else
|
|
2256 let netrw_origdir= s:NetGetcwd(1)
|
839
|
2257 exe 'keepjumps cd '.b:netrw_curdir
|
|
2258 " call Decho("netrw_origdir<".netrw_origdir.">: cd b:netrw_curdir<".b:netrw_curdir.">")
|
482
|
2259 " call Decho("exe silent! !".g:netrw_local_mkdir.' "'.newdirname.'"')
|
|
2260 exe "silent! !".g:netrw_local_mkdir.' "'.newdirname.'"'
|
|
2261 if !g:netrw_keepdir | exe 'keepjumps cd '.netrw_origdir | endif
|
839
|
2262 if !g:netrw_keepdir
|
|
2263 exe 'keepjumps cd '.netrw_origdir
|
|
2264 " call Decho("netrw_keepdir=".g:netrw_keepdir.": cd ".netrw_origdir)
|
|
2265 endif
|
482
|
2266 endif
|
|
2267
|
|
2268 if v:shell_error == 0
|
|
2269 " refresh listing
|
|
2270 " call Decho("refresh listing")
|
|
2271 let linenum= line(".")
|
|
2272 norm! H0
|
|
2273 let hline = line(".")
|
|
2274 set ma|norm! 2D
|
|
2275 call s:LocalBrowse(s:LocalBrowseChgDir(b:netrw_curdir,'./'))
|
|
2276 exe "norm! ".hline."G0z\<CR>"
|
|
2277 exe linenum
|
|
2278 elseif !exists("g:netrw_quiet")
|
|
2279 echohl Error | echo "***netrw*** unable to make directory<".newdirname.">" | echohl None
|
|
2280 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
2281 endif
|
|
2282 redraw!
|
|
2283
|
|
2284 else
|
|
2285 " Remote mkdir:
|
|
2286 let mkdircmd = substitute(g:netrw_mkdir_cmd,'\<HOSTNAME\>',a:usrhost,'')
|
|
2287 let newdirname= "'".'"'.substitute(expand("%"),'^\%(.\{-}/\)\{3}\(.*\)$','\1','').newdirname.'"'."'"
|
|
2288 " call Decho("exe silent! !".mkdircmd." ".newdirname)
|
|
2289 exe "silent! !".mkdircmd." ".newdirname
|
|
2290 if v:shell_error == 0
|
|
2291 " refresh listing
|
|
2292 let linenum= line(".")
|
|
2293 norm! H0
|
|
2294 let hline = line(".")
|
|
2295 call s:NetBrowse(s:NetBrowseChgDir(expand("%"),'./'))
|
|
2296 exe "norm! ".hline."G0z\<CR>"
|
|
2297 exe linenum
|
|
2298 elseif !exists("g:netrw_quiet")
|
|
2299 echohl Error | echo "***netrw*** unable to make directory<".newdirname.">" | echohl None
|
|
2300 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
2301 endif
|
|
2302 redraw!
|
|
2303 endif
|
719
|
2304
|
482
|
2305 " call Dret("NetMakeDir")
|
|
2306 endfun
|
|
2307
|
|
2308 " ---------------------------------------------------------------------
|
|
2309 " NetBookmarkDir: {{{2
|
|
2310 " 0: (user: <b>) bookmark current directory
|
|
2311 " 1: (user: <B>) change to the bookmarked directory
|
|
2312 " 2: (user: <q>) list bookmarks
|
|
2313 " 3: (LocalBrowse) record current directory history
|
|
2314 " 4: (user: <u>) go up (previous) bookmark
|
|
2315 " 5: (user: <U>) go down (next) bookmark
|
|
2316 fun! s:NetBookmarkDir(chg,curdir)
|
|
2317 " call Dfunc("NetBookmarkDir(chg=".a:chg." curdir<".a:curdir.">) cnt=".v:count)
|
|
2318 if exists("w:netrw_bannercnt") && line(".") <= w:netrw_bannercnt
|
|
2319 " looks like a "b" was pressed while in the banner region
|
|
2320 if line("$") > w:netrw_bannercnt
|
559
|
2321 exe 'silent keepjumps '.w:netrw_bannercnt
|
482
|
2322 endif
|
559
|
2323 if &ch > 1
|
|
2324 " "clear" the message
|
|
2325 echo ""
|
|
2326 endif
|
482
|
2327 " call Dret("NetBookmarkDir - ignoring")
|
|
2328 return
|
|
2329 endif
|
|
2330
|
|
2331 if a:chg == 0
|
|
2332 " bookmark the current directory
|
|
2333 let g:NETRW_BOOKMARKDIR_{v:count}= a:curdir
|
|
2334 if !exists("g:NETRW_BOOKMARKMAX")
|
|
2335 let g:NETRW_BOOKMARKMAX= v:count
|
|
2336 elseif v:count > g:NETRW_BOOKMARKMAX
|
|
2337 let g:NETRW_BOOKMARKMAX= v:count
|
|
2338 endif
|
|
2339 echo "bookmarked the current directory"
|
|
2340
|
|
2341 elseif a:chg == 1
|
|
2342 " change to the bookmarked directory
|
|
2343 if exists("g:NETRW_BOOKMARKDIR_{v:count}")
|
|
2344 exe "e ".g:NETRW_BOOKMARKDIR_{v:count}
|
|
2345 else
|
|
2346 echomsg "Sorry, bookmark#".v:count." doesn't exist!"
|
|
2347 endif
|
|
2348
|
|
2349 elseif a:chg == 2
|
|
2350 " list user's bookmarks
|
|
2351 if exists("g:NETRW_BOOKMARKMAX")
|
|
2352 " call Decho("list bookmarks [0,".g:NETRW_BOOKMARKMAX."]")
|
|
2353 let cnt= 0
|
|
2354 while cnt <= g:NETRW_BOOKMARKMAX
|
|
2355 if exists("g:NETRW_BOOKMARKDIR_{cnt}")
|
|
2356 " call Decho("Netrw Bookmark#".cnt.": ".g:NETRW_BOOKMARKDIR_{cnt})
|
|
2357 echo "Netrw Bookmark#".cnt.": ".g:NETRW_BOOKMARKDIR_{cnt}
|
|
2358 endif
|
|
2359 let cnt= cnt + 1
|
|
2360 endwhile
|
|
2361 endif
|
|
2362
|
|
2363 " list directory history
|
|
2364 let cnt = g:NETRW_DIRHIST_CNT
|
|
2365 let first = 1
|
|
2366 let histcnt = 0
|
|
2367 while ( first || cnt != g:NETRW_DIRHIST_CNT )
|
|
2368 " call Decho("first=".first." cnt=".cnt." dirhist_cnt=".g:NETRW_DIRHIST_CNT)
|
|
2369 let histcnt= histcnt + 1
|
|
2370 if exists("g:NETRW_DIRHIST_{cnt}")
|
|
2371 " call Decho("Netrw History#".histcnt.": ".g:NETRW_DIRHIST_{cnt})
|
|
2372 echo "Netrw History#".histcnt.": ".g:NETRW_DIRHIST_{cnt}
|
|
2373 endif
|
|
2374 let first = 0
|
|
2375 let cnt = ( cnt - 1 ) % g:netrw_dirhistmax
|
|
2376 if cnt < 0
|
|
2377 let cnt= cnt + g:netrw_dirhistmax
|
|
2378 endif
|
|
2379 endwhile
|
|
2380
|
|
2381 elseif a:chg == 3
|
|
2382 " saves most recently visited directories (when they differ)
|
|
2383 if !exists("g:NETRW_DIRHIST_0") || g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT} != a:curdir
|
|
2384 let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT + 1 ) % g:netrw_dirhistmax
|
|
2385 let g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}= substitute(a:curdir,'[/\\]$','','e')
|
|
2386 " call Decho("save dirhist#".g:NETRW_DIRHIST_CNT."<".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}.">")
|
|
2387 endif
|
|
2388
|
|
2389 elseif a:chg == 4
|
|
2390 " u: change to the previous directory stored on the history list
|
|
2391 let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT - 1 ) % g:netrw_dirhistmax
|
|
2392 if g:NETRW_DIRHIST_CNT < 0
|
|
2393 let g:NETRW_DIRHIST_CNT= g:NETRW_DIRHIST_CNT + g:netrw_dirhistmax
|
|
2394 endif
|
|
2395 if exists("g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}")
|
|
2396 " call Decho("changedir u#".g:NETRW_DIRHIST_CNT."<".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}.">")
|
|
2397 exe "e ".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}
|
|
2398 else
|
|
2399 let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT + 1 ) % g:netrw_dirhistmax
|
|
2400 echo "Sorry, no predecessor directory exists yet"
|
|
2401 endif
|
|
2402
|
|
2403 elseif a:chg == 5
|
|
2404 " U: change to the subsequent directory stored on the history list
|
|
2405 let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT + 1 ) % g:netrw_dirhistmax
|
|
2406 if exists("g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}")
|
|
2407 " call Decho("changedir U#".g:NETRW_DIRHIST_CNT."<".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}.">")
|
|
2408 exe "e ".g:NETRW_DIRHIST_{g:NETRW_DIRHIST_CNT}
|
|
2409 else
|
|
2410 let g:NETRW_DIRHIST_CNT= ( g:NETRW_DIRHIST_CNT - 1 ) % g:netrw_dirhistmax
|
|
2411 if g:NETRW_DIRHIST_CNT < 0
|
|
2412 let g:NETRW_DIRHIST_CNT= g:NETRW_DIRHIST_CNT + g:netrw_dirhistmax
|
|
2413 endif
|
|
2414 echo "Sorry, no successor directory exists yet"
|
|
2415 endif
|
|
2416 endif
|
|
2417 " call Dret("NetBookmarkDir")
|
|
2418 endfun
|
|
2419
|
519
|
2420 " ---------------------------------------------------------------------
|
|
2421 " NetObtain: obtain file under cursor (for remote browsing support) {{{2
|
719
|
2422 fun! netrw#NetObtain(...)
|
|
2423 " call Dfunc("NetObtain() a:0=".a:0)
|
|
2424
|
|
2425 if a:0==0
|
|
2426 " no arguments -- use word under cursor
|
|
2427 let fname= expand("<cWORD>")
|
|
2428 " call Decho("no arguments, use <".fname.">")
|
|
2429 elseif a:0 > 1
|
|
2430 " more than one argument, recurse with each argument separately
|
|
2431 " call Decho("more than 1 argument, use recursion")
|
|
2432 let i=1
|
|
2433 while i <= a:0
|
|
2434 call netrw#NetObtain(a:{i})
|
|
2435 let i=i+1
|
|
2436 endwhile
|
|
2437 return
|
|
2438 else
|
|
2439 " one argument provided
|
|
2440 let fname = a:1
|
|
2441 let keep_netrw_choice = exists("b:netrw_choice")? b:netrw_choice : ""
|
|
2442 let keep_netrw_fname = exists("b:netrw_fname")? b:netrw_fname : ""
|
|
2443 let keep_netrw_wmethod = exists("w:netrw_method")? w:netrw_method : ""
|
|
2444 call s:NetMethod(fname)
|
|
2445 let w:netrw_method= b:netrw_method
|
|
2446 let fname = b:netrw_fname
|
|
2447 " call Decho("g:netrw_scp_cmd<".g:netrw_scp_cmd.">")
|
|
2448 " call Decho("g:netrw_machine<".g:netrw_machine.">")
|
|
2449 " call Decho("fname<".fname.">")
|
|
2450 endif
|
559
|
2451
|
|
2452 " NetrwStatusLine support - for obtaining support
|
|
2453 call s:SetupNetrwStatusLine('%f %h%m%r%=%9*Obtaining '.fname)
|
519
|
2454
|
719
|
2455 " call Decho("method=".w:netrw_method)
|
519
|
2456 if exists("w:netrw_method") && w:netrw_method =~ '[235]'
|
|
2457 if executable("ftp")
|
|
2458 let curdir = expand("%")
|
|
2459 let path = substitute(curdir,'ftp://[^/]\+/','','e')
|
|
2460 let curline= line(".")
|
|
2461 let endline= line("$")+1
|
|
2462 set ma
|
|
2463 keepjumps $
|
|
2464
|
|
2465 ".........................................
|
|
2466 if w:netrw_method == 2
|
|
2467 " ftp + <.netrc>: Method #2
|
559
|
2468 setlocal ff=unix
|
519
|
2469 if path != ""
|
|
2470 put ='cd '.path
|
|
2471 " call Decho("ftp: cd ".path)
|
|
2472 endif
|
|
2473 put ='get '.fname
|
|
2474 " call Decho("ftp: get ".fname)
|
|
2475 if exists("g:netrw_port") && g:netrw_port != ""
|
|
2476 " call Decho("exe ".g:netrw_silentxfer.endline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port)
|
|
2477 exe g:netrw_silentxfer.endline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port
|
|
2478 else
|
|
2479 " call Decho("exe ".g:netrw_silentxfer.endline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine)
|
|
2480 exe g:netrw_silentxfer.endline.",$!".g:netrw_ftp_cmd." -i ".g:netrw_machine
|
|
2481 endif
|
|
2482
|
|
2483 ".........................................
|
|
2484 elseif w:netrw_method == 3
|
|
2485 " ftp + machine,id,passwd,filename: Method #3
|
|
2486 setlocal ff=unix
|
|
2487 if exists("g:netrw_port") && g:netrw_port != ""
|
|
2488 put ='open '.g:netrw_machine.' '.g:netrw_port
|
|
2489 " call Decho('ftp: open '.g:netrw_machine.' '.g:netrw_port)
|
|
2490 else
|
|
2491 put ='open '.g:netrw_machine
|
719
|
2492 " call Decho('ftp: open '.g:netrw_machine)
|
519
|
2493 endif
|
719
|
2494
|
519
|
2495 if exists("g:netrw_ftp") && g:netrw_ftp == 1
|
|
2496 put =g:netrw_uid
|
559
|
2497 put ='\"'.g:netrw_passwd.'\"'
|
519
|
2498 " call Decho('ftp: g:netrw_uid')
|
|
2499 " call Decho('ftp: g:netrw_passwd')
|
|
2500 else
|
559
|
2501 put ='user \"'.g:netrw_uid.'\" \"'.g:netrw_passwd.'\"'
|
519
|
2502 " call Decho('user '.g:netrw_uid.' '.g:netrw_passwd)
|
|
2503 endif
|
719
|
2504
|
519
|
2505 if a:path != ""
|
|
2506 put ='cd '.a:path
|
|
2507 " call Decho('cd '.a:path)
|
|
2508 endif
|
|
2509 exe "put ='".a:cmd."'"
|
|
2510 " call Decho("ftp: ".a:cmd)
|
719
|
2511
|
519
|
2512 " perform ftp:
|
|
2513 " -i : turns off interactive prompting from ftp
|
|
2514 " -n unix : DON'T use <.netrc>, even though it exists
|
|
2515 " -n win32: quit being obnoxious about password
|
|
2516 " call Decho("exe ".g:netrw_silentxfer.curline.",$!".g:netrw_ftp_cmd." -i -n")
|
|
2517 exe g:netrw_silentxfer.endline.",$!".g:netrw_ftp_cmd." -i -n"
|
719
|
2518
|
519
|
2519 ".........................................
|
|
2520 else
|
|
2521 echo "***warning*** unable to comply with your request<" . choice . ">"
|
|
2522 endif
|
|
2523 " restore
|
|
2524 exe "silent! ".endline.",$d"
|
|
2525 exe "keepjumps ".curline
|
559
|
2526 setlocal noma nomod
|
519
|
2527 else
|
|
2528 if !exists("g:netrw_quiet")
|
|
2529 echohl Error | echo "***netrw*** this system doesn't support ftp" | echohl None
|
|
2530 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
2531 endif
|
719
|
2532 " restore status line
|
559
|
2533 let &stl = s:netrw_users_stl
|
|
2534 let &laststatus = s:netrw_users_ls
|
719
|
2535 " restore NetMethod
|
|
2536 if exists("keep_netrw_method")
|
|
2537 call s:NetMethod(keep_netrw_choice)
|
|
2538 let w:netrw_method = keep_netrw_wmethod
|
|
2539 endif
|
519
|
2540 " call Dret("NetObtain")
|
|
2541 return
|
|
2542 endif
|
|
2543
|
|
2544 ".........................................
|
|
2545 else
|
|
2546 " scp: Method#4
|
559
|
2547 let curdir = expand("%")
|
|
2548 let path = substitute(curdir,'scp://[^/]\+/','','e')
|
719
|
2549 " call Decho("path<".path.">")
|
519
|
2550 if exists("g:netrw_port") && g:netrw_port != ""
|
|
2551 let useport= " -P ".g:netrw_port
|
|
2552 else
|
|
2553 let useport= ""
|
|
2554 endif
|
|
2555 if g:netrw_cygwin == 1
|
|
2556 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
|
559
|
2557 " call Decho("executing: !".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".path.escape(fname,' ?&')." .")
|
|
2558 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".path.escape(fname,' ?&')." ."
|
519
|
2559 else
|
559
|
2560 " call Decho("executing: !".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".path.escape(fname,' ?&')." .")
|
|
2561 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".path.escape(fname,' ?&')." ."
|
519
|
2562 endif
|
|
2563 endif
|
|
2564
|
|
2565 " restore status line
|
559
|
2566 let &stl = s:netrw_users_stl
|
|
2567 let &laststatus = s:netrw_users_ls
|
519
|
2568 redraw!
|
|
2569
|
719
|
2570 " restore NetMethod
|
|
2571 if exists("keep_netrw_method")
|
|
2572 call s:NetMethod(keep_netrw_choice)
|
|
2573 let w:netrw_method = keep_netrw_wmethod
|
|
2574 endif
|
|
2575
|
519
|
2576 " call Dret("NetObtain")
|
|
2577 endfun
|
|
2578
|
650
|
2579 " ---------------------------------------------------------------------
|
828
|
2580 " NetPrevWinOpen: open file/directory in previous window. {{{2
|
650
|
2581 " If there's only one window, then the window will first be split.
|
|
2582 fun! s:NetPrevWinOpen(islocal)
|
|
2583 " call Dfunc("NetPrevWinOpen(islocal=".a:islocal.")")
|
|
2584
|
|
2585 " get last window number and the word currently under the cursor
|
|
2586 let lastwinnr = winnr("$")
|
|
2587 let curword = s:NetGetWord()
|
|
2588 let curdir = b:netrw_curdir
|
|
2589 " call Decho("lastwinnr=".lastwinnr." curword<".curword.">")
|
|
2590
|
|
2591 let didsplit = 0
|
|
2592 if lastwinnr == 1
|
|
2593 " if only one window, open a new one first
|
|
2594 " call Decho("only one window, so open a new one (g:netrw_alto=".g:netrw_alto.")")
|
|
2595 exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s"
|
|
2596 let didsplit = 1
|
|
2597
|
|
2598 else
|
|
2599 wincmd p
|
|
2600 " if the previous window's buffer has been changed (is modified),
|
|
2601 " and it doesn't appear in any other extant window, then ask the
|
|
2602 " user if s/he wants to abandon modifications therein.
|
|
2603 let bnr = winbufnr(0)
|
|
2604 let bnrcnt = 0
|
|
2605 if &mod
|
|
2606 windo if winbufnr(0) == bnr | let bnrcnt=bnrcnt+1 | endif
|
|
2607 " call Decho("bnr=".bnr." bnrcnt=".bnrcnt)
|
|
2608 if bnrcnt == 1
|
|
2609 let bufname= bufname(winbufnr(winnr()))
|
|
2610 let choice= confirm("Save modified file<".bufname.">?","&Yes\n&No\n&Cancel")
|
|
2611
|
|
2612 if choice == 1
|
|
2613 " Yes -- write file & then browse
|
|
2614 let v:errmsg= ""
|
|
2615 silent w
|
|
2616 if v:errmsg != ""
|
|
2617 echohl Error | echo "***netrw*** "unable to write <".bufname.">!" | echohl None
|
|
2618 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
2619 if didsplit
|
|
2620 q
|
|
2621 else
|
|
2622 wincmd p
|
|
2623 endif
|
|
2624 " call Dret("NetPrevWinOpen : unable to write <".bufname.">")
|
|
2625 return
|
|
2626 endif
|
|
2627
|
|
2628 elseif choice == 2
|
|
2629 " No -- don't worry about changed file, just browse anyway
|
|
2630 set nomod
|
|
2631 echohl WarningMsg | echo "***netrw*** ".bufname." changes abandoned" | echohl None
|
|
2632
|
|
2633 else
|
|
2634 " Cancel -- don't do this
|
|
2635 if didsplit
|
|
2636 q
|
|
2637 else
|
|
2638 wincmd p
|
|
2639 endif
|
|
2640 " call Dret("NetPrevWinOpen : cancelled")
|
|
2641 return
|
|
2642 endif
|
|
2643 endif
|
|
2644 endif
|
|
2645 endif
|
|
2646
|
|
2647 if a:islocal
|
|
2648 call s:LocalBrowse(s:LocalBrowseChgDir(curdir,curword))
|
|
2649 else
|
|
2650 call s:NetBrowse(s:NetBrowseChgDir(expand("%"),curword))
|
|
2651 endif
|
|
2652 " call Dret("NetPrevWinOpen")
|
|
2653 endfun
|
|
2654
|
719
|
2655 " ---------------------------------------------------------------------
|
|
2656 " NetMenu: generates the menu for gvim and netrw {{{2
|
828
|
2657 fun! s:NetMenu(domenu)
|
719
|
2658
|
829
|
2659 if !exists("g:NetrwMenuPriority")
|
|
2660 let g:NetrwMenuPriority= 80
|
|
2661 endif
|
|
2662
|
719
|
2663 if has("menu") && has("gui_running") && &go =~ 'm'
|
828
|
2664 " call Dfunc("NetMenu(domenu=".a:domenu.")")
|
|
2665 if !exists("s:netrw_menu_enabled") && a:domenu
|
|
2666 " call Decho("initialize menu")
|
719
|
2667 let s:netrw_menu_enabled= 1
|
828
|
2668 if !exists("g:NetrwTopLvlMenu")
|
|
2669 let g:NetrwTopLvlMenu= "Netrw."
|
719
|
2670 endif
|
829
|
2671 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Help<tab><F1> <F1>'
|
|
2672 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Apply\ Special\ Viewer<tab>x x'
|
|
2673 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Bookmark\ Current\ Directory<tab>b Nb'
|
|
2674 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Go\ Up\ Directory<tab>- -'
|
|
2675 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Goto\ Bookmarked\ Directory<tab>B NB'
|
|
2676 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Change\ To\ Recently\ Used\ Directory<tab>u u'
|
|
2677 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Change\ To\ Subsequently\ Used\ Directory<tab>U U'
|
|
2678 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Delete\ File/Directory<tab>D D'
|
|
2679 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Edit\ File\ Hiding\ List<tab>'."<ctrl-h> \<c-h>"
|
|
2680 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Edit\ File/Directory<tab><cr> '."\<cr>"
|
|
2681 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Edit\ File/Directory,\ New\ Window<tab>o o'
|
|
2682 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Edit\ File/Directory,\ New\ Vertical\ Window<tab>v v'
|
|
2683 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'List\ Bookmarks\ and\ History<tab>q q'
|
|
2684 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Listing\ Style\ (thin-long-wide)<tab>i i'
|
|
2685 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Make\ Subdirectory<tab>d d'
|
|
2686 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Normal-Hide-Show<tab>a a'
|
|
2687 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Obtain\ File<tab>O O'
|
|
2688 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Preview\ File/Directory<tab>p p'
|
|
2689 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Previous\ Window\ Browser<tab>P P'
|
|
2690 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Refresh\ Listing<tab>'."<ctrl-l> \<c-l>"
|
|
2691 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Rename\ File/Directory<tab>R R'
|
|
2692 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Reverse\ Sorting\ Order<tab>'."r r"
|
|
2693 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Select\ Sorting\ Style<tab>s s'
|
|
2694 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Sorting\ Sequence\ Edit<tab>S S'
|
|
2695 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Set\ Current\ Directory<tab>c c'
|
|
2696 exe 'silent! '.g:NetrwMenuPriority.'menu '.g:NetrwTopLvlMenu.'Settings/Options<tab>:NetrwSettings '.":NetrwSettings\<cr>"
|
828
|
2697 elseif !a:domenu
|
|
2698 let s:netrwcnt = 0
|
|
2699 let curwin = winnr()
|
|
2700 windo if getline(2) =~ "Netrw" | let s:netrwcnt= s:netrwcnt + 1 | endif
|
|
2701 exe curwin."wincmd w"
|
|
2702
|
|
2703 if s:netrwcnt <= 1
|
|
2704 " call Decho("clear menus")
|
|
2705 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Help'
|
|
2706 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Apply\ Special\ Viewer'
|
|
2707 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Bookmark\ Current\ Directory'
|
|
2708 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Go\ Up\ Directory'
|
|
2709 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Goto\ Bookmarked\ Directory'
|
|
2710 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Change\ To\ Recently\ Used\ Directory'
|
|
2711 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Change\ To\ Subsequently\ Used\ Directory'
|
|
2712 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Delete\ File/Directory'
|
|
2713 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Edit\ File/Directory'
|
|
2714 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Edit\ File/Directory,\ New\ Window'
|
|
2715 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Edit\ File/Directory,\ New\ Vertical\ Window'
|
|
2716 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Edit\ File\ Hiding\ List'
|
|
2717 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Edit\ File'
|
|
2718 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Enter\ File/Directory'
|
|
2719 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Enter\ File/Directory\ (vertical\ split)'
|
|
2720 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'List\ Bookmarks\ and\ History'
|
|
2721 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Listing\ Style\ (thin-long-wide)'
|
|
2722 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Make\ Subdirectory'
|
|
2723 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Normal-Hide-Show'
|
|
2724 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Obtain\ File'
|
|
2725 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Preview\ File/Directory'
|
|
2726 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Previous\ Window\ Browser'
|
|
2727 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Refresh\ Listing'
|
|
2728 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Rename\ File/Directory'
|
|
2729 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Reverse\ Sorting\ Order'
|
|
2730 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Select\ Sorting\ Style'
|
|
2731 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Sorting\ Sequence\ Edit'
|
|
2732 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Set\ Current\ Directory'
|
|
2733 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Settings/Options'
|
|
2734 unlet s:netrw_menu_enabled
|
|
2735 endif
|
719
|
2736 endif
|
|
2737 " call Dret("NetMenu")
|
|
2738 endif
|
|
2739
|
|
2740 endfun
|
|
2741
|
482
|
2742 " ==========================================
|
|
2743 " Local Directory Browsing Support: {{{1
|
|
2744 " ==========================================
|
|
2745
|
|
2746 " ---------------------------------------------------------------------
|
|
2747 " LocalBrowse: {{{2
|
|
2748 fun! s:LocalBrowse(dirname)
|
|
2749 " unfortunate interaction -- debugging calls can't be used here;
|
|
2750 " the BufEnter event causes triggering when attempts to write to
|
|
2751 " the DBG buffer are made.
|
|
2752 if isdirectory(a:dirname)
|
650
|
2753 silent! call netrw#DirBrowse(a:dirname)
|
482
|
2754 endif
|
|
2755 " not a directory, ignore it
|
|
2756 endfun
|
|
2757
|
|
2758 " ---------------------------------------------------------------------
|
|
2759 " DirBrowse: supports local file/directory browsing {{{2
|
|
2760 fun! netrw#DirBrowse(dirname)
|
519
|
2761 if !exists("w:netrw_longlist")|let w:netrw_longlist= g:netrw_longlist|endif
|
482
|
2762 " call Dfunc("DirBrowse(dirname<".a:dirname.">) buf#".bufnr("%")." winnr=".winnr()." sortby=".g:netrw_sort_by)
|
|
2763 " call Dredir("ls!")
|
|
2764
|
|
2765 if exists("s:netrw_skipbrowse")
|
|
2766 unlet s:netrw_skipbrowse
|
|
2767 " call Dret("DirBrowse")
|
|
2768 return
|
|
2769 endif
|
719
|
2770 if &fo =~ '[ta]'
|
|
2771 set fo-=t
|
|
2772 set fo-=a
|
|
2773 echohl Warning
|
|
2774 echo '***warning*** directory browsing and formatoptions "ta" are incompatible'
|
|
2775 echohl None
|
|
2776 endif
|
650
|
2777
|
484
|
2778 call s:NetOptionSave()
|
839
|
2779 if w:acdkeep
|
|
2780 exe 'cd '.escape(a:dirname,s:netrw_cd_escape)
|
|
2781 " call Decho("cd ".escape(a:dirname,s:netrw_cd_escape))
|
|
2782 " call Decho("getcwd<".getcwd().">")
|
|
2783 endif
|
482
|
2784
|
|
2785 if v:version < 603
|
|
2786 if !exists("g:netrw_quiet")
|
|
2787 echohl Error | echo "***netrw*** vim version<".v:version."> too old for browsing with netrw" | echohl None
|
|
2788 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
2789 endif
|
484
|
2790 call s:NetOptionRestore()
|
482
|
2791 " call Dret("DirBrowse : vim version<".v:version."> too old")
|
|
2792 return
|
|
2793 endif
|
|
2794
|
|
2795 " use buffer-oriented WinVars if buffer ones exist but window ones don't
|
|
2796 call s:UseBufWinVars()
|
|
2797
|
719
|
2798 " set up menus
|
|
2799 let b:netrw_browser_active= 1
|
828
|
2800 call s:NetMenu(1)
|
719
|
2801
|
482
|
2802 " find buffer number of buffer named precisely the same as a:dirname
|
|
2803 let bufnum= bufnr(escape(a:dirname,'\'))
|
|
2804 " call Decho("findbuf: bufnum=".bufnum)
|
|
2805 if bufnum > 0 && bufname(bufnum) != a:dirname
|
|
2806 let ibuf= 1
|
|
2807 let buflast= bufnr("$")
|
|
2808 while bufname(ibuf) !~ '^'.a:dirname.'\=$' && ibuf <= buflast
|
|
2809 " call Decho("findbuf: ibuf=".ibuf. " bufname<".bufname(ibuf)."> dirname<".a:dirname.">")
|
|
2810 let ibuf= ibuf + 1
|
|
2811 endwhile
|
|
2812 if ibuf > buflast
|
|
2813 let bufnum= -1
|
|
2814 else
|
|
2815 let bufnum= ibuf
|
|
2816 endif
|
|
2817 " call Decho("findbuf: bufnum=".bufnum." (final)")
|
|
2818 endif
|
|
2819
|
|
2820 " get cleared buffer
|
839
|
2821 mark '
|
484
|
2822 if bufnum < 0 || !bufexists(bufnum)
|
559
|
2823 keepjumps keepalt enew!
|
482
|
2824 " call Decho("enew buffer")
|
|
2825 else
|
519
|
2826 exe "keepalt b ".bufnum
|
482
|
2827 if exists("s:last_sort_by") && g:netrw_sort_by == s:last_sort_by
|
828
|
2828 if getline(2) =~ '^" Netrw Directory Listing '
|
482
|
2829 if !g:netrw_keepdir
|
|
2830 exe 'cd '.escape(b:netrw_curdir,s:netrw_cd_escape)
|
839
|
2831 " call Decho("netrw_keepdir=".g:netrw_keepdir.": cd ".escape(b:netrw_curdir,s:netrw_cd_escape))
|
482
|
2832 endif
|
484
|
2833 call s:NetOptionRestore()
|
482
|
2834 " call Dret("DirBrowse : reusing buffer#".bufnum."<".a:dirname.">")
|
|
2835 return
|
|
2836 endif
|
|
2837 endif
|
|
2838 endif
|
|
2839 let s:last_sort_by= g:netrw_sort_by
|
|
2840
|
758
|
2841 " set up ShellCmdPost handling. Append current buffer to browselist
|
766
|
2842 call s:LocalFastBrowser()
|
758
|
2843
|
482
|
2844 " get the new directory name
|
|
2845 if has("win32") || has("win95") || has("win64") || has("win16")
|
|
2846 let b:netrw_curdir= substitute(a:dirname,'\\','/','ge')
|
|
2847 else
|
|
2848 let b:netrw_curdir= a:dirname
|
|
2849 endif
|
|
2850 if b:netrw_curdir =~ '[/\\]$'
|
|
2851 let b:netrw_curdir= substitute(b:netrw_curdir,'[/\\]$','','e')
|
|
2852 endif
|
484
|
2853 if b:netrw_curdir == ''
|
|
2854 " under unix, when the root directory is encountered, the result
|
|
2855 " from the preceding substitute is an empty string.
|
|
2856 let b:netrw_curdir= '/'
|
|
2857 endif
|
482
|
2858 " call Decho("b:netrw_curdir<".b:netrw_curdir.">")
|
|
2859
|
|
2860 " make netrw's idea of the current directory vim's if the user wishes
|
|
2861 if !g:netrw_keepdir
|
839
|
2862 " call Decho("netrw_keepdir=".g:netrw_keepdir.": cd ".escape(b:netrw_curdir,s:netrw_cd_escape))
|
482
|
2863 try
|
|
2864 exe 'cd '.escape(b:netrw_curdir,s:netrw_cd_escape)
|
|
2865 catch /^Vim\%((\a\+)\)\=:E472/
|
|
2866 echohl Error | echo "***netrw*** unable to change directory to <".b:netrw_curdir."> (permissions?)" | echohl None
|
|
2867 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
2868 if exists("w:netrw_prvdir")
|
|
2869 let b:netrw_curdir= w:netrw_prvdir
|
|
2870 else
|
484
|
2871 call s:NetOptionRestore()
|
482
|
2872 " call Dret("DirBrowse : reusing buffer#".bufnum."<".a:dirname.">")
|
|
2873 return
|
|
2874 endif
|
|
2875 endtry
|
|
2876 endif
|
|
2877
|
|
2878 " change the name of the buffer to reflect the b:netrw_curdir
|
650
|
2879 " Hmm. When another vim is open to the same directory, I get
|
|
2880 " a "Press ENTER" ... ok, setting "noswf" avoids it.
|
|
2881 " call Decho('exe silent! file '.escape(b:netrw_curdir,s:netrw_cd_escape))
|
482
|
2882 exe 'silent! file '.escape(b:netrw_curdir,s:netrw_cd_escape)
|
|
2883
|
484
|
2884 " make this buffer not-a-file, modifiable, not line-numbered, etc
|
719
|
2885 setlocal bt=nofile nobl ma nonu noswf nowrap
|
|
2886 if g:netrw_fastbrowse >= 2
|
|
2887 setlocal bh=hide
|
799
|
2888 else
|
|
2889 setlocal bh=delete
|
719
|
2890 endif
|
519
|
2891 keepalt silent! %d
|
482
|
2892
|
|
2893 " ---------------------------
|
|
2894 " Perform Directory Listing:
|
559
|
2895 if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1
|
|
2896 echo "(netrw) Processing your browsing request..."
|
|
2897 endif
|
482
|
2898
|
|
2899 " save current directory on directory history list
|
650
|
2900 call s:NetBookmarkDir(3,b:netrw_curdir)
|
482
|
2901
|
|
2902 " set up all the maps
|
|
2903 " call Decho("Setting up local browser maps")
|
519
|
2904 nnoremap <buffer> <silent> <cr> :call <SID>LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,<SID>NetGetWord()))<cr>
|
559
|
2905 nnoremap <buffer> <silent> <c-l> :call <SID>NetRefresh(<SID>LocalBrowseChgDir(b:netrw_curdir,'./'),1)<cr>
|
482
|
2906 nnoremap <buffer> <silent> - :exe "norm! 0"<bar>call <SID>LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,'../'))<cr>
|
559
|
2907 nnoremap <buffer> <silent> a :let g:netrw_hide=(g:netrw_hide+1)%3<bar>exe "norm! 0"<bar>call <SID>NetRefresh(<SID>LocalBrowseChgDir(b:netrw_curdir,'./'),1)<cr>
|
519
|
2908 if w:netrw_longlist != 2
|
|
2909 nnoremap <buffer> <silent> b :<c-u>call <SID>NetBookmarkDir(0,b:netrw_curdir)<cr>
|
|
2910 nnoremap <buffer> <silent> B :<c-u>call <SID>NetBookmarkDir(1,b:netrw_curdir)<cr>
|
|
2911 endif
|
|
2912 nnoremap <buffer> <silent> Nb :<c-u>call <SID>NetBookmarkDir(0,b:netrw_curdir)<cr>
|
|
2913 nnoremap <buffer> <silent> NB :<c-u>call <SID>NetBookmarkDir(1,b:netrw_curdir)<cr>
|
482
|
2914 nnoremap <buffer> <silent> c :exe "cd ".b:netrw_curdir<cr>
|
|
2915 nnoremap <buffer> <silent> d :call <SID>NetMakeDir("")<cr>
|
|
2916 nnoremap <buffer> <silent> <c-h> :call <SID>NetHideEdit(1)<cr>
|
|
2917 nnoremap <buffer> <silent> i :call <SID>NetLongList(1)<cr>
|
|
2918 nnoremap <buffer> <silent> o :call <SID>NetSplit(2)<cr>
|
519
|
2919 nnoremap <buffer> <silent> O :call <SID>LocalObtain()<cr>
|
|
2920 nnoremap <buffer> <silent> p :call <SID>LocalPreview(<SID>LocalBrowseChgDir(b:netrw_curdir,<SID>NetGetWord(),1))<cr>
|
650
|
2921 nnoremap <buffer> <silent> P :call <SID>NetPrevWinOpen(1)<cr>
|
482
|
2922 nnoremap <buffer> <silent> q :<c-u>call <SID>NetBookmarkDir(2,b:netrw_curdir)<cr>
|
559
|
2923 nnoremap <buffer> <silent> r :let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetRefresh(<SID>LocalBrowseChgDir(b:netrw_curdir,'./'),1)<cr>
|
482
|
2924 nnoremap <buffer> <silent> s :call <SID>NetSaveWordPosn()<bar>let g:netrw_sort_by= (g:netrw_sort_by =~ 'n')? 'time' : (g:netrw_sort_by =~ 't')? 'size' : 'name'<bar>exe "norm! 0"<bar>call <SID>LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,'./'))<bar>call <SID>NetRestoreWordPosn()<cr>
|
|
2925 nnoremap <buffer> <silent> S :call <SID>NetSortSequence(1)<cr>
|
|
2926 nnoremap <buffer> <silent> u :<c-u>call <SID>NetBookmarkDir(4,expand("%"))<cr>
|
|
2927 nnoremap <buffer> <silent> U :<c-u>call <SID>NetBookmarkDir(5,expand("%"))<cr>
|
|
2928 nnoremap <buffer> <silent> v :call <SID>NetSplit(3)<cr>
|
650
|
2929 nnoremap <buffer> <silent> x :call netrw#NetBrowseX(<SID>LocalBrowseChgDir(b:netrw_curdir,<SID>NetGetWord(),0),0)"<cr>
|
559
|
2930 nnoremap <buffer> <silent> <2-leftmouse> :call <SID>LocalBrowse(<SID>LocalBrowseChgDir(b:netrw_curdir,<SID>NetGetWord()))<cr>
|
839
|
2931 if s:didstarstar || !mapcheck("<s-down>","n")
|
|
2932 nnoremap <buffer> <silent> <s-down> :Nexplore<cr>
|
|
2933 endif
|
|
2934 if s:didstarstar || !mapcheck("<s-up>","n")
|
|
2935 nnoremap <buffer> <silent> <s-up> :Pexplore<cr>
|
|
2936 endif
|
519
|
2937 exe 'nnoremap <buffer> <silent> <del> :call <SID>LocalBrowseRm("'.b:netrw_curdir.'")<cr>'
|
482
|
2938 exe 'vnoremap <buffer> <silent> <del> :call <SID>LocalBrowseRm("'.b:netrw_curdir.'")<cr>'
|
519
|
2939 exe 'nnoremap <buffer> <silent> D :call <SID>LocalBrowseRm("'.b:netrw_curdir.'")<cr>'
|
482
|
2940 exe 'vnoremap <buffer> <silent> D :call <SID>LocalBrowseRm("'.b:netrw_curdir.'")<cr>'
|
519
|
2941 exe 'nnoremap <buffer> <silent> R :call <SID>LocalBrowseRename("'.b:netrw_curdir.'")<cr>'
|
482
|
2942 exe 'vnoremap <buffer> <silent> R :call <SID>LocalBrowseRename("'.b:netrw_curdir.'")<cr>'
|
|
2943 exe 'nnoremap <buffer> <silent> <Leader>m :call <SID>NetMakeDir("")<cr>'
|
794
|
2944 nnoremap <buffer> <F1> :he netrw-dir<cr>
|
482
|
2945
|
|
2946 " Set up the banner
|
|
2947 " call Decho("set up banner")
|
|
2948 keepjumps put ='\" ============================================================================'
|
|
2949 keepjumps 1d
|
828
|
2950 keepjumps put ='\" Netrw Directory Listing (netrw '.g:loaded_netrw.')'
|
482
|
2951 keepjumps put ='\" '.b:netrw_curdir
|
|
2952 let w:netrw_bannercnt= 3
|
|
2953
|
|
2954 let sortby= g:netrw_sort_by
|
|
2955 if g:netrw_sort_direction =~ "^r"
|
|
2956 let sortby= sortby." reversed"
|
|
2957 endif
|
|
2958
|
|
2959 " Sorted by...
|
|
2960 if g:netrw_sort_by =~ "^n"
|
|
2961 " call Decho("directories will be sorted by name")
|
|
2962 " sorted by name
|
|
2963 keepjumps put ='\" Sorted by '.sortby
|
|
2964 keepjumps put ='\" Sort sequence: '.g:netrw_sort_sequence
|
|
2965 let w:netrw_bannercnt= w:netrw_bannercnt + 2
|
|
2966 else
|
|
2967 " call Decho("directories will be sorted by size or date")
|
|
2968 " sorted by size or date
|
|
2969 keepjumps put ='\" Sorted by '.sortby
|
|
2970 let w:netrw_bannercnt= w:netrw_bannercnt + 1
|
|
2971 endif
|
|
2972
|
|
2973 " Hiding... -or- Showing...
|
|
2974 if g:netrw_list_hide != "" && g:netrw_hide
|
|
2975 if g:netrw_hide == 1
|
|
2976 keepjumps put ='\" Hiding: '.g:netrw_list_hide
|
|
2977 else
|
|
2978 keepjumps put ='\" Showing: '.g:netrw_list_hide
|
|
2979 endif
|
|
2980 let w:netrw_bannercnt= w:netrw_bannercnt + 1
|
|
2981 endif
|
819
|
2982 keepjumps put ='\" Quick Help: <F1>:help -:go up dir D:delete R:rename s:sort-by x:exec'
|
482
|
2983 keepjumps put ='\" ============================================================================'
|
|
2984 let w:netrw_bannercnt= w:netrw_bannercnt + 2
|
|
2985
|
|
2986 " bannercnt should index the line just after the banner
|
|
2987 let w:netrw_bannercnt= w:netrw_bannercnt + 1
|
|
2988 " call Decho("bannercnt=".w:netrw_bannercnt)
|
|
2989
|
|
2990 " generate the requested directory listing
|
|
2991 call s:LocalBrowseList()
|
|
2992
|
|
2993 " set up syntax highlighting
|
|
2994 if has("syntax")
|
829
|
2995 setlocal ft=netrw
|
482
|
2996 if !exists("g:syntax_on") || !g:syntax_on
|
|
2997 setlocal ft=
|
|
2998 endif
|
|
2999 endif
|
|
3000
|
|
3001 " manipulate the directory listing (hide, sort)
|
|
3002 if line("$") >= w:netrw_bannercnt
|
|
3003 if g:netrw_hide && g:netrw_list_hide != ""
|
|
3004 call s:NetrwListHide()
|
|
3005 endif
|
|
3006 if line("$") >= w:netrw_bannercnt
|
|
3007
|
|
3008 if g:netrw_sort_by =~ "^n"
|
|
3009 call s:SetSort()
|
|
3010
|
559
|
3011 if w:netrw_bannercnt < line("$")
|
|
3012 if g:netrw_sort_direction =~ 'n'
|
|
3013 exe 'silent keepjumps '.w:netrw_bannercnt.',$sort'
|
|
3014 else
|
|
3015 exe 'silent keepjumps '.w:netrw_bannercnt.',$sort!'
|
|
3016 endif
|
482
|
3017 endif
|
828
|
3018 " remove priority pattern prefix
|
559
|
3019 exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\d\{3}\///e'
|
482
|
3020
|
|
3021 else
|
559
|
3022 if w:netrw_bannercnt < line("$")
|
|
3023 if g:netrw_sort_direction =~ 'n'
|
|
3024 exe 'silent keepjumps '.w:netrw_bannercnt.',$sort'
|
|
3025 else
|
|
3026 exe 'silent keepjumps '.w:netrw_bannercnt.',$sort!'
|
|
3027 endif
|
482
|
3028 endif
|
559
|
3029 exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\d\{-}\///e'
|
482
|
3030 endif
|
|
3031
|
|
3032 endif
|
|
3033 endif
|
519
|
3034
|
|
3035 call s:NetrwWideListing()
|
482
|
3036 if exists("w:netrw_bannercnt") && line("$") > w:netrw_bannercnt
|
559
|
3037 " place cursor on the top-left corner of the file listing
|
|
3038 exe 'silent '.w:netrw_bannercnt
|
|
3039 norm! 0
|
482
|
3040 endif
|
|
3041
|
|
3042 " record previous current directory
|
|
3043 let w:netrw_prvdir= b:netrw_curdir
|
|
3044
|
|
3045 " save certain window-oriented variables into buffer-oriented variables
|
559
|
3046 call s:SetBufWinVars()
|
484
|
3047 call s:NetOptionRestore()
|
719
|
3048 setlocal noma nomod nonu nobl nowrap
|
|
3049 if g:netrw_fastbrowse >= 2
|
|
3050 setlocal bh=hide
|
|
3051 endif
|
482
|
3052
|
|
3053 " call Dret("DirBrowse : file<".expand("%:p")."> bufname<".bufname("%").">")
|
|
3054 endfun
|
|
3055
|
|
3056 " ---------------------------------------------------------------------
|
|
3057 " LocalBrowseList: does the job of "ls" for local directories {{{2
|
|
3058 fun! s:LocalBrowseList()
|
839
|
3059 " call Dfunc("LocalBrowseList() b:netrw_curdir<".b:netrw_curdir."> sortby<".g:netrw_sort_by.">")
|
482
|
3060
|
|
3061 " get the list of files contained in the current directory
|
|
3062 let dirname = escape(b:netrw_curdir,s:netrw_glob_escape)
|
|
3063 let dirnamelen = strlen(b:netrw_curdir)
|
|
3064 let filelist = glob(dirname."/*")
|
828
|
3065 " call Decho("glob(dirname<".dirname."/.*>)=".filelist)
|
482
|
3066 if filelist != ""
|
|
3067 let filelist= filelist."\n"
|
|
3068 endif
|
|
3069 let filelist= filelist.glob(dirname."/.*")
|
828
|
3070 " call Decho("glob(dirname<".dirname."/.*>)=".glob(dirname.".*"))
|
482
|
3071
|
|
3072 " if the directory name includes a "$", and possibly other characters,
|
|
3073 " the glob() doesn't include "." and ".." entries.
|
|
3074 if filelist !~ '[\\/]\.[\\/]\=\(\n\|$\)'
|
|
3075 " call Decho("forcibly tacking on .")
|
|
3076 if filelist == ""
|
|
3077 let filelist= dirname."."
|
|
3078 else
|
|
3079 let filelist= filelist."\n".b:netrw_curdir."."
|
|
3080 endif
|
|
3081 " call Decho("filelist<".filelist.">")
|
|
3082 endif
|
|
3083 if filelist !~ '[\\/]\.\.[\\/]\=\(\n\|$\)'
|
|
3084 " call Decho("forcibly tacking on ..")
|
|
3085 let filelist= filelist."\n".b:netrw_curdir.".."
|
|
3086 " call Decho("filelist<".filelist.">")
|
|
3087 endif
|
|
3088 let filelist= substitute(filelist,'\n\{2,}','\n','ge')
|
839
|
3089 if (has("win32") || has("win95") || has("win64") || has("win16"))
|
|
3090 let filelist= substitute(filelist,'\','/','ge')
|
|
3091 else
|
|
3092 let filelist= substitute(filelist,'\','\\','ge')
|
|
3093 endif
|
482
|
3094
|
|
3095 " call Decho("dirname<".dirname.">")
|
|
3096 " call Decho("dirnamelen<".dirnamelen.">")
|
|
3097 " call Decho("filelist<".filelist.">")
|
|
3098
|
|
3099 while filelist != ""
|
|
3100 if filelist =~ '\n'
|
|
3101 let filename = substitute(filelist,'\n.*$','','e')
|
|
3102 let filelist = substitute(filelist,'^.\{-}\n\(.*\)$','\1','e')
|
|
3103 else
|
|
3104 let filename = filelist
|
|
3105 let filelist = ""
|
|
3106 endif
|
|
3107 let pfile= filename
|
|
3108 if isdirectory(filename)
|
|
3109 let pfile= filename."/"
|
|
3110 endif
|
|
3111 if pfile =~ '//$'
|
|
3112 let pfile= substitute(pfile,'//$','/','e')
|
|
3113 endif
|
|
3114 let pfile= strpart(pfile,dirnamelen)
|
|
3115 let pfile= substitute(pfile,'^/','','e')
|
|
3116 " call Decho(" ")
|
|
3117 " call Decho("filename<".filename.">")
|
|
3118 " call Decho("pfile <".pfile.">")
|
|
3119
|
519
|
3120 if w:netrw_longlist == 1
|
482
|
3121 let sz = getfsize(filename)
|
519
|
3122 let fsz = strpart(" ",1,15-strlen(sz)).sz
|
|
3123 let pfile= pfile."\t".fsz." ".strftime(g:netrw_timefmt,getftime(filename))
|
482
|
3124 " call Decho("sz=".sz." fsz=".fsz)
|
|
3125 endif
|
|
3126
|
|
3127 if g:netrw_sort_by =~ "^t"
|
|
3128 " sort by time (handles time up to 1 quintillion seconds, US)
|
|
3129 " call Decho("getftime(".filename.")=".getftime(filename))
|
|
3130 let t = getftime(filename)
|
|
3131 let ft = strpart("000000000000000000",1,18-strlen(t)).t
|
|
3132 " call Decho("exe keepjumps put ='".ft.'/'.filename."'")
|
|
3133 let ftpfile= ft.'/'.pfile
|
650
|
3134 keepjumps silent! put=ftpfile
|
482
|
3135
|
|
3136 elseif g:netrw_sort_by =~ "^s"
|
|
3137 " sort by size (handles file sizes up to 1 quintillion bytes, US)
|
|
3138 " call Decho("getfsize(".filename.")=".getfsize(filename))
|
|
3139 let sz = getfsize(filename)
|
|
3140 let fsz = strpart("000000000000000000",1,18-strlen(sz)).sz
|
|
3141 " call Decho("exe keepjumps put ='".fsz.'/'.filename."'")
|
|
3142 let fszpfile= fsz.'/'.pfile
|
650
|
3143 keepjumps silent! put =fszpfile
|
482
|
3144
|
|
3145 else
|
|
3146 " sort by name
|
|
3147 " call Decho("exe keepjumps put ='".pfile."'")
|
650
|
3148 keepjumps silent! put=pfile
|
482
|
3149 endif
|
|
3150 endwhile
|
719
|
3151
|
484
|
3152 " cleanup any windows mess at end-of-line
|
559
|
3153 silent! keepjumps %s/\r$//e
|
482
|
3154 setlocal ts=32
|
|
3155
|
|
3156 " call Dret("LocalBrowseList")
|
|
3157 endfun
|
|
3158
|
|
3159 " ---------------------------------------------------------------------
|
|
3160 " LocalBrowseChgDir: constructs a new directory based on the current {{{2
|
|
3161 " directory and a new directory name
|
|
3162 fun! s:LocalBrowseChgDir(dirname,newdir,...)
|
|
3163 " call Dfunc("LocalBrowseChgDir(dirname<".a:dirname."> newdir<".a:newdir.">) a:0=".a:0)
|
|
3164
|
|
3165 let dirname= substitute(a:dirname,'\\','','ge')
|
|
3166 let newdir = a:newdir
|
|
3167
|
|
3168 if dirname !~ '[\/]$'
|
|
3169 " apparently vim is "recognizing" that it is in the home directory and
|
|
3170 " is removing the "/". Bad idea, so I have to put it back.
|
|
3171 let dirname= dirname.'/'
|
|
3172 " call Decho("adjusting dirname<".dirname.">")
|
|
3173 endif
|
|
3174
|
|
3175 if newdir !~ '[\/]$'
|
|
3176 " handling a file
|
|
3177 let dirname= dirname.newdir
|
|
3178 " call Decho("handling a file: dirname<".dirname.">")
|
|
3179 " this lets NetBrowseX avoid the edit
|
|
3180 if a:0 < 1
|
|
3181 " call Decho("dirname<".dirname."> netrw_cd_escape<".s:netrw_cd_escape.">")
|
|
3182 " call Decho("about to edit<".escape(dirname,s:netrw_cd_escape).">")
|
650
|
3183 if g:netrw_browse_split == 1
|
|
3184 new
|
|
3185 wincmd _
|
|
3186 elseif g:netrw_browse_split == 2
|
|
3187 rightb vert new
|
|
3188 wincmd |
|
828
|
3189 else
|
|
3190 " handling a file, didn't split, so possibly remove menu
|
|
3191 call s:NetMenu(0)
|
650
|
3192 endif
|
482
|
3193 exe "e! ".escape(dirname,s:netrw_cd_escape)
|
519
|
3194 set ma nomod
|
482
|
3195 endif
|
|
3196
|
|
3197 elseif newdir == './'
|
|
3198 " refresh the directory list
|
|
3199 " call Decho("refresh directory listing")
|
|
3200
|
|
3201 elseif newdir == '../'
|
|
3202 " go up one directory
|
|
3203 let dirname= substitute(dirname,'^\(.*/\)\([^/]\+[\/]$\)','\1','e')
|
|
3204 " call Decho("go up one dir: dirname<".dirname.">")
|
|
3205
|
|
3206 else
|
|
3207 " go down one directory
|
|
3208 let dirname= dirname.newdir
|
|
3209 " call Decho("go down one dir: dirname<".dirname."> newdir<".newdir.">")
|
|
3210 endif
|
|
3211
|
|
3212 " call Dret("LocalBrowseChgDir <".dirname.">")
|
|
3213 return dirname
|
|
3214 endfun
|
|
3215
|
|
3216 " ---------------------------------------------------------------------
|
758
|
3217 " LocalBrowseShellCmdRefresh: this function is called after a user has {{{2
|
|
3218 " performed any shell command. The idea is to cause all local-browsing
|
|
3219 " buffers to be refreshed after a user has executed some shell command,
|
|
3220 " on the chance that s/he removed/created a file/directory with it.
|
|
3221 fun! s:LocalBrowseShellCmdRefresh()
|
|
3222 " call Dfunc("LocalBrowseShellCmdRefresh() browselist=".string(s:netrw_browselist))
|
828
|
3223 " GO through all buffers on netrw_browselist (ie. just local-netrw buffers):
|
|
3224 " | refresh any netrw window
|
|
3225 " | wipe out any non-displaying netrw buffer
|
758
|
3226 let curwin = winnr()
|
|
3227 let ibl = 0
|
|
3228 for ibuf in s:netrw_browselist
|
|
3229 if bufwinnr(ibuf) == -1
|
|
3230 " call Decho("wiping buf#".ibuf)
|
799
|
3231 exe "silent! bw ".ibuf
|
758
|
3232 call remove(s:netrw_browselist,ibl)
|
|
3233 " call Decho("browselist=".string(s:netrw_browselist))
|
|
3234 continue
|
|
3235 else
|
|
3236 " call Decho("refresh buf#".ibuf.'-> win#'.bufwinnr(ibuf))
|
|
3237 exe bufwinnr(ibuf)."wincmd w"
|
|
3238 call s:NetRefresh(s:LocalBrowseChgDir(b:netrw_curdir,'./'),1)
|
|
3239 endif
|
|
3240 let ibl= ibl + 1
|
|
3241 endfor
|
|
3242 exe curwin."wincmd w"
|
|
3243
|
|
3244 " call Dret("LocalBrowseShellCmdRefresh")
|
|
3245 endfun
|
|
3246
|
|
3247 " ---------------------------------------------------------------------
|
482
|
3248 " LocalBrowseRm: {{{2
|
|
3249 fun! s:LocalBrowseRm(path) range
|
|
3250 " call Dfunc("LocalBrowseRm(path<".a:path.">)")
|
|
3251 " call Decho("firstline=".a:firstline." lastline=".a:lastline)
|
|
3252
|
|
3253 " preparation for removing multiple files/directories
|
|
3254 let ctr = a:firstline
|
|
3255 let ret = 0
|
|
3256 let all= 0
|
|
3257
|
|
3258 " remove multiple files and directories
|
|
3259 while ctr <= a:lastline
|
|
3260 exe "keepjumps ".ctr
|
|
3261
|
|
3262 " sanity checks
|
|
3263 if line(".") < w:netrw_bannercnt
|
|
3264 let ctr= ctr + 1
|
|
3265 continue
|
|
3266 endif
|
|
3267 let curword= s:NetGetWord()
|
|
3268 if curword == "./" || curword == "../"
|
|
3269 let ctr= ctr + 1
|
|
3270 continue
|
|
3271 endif
|
|
3272
|
|
3273 norm! 0
|
|
3274 let rmfile= a:path."/".curword
|
|
3275 " call Decho("rmfile<".rmfile.">")
|
|
3276
|
|
3277 if rmfile !~ '^"' && (rmfile =~ '@$' || rmfile !~ '[\/]$')
|
|
3278 " attempt to remove file
|
|
3279 if !all
|
|
3280 echohl Statement
|
|
3281 call inputsave()
|
|
3282 let ok= input("Confirm deletion of file<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ")
|
|
3283 call inputrestore()
|
|
3284 echohl NONE
|
559
|
3285 if ok == ""
|
|
3286 let ok="no"
|
|
3287 endif
|
|
3288 " call Decho("response: ok<".ok.">")
|
482
|
3289 let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e')
|
559
|
3290 " call Decho("response: ok<".ok."> (after sub)")
|
482
|
3291 if ok =~ 'a\%[ll]'
|
|
3292 let all= 1
|
|
3293 endif
|
|
3294 endif
|
|
3295
|
|
3296 if all || ok =~ 'y\%[es]' || ok == ""
|
|
3297 let ret= delete(rmfile)
|
|
3298 " call Decho("errcode=".v:shell_error." ret=".ret)
|
|
3299 elseif ok =~ 'q\%[uit]'
|
|
3300 break
|
|
3301 endif
|
719
|
3302
|
482
|
3303 else
|
|
3304 " attempt to remove directory
|
|
3305 if !all
|
|
3306 echohl Statement
|
|
3307 call inputsave()
|
|
3308 let ok= input("Confirm deletion of directory<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ")
|
|
3309 call inputrestore()
|
|
3310 let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e')
|
559
|
3311 if ok == ""
|
|
3312 let ok="no"
|
|
3313 endif
|
482
|
3314 if ok =~ 'a\%[ll]'
|
|
3315 let all= 1
|
|
3316 endif
|
|
3317 endif
|
|
3318 let rmfile= substitute(rmfile,'[\/]$','','e')
|
|
3319
|
|
3320 if all || ok =~ 'y\%[es]' || ok == ""
|
|
3321 " call Decho("1st attempt: system(".g:netrw_local_rmdir.' "'.rmfile.'")')
|
|
3322 call system(g:netrw_local_rmdir.' "'.rmfile.'"')
|
|
3323 " call Decho("v:shell_error=".v:shell_error)
|
|
3324
|
|
3325 if v:shell_error != 0
|
|
3326 " call Decho("2nd attempt to remove directory<".rmfile.">")
|
|
3327 let errcode= delete(rmfile)
|
|
3328 " call Decho("errcode=".errcode)
|
|
3329
|
|
3330 if errcode != 0
|
|
3331 if has("unix")
|
|
3332 " call Decho("3rd attempt to remove directory<".rmfile.">")
|
519
|
3333 call system("rm ".rmfile)
|
482
|
3334 if v:shell_error != 0 && !exists("g:netrw_quiet")
|
|
3335 echohl Error | echo "***netrw*** unable to remove directory<".rmfile."> -- is it empty?" | echohl None
|
|
3336 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
519
|
3337 endif
|
482
|
3338 elseif !exists("g:netrw_quiet")
|
|
3339 echohl Error | echo "***netrw*** unable to remove directory<".rmfile."> -- is it empty?" | echohl None
|
|
3340 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
3341 endif
|
|
3342 endif
|
|
3343 endif
|
|
3344
|
|
3345 elseif ok =~ 'q\%[uit]'
|
|
3346 break
|
|
3347 endif
|
|
3348 endif
|
|
3349
|
|
3350 let ctr= ctr + 1
|
|
3351 endwhile
|
|
3352
|
|
3353 " refresh the directory
|
|
3354 let curline= line(".")
|
|
3355 " call Decho("refresh the directory")
|
559
|
3356 call s:NetRefresh(s:LocalBrowseChgDir(b:netrw_curdir,'./'),1)
|
482
|
3357 exe curline
|
|
3358
|
|
3359 " call Dret("LocalBrowseRm")
|
|
3360 endfun
|
|
3361
|
|
3362 " ---------------------------------------------------------------------
|
|
3363 " LocalBrowseRename: rename a remote file or directory {{{2
|
|
3364 fun! s:LocalBrowseRename(path) range
|
|
3365 " call Dfunc("LocalBrowseRename(path<".a:path.">)")
|
|
3366
|
|
3367 " preparation for removing multiple files/directories
|
|
3368 let ctr= a:firstline
|
|
3369
|
|
3370 " attempt to rename files/directories
|
|
3371 while ctr <= a:lastline
|
|
3372 exe "keepjumps ".ctr
|
|
3373
|
|
3374 " sanity checks
|
|
3375 if line(".") < w:netrw_bannercnt
|
|
3376 let ctr= ctr + 1
|
|
3377 continue
|
|
3378 endif
|
|
3379 let curword= s:NetGetWord()
|
|
3380 if curword == "./" || curword == "../"
|
|
3381 let ctr= ctr + 1
|
|
3382 continue
|
|
3383 endif
|
|
3384
|
|
3385 norm! 0
|
|
3386 let oldname= a:path."/".curword
|
|
3387 " call Decho("oldname<".oldname.">")
|
|
3388
|
|
3389 call inputsave()
|
|
3390 let newname= input("Moving ".oldname." to : ",substitute(oldname,'/*$','','e'))
|
|
3391 call inputrestore()
|
|
3392
|
|
3393 let ret= rename(oldname,newname)
|
|
3394 " call Decho("renaming <".oldname."> to <".newname.">")
|
|
3395
|
|
3396 let ctr= ctr + 1
|
|
3397 endwhile
|
|
3398
|
|
3399 " refresh the directory
|
|
3400 let curline= line(".")
|
|
3401 " call Decho("refresh the directory listing")
|
559
|
3402 call s:NetRefresh(s:LocalBrowseChgDir(b:netrw_curdir,'./'),1)
|
482
|
3403 exe "keepjumps ".curline
|
|
3404 " call Dret("LocalBrowseRename")
|
|
3405 endfun
|
|
3406
|
|
3407 " ---------------------------------------------------------------------
|
766
|
3408 " LocalFastBrowser: handles setting up/taking down fast browsing for the {{{2
|
|
3409 " local browser
|
|
3410 fun! s:LocalFastBrowser()
|
|
3411 " call Dfunc("LocalFastBrowser()")
|
|
3412
|
|
3413 " initialize browselist, a list of buffer numbers that the local browser has used
|
|
3414 if !exists("s:netrw_browselist")
|
|
3415 let s:netrw_browselist= []
|
|
3416 endif
|
|
3417
|
|
3418 " append current buffer to fastbrowse list
|
|
3419 if g:netrw_fastbrowse <= 1 && (empty(s:netrw_browselist) || bufnr("%") > s:netrw_browselist[-1])
|
|
3420 call add(s:netrw_browselist,bufnr("%"))
|
|
3421 " call Decho("browselist=".string(s:netrw_browselist))
|
|
3422 endif
|
|
3423
|
|
3424 " enable autocmd events to handle refreshing/removing local browser buffers
|
|
3425 " If local browse buffer is currently showing: refresh it
|
|
3426 " If local browse buffer is currently hidden : wipe it
|
|
3427 if !exists("s:netrw_browser_shellcmd") && g:netrw_fastbrowse <= 1
|
|
3428 " call Decho("setting up local-browser shell command refresh")
|
|
3429 let s:netrw_browser_shellcmd= 1
|
|
3430 augroup AuNetrwShellCmd
|
|
3431 au!
|
842
|
3432 if (has("win32") || has("win95") || has("win64") || has("win16"))
|
|
3433 au ShellCmdPost * call s:LocalBrowseShellCmdRefresh()
|
|
3434 else
|
|
3435 au ShellCmdPost,FocusGained * call s:LocalBrowseShellCmdRefresh()
|
|
3436 endif
|
766
|
3437 augroup END
|
820
|
3438 endif
|
766
|
3439
|
|
3440 " user must have changed fastbrowse to its fast setting, so remove
|
|
3441 " the associated autocmd events
|
|
3442 if g:netrw_fastbrowse > 1 && exists("s:netrw_browser_shellcmd")
|
|
3443 unlet s:netrw_browser_shellcmd
|
|
3444 augroup AuNetrwShellCmd
|
|
3445 au!
|
|
3446 augroup END
|
|
3447 augroup! AuNetrwShellCmd
|
|
3448 endif
|
|
3449
|
|
3450 " call Dret("LocalFastBrowser")
|
|
3451 endfun
|
|
3452
|
|
3453 " ---------------------------------------------------------------------
|
519
|
3454 " LocalObtain: copy selected file to current working directory {{{2
|
|
3455 fun! s:LocalObtain()
|
|
3456 " call Dfunc("LocalObtain()")
|
|
3457 if exists("b:netrw_curdir") && getcwd() != b:netrw_curdir
|
|
3458 let fname= expand("<cWORD>")
|
|
3459 let fcopy= readfile(b:netrw_curdir."/".fname,"b")
|
|
3460 call writefile(fcopy,getcwd()."/".fname,"b")
|
|
3461 elseif !exists("b:netrw_curdir")
|
|
3462 echohl Error | echo "***netrw*** local browsing directory doesn't exist!"
|
|
3463 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
3464 else
|
|
3465 echohl Error | echo "***netrw*** local browsing directory and current directory are identical"
|
|
3466 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
3467 endif
|
|
3468 " call Dret("LocalObtain")
|
|
3469 endfun
|
|
3470
|
|
3471 " ---------------------------------------------------------------------
|
482
|
3472 " LocalPreview: {{{2
|
|
3473 fun! s:LocalPreview(path) range
|
|
3474 " call Dfunc("LocalPreview(path<".a:path.">)")
|
|
3475 if has("quickfix")
|
|
3476 if !isdirectory(a:path)
|
|
3477 exe "pedit ".a:path
|
|
3478 elseif !exists("g:netrw_quiet")
|
|
3479 echohl WarningMsg | echo "***netrw*** sorry, cannot preview a directory such as <".a:path.">" | echohl None
|
|
3480 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
3481 endif
|
|
3482 elseif !exists("g:netrw_quiet")
|
|
3483 echohl WarningMsg | echo "***netrw*** sorry, to preview your vim needs the quickfix feature compiled in" | echohl None
|
|
3484 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
3485 endif
|
|
3486 " call Dret("LocalPreview")
|
|
3487 endfun
|
|
3488
|
|
3489 " ---------------------------------------------------------------------
|
|
3490 " Explore: launch the local browser in the directory of the current file {{{2
|
|
3491 " dosplit==0: the window will be split iff the current file has
|
|
3492 " been modified
|
|
3493 " dosplit==1: the window will be split before running the local
|
|
3494 " browser
|
|
3495 fun! netrw#Explore(indx,dosplit,style,...)
|
|
3496 " call Dfunc("Explore(indx=".a:indx." dosplit=".a:dosplit." style=".a:style.")")
|
|
3497
|
|
3498 " if dosplit or file has been modified
|
|
3499 if a:dosplit || &modified
|
650
|
3500 call s:SaveWinVars()
|
482
|
3501
|
|
3502 if a:style == 0 " Explore, Sexplore
|
|
3503 exe g:netrw_winsize."wincmd s"
|
|
3504 " call Decho("style=0: Explore or Sexplore")
|
|
3505
|
|
3506 elseif a:style == 1 "Explore!, Sexplore!
|
|
3507 exe g:netrw_winsize."wincmd v"
|
|
3508 " call Decho("style=1: Explore! or Sexplore!")
|
|
3509
|
|
3510 elseif a:style == 2 " Hexplore
|
|
3511 exe "bel ".g:netrw_winsize."wincmd s"
|
|
3512 " call Decho("style=2: Hexplore")
|
|
3513
|
|
3514 elseif a:style == 3 " Hexplore!
|
|
3515 exe "abo ".g:netrw_winsize."wincmd s"
|
|
3516 " call Decho("style=3: Hexplore!")
|
|
3517
|
|
3518 elseif a:style == 4 " Vexplore
|
|
3519 exe "lefta ".g:netrw_winsize."wincmd v"
|
|
3520 " call Decho("style=4: Vexplore")
|
|
3521
|
|
3522 elseif a:style == 5 " Vexplore!
|
|
3523 exe "rightb ".g:netrw_winsize."wincmd v"
|
|
3524 " call Decho("style=5: Vexplore!")
|
|
3525 endif
|
|
3526 call s:CopyWinVars()
|
|
3527 endif
|
|
3528 norm! 0
|
|
3529
|
841
|
3530 if a:1 =~ '^\*/'
|
839
|
3531 " Explore */pattern
|
|
3532 let pattern= substitute(a:1,'^\*/\(.*\)$','\1','')
|
841
|
3533 " call Decho("Explore */pat: a:1<".a:1."> -> pattern<".pattern.">")
|
|
3534 elseif a:1 =~ '^\*\*//'
|
|
3535 " Explore **//pattern
|
|
3536 let pattern = substitute(a:1,'^\*\*//','','')
|
|
3537 let starstarpat = 1
|
|
3538 " call Decho("Explore **//pat: a:1<".a:1."> -> pattern<".pattern.">")
|
839
|
3539 endif
|
|
3540
|
482
|
3541 if a:1 == "" && a:indx >= 0
|
|
3542 " Explore Hexplore Vexplore Sexplore
|
559
|
3543 " call Decho("Explore Hexplore Vexplore Sexplore")
|
482
|
3544 let newdir= substitute(expand("%:p"),'^\(.*[/\\]\)[^/\\]*$','\1','e')
|
|
3545 if newdir =~ '^scp:' || newdir =~ '^ftp:'
|
|
3546 " call Decho("calling NetBrowse(newdir<".newdir.">)")
|
|
3547 call s:NetBrowse(newdir)
|
|
3548 else
|
559
|
3549 if newdir == ""|let newdir= getcwd()|endif
|
482
|
3550 " call Decho("calling LocalBrowse(newdir<".newdir.">)")
|
|
3551 call s:LocalBrowse(newdir)
|
|
3552 endif
|
|
3553
|
839
|
3554 elseif a:1 =~ '^\*\*/' || a:indx < 0 || a:1 =~ '^\*/'
|
|
3555 " Nexplore, Pexplore, Explore **/... , or Explore */pattern
|
|
3556 " call Decho("Nexplore, Pexplore, <s-down>, <s-up>, Explore ".a:1)
|
|
3557 let s:didstarstar= 1
|
|
3558 if exists("b:netrw_curdir")
|
|
3559 nnoremap <buffer> <silent> <s-up> :Pexplore<cr>
|
|
3560 nnoremap <buffer> <silent> <s-down> :Nexplore<cr>
|
|
3561 endif
|
482
|
3562
|
519
|
3563 if has("path_extra")
|
482
|
3564 if !exists("w:netrw_explore_indx")
|
|
3565 let w:netrw_explore_indx= 0
|
|
3566 endif
|
|
3567 let indx = a:indx
|
841
|
3568 " call Decho("set indx=".indx)
|
839
|
3569 "
|
482
|
3570 if indx == -1
|
841
|
3571 "Nexplore
|
839
|
3572 if !exists("w:netrw_explore_list") " sanity check
|
|
3573 echohl WarningMsg | echo "***netrw*** using Nexplore or <s-down> improperly; see help for netrw-starstar" | echohl None
|
|
3574 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
3575 " call Dret("Explore")
|
|
3576 return
|
|
3577 endif
|
841
|
3578 let indx = w:netrw_explore_indx
|
|
3579 let curfile= w:netrw_explore_list[indx]
|
|
3580 while indx < w:netrw_explore_listlen && curfile == w:netrw_explore_list[indx]
|
|
3581 let indx= indx + 1
|
|
3582 " call Decho("indx=".indx)
|
|
3583 endwhile
|
|
3584 " call Decho("Nexplore: indx= [w:netrw_explore_indx=".w:netrw_explore_indx."]=".indx)
|
839
|
3585
|
482
|
3586 elseif indx == -2
|
841
|
3587 "Pexplore
|
839
|
3588 if !exists("w:netrw_explore_list") " sanity check
|
|
3589 echohl WarningMsg | echo "***netrw*** using Pexplore or <s-up> improperly; see help for netrw-starstar" | echohl None
|
|
3590 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
3591 " call Dret("Explore")
|
|
3592 return
|
|
3593 endif
|
841
|
3594 let indx = w:netrw_explore_indx
|
|
3595 let curfile= w:netrw_explore_list[indx]
|
|
3596 while indx > 0 && curfile == w:netrw_explore_list[indx]
|
|
3597 let indx= indx - 1
|
|
3598 endwhile
|
|
3599 " call Decho("Pexplore: indx= [w:netrw_explore_indx=".w:netrw_explore_indx."]=".indx)
|
839
|
3600
|
482
|
3601 else
|
841
|
3602 " Explore -- initialize
|
839
|
3603 " build list of files to Explore with Nexplore/Pexplore
|
841
|
3604 " call Decho("Explore -- initialize")
|
|
3605 let w:netrw_explore_indx= 0
|
482
|
3606 if !exists("b:netrw_curdir")
|
|
3607 let b:netrw_curdir= getcwd()
|
|
3608 endif
|
839
|
3609 " call Decho("b:netrw_curdir<".b:netrw_curdir.">")
|
|
3610 if exists("pattern")
|
|
3611 " call Decho("building list based on pattern<".pattern."> cwd<".getcwd().">")
|
841
|
3612 if exists("starstarpat")
|
|
3613 exe "vimgrep /".pattern."/gj "."**/*"
|
|
3614 let s:netrw_curdir= b:netrw_curdir
|
|
3615 let w:netrw_explore_list = map(getqflist(),'s:netrw_curdir."/".bufname(v:val.bufnr)')
|
|
3616 else
|
|
3617 exe "vimgrep /".pattern."/gj ".b:netrw_curdir."/*"
|
|
3618 if (has("win32") || has("win95") || has("win64") || has("win16"))
|
|
3619 let w:netrw_explore_list = map(getqflist(),'bufname(v:val.bufnr)')
|
|
3620 else
|
|
3621 let w:netrw_explore_list = map(getqflist(),'b:netrw_curdir.bufname(v:val.bufnr)')
|
|
3622 endif
|
|
3623 endif
|
839
|
3624 else
|
|
3625 " call Decho("building list based on ".b:netrw_curdir."/".a:1)
|
|
3626 let w:netrw_explore_list= split(expand(b:netrw_curdir."/".a:1),'\n')
|
|
3627 endif
|
|
3628
|
482
|
3629 let w:netrw_explore_listlen = len(w:netrw_explore_list)
|
839
|
3630 " call Decho("w:netrw_explore_list<".string(w:netrw_explore_list)."> listlen=".w:netrw_explore_listlen)
|
|
3631
|
482
|
3632 if w:netrw_explore_listlen == 1 && w:netrw_explore_list[0] =~ '\*\*\/'
|
|
3633 echohl WarningMsg | echo "***netrw*** no files matched" | echohl None
|
|
3634 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
3635 " call Dret("Explore")
|
|
3636 return
|
|
3637 endif
|
|
3638 endif
|
|
3639
|
559
|
3640 " NetrwStatusLine support - for exploring support
|
482
|
3641 let w:netrw_explore_indx= indx
|
|
3642 " call Decho("explorelist<".join(w:netrw_explore_list,',')."> len=".w:netrw_explore_listlen)
|
|
3643
|
|
3644 " sanity check
|
|
3645 if indx >= w:netrw_explore_listlen || indx < 0
|
|
3646 let indx= (indx < 0)? 0 : ( w:netrw_explore_listlen - 1 )
|
|
3647 echohl WarningMsg | echo "***netrw*** no more files match Explore pattern" | echohl None
|
|
3648 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
3649 " call Dret("Explore")
|
|
3650 return
|
|
3651 endif
|
|
3652
|
|
3653 exe "let dirfile= w:netrw_explore_list[".indx."]"
|
559
|
3654 " call Decho("dirfile=w:netrw_explore_list[indx=".indx."]= <".dirfile.">")
|
482
|
3655 let newdir= substitute(dirfile,'/[^/]*$','','e')
|
|
3656 " call Decho("newdir<".newdir.">")
|
559
|
3657
|
482
|
3658 " call Decho("calling LocalBrowse(newdir<".newdir.">)")
|
|
3659 call s:LocalBrowse(newdir)
|
559
|
3660 if w:netrw_longlist == 0 || w:netrw_longlist == 1
|
|
3661 call search('^'.substitute(dirfile,"^.*/","","").'\>',"W")
|
|
3662 else
|
|
3663 call search('\<'.substitute(dirfile,"^.*/","","").'\>',"w")
|
|
3664 endif
|
482
|
3665 let w:netrw_explore_mtchcnt = indx + 1
|
758
|
3666 let w:netrw_explore_bufnr = bufnr("%")
|
482
|
3667 let w:netrw_explore_line = line(".")
|
559
|
3668 call s:SetupNetrwStatusLine('%f %h%m%r%=%9*%{NetrwStatusLine()}')
|
482
|
3669 " call Decho("explore: mtchcnt=".w:netrw_explore_mtchcnt." bufnr=".w:netrw_explore_bufnr." line#".w:netrw_explore_line)
|
|
3670
|
|
3671 else
|
519
|
3672 if !exists("g:netrw_quiet")
|
482
|
3673 echohl WarningMsg | echo "***netrw*** your vim needs the +path_extra feature for Exploring with **!" | echohl None | echohl None
|
|
3674 endif
|
|
3675 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
3676 endif
|
|
3677
|
|
3678 else
|
559
|
3679 " call Decho("Explore newdir<".a:1.">")
|
482
|
3680 let newdir= a:1
|
|
3681 call s:LocalBrowse(newdir)
|
|
3682 endif
|
|
3683
|
|
3684 " call Dret("Explore")
|
|
3685 endfun
|
|
3686
|
|
3687 " ---------------------------------------------------------------------
|
559
|
3688 " SetupNetrwStatusLine: {{{2
|
|
3689 fun! s:SetupNetrwStatusLine(statline)
|
|
3690 " call Dfunc("SetupNetrwStatusLine(statline<".a:statline.">)")
|
|
3691
|
|
3692 if !exists("s:netrw_setup_statline")
|
|
3693 let s:netrw_setup_statline= 1
|
|
3694 " call Decho("do first-time status line setup")
|
|
3695
|
|
3696 if !exists("s:netrw_users_stl")
|
|
3697 let s:netrw_users_stl= &stl
|
|
3698 endif
|
|
3699 if !exists("s:netrw_users_ls")
|
|
3700 let s:netrw_users_ls= &laststatus
|
|
3701 endif
|
|
3702
|
|
3703 " set up User9 highlighting as needed
|
|
3704 let keepa= @a
|
|
3705 redir @a
|
|
3706 try
|
|
3707 hi User9
|
|
3708 catch /^Vim\%((\a\+)\)\=:E411/
|
|
3709 if &bg == "dark"
|
|
3710 hi User9 ctermfg=yellow ctermbg=blue guifg=yellow guibg=blue
|
|
3711 else
|
|
3712 hi User9 ctermbg=yellow ctermfg=blue guibg=yellow guifg=blue
|
|
3713 endif
|
|
3714 endtry
|
|
3715 redir END
|
|
3716 let @a= keepa
|
|
3717 endif
|
|
3718
|
|
3719 " set up status line (may use User9 highlighting)
|
|
3720 " insure that windows have a statusline
|
|
3721 " make sure statusline is displayed
|
|
3722 let &stl=a:statline
|
|
3723 set laststatus=2
|
|
3724 " call Decho("stl=".&stl)
|
|
3725 redraw!
|
|
3726
|
|
3727 " call Dret("SetupNetrwStatusLine : stl=".&stl)
|
|
3728 endfun
|
|
3729
|
|
3730 " ---------------------------------------------------------------------
|
482
|
3731 " NetrwStatusLine: {{{2
|
|
3732 fun! NetrwStatusLine()
|
559
|
3733
|
|
3734 " vvv NetrwStatusLine() debugging vvv
|
|
3735 " let g:stlmsg=""
|
|
3736 " if !exists("w:netrw_explore_bufnr")
|
|
3737 " let g:stlmsg="!X<explore_bufnr>"
|
758
|
3738 " elseif w:netrw_explore_bufnr != bufnr("%")
|
|
3739 " let g:stlmsg="explore_bufnr!=".bufnr("%")
|
559
|
3740 " endif
|
|
3741 " if !exists("w:netrw_explore_line")
|
|
3742 " let g:stlmsg=" !X<explore_line>"
|
|
3743 " elseif w:netrw_explore_line != line(".")
|
|
3744 " let g:stlmsg=" explore_line!={line(.)<".line(".").">"
|
|
3745 " endif
|
|
3746 " if !exists("w:netrw_explore_list")
|
|
3747 " let g:stlmsg=" !X<explore_list>"
|
|
3748 " endif
|
|
3749 " ^^^ NetrwStatusLine() debugging ^^^
|
|
3750
|
758
|
3751 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")
|
519
|
3752 " restore user's status line
|
559
|
3753 let &stl = s:netrw_users_stl
|
|
3754 let &laststatus = s:netrw_users_ls
|
482
|
3755 if exists("w:netrw_explore_bufnr")|unlet w:netrw_explore_bufnr|endif
|
|
3756 if exists("w:netrw_explore_line")|unlet w:netrw_explore_line|endif
|
|
3757 return ""
|
|
3758 else
|
|
3759 return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen
|
|
3760 endif
|
|
3761 endfun
|
|
3762
|
|
3763 " ---------------------------------------------------------------------
|
|
3764 " NetGetcwd: get the current directory. {{{2
|
|
3765 " Change backslashes to forward slashes, if any.
|
|
3766 " If doesc is true, escape certain troublesome characters
|
|
3767 fun! s:NetGetcwd(doesc)
|
|
3768 " call Dfunc("NetGetcwd(doesc=".a:doesc.")")
|
|
3769 let curdir= substitute(getcwd(),'\\','/','ge')
|
|
3770 if curdir !~ '[\/]$'
|
|
3771 let curdir= curdir.'/'
|
|
3772 endif
|
|
3773 if a:doesc
|
|
3774 let curdir= escape(curdir,s:netrw_cd_escape)
|
|
3775 endif
|
|
3776 " call Dret("NetGetcwd <".curdir.">")
|
|
3777 return curdir
|
|
3778 endfun
|
|
3779
|
|
3780 " ---------------------------------------------------------------------
|
650
|
3781 " NetMethod: determine method of transfer {{{2
|
482
|
3782 " method == 1: rcp
|
|
3783 " 2: ftp + <.netrc>
|
|
3784 " 3: ftp + machine, id, password, and [path]filename
|
|
3785 " 4: scp
|
|
3786 " 5: http (wget)
|
|
3787 " 6: cadaver
|
|
3788 " 7: rsync
|
|
3789 " 8: fetch
|
|
3790 " 9: sftp
|
|
3791 fun! s:NetMethod(choice) " globals: method machine id passwd fname
|
|
3792 " call Dfunc("NetMethod(a:choice<".a:choice.">)")
|
719
|
3793
|
482
|
3794 " initialization
|
|
3795 let b:netrw_method = 0
|
|
3796 let g:netrw_machine = ""
|
|
3797 let b:netrw_fname = ""
|
|
3798 let g:netrw_port = ""
|
719
|
3799 let g:netrw_choice = a:choice
|
|
3800
|
482
|
3801 " Patterns:
|
|
3802 " mipf : a:machine a:id password filename Use ftp
|
|
3803 " mf : a:machine filename Use ftp + <.netrc> or g:netrw_uid g:netrw_passwd
|
|
3804 " ftpurm : ftp://[user@]host[[#:]port]/filename Use ftp + <.netrc> or g:netrw_uid g:netrw_passwd
|
|
3805 " rcpurm : rcp://[user@]host/filename Use rcp
|
|
3806 " rcphf : [user@]host:filename Use rcp
|
|
3807 " scpurm : scp://[user@]host[[#:]port]/filename Use scp
|
|
3808 " httpurm : http://[user@]host/filename Use wget
|
|
3809 " davurm : [s]dav://host[:port]/path Use cadaver
|
|
3810 " rsyncurm : rsync://host[:port]/path Use rsync
|
|
3811 " fetchurm : fetch://[user@]host[:http]/filename Use fetch (defaults to ftp, override for http)
|
|
3812 " sftpurm : sftp://[user@]host/filename Use scp
|
|
3813 let mipf = '^\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)$'
|
|
3814 let mf = '^\(\S\+\)\s\+\(\S\+\)$'
|
|
3815 let ftpurm = '^ftp://\(\([^/@]\{-}\)@\)\=\([^/#:]\{-}\)\([#:]\d\+\)\=/\(.*\)$'
|
|
3816 let rcpurm = '^rcp://\%(\([^/@]\{-}\)@\)\=\([^/]\{-}\)/\(.*\)$'
|
|
3817 let rcphf = '^\(\(\h\w*\)@\)\=\(\h\w*\):\([^@]\+\)$'
|
559
|
3818 let scpurm = '^scp://\([^/#:]\+\)\%([#:]\(\d\+\)\)\=/\(.*\)$'
|
482
|
3819 let httpurm = '^http://\([^/]\{-}\)\(/.*\)\=$'
|
|
3820 let davurm = '^s\=dav://\([^/]\+\)/\(.*/\)\([-_.~[:alnum:]]\+\)$'
|
|
3821 let rsyncurm = '^rsync://\([^/]\{-}\)/\(.*\)\=$'
|
|
3822 let fetchurm = '^fetch://\(\([^/@]\{-}\)@\)\=\([^/#:]\{-}\)\(:http\)\=/\(.*\)$'
|
|
3823 let sftpurm = '^sftp://\([^/]\{-}\)/\(.*\)\=$'
|
719
|
3824
|
482
|
3825 " call Decho("determine method:")
|
|
3826 " Determine Method
|
|
3827 " rcp://user@hostname/...path-to-file
|
|
3828 if match(a:choice,rcpurm) == 0
|
|
3829 " call Decho("rcp://...")
|
|
3830 let b:netrw_method = 1
|
|
3831 let userid = substitute(a:choice,rcpurm,'\1',"")
|
|
3832 let g:netrw_machine = substitute(a:choice,rcpurm,'\2',"")
|
|
3833 let b:netrw_fname = substitute(a:choice,rcpurm,'\3',"")
|
|
3834 if userid != ""
|
|
3835 let g:netrw_uid= userid
|
|
3836 endif
|
719
|
3837
|
482
|
3838 " scp://user@hostname/...path-to-file
|
|
3839 elseif match(a:choice,scpurm) == 0
|
|
3840 " call Decho("scp://...")
|
519
|
3841 let b:netrw_method = 4
|
482
|
3842 let g:netrw_machine = substitute(a:choice,scpurm,'\1',"")
|
|
3843 let g:netrw_port = substitute(a:choice,scpurm,'\2',"")
|
|
3844 let b:netrw_fname = substitute(a:choice,scpurm,'\3',"")
|
719
|
3845
|
482
|
3846 " http://user@hostname/...path-to-file
|
|
3847 elseif match(a:choice,httpurm) == 0
|
|
3848 " call Decho("http://...")
|
|
3849 let b:netrw_method = 5
|
|
3850 let g:netrw_machine= substitute(a:choice,httpurm,'\1',"")
|
|
3851 let b:netrw_fname = substitute(a:choice,httpurm,'\2',"")
|
719
|
3852
|
482
|
3853 " dav://hostname[:port]/..path-to-file..
|
|
3854 elseif match(a:choice,davurm) == 0
|
|
3855 " call Decho("dav://...")
|
|
3856 let b:netrw_method= 6
|
|
3857 if a:choice =~ '^s'
|
|
3858 let g:netrw_machine= 'https://'.substitute(a:choice,davurm,'\1/\2',"")
|
|
3859 else
|
|
3860 let g:netrw_machine= 'http://'.substitute(a:choice,davurm,'\1/\2',"")
|
|
3861 endif
|
|
3862 let b:netrw_fname = substitute(a:choice,davurm,'\3',"")
|
719
|
3863
|
482
|
3864 " rsync://user@hostname/...path-to-file
|
|
3865 elseif match(a:choice,rsyncurm) == 0
|
|
3866 " call Decho("rsync://...")
|
|
3867 let b:netrw_method = 7
|
|
3868 let g:netrw_machine= substitute(a:choice,rsyncurm,'\1',"")
|
|
3869 let b:netrw_fname = substitute(a:choice,rsyncurm,'\2',"")
|
719
|
3870
|
482
|
3871 " ftp://[user@]hostname[[:#]port]/...path-to-file
|
|
3872 elseif match(a:choice,ftpurm) == 0
|
|
3873 " call Decho("ftp://...")
|
519
|
3874 let userid = substitute(a:choice,ftpurm,'\2',"")
|
482
|
3875 let g:netrw_machine= substitute(a:choice,ftpurm,'\3',"")
|
|
3876 let g:netrw_port = substitute(a:choice,ftpurm,'\4',"")
|
|
3877 let b:netrw_fname = substitute(a:choice,ftpurm,'\5',"")
|
|
3878 if userid != ""
|
|
3879 let g:netrw_uid= userid
|
|
3880 endif
|
|
3881 if exists("g:netrw_uid") && exists("g:netrw_passwd")
|
|
3882 let b:netrw_method = 3
|
|
3883 else
|
|
3884 if filereadable(expand("$HOME/.netrc")) && !exists("g:netrw_ignorenetrc")
|
|
3885 let b:netrw_method= 2
|
|
3886 else
|
|
3887 if !exists("g:netrw_uid") || g:netrw_uid == ""
|
|
3888 call NetUserPass()
|
|
3889 elseif !exists("g:netrw_passwd") || g:netrw_passwd == ""
|
|
3890 call NetUserPass(g:netrw_uid)
|
|
3891 " else just use current g:netrw_uid and g:netrw_passwd
|
|
3892 endif
|
|
3893 let b:netrw_method= 3
|
|
3894 endif
|
|
3895 endif
|
719
|
3896
|
482
|
3897 elseif match(a:choice,fetchurm) == 0
|
|
3898 " call Decho("fetch://...")
|
|
3899 let b:netrw_method = 8
|
|
3900 let g:netrw_userid = substitute(a:choice,fetchurm,'\2',"")
|
|
3901 let g:netrw_machine= substitute(a:choice,fetchurm,'\3',"")
|
|
3902 let b:netrw_option = substitute(a:choice,fetchurm,'\4',"")
|
|
3903 let b:netrw_fname = substitute(a:choice,fetchurm,'\5',"")
|
719
|
3904
|
482
|
3905 " Issue an ftp : "machine id password [path/]filename"
|
|
3906 elseif match(a:choice,mipf) == 0
|
|
3907 " call Decho("(ftp) host id pass file")
|
|
3908 let b:netrw_method = 3
|
|
3909 let g:netrw_machine = substitute(a:choice,mipf,'\1',"")
|
|
3910 let g:netrw_uid = substitute(a:choice,mipf,'\2',"")
|
|
3911 let g:netrw_passwd = substitute(a:choice,mipf,'\3',"")
|
|
3912 let b:netrw_fname = substitute(a:choice,mipf,'\4',"")
|
719
|
3913
|
482
|
3914 " Issue an ftp: "hostname [path/]filename"
|
|
3915 elseif match(a:choice,mf) == 0
|
|
3916 " call Decho("(ftp) host file")
|
|
3917 if exists("g:netrw_uid") && exists("g:netrw_passwd")
|
|
3918 let b:netrw_method = 3
|
|
3919 let g:netrw_machine = substitute(a:choice,mf,'\1',"")
|
|
3920 let b:netrw_fname = substitute(a:choice,mf,'\2',"")
|
719
|
3921
|
482
|
3922 elseif filereadable(expand("$HOME/.netrc"))
|
|
3923 let b:netrw_method = 2
|
|
3924 let g:netrw_machine = substitute(a:choice,mf,'\1',"")
|
|
3925 let b:netrw_fname = substitute(a:choice,mf,'\2',"")
|
|
3926 endif
|
719
|
3927
|
482
|
3928 " sftp://user@hostname/...path-to-file
|
|
3929 elseif match(a:choice,sftpurm) == 0
|
|
3930 " call Decho("sftp://...")
|
|
3931 let b:netrw_method = 9
|
|
3932 let g:netrw_machine= substitute(a:choice,sftpurm,'\1',"")
|
|
3933 let b:netrw_fname = substitute(a:choice,sftpurm,'\2',"")
|
719
|
3934
|
482
|
3935 " Issue an rcp: hostname:filename" (this one should be last)
|
|
3936 elseif match(a:choice,rcphf) == 0
|
|
3937 " call Decho("(rcp) [user@]host:file) rcphf<".rcphf.">")
|
|
3938 let b:netrw_method = 1
|
|
3939 let userid = substitute(a:choice,rcphf,'\2',"")
|
|
3940 let g:netrw_machine= substitute(a:choice,rcphf,'\3',"")
|
|
3941 let b:netrw_fname = substitute(a:choice,rcphf,'\4',"")
|
|
3942 " call Decho('\1<'.substitute(a:choice,rcphf,'\1',"").">")
|
|
3943 " call Decho('\2<'.substitute(a:choice,rcphf,'\2',"").">")
|
|
3944 " call Decho('\3<'.substitute(a:choice,rcphf,'\3',"").">")
|
|
3945 " call Decho('\4<'.substitute(a:choice,rcphf,'\4',"").">")
|
|
3946 if userid != ""
|
|
3947 let g:netrw_uid= userid
|
|
3948 endif
|
|
3949 if has("win32") || has("win95") || has("win64") || has("win16")
|
|
3950 " don't let PCs try <.netrc>
|
|
3951 let b:netrw_method = 3
|
|
3952 endif
|
719
|
3953
|
482
|
3954 else
|
|
3955 if !exists("g:netrw_quiet")
|
|
3956 echohl Error | echo "***netrw*** cannot determine method" | echohl None
|
|
3957 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
3958 endif
|
|
3959 let b:netrw_method = -1
|
|
3960 endif
|
|
3961
|
|
3962 " remove any leading [:#] from port number
|
|
3963 if g:netrw_port != ""
|
|
3964 let g:netrw_port = substitute(g:netrw_port,'[#:]\+','','')
|
|
3965 endif
|
719
|
3966
|
482
|
3967 " call Decho("a:choice <".a:choice.">")
|
|
3968 " call Decho("b:netrw_method <".b:netrw_method.">")
|
|
3969 " call Decho("g:netrw_machine<".g:netrw_machine.">")
|
|
3970 " call Decho("g:netrw_port <".g:netrw_port.">")
|
|
3971 " if exists("g:netrw_uid") "Decho
|
|
3972 " call Decho("g:netrw_uid <".g:netrw_uid.">")
|
|
3973 " endif "Decho
|
|
3974 " if exists("g:netrw_passwd") "Decho
|
|
3975 " call Decho("g:netrw_passwd <".g:netrw_passwd.">")
|
|
3976 " endif "Decho
|
|
3977 " call Decho("b:netrw_fname <".b:netrw_fname.">")
|
719
|
3978 " call Dret("NetMethod : b:netrw_method=".b:netrw_method)
|
482
|
3979 endfun
|
|
3980
|
|
3981 " ------------------------------------------------------------------------
|
650
|
3982 " NetUserPass: set username and password for subsequent ftp transfer {{{2
|
482
|
3983 " Usage: :call NetUserPass() -- will prompt for userid and password
|
|
3984 " :call NetUserPass("uid") -- will prompt for password
|
|
3985 " :call NetUserPass("uid","password") -- sets global userid and password
|
|
3986 fun! NetUserPass(...)
|
|
3987
|
|
3988 " get/set userid
|
|
3989 if a:0 == 0
|
|
3990 " call Dfunc("NetUserPass(a:0<".a:0.">)")
|
|
3991 if !exists("g:netrw_uid") || g:netrw_uid == ""
|
|
3992 " via prompt
|
|
3993 let g:netrw_uid= input('Enter username: ')
|
|
3994 endif
|
|
3995 else " from command line
|
|
3996 " call Dfunc("NetUserPass(a:1<".a:1.">) {")
|
|
3997 let g:netrw_uid= a:1
|
|
3998 endif
|
|
3999
|
|
4000 " get password
|
|
4001 if a:0 <= 1 " via prompt
|
|
4002 " call Decho("a:0=".a:0." case <=1:")
|
|
4003 let g:netrw_passwd= inputsecret("Enter Password: ")
|
|
4004 else " from command line
|
|
4005 " call Decho("a:0=".a:0." case >1: a:2<".a:2.">")
|
|
4006 let g:netrw_passwd=a:2
|
|
4007 endif
|
559
|
4008
|
482
|
4009 " call Dret("NetUserPass")
|
|
4010 endfun
|
|
4011
|
|
4012 " ------------------------------------------------------------------------
|
650
|
4013 " NetOptionSave: save options and set to "standard" form {{{2
|
484
|
4014 fun! s:NetOptionSave()
|
482
|
4015 " call Dfunc("NetOptionSave()")
|
484
|
4016 if !exists("w:netoptionsave")
|
|
4017 let w:netoptionsave= 1
|
|
4018 else
|
|
4019 " call Dret("NetOptionSave : netoptionsave=".w:netoptionsave)
|
|
4020 return
|
|
4021 endif
|
482
|
4022
|
|
4023 " Get Temporary Filename
|
839
|
4024 let w:acdkeep = &acd
|
|
4025 let w:aikeep = &ai
|
719
|
4026 let w:fokeep = &fo
|
|
4027 let w:cikeep = &ci
|
559
|
4028 let w:cinkeep = &cin
|
|
4029 let w:cinokeep = &cino
|
|
4030 let w:comkeep = &com
|
|
4031 let w:cpokeep = &cpo
|
766
|
4032 let w:hidkeep = &hidden
|
719
|
4033 let w:magickeep = &magic
|
559
|
4034 let w:gdkeep = &gd
|
|
4035 let w:repkeep = &report
|
|
4036 let w:spellkeep = &spell
|
|
4037 let w:twkeep = &tw
|
482
|
4038 setlocal cino =
|
|
4039 setlocal com =
|
|
4040 setlocal cpo -=aA
|
839
|
4041 setlocal noacd nocin noai noci magic nospell fo=nroql2 nohid
|
482
|
4042 setlocal tw =0
|
484
|
4043 setlocal report=10000
|
482
|
4044 if has("win32") && !has("win95")
|
484
|
4045 let w:swfkeep= &swf
|
482
|
4046 setlocal noswf
|
484
|
4047 " call Decho("setting w:swfkeep to <".&swf.">")
|
482
|
4048 endif
|
|
4049
|
|
4050 " call Dret("NetOptionSave")
|
|
4051 endfun
|
|
4052
|
|
4053 " ------------------------------------------------------------------------
|
650
|
4054 " NetOptionRestore: restore options {{{2
|
482
|
4055 fun! s:NetOptionRestore()
|
|
4056 " call Dfunc("NetOptionRestore()")
|
484
|
4057 if !exists("w:netoptionsave")
|
519
|
4058 " call Dret("NetOptionRestore : w:netoptionsave doesn't exist")
|
484
|
4059 return
|
|
4060 endif
|
|
4061 unlet w:netoptionsave
|
719
|
4062
|
839
|
4063 if exists("w:acdkeep") |let &acd = w:acdkeep |unlet w:acdkeep |endif
|
719
|
4064 if exists("w:aikeep") |let &ai = w:aikeep |unlet w:aikeep |endif
|
|
4065 if exists("w:cikeep") |let &ci = w:cikeep |unlet w:cikeep |endif
|
559
|
4066 if exists("w:cinkeep") |let &cin = w:cinkeep |unlet w:cinkeep |endif
|
|
4067 if exists("w:cinokeep") |let &cino = w:cinokeep |unlet w:cinokeep |endif
|
|
4068 if exists("w:comkeep") |let &com = w:comkeep |unlet w:comkeep |endif
|
|
4069 if exists("w:cpokeep") |let &cpo = w:cpokeep |unlet w:cpokeep |endif
|
719
|
4070 if exists("w:fokeep") |let &fo = w:fokeep |unlet w:fokeep |endif
|
559
|
4071 if exists("w:gdkeep") |let &gd = w:gdkeep |unlet w:gdkeep |endif
|
766
|
4072 if exists("w:hidkeep") |let &hidden = w:hidkeep |unlet w:hidkeep |endif
|
719
|
4073 if exists("w:magic") |let &magic = w:magic |unlet w:magic |endif
|
559
|
4074 if exists("w:repkeep") |let &report = w:repkeep |unlet w:repkeep |endif
|
|
4075 if exists("w:spellkeep")|let &spell = w:spellkeep |unlet w:spellkeep|endif
|
|
4076 if exists("w:twkeep") |let &tw = w:twkeep |unlet w:twkeep |endif
|
484
|
4077 if exists("w:swfkeep")
|
559
|
4078 if &directory == "" && exists("w:swfkeep")
|
482
|
4079 " user hasn't specified a swapfile directory;
|
|
4080 " netrw will temporarily make the swapfile
|
|
4081 " directory the current local one.
|
|
4082 let &directory = getcwd()
|
484
|
4083 silent! let &swf = w:swfkeep
|
482
|
4084 set directory=
|
|
4085 else
|
484
|
4086 let &swf= w:swfkeep
|
482
|
4087 endif
|
484
|
4088 unlet w:swfkeep
|
482
|
4089 endif
|
719
|
4090
|
482
|
4091 " call Dret("NetOptionRestore")
|
|
4092 endfun
|
|
4093
|
|
4094 " ------------------------------------------------------------------------
|
650
|
4095 " NetReadFixup: this sort of function is typically written by the user {{{2
|
482
|
4096 " to handle extra junk that their system's ftp dumps
|
|
4097 " into the transfer. This function is provided as an
|
|
4098 " example and as a fix for a Windows 95 problem: in my
|
|
4099 " experience, win95's ftp always dumped four blank lines
|
|
4100 " at the end of the transfer.
|
559
|
4101 if has("win95") && exists("g:netrw_win95ftp") && g:netrw_win95ftp
|
482
|
4102 fun! NetReadFixup(method, line1, line2)
|
|
4103 " call Dfunc("NetReadFixup(method<".a:method."> line1=".a:line1." line2=".a:line2.")")
|
|
4104 if method == 3 " ftp (no <.netrc>)
|
|
4105 let fourblanklines= line2 - 3
|
|
4106 silent fourblanklines.",".line2."g/^\s*/d"
|
|
4107 endif
|
|
4108 " call Dret("NetReadFixup")
|
|
4109 endfun
|
|
4110 endif
|
|
4111
|
|
4112 " ---------------------------------------------------------------------
|
650
|
4113 " NetSort: Piet Delport's BISort2() function, modified to take a range {{{2
|
482
|
4114 if v:version < 700
|
|
4115 fun! s:NetSort() range
|
|
4116 " " call Dfunc("NetSort()")
|
719
|
4117
|
482
|
4118 let i = a:firstline + 1
|
|
4119 while i <= a:lastline
|
|
4120 " find insertion point via binary search
|
|
4121 let i_val = getline(i)
|
|
4122 let lo = a:firstline
|
|
4123 let hi = i
|
|
4124 while lo < hi
|
|
4125 let mid = (lo + hi) / 2
|
|
4126 let mid_val = getline(mid)
|
|
4127 if g:netrw_sort_direction =~ '^n'
|
|
4128 " normal sorting order
|
|
4129 if i_val < mid_val
|
|
4130 let hi = mid
|
|
4131 else
|
|
4132 let lo = mid + 1
|
|
4133 if i_val == mid_val | break | endif
|
|
4134 endif
|
|
4135 else
|
|
4136 " reverse sorting order
|
|
4137 if i_val > mid_val
|
|
4138 let hi = mid
|
|
4139 else
|
|
4140 let lo = mid + 1
|
|
4141 if i_val == mid_val | break | endif
|
|
4142 endif
|
|
4143 endif
|
|
4144 endwhile
|
|
4145 " do insert
|
|
4146 if lo < i
|
|
4147 exe 'keepjumps '.i.'d_'
|
|
4148 keepjumps call append(lo - 1, i_val)
|
|
4149 endif
|
|
4150 let i = i + 1
|
|
4151 endwhile
|
719
|
4152
|
482
|
4153 " " call Dret("NetSort")
|
|
4154 endfun
|
|
4155 endif
|
|
4156
|
|
4157 " ---------------------------------------------------------------------
|
650
|
4158 " SetSort: sets up the sort based on the g:netrw_sort_sequence {{{2
|
482
|
4159 " What this function does is to compute a priority for the patterns
|
|
4160 " in the g:netrw_sort_sequence. It applies a substitute to any
|
|
4161 " "files" that satisfy each pattern, putting the priority / in
|
|
4162 " front. An "*" pattern handles the default priority.
|
|
4163 fun! s:SetSort()
|
|
4164 " call Dfunc("SetSort() bannercnt=".w:netrw_bannercnt)
|
519
|
4165 if w:netrw_longlist == 1
|
482
|
4166 let seqlist = substitute(g:netrw_sort_sequence,'\$','\\%(\t\\|\$\\)','ge')
|
|
4167 else
|
|
4168 let seqlist = g:netrw_sort_sequence
|
|
4169 endif
|
|
4170 " sanity check -- insure that * appears somewhere
|
|
4171 if seqlist == ""
|
|
4172 let seqlist= '*'
|
|
4173 elseif seqlist !~ '\*'
|
|
4174 let seqlist= seqlist.',*'
|
|
4175 endif
|
|
4176 let priority = 1
|
|
4177 while seqlist != ""
|
|
4178 if seqlist =~ ','
|
|
4179 let seq = substitute(seqlist,',.*$','','e')
|
|
4180 let seqlist = substitute(seqlist,'^.\{-},\(.*\)$','\1','e')
|
|
4181 else
|
|
4182 let seq = seqlist
|
|
4183 let seqlist = ""
|
|
4184 endif
|
|
4185 let eseq= escape(seq,'/')
|
|
4186 if priority < 10
|
|
4187 let spriority= "00".priority.'\/'
|
|
4188 elseif priority < 100
|
|
4189 let spriority= "0".priority.'\/'
|
|
4190 else
|
|
4191 let spriority= priority.'\/'
|
|
4192 endif
|
|
4193 " call Decho("priority=".priority." spriority<".spriority."> seq<".seq."> seqlist<".seqlist.">")
|
|
4194
|
|
4195 " sanity check
|
|
4196 if w:netrw_bannercnt > line("$")
|
|
4197 " apparently no files were left after a Hiding pattern was used
|
|
4198 " call Dret("SetSort : no files left after hiding")
|
|
4199 return
|
|
4200 endif
|
|
4201 if seq == '*'
|
559
|
4202 exe 'silent keepjumps '.w:netrw_bannercnt.',$v/^\d\{3}\//s/^/'.spriority.'/'
|
482
|
4203 else
|
559
|
4204 exe 'silent keepjumps '.w:netrw_bannercnt.',$g/'.eseq.'/s/^/'.spriority.'/'
|
482
|
4205 endif
|
|
4206 let priority = priority + 1
|
|
4207 endwhile
|
|
4208
|
828
|
4209 " Following line associated with priority -- items that satisfy a priority
|
|
4210 " pattern get prefixed by ###/ which permits easy sorting by priority.
|
|
4211 " Sometimes files can satisfy multiple priority patterns -- only the latest
|
|
4212 " priority pattern needs to be retained. So, at this point, these excess
|
|
4213 " priority prefixes need to be removed, but not directories that happen to
|
|
4214 " be just digits themselves.
|
820
|
4215 exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\(\d\{3}\/\)\%(\d\{3}\/\)\+\ze./\1/e'
|
482
|
4216
|
|
4217 " call Dret("SetSort")
|
|
4218 endfun
|
|
4219
|
|
4220 " ---------------------------------------------------------------------
|
650
|
4221 " SaveWinVars: (used by Explore()) {{{2
|
482
|
4222 fun! s:SaveWinVars()
|
|
4223 " call Dfunc("SaveWinVars()")
|
|
4224 if exists("w:netrw_bannercnt") |let s:bannercnt = w:netrw_bannercnt |endif
|
|
4225 if exists("w:netrw_method") |let s:method = w:netrw_method |endif
|
|
4226 if exists("w:netrw_prvdir") |let s:prvdir = w:netrw_prvdir |endif
|
|
4227 if exists("w:netrw_explore_indx") |let s:explore_indx = w:netrw_explore_indx |endif
|
|
4228 if exists("w:netrw_explore_listlen")|let s:explore_listlen = w:netrw_explore_listlen|endif
|
|
4229 if exists("w:netrw_explore_mtchcnt")|let s:explore_mtchcnt = w:netrw_explore_mtchcnt|endif
|
|
4230 if exists("w:netrw_explore_bufnr") |let s:explore_bufnr = w:netrw_explore_bufnr |endif
|
|
4231 if exists("w:netrw_explore_line") |let s:explore_line = w:netrw_explore_line |endif
|
|
4232 if exists("w:netrw_explore_list") |let s:explore_list = w:netrw_explore_list |endif
|
|
4233 " call Dret("SaveWinVars")
|
|
4234 endfun
|
|
4235
|
|
4236 " ---------------------------------------------------------------------
|
650
|
4237 " CopyWinVars: (used by Explore()) {{{2
|
482
|
4238 fun! s:CopyWinVars()
|
|
4239 " call Dfunc("CopyWinVars()")
|
|
4240 if exists("s:bannercnt") |let w:netrw_bannercnt = s:bannercnt |unlet s:bannercnt |endif
|
|
4241 if exists("s:method") |let w:netrw_method = s:method |unlet s:method |endif
|
|
4242 if exists("s:prvdir") |let w:netrw_prvdir = s:prvdir |unlet s:prvdir |endif
|
|
4243 if exists("s:explore_indx") |let w:netrw_explore_indx = s:explore_indx |unlet s:explore_indx |endif
|
|
4244 if exists("s:explore_listlen")|let w:netrw_explore_listlen = s:explore_listlen|unlet s:explore_listlen|endif
|
|
4245 if exists("s:explore_mtchcnt")|let w:netrw_explore_mtchcnt = s:explore_mtchcnt|unlet s:explore_mtchcnt|endif
|
|
4246 if exists("s:explore_bufnr") |let w:netrw_explore_bufnr = s:explore_bufnr |unlet s:explore_bufnr |endif
|
|
4247 if exists("s:explore_line") |let w:netrw_explore_line = s:explore_line |unlet s:explore_line |endif
|
|
4248 if exists("s:explore_list") |let w:netrw_explore_list = s:explore_list |unlet s:explore_list |endif
|
|
4249 " call Dret("CopyWinVars")
|
|
4250 endfun
|
|
4251
|
|
4252 " ---------------------------------------------------------------------
|
650
|
4253 " SetBufWinVars: (used by NetBrowse() and LocalBrowse()) {{{2
|
482
|
4254 " To allow separate windows to have their own activities, such as
|
|
4255 " Explore **/pattern, several variables have been made window-oriented.
|
|
4256 " However, when the user splits a browser window (ex: ctrl-w s), these
|
559
|
4257 " variables are not inherited by the new window. SetBufWinVars() and
|
482
|
4258 " UseBufWinVars() get around that.
|
559
|
4259 fun! s:SetBufWinVars()
|
|
4260 " call Dfunc("SetBufWinVars()")
|
519
|
4261 if exists("w:netrw_longlist") |let b:netrw_longlist = w:netrw_longlist |endif
|
482
|
4262 if exists("w:netrw_bannercnt") |let b:netrw_bannercnt = w:netrw_bannercnt |endif
|
|
4263 if exists("w:netrw_method") |let b:netrw_method = w:netrw_method |endif
|
|
4264 if exists("w:netrw_prvdir") |let b:netrw_prvdir = w:netrw_prvdir |endif
|
|
4265 if exists("w:netrw_explore_indx") |let b:netrw_explore_indx = w:netrw_explore_indx |endif
|
|
4266 if exists("w:netrw_explore_listlen")|let b:netrw_explore_listlen = w:netrw_explore_listlen|endif
|
|
4267 if exists("w:netrw_explore_mtchcnt")|let b:netrw_explore_mtchcnt = w:netrw_explore_mtchcnt|endif
|
|
4268 if exists("w:netrw_explore_bufnr") |let b:netrw_explore_bufnr = w:netrw_explore_bufnr |endif
|
|
4269 if exists("w:netrw_explore_line") |let b:netrw_explore_line = w:netrw_explore_line |endif
|
|
4270 if exists("w:netrw_explore_list") |let b:netrw_explore_list = w:netrw_explore_list |endif
|
559
|
4271 " call Dret("SetBufWinVars")
|
482
|
4272 endfun
|
|
4273
|
|
4274 " ---------------------------------------------------------------------
|
650
|
4275 " UseBufWinVars: (used by NetBrowse() and LocalBrowse() {{{2
|
482
|
4276 " Matching function to BufferWinVars()
|
|
4277 fun! s:UseBufWinVars()
|
|
4278 " call Dfunc("UseBufWinVars()")
|
519
|
4279 if exists("b:netrw_longlist") && !exists("w:netrw_longlist") |let w:netrw_longlist = b:netrw_longlist |endif
|
482
|
4280 if exists("b:netrw_bannercnt") && !exists("w:netrw_bannercnt") |let w:netrw_bannercnt = b:netrw_bannercnt |endif
|
|
4281 if exists("b:netrw_method") && !exists("w:netrw_method") |let w:netrw_method = b:netrw_method |endif
|
|
4282 if exists("b:netrw_prvdir") && !exists("w:netrw_prvdir") |let w:netrw_prvdir = b:netrw_prvdir |endif
|
|
4283 if exists("b:netrw_explore_indx") && !exists("w:netrw_explore_indx") |let w:netrw_explore_indx = b:netrw_explore_indx |endif
|
|
4284 if exists("b:netrw_explore_listlen") && !exists("w:netrw_explore_listlen")|let w:netrw_explore_listlen = b:netrw_explore_listlen|endif
|
|
4285 if exists("b:netrw_explore_mtchcnt") && !exists("w:netrw_explore_mtchcnt")|let w:netrw_explore_mtchcnt = b:netrw_explore_mtchcnt|endif
|
|
4286 if exists("b:netrw_explore_bufnr") && !exists("w:netrw_explore_bufnr") |let w:netrw_explore_bufnr = b:netrw_explore_bufnr |endif
|
|
4287 if exists("b:netrw_explore_line") && !exists("w:netrw_explore_line") |let w:netrw_explore_line = b:netrw_explore_line |endif
|
|
4288 if exists("b:netrw_explore_list") && !exists("w:netrw_explore_list") |let w:netrw_explore_list = b:netrw_explore_list |endif
|
|
4289 " call Dret("UseBufWinVars")
|
|
4290 endfun
|
|
4291
|
559
|
4292 " ---------------------------------------------------------------------
|
650
|
4293 " RFC2396: converts %xx into characters {{{2
|
559
|
4294 fun! netrw#RFC2396(fname)
|
|
4295 " call Dfunc("RFC2396(fname<".a:fname.">)")
|
|
4296 let fname = escape(substitute(a:fname,'%\(\x\x\)','\=nr2char("0x".submatch(1))','ge')," \t")
|
|
4297 " call Dret("RFC2396 ".fname)
|
|
4298 return fname
|
|
4299 endfun
|
|
4300
|
482
|
4301 " ------------------------------------------------------------------------
|
650
|
4302 " Settings Restoration: {{{2
|
482
|
4303 let &cpo= s:keepcpo
|
|
4304 unlet s:keepcpo
|
|
4305
|
|
4306 " ------------------------------------------------------------------------
|
|
4307 " Modelines: {{{1
|
|
4308 " vim:ts=8 fdm=marker
|