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