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