7
|
1 " netrw.vim: (global plugin) Handles file transfer across a network
|
9
|
2 " Last Change: Jun 18, 2004
|
7
|
3 " Maintainer: Charles E. Campbell, Jr. PhD <drchipNOSPAM at campbellfamily.biz>
|
9
|
4 " Version: 46
|
7
|
5 " License: Vim License (see vim's :help license)
|
|
6 "
|
|
7 " But be doers of the word, and not only hearers, deluding your own selves
|
|
8 " (James 1:22 RSV)
|
|
9 " =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
|
10
|
|
11 " Exit quickly when already loaded or when 'compatible' is set.
|
|
12 if exists("loaded_netrw") || &cp
|
|
13 finish
|
|
14 endif
|
9
|
15 let loaded_netrw = "v46"
|
7
|
16 let s:save_cpo = &cpo
|
|
17 set cpo&vim
|
|
18
|
|
19 " ---------------------------------------------------------------------
|
|
20 " Default values for global netrw variables {{{1
|
|
21 if !exists("g:netrw_ftpmode")
|
|
22 let g:netrw_ftpmode= "binary"
|
|
23 endif
|
|
24 if !exists("g:netrw_win95ftp")
|
|
25 let g:netrw_win95ftp= 1
|
|
26 endif
|
|
27 if !exists("g:netrw_cygwin")
|
|
28 if has("win32")
|
|
29 let g:netrw_cygwin= 1
|
|
30 else
|
|
31 let g:netrw_cygwin= 0
|
|
32 endif
|
|
33 endif
|
|
34
|
|
35 " ---------------------------------------------------------------------
|
|
36 " Default values for global protocol variables {{{1
|
|
37 if !exists("g:netrw_rcp_cmd")
|
|
38 let g:netrw_rcp_cmd = "rcp"
|
|
39 endif
|
|
40 if !exists("g:netrw_ftp_cmd")
|
|
41 let g:netrw_ftp_cmd = "ftp"
|
|
42 endif
|
|
43 if !exists("g:netrw_scp_cmd")
|
|
44 let g:netrw_scp_cmd = "scp -q"
|
|
45 endif
|
|
46 if !exists("g:netrw_sftp_cmd")
|
|
47 let g:netrw_sftp_cmd = "sftp"
|
|
48 endif
|
|
49 if !exists("g:netrw_http_cmd")
|
|
50 if executable("wget")
|
|
51 let g:netrw_http_cmd = "wget -q -O"
|
|
52 elseif executable("fetch")
|
|
53 let g:netrw_http_cmd = "fetch -o"
|
|
54 else
|
|
55 let g:netrw_http_cmd = ""
|
|
56 endif
|
|
57 endif
|
|
58 if !exists("g:netrw_dav_cmd")
|
|
59 let g:netrw_dav_cmd = "cadaver"
|
|
60 endif
|
|
61 if !exists("g:netrw_rsync_cmd")
|
|
62 let g:netrw_rsync_cmd = "rsync"
|
|
63 endif
|
|
64 if !exists("g:netrw_fetch_cmd")
|
|
65 if executable("fetch")
|
|
66 let g:netrw_fetch_cmd = "fetch -o"
|
|
67 else
|
|
68 let g:netrw_fetch_cmd = ""
|
|
69 endif
|
|
70 endif
|
9
|
71 if !exists("g:netrw_list_cmd")
|
|
72 if executable("ssh")
|
|
73 let g:netrw_list_cmd= "ssh HOSTNAME ls -Fa"
|
|
74 else
|
|
75 " call Decho("ssh is not executable, can't do netlist")
|
|
76 let g:netrw_list_cmd= ""
|
|
77 endif
|
|
78 endif
|
|
79 if exists("g:netrw_silent") && g:netrw_silent != 0
|
|
80 let g:netrw_silentxfer= "silent "
|
|
81 else
|
|
82 let g:netrw_silentxfer= ""
|
|
83 endif
|
|
84
|
7
|
85
|
|
86 if has("win32")
|
|
87 \ && exists("g:netrw_use_nt_rcp")
|
|
88 \ && g:netrw_use_nt_rcp
|
|
89 \ && executable( $SystemRoot .'/system32/rcp.exe')
|
|
90 let s:netrw_has_nt_rcp = 1
|
|
91 let s:netrw_rcpmode = '-b'
|
|
92 else
|
|
93 let s:netrw_has_nt_rcp = 0
|
|
94 let s:netrw_rcpmode = ''
|
|
95 endif
|
|
96
|
|
97 " ---------------------------------------------------------------------
|
|
98 " Transparency Support: {{{1
|
|
99 " Auto-detection for ftp://*, rcp://*, scp://*, sftp://*, http://*, dav://*,
|
|
100 " and rsync://*
|
|
101 " Should make file transfers across networks transparent. Currently I haven't
|
|
102 " supported appends. Hey, gotta leave something for a future <netrw.vim>!
|
|
103 if version >= 600
|
|
104 augroup Network
|
|
105 au!
|
|
106 if has("win32")
|
|
107 au BufReadCmd file://* exe "doau BufReadPre ".expand("<afile>")|exe 'e '.substitute(expand("<afile>"),"file:/*","","")|exe "doau BufReadPost ".expand("<afile>")
|
|
108 else
|
|
109 au BufReadCmd file:///* exe "doau BufReadPre ".expand("<afile>")|exe 'e /'.substitute(expand("<afile>"),"file:/*","","")|exe "doau BufReadPost ".expand("<afile>")
|
|
110 au BufReadCmd file://localhost/* exe "doau BufReadPre ".expand("<afile>")|exe 'e /'.substitute(expand("<afile>"),"file:/*","","")|exe "doau BufReadPost ".expand("<afile>")
|
|
111 endif
|
|
112 au BufReadCmd ftp://*,rcp://*,scp://*,http://*,dav://*,rsync://*,sftp://* exe "doau BufReadPre ".expand("<afile>")|exe "Nread 0r ".expand("<afile>")|exe "doau BufReadPost ".expand("<afile>")
|
|
113 au FileReadCmd ftp://*,rcp://*,scp://*,http://*,dav://*,rsync://*,sftp://* exe "doau BufReadPre ".expand("<afile>")|exe "Nread " .expand("<afile>")|exe "doau BufReadPost ".expand("<afile>")
|
9
|
114 au BufWriteCmd ftp://*,rcp://*,scp://*,dav://*,rsync://*,sftp://* exe "Nwrite " .expand("<afile>")|call <SID>NetRestorePosn()
|
7
|
115 augroup END
|
|
116 endif
|
|
117
|
|
118 " ------------------------------------------------------------------------
|
|
119 " Commands: :Nread, :Nwrite, and :NetUserPass {{{1
|
|
120 com! -nargs=* Nread call <SID>NetSavePosn()<bar>call <SID>NetRead(<f-args>)<bar>call <SID>NetRestorePosn()
|
|
121 com! -range=% -nargs=* Nwrite call <SID>NetSavePosn()<bar><line1>,<line2>call <SID>NetWrite(<f-args>)<bar>call <SID>NetRestorePosn()
|
|
122 com! -nargs=* NetUserPass call NetUserPass(<f-args>)
|
|
123
|
|
124 " ------------------------------------------------------------------------
|
|
125 " NetSavePosn: saves position of cursor on screen {{{1
|
|
126 fun! s:NetSavePosn()
|
|
127 " call Dfunc("NetSavePosn()")
|
|
128 " Save current line and column
|
|
129 let s:netrw_winnr= winnr()
|
|
130 let s:netrw_line = line(".")
|
|
131 let s:netrw_col = virtcol(".")
|
|
132
|
|
133 " Save top-of-screen line
|
|
134 norm! H0
|
|
135 let s:netrw_hline= line(".")
|
|
136
|
|
137 call s:NetRestorePosn()
|
|
138 " call Dret("NetSavePosn : winnr=".s:netrw_winnr." line=".s:netrw_line." col=".s:netrw_col." hline=".s:netrw_hline)
|
|
139 endfun
|
|
140
|
|
141 " ------------------------------------------------------------------------
|
|
142 " NetRestorePosn: restores the cursor and file position as saved by NetSavePosn() {{{1
|
|
143 fun! <SID>NetRestorePosn()
|
|
144 " call Dfunc("NetRestorePosn() winnr=".s:netrw_winnr." line=".s:netrw_line." col=".s:netrw_col." hline=".s:netrw_hline)
|
|
145
|
|
146 exe "silent! ".s:netrw_winnr."wincmd w"
|
|
147 if v:shell_error == 0
|
|
148 " as suggested by Bram M: redraw on no error
|
|
149 " allows protocol error messages to remain visible
|
|
150 redraw!
|
|
151 endif
|
|
152 " restore top-of-screen line
|
|
153 exe "norm! ".s:netrw_hline."G0z\<CR>"
|
|
154 " restore position
|
|
155 exe "norm! ".s:netrw_line."G0".s:netrw_col."\<bar>"
|
|
156
|
|
157 " call Dret("NetRestorePosn")
|
|
158 endfun
|
|
159
|
|
160 " ------------------------------------------------------------------------
|
|
161 " NetRead: responsible for reading a file over the net {{{1
|
|
162 fun! s:NetRead(...)
|
|
163 " call Dfunc("NetRead(a:1<".a:1.">)")
|
|
164
|
|
165 " save options
|
|
166 call s:NetOptionSave()
|
|
167
|
|
168 " Special Exception: if a file is named "0r", then
|
|
169 " "0r" will be used to read the
|
|
170 " following files instead of "r"
|
|
171 if a:0 == 0
|
|
172 let readcmd= "r"
|
|
173 let ichoice= 0
|
|
174 elseif a:1 == "0r"
|
|
175 let readcmd = "0r"
|
|
176 let ichoice = 2
|
|
177 else
|
|
178 let readcmd = "r"
|
|
179 let ichoice = 1
|
|
180 endif
|
|
181
|
9
|
182 " get name of a temporary file
|
|
183 let tmpfile= tempname()
|
|
184
|
|
185 " call Decho("ichoice=".ichoice." readcmd<".readcmd.">")
|
7
|
186 while ichoice <= a:0
|
|
187
|
|
188 " attempt to repeat with previous host-file-etc
|
|
189 if exists("b:netrw_lastfile") && a:0 == 0
|
|
190 " call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">")
|
|
191 let choice = b:netrw_lastfile
|
|
192 let ichoice= ichoice + 1
|
|
193
|
|
194 else
|
|
195 exe "let choice= a:" . ichoice
|
9
|
196 " call Decho("no lastfile: choice<" . choice . ">")
|
7
|
197
|
|
198 " Reconstruct Choice if choice starts with '"'
|
|
199 if match(choice,"?") == 0
|
|
200 echo 'NetRead Usage:'
|
|
201 echo ':Nread machine:path uses rcp'
|
|
202 echo ':Nread "machine path" uses ftp with <.netrc>'
|
|
203 echo ':Nread "machine id password path" uses ftp'
|
|
204 echo ':Nread dav://machine[:port]/path uses cadaver'
|
|
205 echo ':Nread fetch://machine/path uses fetch'
|
|
206 echo ':Nread ftp://[user@]machine[:port]/path uses ftp autodetects <.netrc>'
|
|
207 echo ':Nread http://[user@]machine/path uses http wget'
|
|
208 echo ':Nread rcp://[user@]machine/path uses rcp'
|
|
209 echo ':Nread rsync://machine[:port]/path uses rsync'
|
|
210 echo ':Nread scp://[user@]machine[[:#]port]/path uses scp'
|
|
211 echo ':Nread sftp://[user@]machine[[:#]port]/path uses sftp'
|
|
212 break
|
|
213 elseif match(choice,"^\"") != -1
|
|
214 " call Decho("reconstructing choice")
|
|
215 if match(choice,"\"$") != -1
|
|
216 " case "..."
|
|
217 let choice=strpart(choice,1,strlen(choice)-2)
|
|
218 else
|
|
219 " case "... ... ..."
|
|
220 let choice = strpart(choice,1,strlen(choice)-1)
|
|
221 let wholechoice = ""
|
|
222
|
|
223 while match(choice,"\"$") == -1
|
|
224 let wholechoice = wholechoice . " " . choice
|
|
225 let ichoice = ichoice + 1
|
|
226 if ichoice > a:0
|
|
227 echoerr "Unbalanced string in filename '". wholechoice ."'"
|
|
228 " call Dret("NetRead")
|
|
229 return
|
|
230 endif
|
|
231 let choice= a:{ichoice}
|
|
232 endwhile
|
|
233 let choice= strpart(wholechoice,1,strlen(wholechoice)-1) . " " . strpart(choice,0,strlen(choice)-1)
|
|
234 endif
|
|
235 endif
|
|
236 endif
|
9
|
237 " call Decho("choice<" . choice . ">")
|
7
|
238 let ichoice= ichoice + 1
|
|
239
|
|
240 " fix up windows urls
|
|
241 if has("win32")
|
|
242 let choice = substitute(choice,'\\','/','ge')
|
9
|
243 " call Decho("fixing up windows url to <".choice."> tmpfile<".tmpfile)
|
7
|
244 exe 'lcd ' . fnamemodify(tmpfile,':h')
|
|
245 let tmpfile = fnamemodify(tmpfile,':t')
|
|
246 endif
|
|
247
|
|
248 " Determine method of read (ftp, rcp, etc)
|
|
249 call s:NetMethod(choice)
|
|
250
|
9
|
251 " Check if NetList() should be handling this request
|
|
252 " call Decho("checking if netlist: choice<".choice."> netrw_list_cmd<".g:netrw_list_cmd.">")
|
|
253 if choice =~ "^.*/$"
|
|
254 if strlen(g:netrw_list_cmd) > 0
|
|
255 call s:NetList(choice)
|
|
256 " call Dret("NetRead")
|
|
257 else
|
|
258 echoerr "sorry, can't do a remote listing; ssh isn't executable"
|
|
259 endif
|
|
260 return
|
|
261 endif
|
|
262
|
7
|
263 " ============
|
|
264 " Perform Read
|
|
265 " ============
|
|
266
|
|
267 ".........................................
|
9
|
268 " rcp: NetRead Method #1
|
7
|
269 if b:netrw_method == 1 " read with rcp
|
|
270 " call Decho("read via rcp (method #1)")
|
|
271 " ER: noting done with g:netrw_uid yet?
|
|
272 " ER: on Win2K" rcp machine[.user]:file tmpfile
|
|
273 " ER: if machine contains '.' adding .user is required (use $USERNAME)
|
|
274 " ER: the tmpfile is full path: rcp sees C:\... as host C
|
|
275 if s:netrw_has_nt_rcp == 1
|
|
276 if exists("g:netrw_uid") && ( g:netrw_uid != "" )
|
|
277 let uid_machine = g:netrw_machine .'.'. g:netrw_uid
|
|
278 else
|
|
279 " Any way needed it machine contains a '.'
|
|
280 let uid_machine = g:netrw_machine .'.'. $USERNAME
|
|
281 endif
|
|
282 else
|
|
283 if exists("g:netrw_uid") && ( g:netrw_uid != "" )
|
|
284 let uid_machine = g:netrw_uid .'@'. g:netrw_machine
|
|
285 else
|
|
286 let uid_machine = g:netrw_machine
|
|
287 endif
|
|
288 endif
|
|
289 " call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".uid_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile)
|
9
|
290 exe g:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".uid_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile
|
|
291 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
|
7
|
292 let b:netrw_lastfile = choice
|
|
293
|
|
294 ".........................................
|
9
|
295 " ftp + <.netrc>: NetRead Method #2
|
7
|
296 elseif b:netrw_method == 2 " read with ftp + <.netrc>
|
|
297 " call Decho("read via ftp+.netrc (method #2)")
|
|
298 let netrw_fname= b:netrw_fname
|
|
299 new
|
|
300 set ff=unix
|
|
301 exe "put ='".g:netrw_ftpmode."'"
|
|
302 exe "put ='get ".netrw_fname." ".tmpfile."'"
|
|
303 if exists("g:netrw_port") && g:netrw_port != ""
|
|
304 " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port)
|
9
|
305 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port
|
7
|
306 else
|
|
307 " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine)
|
9
|
308 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine
|
7
|
309 endif
|
|
310 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
|
|
311 if getline(1) !~ "^$"
|
|
312 echoerr getline(1)
|
|
313 endif
|
|
314 bd!
|
|
315 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
|
|
316 let b:netrw_lastfile = choice
|
|
317
|
|
318 ".........................................
|
9
|
319 " ftp + machine,id,passwd,filename: NetRead Method #3
|
7
|
320 elseif b:netrw_method == 3 " read with ftp + machine, id, passwd, and fname
|
|
321 " Construct execution string (four lines) which will be passed through filter
|
|
322 " call Decho("read via ftp+mipf (method #3)")
|
|
323 let netrw_fname= b:netrw_fname
|
|
324 new
|
|
325 set ff=unix
|
|
326 if exists("g:netrw_port") && g:netrw_port != ""
|
|
327 put ='open '.g:netrw_machine.' '.g:netrw_port
|
|
328 else
|
|
329 put ='open '.g:netrw_machine
|
|
330 endif
|
|
331
|
|
332 if exists("g:netrw_ftp") && g:netrw_ftp == 1
|
|
333 put =g:netrw_uid
|
|
334 put =g:netrw_passwd
|
|
335 else
|
|
336 put ='user '.g:netrw_uid.' '.g:netrw_passwd
|
|
337 endif
|
|
338
|
|
339 if exists("g:netrw_ftpmode") && g:netrw_ftpmode != ""
|
|
340 put =g:netrw_ftpmode
|
|
341 endif
|
|
342 put ='get '.netrw_fname.' '.tmpfile
|
|
343
|
|
344 " perform ftp:
|
|
345 " -i : turns off interactive prompting from ftp
|
|
346 " -n unix : DON'T use <.netrc>, even though it exists
|
|
347 " -n win32: quit being obnoxious about password
|
|
348 " call Decho('performing ftp -i -n')
|
|
349 norm 1Gdd
|
|
350 " call Decho("executing: %!".g:netrw_ftp_cmd." -i -n")
|
9
|
351 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n"
|
7
|
352 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
|
|
353 if getline(1) !~ "^$"
|
|
354 echoerr getline(1)
|
|
355 endif
|
|
356 bd!
|
|
357 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
|
|
358 let b:netrw_lastfile = choice
|
|
359
|
|
360 ".........................................
|
9
|
361 " scp: NetRead Method #4
|
7
|
362 elseif b:netrw_method == 4 " read with scp
|
|
363 " call Decho("read via scp (method #4)")
|
|
364 if exists("g:netrw_port") && g:netrw_port != ""
|
|
365 let useport= " -P ".g:netrw_port
|
|
366 else
|
|
367 let useport= ""
|
|
368 endif
|
|
369 if g:netrw_cygwin == 1
|
|
370 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
|
|
371 " call Decho("executing: !".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile)
|
9
|
372 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile
|
7
|
373 else
|
|
374 " call Decho("executing: !".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile)
|
9
|
375 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile
|
7
|
376 endif
|
|
377 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
|
|
378 let b:netrw_lastfile = choice
|
|
379
|
|
380 ".........................................
|
|
381 elseif b:netrw_method == 5 " read with http (wget)
|
|
382 " call Decho("read via http (method #5)")
|
|
383 if g:netrw_http_cmd == ""
|
|
384 echoerr "neither wget nor fetch command is available"
|
|
385 exit
|
|
386 endif
|
|
387
|
|
388 if match(b:netrw_fname,"#") == -1
|
|
389 " simple wget
|
|
390 " call Decho("executing: !".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.escape(b:netrw_fname,' ?&'))
|
9
|
391 exe g:netrw_silentxfer."!".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.escape(b:netrw_fname,' ?&')
|
7
|
392 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
|
|
393
|
|
394 else
|
|
395 " wget plus a jump to an in-page marker (ie. http://abc/def.html#aMarker)
|
|
396 let netrw_html= substitute(b:netrw_fname,"#.*$","","")
|
|
397 let netrw_tag = substitute(b:netrw_fname,"^.*#","","")
|
|
398 " call Decho("netrw_html<".netrw_html.">")
|
|
399 " call Decho("netrw_tag <".netrw_tag.">")
|
|
400 " call Decho("executing: !".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_html)
|
9
|
401 exe g:netrw_silentxfer."!".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_html
|
7
|
402 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
|
|
403 " call Decho('<\s*a\s*name=\s*"'.netrw_tag.'"/')
|
|
404 exe 'norm! 1G/<\s*a\s*name=\s*"'.netrw_tag.'"/'."\<CR>"
|
|
405 endif
|
|
406 let b:netrw_lastfile = choice
|
|
407
|
|
408 ".........................................
|
9
|
409 " cadaver: NetRead Method #6
|
7
|
410 elseif b:netrw_method == 6 " read with cadaver
|
|
411 " call Decho("read via cadaver (method #6)")
|
|
412
|
|
413 " Construct execution string (four lines) which will be passed through filter
|
|
414 let netrw_fname= b:netrw_fname
|
|
415 new
|
|
416 set ff=unix
|
|
417 if exists("g:netrw_port") && g:netrw_port != ""
|
|
418 put ='open '.g:netrw_machine.' '.g:netrw_port
|
|
419 else
|
|
420 put ='open '.g:netrw_machine
|
|
421 endif
|
|
422 put ='user '.g:netrw_uid.' '.g:netrw_passwd
|
|
423
|
|
424 if g:netrw_cygwin == 1
|
|
425 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
|
|
426 put ='get '.netrw_fname.' '.cygtmpfile
|
|
427 else
|
|
428 put ='get '.netrw_fname.' '.tmpfile
|
|
429 endif
|
|
430
|
|
431 " perform cadaver operation:
|
|
432 norm 1Gdd
|
|
433 " call Decho("executing: %!".g:netrw_dav_cmd)
|
9
|
434 exe g:netrw_silentxfer."%!".g:netrw_dav_cmd
|
7
|
435 bd!
|
|
436 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
|
|
437 let b:netrw_lastfile = choice
|
|
438
|
|
439 ".........................................
|
9
|
440 " rsync: NetRead Method #7
|
7
|
441 elseif b:netrw_method == 7 " read with rsync
|
|
442 " call Decho("read via rsync (method #7)")
|
|
443 if g:netrw_cygwin == 1
|
|
444 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
|
|
445 " call Decho("executing: !".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile)
|
9
|
446 exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile
|
7
|
447 else
|
|
448 " call Decho("executing: !".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile)
|
9
|
449 exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile
|
7
|
450 endif
|
|
451 let result = s:NetGetFile(readcmd,tmpfile, b:netrw_method)
|
|
452 let b:netrw_lastfile = choice
|
|
453
|
|
454 ".........................................
|
9
|
455 " fetch: NetRead Method #8
|
7
|
456 " fetch://[user@]host[:http]/path
|
|
457 elseif b:netrw_method == 8 " read with fetch
|
|
458 if g:netrw_fetch_cmd == ""
|
|
459 echoerr "fetch command not available"
|
|
460 exit
|
|
461 endif
|
|
462 if exists("g:netrw_option") && g:netrw_option == ":http"
|
|
463 let netrw_option= "http"
|
|
464 else
|
|
465 let netrw_option= "ftp"
|
|
466 endif
|
|
467 " call Decho("read via fetch for ".netrw_option)
|
|
468
|
|
469 if exists("g:netrw_uid") && g:netrw_uid != "" && exists("g:netrw_passwd") && g:netrw_passwd != ""
|
|
470 " call Decho("executing: !".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_uid.':'.g:netrw_passwd.'@'.g:netrw_machine."/".escape(b:netrw_fname,' ?&'))
|
9
|
471 exe g:netrw_silentxfer."!".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_uid.':'.g:netrw_passwd.'@'.g:netrw_machine."/".escape(b:netrw_fname,' ?&')
|
7
|
472 else
|
|
473 " call Decho("executing: !".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_machine."/".escape(b:netrw_fname,' ?&'))
|
9
|
474 exe g:netrw_silentxfer."!".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_machine."/".escape(b:netrw_fname,' ?&')
|
7
|
475 endif
|
|
476
|
|
477 let result = s:NetGetFile(readcmd,tmpfile, b:netrw_method)
|
|
478 let b:netrw_lastfile = choice
|
|
479
|
|
480 ".........................................
|
9
|
481 " sftp: NetRead Method #9
|
7
|
482 elseif b:netrw_method == 9 " read with sftp
|
|
483 " call Decho("read via sftp (method #4)")
|
|
484 if g:netrw_cygwin == 1
|
|
485 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
|
|
486 " call Decho("!".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile)
|
|
487 " call Decho("executing: !".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile)
|
|
488 exe "!".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile
|
|
489 else
|
|
490 " call Decho("executing: !".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile)
|
9
|
491 exe g:netrw_silentxfer."!".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile
|
7
|
492 endif
|
|
493 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
|
|
494 let b:netrw_lastfile = choice
|
|
495
|
|
496 ".........................................
|
|
497 else " Complain
|
|
498 echo "***warning*** unable to comply with your request<" . choice . ">"
|
|
499 endif
|
|
500 endwhile
|
|
501
|
|
502 " cleanup
|
|
503 " call Decho("cleanup")
|
|
504 if exists("b:netrw_method")
|
|
505 unlet b:netrw_method
|
|
506 unlet g:netrw_machine
|
|
507 unlet b:netrw_fname
|
|
508 endif
|
|
509 call s:NetOptionRestore()
|
|
510
|
|
511 " call Dret("NetRead")
|
|
512 endfun
|
|
513 " end of NetRead
|
|
514
|
|
515 " ------------------------------------------------------------------------
|
|
516 " NetGetFile: Function to read file "fname" with command "readcmd". {{{1
|
|
517 fun! s:NetGetFile(readcmd, fname, method)
|
9
|
518 "" call Dfunc("NetGetFile(readcmd<".a:readcmd.">,fname<".a:fname."> method<".a:method.">)")
|
7
|
519
|
|
520 if exists("*NetReadFixup")
|
|
521 " for the use of NetReadFixup (not otherwise used internally)
|
|
522 let line2= line("$")
|
|
523 endif
|
|
524
|
|
525 " transform paths from / to \ for Windows, unless the shell is bash
|
|
526 if &term == "win32"
|
|
527 if &shell == "bash"
|
|
528 let fname=a:fname
|
9
|
529 "" call Decho("(win32 && bash) fname<".fname.">")
|
7
|
530 else
|
|
531 let fname=substitute(a:fname,'/','\\\\','ge')
|
9
|
532 "" call Decho("(win32 && !bash) fname<".fname.">")
|
7
|
533 endif
|
|
534 else
|
|
535 let fname= a:fname
|
9
|
536 "" call Decho("(copied) fname<".fname.">")
|
7
|
537 endif
|
|
538
|
|
539 " get the file, but disable undo when reading a new buffer
|
|
540 if a:readcmd[0] == '0'
|
|
541 let use_e_cmd = 0 " 1 when using ':edit'
|
|
542 let delline = 0 " 1 when have to delete empty last line
|
|
543 if line("$") == 1 && getline(1) == ""
|
|
544 " Now being asked to 0r a file into an empty file.
|
|
545 " Safe to :e it instead, unless there is another window on the same buffer.
|
|
546 let curbufnr = bufnr("%")
|
|
547 let use_e_cmd = 1
|
|
548 let delline = 1
|
|
549 " Loop over all windows,
|
|
550 " reset use_e_cmd when another one is editing the current buffer.
|
|
551 let i = 1
|
|
552 while 1
|
|
553 if i != winnr() && winbufnr(i) == curbufnr
|
|
554 let use_e_cmd = 0
|
|
555 break
|
|
556 endif
|
|
557 let i = i + 1
|
|
558 if winbufnr(i) < 0
|
|
559 break
|
|
560 endif
|
|
561 endwhile
|
|
562 endif
|
|
563
|
|
564 if use_e_cmd > 0
|
|
565 " ':edit' the temp file, wipe out the old buffer and rename the buffer
|
|
566 let curfilename = expand("%")
|
|
567
|
|
568 let binlocal = &l:bin
|
|
569 let binglobal = &g:bin
|
|
570 if binlocal
|
|
571 setglobal bin " Need to set 'bin' globally for ":e" command.
|
|
572 endif
|
|
573 silent exe "e! ".v:cmdarg." ".fname
|
|
574 if binlocal && !binglobal
|
|
575 setglobal nobin
|
|
576 setlocal bin
|
|
577 endif
|
|
578
|
|
579 exe curbufnr . "bwipe!"
|
|
580 exe "f ".curfilename
|
|
581 " the ":f newname" apparently leaves the temporary file as the alternate
|
|
582 " file in the buffer list (see :ls!). The following command wipes it out.
|
|
583 exe bufnr("#")."bwipe!"
|
|
584 else
|
|
585 let oldul= &ul
|
|
586 set ul=-1
|
|
587 exe a:readcmd." ".v:cmdarg." ".fname
|
|
588 if delline > 0
|
|
589 " wipe out last line, which should be a blank line anyway
|
|
590 $del
|
|
591 endif
|
|
592 let &ul= oldul
|
|
593 endif
|
|
594 else
|
|
595 exe a:readcmd." ".v:cmdarg." ".fname
|
|
596 endif
|
|
597
|
|
598 " User-provided (ie. optional) fix-it-up command
|
|
599 if exists("*NetReadFixup")
|
|
600 let line1= line(".")
|
|
601 if a:readcmd == "r"
|
|
602 let line2= line("$") - line2 + line1
|
|
603 else
|
|
604 let line2= line("$") - line2
|
|
605 endif
|
9
|
606 "" call Decho("calling NetReadFixup(method<".a:method."> line1=".line1." line2=".line2.")")
|
7
|
607 call NetReadFixup(a:method, line1, line2)
|
|
608 endif
|
9
|
609 "" call Decho("readcmd<".a:readcmd."> cmdarg<".v:cmdarg."> fname<".a:fname."> readable=".filereadable(a:fname))
|
7
|
610
|
|
611 " insure that we have the right filetype and that its being displayed
|
|
612 filetype detect
|
|
613 redraw!
|
9
|
614 "" call Dret("NetGetFile")
|
7
|
615 endfun
|
|
616
|
|
617 " ------------------------------------------------------------------------
|
|
618 " NetWrite: responsible for writing a file over the net {{{1
|
|
619 fun! s:NetWrite(...) range
|
9
|
620 "" call Dfunc("NetWrite(a:0=".a:0.")")
|
7
|
621
|
|
622 " option handling
|
|
623 let mod= 0
|
|
624 call s:NetOptionSave()
|
|
625
|
|
626 " Get Temporary Filename
|
|
627 let tmpfile= tempname()
|
|
628
|
|
629 if a:0 == 0
|
|
630 let ichoice = 0
|
|
631 else
|
|
632 let ichoice = 1
|
|
633 endif
|
|
634
|
|
635 " write (selected portion of) file to temporary
|
|
636 silent exe a:firstline."," . a:lastline . "w! ".v:cmdarg." ".tmpfile
|
|
637
|
|
638 while ichoice <= a:0
|
|
639
|
|
640 " attempt to repeat with previous host-file-etc
|
|
641 if exists("b:netrw_lastfile") && a:0 == 0
|
9
|
642 "" call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">")
|
7
|
643 let choice = b:netrw_lastfile
|
|
644 let ichoice= ichoice + 1
|
|
645 else
|
|
646 exe "let choice= a:" . ichoice
|
|
647
|
|
648 " Reconstruct Choice if choice starts with '"'
|
|
649 if match(choice,"?") == 0
|
|
650 echo 'NetWrite Usage:"'
|
|
651 echo ':Nwrite machine:path uses rcp'
|
|
652 echo ':Nwrite "machine path" uses ftp with <.netrc>'
|
|
653 echo ':Nwrite "machine id password path" uses ftp'
|
|
654 echo ':Nwrite dav://[user@]machine/path uses cadaver'
|
|
655 echo ':Nwrite fetch://[user@]machine/path uses fetch'
|
|
656 echo ':Nwrite ftp://machine[#port]/path uses ftp (autodetects <.netrc>)'
|
|
657 echo ':Nwrite rcp://machine/path uses rcp'
|
|
658 echo ':Nwrite rsync://[user@]machine/path uses rsync'
|
|
659 echo ':Nwrite scp://[user@]machine[[:#]port]/path uses scp'
|
|
660 echo ':Nwrite sftp://[user@]machine/path uses sftp'
|
|
661 break
|
|
662
|
|
663 elseif match(choice,"^\"") != -1
|
|
664 if match(choice,"\"$") != -1
|
|
665 " case "..."
|
|
666 let choice=strpart(choice,1,strlen(choice)-2)
|
|
667 else
|
|
668 " case "... ... ..."
|
|
669 let choice = strpart(choice,1,strlen(choice)-1)
|
|
670 let wholechoice = ""
|
|
671
|
|
672 while match(choice,"\"$") == -1
|
|
673 let wholechoice= wholechoice . " " . choice
|
|
674 let ichoice = ichoice + 1
|
|
675 if choice > a:0
|
|
676 echoerr "Unbalanced string in filename '". wholechoice ."'"
|
9
|
677 "" call Dret("NetWrite")
|
7
|
678 return
|
|
679 endif
|
|
680 let choice= a:{ichoice}
|
|
681 endwhile
|
|
682 let choice= strpart(wholechoice,1,strlen(wholechoice)-1) . " " . strpart(choice,0,strlen(choice)-1)
|
|
683 endif
|
|
684 endif
|
|
685 endif
|
9
|
686 "" call Decho("choice<" . choice . ">")
|
7
|
687 let ichoice= ichoice + 1
|
|
688
|
|
689 " fix up windows urls
|
|
690 if has("win32")
|
|
691 let choice= substitute(choice,'\\','/','ge')
|
|
692 "ER: see NetRead()
|
|
693 exe 'lcd ' . fnamemodify(tmpfile,':h')
|
|
694 let tmpfile = fnamemodify(tmpfile,':t')
|
|
695 endif
|
|
696
|
|
697 " Determine method of read (ftp, rcp, etc)
|
|
698 call s:NetMethod(choice)
|
|
699
|
|
700 " =============
|
|
701 " Perform Write
|
|
702 " =============
|
|
703
|
|
704 ".........................................
|
9
|
705 " rcp: NetWrite Method #1
|
7
|
706 if b:netrw_method == 1 " write with rcp
|
9
|
707 "" Decho "write via rcp (method #1)"
|
7
|
708 if s:netrw_has_nt_rcp == 1
|
|
709 if exists("g:netrw_uid") && ( g:netrw_uid != "" )
|
|
710 let uid_machine = g:netrw_machine .'.'. g:netrw_uid
|
|
711 else
|
|
712 let uid_machine = g:netrw_machine .'.'. $USERNAME
|
|
713 endif
|
|
714 else
|
|
715 if exists("g:netrw_uid") && ( g:netrw_uid != "" )
|
|
716 let uid_machine = g:netrw_uid .'@'. g:netrw_machine
|
|
717 else
|
|
718 let uid_machine = g:netrw_machine
|
|
719 endif
|
|
720 endif
|
9
|
721 "" call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".tmpfile." ".uid_machine.":".escape(b:netrw_fname,' ?&'))
|
|
722 exe g:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".tmpfile." ".uid_machine.":".escape(b:netrw_fname,' ?&')
|
7
|
723 let b:netrw_lastfile = choice
|
|
724
|
|
725 ".........................................
|
9
|
726 " ftp + <.netrc>: NetWrite Method #2
|
7
|
727 elseif b:netrw_method == 2 " write with ftp + <.netrc>
|
|
728 let netrw_fname = b:netrw_fname
|
|
729 new
|
|
730 set ff=unix
|
|
731 exe "put ='".g:netrw_ftpmode."'"
|
9
|
732 "" call Decho(" NetWrite: put ='".g:netrw_ftpmode."'")
|
7
|
733 exe "put ='put ".tmpfile." ".netrw_fname."'"
|
9
|
734 "" call Decho("put ='put ".tmpfile." ".netrw_fname."'")
|
7
|
735 if exists("g:netrw_port") && g:netrw_port != ""
|
9
|
736 "" call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port)
|
|
737 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port
|
7
|
738 else
|
9
|
739 "" call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine)
|
|
740 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine
|
7
|
741 endif
|
|
742 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
|
|
743 if getline(1) !~ "^$"
|
|
744 echoerr getline(1)
|
|
745 let mod=1
|
|
746 endif
|
|
747 bd!
|
|
748 let b:netrw_lastfile = choice
|
|
749
|
|
750 ".........................................
|
9
|
751 " ftp + machine, id, passwd, filename: NetWrite Method #3
|
7
|
752 elseif b:netrw_method == 3 " write with ftp + machine, id, passwd, and fname
|
|
753 let netrw_fname= b:netrw_fname
|
|
754 new
|
|
755 set ff=unix
|
|
756 if exists("g:netrw_port") && g:netrw_port != ""
|
|
757 put ='open '.g:netrw_machine.' '.g:netrw_port
|
|
758 else
|
|
759 put ='open '.g:netrw_machine
|
|
760 endif
|
|
761 if exists("g:netrw_ftp") && g:netrw_ftp == 1
|
|
762 put =g:netrw_uid
|
|
763 put =g:netrw_passwd
|
|
764 else
|
|
765 put ='user '.g:netrw_uid.' '.g:netrw_passwd
|
|
766 endif
|
|
767 put ='put '.tmpfile.' '.netrw_fname
|
|
768 " save choice/id/password for future use
|
|
769 let b:netrw_lastfile = choice
|
|
770
|
|
771 " perform ftp:
|
|
772 " -i : turns off interactive prompting from ftp
|
|
773 " -n unix : DON'T use <.netrc>, even though it exists
|
|
774 " -n win32: quit being obnoxious about password
|
9
|
775 "" call Decho('performing ftp -i -n')
|
7
|
776 norm 1Gdd
|
9
|
777 "" call Decho("executing: %!".g:netrw_ftp_cmd." -i -n")
|
|
778 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n"
|
7
|
779 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
|
|
780 if getline(1) !~ "^$"
|
|
781 echoerr getline(1)
|
|
782 let mod=1
|
|
783 endif
|
|
784 bd!
|
|
785
|
|
786 ".........................................
|
9
|
787 " scp: NetWrite Method #4
|
7
|
788 elseif b:netrw_method == 4 " write with scp
|
|
789 if exists("g:netrw_port") && g:netrw_port != ""
|
|
790 let useport= " -P ".g:netrw_port
|
|
791 else
|
|
792 let useport= ""
|
|
793 endif
|
|
794 if g:netrw_cygwin == 1
|
|
795 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
|
9
|
796 "" call Decho("executing: !".g:netrw_scp_cmd.useport." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&'))
|
|
797 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')
|
7
|
798 else
|
9
|
799 "" call Decho("executing: !".g:netrw_scp_cmd.useport." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&'))
|
|
800 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')
|
7
|
801 endif
|
|
802 let b:netrw_lastfile = choice
|
|
803
|
|
804 ".........................................
|
9
|
805 " http: NetWrite Method #5
|
7
|
806 elseif b:netrw_method == 5
|
|
807 echoerr "***warning*** currently <netrw.vim> does not support writing using http:"
|
|
808
|
|
809 ".........................................
|
9
|
810 " dav: NetWrite Method #6
|
7
|
811 elseif b:netrw_method == 6 " write with cadaver
|
9
|
812 "" call Decho("write via cadaver (method #6)")
|
7
|
813
|
|
814 " Construct execution string (four lines) which will be passed through filter
|
|
815 let netrw_fname= b:netrw_fname
|
|
816 new
|
|
817 set ff=unix
|
|
818 if exists("g:netrw_port") && g:netrw_port != ""
|
|
819 put ='open '.g:netrw_machine.' '.g:netrw_port
|
|
820 else
|
|
821 put ='open '.g:netrw_machine
|
|
822 endif
|
|
823 put ='user '.g:netrw_uid.' '.g:netrw_passwd
|
|
824
|
|
825 if g:netrw_cygwin == 1
|
|
826 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
|
|
827 put ='put '.cygtmpfile.' '.netrw_fname
|
|
828 else
|
|
829 put ='put '.tmpfile.' '.netrw_fname
|
|
830 endif
|
|
831
|
|
832 " perform cadaver operation:
|
|
833 norm 1Gdd
|
9
|
834 "" call Decho("executing: %!".g:netrw_dav_cmd)
|
|
835 exe g:netrw_silentxfer."%!".g:netrw_dav_cmd
|
7
|
836 bd!
|
|
837 let b:netrw_lastfile = choice
|
|
838
|
|
839 ".........................................
|
9
|
840 " rsync: NetWrite Method #7
|
7
|
841 elseif b:netrw_method == 7 " write with rsync
|
|
842 if g:netrw_cygwin == 1
|
|
843 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e')
|
9
|
844 "" call Decho("executing: !".g:netrw_rsync_cmd." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&'))
|
|
845 exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')
|
7
|
846 else
|
9
|
847 "" call Decho("executing: !".g:netrw_rsync_cmd." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&'))
|
|
848 exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')
|
7
|
849 endif
|
|
850 let b:netrw_lastfile = choice
|
|
851
|
|
852 ".........................................
|
9
|
853 " scp: NetWrite Method #9
|
7
|
854 elseif b:netrw_method == 9 " write with sftp
|
|
855 let netrw_fname= b:netrw_fname
|
|
856 if exists("g:netrw_uid") && ( g:netrw_uid != "" )
|
|
857 let uid_machine = g:netrw_uid .'@'. g:netrw_machine
|
|
858 else
|
|
859 let uid_machine = g:netrw_machine
|
|
860 endif
|
|
861 new
|
|
862 set ff=unix
|
|
863 put ='put '.tmpfile.' '.netrw_fname
|
|
864 norm 1Gdd
|
9
|
865 "" call Decho("executing: %!".g:netrw_sftp_cmd.' '.uid_machine)
|
|
866 exe g:netrw_silentxfer."%!".g:netrw_sftp_cmd.' '.uid_machine
|
7
|
867 bd!
|
|
868 let b:netrw_lastfile= choice
|
|
869
|
|
870 ".........................................
|
|
871 else " Complain
|
|
872 echo "***warning*** unable to comply with your request<" . choice . ">"
|
|
873 endif
|
|
874 endwhile
|
|
875
|
|
876 " cleanup
|
9
|
877 "" call Decho("cleanup")
|
7
|
878 let result=delete(tmpfile)
|
|
879 call s:NetOptionRestore()
|
|
880
|
|
881 if a:firstline == 1 && a:lastline == line("$")
|
|
882 let &mod= mod " usually equivalent to set nomod
|
|
883 endif
|
|
884
|
9
|
885 "" call Dret("NetWrite")
|
7
|
886 endfun
|
|
887 " end of NetWrite
|
|
888
|
|
889 " ------------------------------------------------------------------------
|
9
|
890 " NetList: This function uses the command in g:netrw_list_cmd to get a list {{{1
|
|
891 " of the contents of a remote directory. It is assumed that the
|
|
892 " g:netrw_list_cmd has a string, HOSTNAME, that needs to be substituted
|
|
893 " with the requested remote hostname first.
|
|
894 fun! <SID>NetList(dirname)
|
|
895 "" call Dfunc("NetList(dirname<".a:dirname.">)")
|
|
896
|
|
897 " sanity maintenance
|
|
898 let dirname= a:dirname
|
|
899 if dirname !~ '/$' && (!exists("g:netrw_machine") || !exists("b:netlist_method") || !exists("b:netlist_path"))
|
|
900 let dirname= dirname."/"
|
|
901 endif
|
|
902 set ma
|
|
903
|
|
904 if dirname !~ '/$' && dirname !~ '^"'
|
|
905 " looks like a regular file, attempt transfer
|
|
906 "" call Decho("attempt transfer with regular file<".dirname.">")
|
|
907 "" call Decho("netlist method<".b:netlist_method."> cmd<".b:netlist_cmd."> path<".b:netlist_path.">")
|
|
908 %d
|
|
909
|
|
910 " remove any filetype indicator from end of dirname, except for the
|
|
911 " "this is a directory" indicator (/)
|
|
912 let dirname= substitute(dirname,"[*=@|]$","","e")
|
|
913 "" call Decho("modified dirname<".dirname.">")
|
|
914
|
|
915 " remote-read the requested file into current buffer
|
|
916 let machine= g:netrw_machine
|
|
917 let method = b:netlist_method
|
|
918 let path = b:netlist_path
|
|
919 enew!
|
|
920 exe "file ".method."://".machine."/".path.dirname
|
|
921 exe "doau BufReadPre ".dirname
|
|
922 silent call s:NetRead(method."://".machine."/".path.dirname)
|
|
923 exe "doau BufReadPost ".dirname
|
|
924 1d
|
|
925 set nomod noma
|
|
926
|
|
927 silent! unlet b:netlist_method
|
|
928 silent! unlet b:netlist_cmd
|
|
929 silent! unlet b:netlist_path
|
|
930 "" call Dret("NetList")
|
|
931 return
|
|
932
|
|
933 elseif dirname == './'
|
|
934 " refresh the directory list
|
|
935 "" call Decho("refresh directory listing")
|
|
936 "" call Decho("netlist method<".b:netlist_method."> cmd<".b:netlist_cmd."> path<".b:netlist_path.">")
|
|
937 %d
|
|
938
|
|
939 elseif dirname == '../'
|
|
940 " go up one directory
|
|
941
|
|
942 if b:netlist_path !~ '/' && strlen(b:netlist_path) > 0
|
|
943 " go to top (rltv) directory
|
|
944 "" call Decho("go up one directory : 1 path<".b:netlist_path.">")
|
|
945 let b:netlist_path= ""
|
|
946
|
|
947 elseif b:netlist_path !~ '^[./]\+$' && strlen(b:netlist_path) > 0
|
|
948 " remove a directory from the netlist_path
|
|
949 "" call Decho("go up one directory : 2 path<".b:netlist_path.">")
|
|
950 if b:netlist_path =~ '^[^/]*/$'
|
|
951 let b:netlist_path= ""
|
|
952 else
|
|
953 let b:netlist_path= substitute(b:netlist_path,'^\(.*/\)[^/]*/$','\1','')
|
|
954 endif
|
|
955
|
|
956 else
|
|
957 " append ../
|
|
958 "" call Decho("go up one directory : 3 path<".b:netlist_path.">")
|
|
959 let b:netlist_path= b:netlist_path.'../'
|
|
960 endif
|
|
961 "" call Decho("netlist method<".b:netlist_method."> cmd<".b:netlist_cmd."> path<".b:netlist_path.">")
|
|
962 %d
|
|
963
|
|
964 elseif dirname !~ '^\w\+:' && dirname =~ '/$'
|
|
965 " go down one directory
|
|
966 "" call Decho("go down one directory<".dirname.">")
|
|
967 let b:netlist_path=b:netlist_path.dirname
|
|
968 "" call Decho("netlist method<".b:netlist_method."> cmd<".b:netlist_cmd."> path<".b:netlist_path.">")
|
|
969 %d
|
|
970
|
|
971 else
|
|
972 " normal initial directory listing
|
|
973 "" call Decho("normal initial directory listing")
|
|
974
|
|
975 let listcmd = substitute(g:netrw_list_cmd,'\<HOSTNAME\>',g:netrw_machine,'')
|
|
976 let method = substitute(dirname,'^\(\w\+\):.*$','\1','')
|
|
977 let fname = b:netrw_fname
|
|
978 "" call Decho("set up listcmd<".listcmd.">")
|
|
979 "" call Decho("set up method <".method.">")
|
|
980 "" call Decho("set up fname <".fname.">")
|
|
981
|
|
982 " set up window
|
|
983 if &mod == 1
|
|
984 wincmd s
|
|
985 endif
|
|
986 enew!
|
|
987 if v:version >= 602
|
|
988 setlocal bh=wipe
|
|
989 endif
|
|
990
|
|
991 " set up buffer-local variables
|
|
992 let b:netlist_method = method
|
|
993 let b:netlist_cmd = listcmd
|
|
994 let b:netlist_path = fname
|
|
995
|
|
996 " set up buffer-local map
|
|
997 nnoremap <buffer> <cr> :call <SID>NetList(expand("<cWORD>"))<cr>
|
|
998
|
|
999 "" call Decho("netlist method<".b:netlist_method."> cmd<".b:netlist_cmd."> path<".b:netlist_path.">")
|
|
1000 endif
|
|
1001
|
|
1002 "" call Decho("executing: r! ".b:netlist_cmd." '".b:netlist_path."'")
|
|
1003 put ='\" =============================='
|
|
1004 put ='\" Netrw Remote Directory Listing'
|
|
1005 put ='\" '.g:netrw_machine.':'.b:netlist_path
|
|
1006 put ='\" =============================='
|
|
1007 exe "silent r! ".b:netlist_cmd." '".b:netlist_path."'"
|
|
1008 1d
|
|
1009 set ft=netrwlist
|
|
1010 silent 5,$s/^\(.*\)\/$/ \1/e
|
|
1011 silent 5,$call s:NetSort()
|
|
1012 silent 5,$s/^ \(.*\)$/\1\//e
|
|
1013 5
|
|
1014 exe 'file ['.g:netrw_machine.':'.b:netlist_path.']'
|
|
1015 if v:version >= 602
|
|
1016 setlocal nomod bh=wipe bt=nofile nobl noma
|
|
1017 else
|
|
1018 setlocal nomod
|
|
1019 endif
|
|
1020
|
|
1021 "" call Dret("NetList")
|
|
1022 endfun
|
|
1023
|
|
1024 " ------------------------------------------------------------------------
|
7
|
1025 " NetMethod: determine method of transfer {{{1
|
|
1026 " method == 1: rcp
|
|
1027 " 2: ftp + <.netrc>
|
|
1028 " 3: ftp + machine, id, password, and [path]filename
|
|
1029 " 4: scp
|
|
1030 " 5: http (wget)
|
|
1031 " 6: cadaver
|
|
1032 " 7: rsync
|
|
1033 " 8: fetch
|
|
1034 " 9: sftp
|
|
1035 fun! s:NetMethod(choice) " globals: method machine id passwd fname
|
9
|
1036 "" call Dfunc("NetMethod(a:choice<".a:choice.">)")
|
7
|
1037
|
|
1038 " initialization
|
|
1039 let b:netrw_method = 0
|
|
1040 let g:netrw_machine = ""
|
|
1041 let b:netrw_fname = ""
|
|
1042 let g:netrw_port = ""
|
|
1043
|
|
1044 " Patterns:
|
|
1045 " mipf : a:machine a:id password filename Use ftp
|
|
1046 " mf : a:machine filename Use ftp + <.netrc> or g:netrw_uid g:netrw_passwd
|
|
1047 " ftpurm : ftp://[user@]host[[#:]port]/filename Use ftp + <.netrc> or g:netrw_uid g:netrw_passwd
|
|
1048 " rcpurm : rcp://[user@]host/filename Use rcp
|
|
1049 " rcphf : [user@]host:filename Use rcp
|
|
1050 " scpurm : scp://[user@]host[[#:]port]/filename Use scp
|
|
1051 " httpurm : http://[user@]host/filename Use wget
|
|
1052 " davurm : dav://host[:port]/path Use cadaver
|
|
1053 " rsyncurm : rsync://host[:port]/path Use rsync
|
|
1054 " fetchurm : fetch://[user@]host[:http]/filename Use fetch (defaults to ftp, override for http)
|
|
1055 " sftpurm : sftp://[user@]host/filename Use scp
|
9
|
1056 let mipf = '^\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)$'
|
|
1057 let mf = '^\(\S\+\)\s\+\(\S\+\)$'
|
|
1058 let ftpurm = '^ftp://\(\([^/@]\{-}\)@\)\=\([^/#:]\{-}\)\([#:]\d\+\)\=/\(.*\)$'
|
|
1059 let rcpurm = '^rcp://\(\([^/@]\{-}\)@\)\=\([^/]\{-}\)/\(.*\)$'
|
|
1060 let rcphf = '^\(\(\h\w*\)@\)\=\(\h\w*\):\([^@]\+\)$'
|
|
1061 let scpurm = '^scp://\([^/]\{-}\)\([#:]\d\+\)\=/\(.*\)$'
|
|
1062 let httpurm = '^http://\([^/]\{-}\)\(/.*\)\=$'
|
|
1063 let davurm = '^dav://\([^/]\{-}\)/\(.*\)\=$'
|
|
1064 let rsyncurm = '^rsync://\([^/]\{-}\)/\(.*\)\=$'
|
|
1065 let fetchurm = '^fetch://\(\([^/@]\{-}\)@\)\=\([^/#:]\{-}\)\(:http\)\=/\(.*\)$'
|
|
1066 let sftpurm = '^sftp://\([^/]\{-}\)/\(.*\)\=$'
|
7
|
1067
|
9
|
1068 "" call Decho("determine method:")
|
7
|
1069 " Determine Method
|
|
1070 " rcp://user@hostname/...path-to-file
|
|
1071 if match(a:choice,rcpurm) == 0
|
9
|
1072 "" call Decho("rcp://...")
|
7
|
1073 let b:netrw_method = 1
|
|
1074 let userid = substitute(a:choice,rcpurm,'\2',"")
|
|
1075 let g:netrw_machine= substitute(a:choice,rcpurm,'\3',"")
|
|
1076 let b:netrw_fname = substitute(a:choice,rcpurm,'\4',"")
|
|
1077 if userid != ""
|
|
1078 let g:netrw_uid= userid
|
|
1079 endif
|
|
1080
|
|
1081 " scp://user@hostname/...path-to-file
|
|
1082 elseif match(a:choice,scpurm) == 0
|
9
|
1083 "" call Decho("scp://...")
|
7
|
1084 let b:netrw_method = 4
|
|
1085 let g:netrw_machine= substitute(a:choice,scpurm,'\1',"")
|
|
1086 let b:netrw_port = substitute(a:choice,scpurm,'\2',"")
|
|
1087 let b:netrw_fname = substitute(a:choice,scpurm,'\3',"")
|
|
1088
|
|
1089 " http://user@hostname/...path-to-file
|
|
1090 elseif match(a:choice,httpurm) == 0
|
9
|
1091 "" call Decho("http://...")
|
7
|
1092 let b:netrw_method = 5
|
|
1093 let g:netrw_machine= substitute(a:choice,httpurm,'\1',"")
|
|
1094 let b:netrw_fname = substitute(a:choice,httpurm,'\2',"")
|
|
1095
|
|
1096 " dav://hostname[:port]/..path-to-file..
|
|
1097 elseif match(a:choice,davurm) == 0
|
9
|
1098 "" call Decho("dav://...")
|
7
|
1099 let b:netrw_method= 6
|
|
1100 let g:netrw_machine= substitute(a:choice,davurm,'\1',"")
|
|
1101 let b:netrw_fname = substitute(a:choice,davurm,'\2',"")
|
|
1102
|
|
1103 " rsync://user@hostname/...path-to-file
|
|
1104 elseif match(a:choice,rsyncurm) == 0
|
9
|
1105 "" call Decho("rsync://...")
|
7
|
1106 let b:netrw_method = 7
|
|
1107 let g:netrw_machine= substitute(a:choice,rsyncurm,'\1',"")
|
|
1108 let b:netrw_fname = substitute(a:choice,rsyncurm,'\2',"")
|
|
1109
|
|
1110 " ftp://[user@]hostname[[:#]port]/...path-to-file
|
|
1111 elseif match(a:choice,ftpurm) == 0
|
9
|
1112 "" call Decho("ftp://...")
|
7
|
1113 let userid = substitute(a:choice,ftpurm,'\2',"")
|
|
1114 let g:netrw_machine= substitute(a:choice,ftpurm,'\3',"")
|
|
1115 let g:netrw_port = substitute(a:choice,ftpurm,'\4',"")
|
|
1116 let b:netrw_fname = substitute(a:choice,ftpurm,'\5',"")
|
|
1117 if g:netrw_port != ""
|
|
1118 let g:netrw_port = substitute(g:netrw_port,"[#:]","","")
|
|
1119 endif
|
|
1120 if userid != ""
|
|
1121 let g:netrw_uid= userid
|
|
1122 endif
|
|
1123 if exists("g:netrw_uid") && exists("g:netrw_passwd")
|
|
1124 let b:netrw_method = 3
|
|
1125 else
|
|
1126 if filereadable(expand("$HOME/.netrc")) && !exists("g:netrw_ignorenetrc")
|
|
1127 let b:netrw_method= 2
|
|
1128 else
|
|
1129 if !exists("g:netrw_uid") || g:netrw_uid == ""
|
|
1130 call NetUserPass()
|
|
1131 elseif !exists("g:netrw_passwd") || g:netrw_passwd == ""
|
|
1132 call NetUserPass(g:netrw_uid)
|
|
1133 " else just use current g:netrw_uid and g:netrw_passwd
|
|
1134 endif
|
|
1135 let b:netrw_method= 3
|
|
1136 endif
|
|
1137 endif
|
|
1138
|
|
1139 elseif match(a:choice,fetchurm) == 0
|
9
|
1140 "" call Decho("fetch://...")
|
7
|
1141 let b:netrw_method = 8
|
|
1142 let g:netrw_userid = substitute(a:choice,fetchurm,'\2',"")
|
|
1143 let g:netrw_machine= substitute(a:choice,fetchurm,'\3',"")
|
|
1144 let b:netrw_option = substitute(a:choice,fetchurm,'\4',"")
|
|
1145 let b:netrw_fname = substitute(a:choice,fetchurm,'\5',"")
|
|
1146
|
|
1147 " Issue an ftp : "machine id password [path/]filename"
|
|
1148 elseif match(a:choice,mipf) == 0
|
9
|
1149 "" call Decho("(ftp) host id pass file")
|
7
|
1150 let b:netrw_method = 3
|
|
1151 let g:netrw_machine = substitute(a:choice,mipf,'\1',"")
|
|
1152 let g:netrw_uid = substitute(a:choice,mipf,'\2',"")
|
|
1153 let g:netrw_passwd = substitute(a:choice,mipf,'\3',"")
|
|
1154 let b:netrw_fname = substitute(a:choice,mipf,'\4',"")
|
|
1155
|
|
1156 " Issue an ftp: "hostname [path/]filename"
|
|
1157 elseif match(a:choice,mf) == 0
|
9
|
1158 "" call Decho("(ftp) host file")
|
7
|
1159 if exists("g:netrw_uid") && exists("g:netrw_passwd")
|
|
1160 let b:netrw_method = 3
|
|
1161 let g:netrw_machine = substitute(a:choice,mf,'\1',"")
|
|
1162 let b:netrw_fname = substitute(a:choice,mf,'\2',"")
|
|
1163
|
|
1164 elseif filereadable(expand("$HOME/.netrc"))
|
|
1165 let b:netrw_method = 2
|
|
1166 let g:netrw_machine = substitute(a:choice,mf,'\1',"")
|
|
1167 let b:netrw_fname = substitute(a:choice,mf,'\2',"")
|
|
1168 endif
|
|
1169
|
|
1170 " sftp://user@hostname/...path-to-file
|
|
1171 elseif match(a:choice,sftpurm) == 0
|
9
|
1172 "" call Decho("sftp://...")
|
7
|
1173 let b:netrw_method = 9
|
|
1174 let g:netrw_machine= substitute(a:choice,sftpurm,'\1',"")
|
|
1175 let b:netrw_fname = substitute(a:choice,sftpurm,'\2',"")
|
|
1176
|
|
1177 " Issue an rcp: hostname:filename" (this one should be last)
|
|
1178 elseif match(a:choice,rcphf) == 0
|
9
|
1179 "" call Decho("(rcp) [user@]host:file) rcphf<".rcphf.">")
|
7
|
1180 let b:netrw_method = 1
|
|
1181 let userid = substitute(a:choice,rcphf,'\2',"")
|
|
1182 let g:netrw_machine= substitute(a:choice,rcphf,'\3',"")
|
|
1183 let b:netrw_fname = substitute(a:choice,rcphf,'\4',"")
|
9
|
1184 "" call Decho('\1<'.substitute(a:choice,rcphf,'\1',"").">")
|
|
1185 "" call Decho('\2<'.substitute(a:choice,rcphf,'\2',"").">")
|
|
1186 "" call Decho('\3<'.substitute(a:choice,rcphf,'\3',"").">")
|
|
1187 "" call Decho('\4<'.substitute(a:choice,rcphf,'\4',"").">")
|
7
|
1188 if userid != ""
|
|
1189 let g:netrw_uid= userid
|
|
1190 endif
|
|
1191 if has("win32")
|
|
1192 " don't let PCs try <.netrc>
|
|
1193 let b:netrw_method = 3
|
|
1194 endif
|
|
1195
|
|
1196 else
|
|
1197 echoerr "***error*** cannot determine method"
|
|
1198 let b:netrw_method = -1
|
|
1199 endif
|
|
1200
|
9
|
1201 "" call Decho("a:choice <".a:choice.">")
|
|
1202 "" call Decho("b:netrw_method <".b:netrw_method.">")
|
|
1203 "" call Decho("g:netrw_machine<".g:netrw_machine.">")
|
|
1204 "" call Decho("g:netrw_port <".g:netrw_port.">")
|
|
1205 "" if exists("g:netrw_uid") "Decho
|
|
1206 "" call Decho("g:netrw_uid <".g:netrw_uid.">")
|
|
1207 "" endif "Decho
|
|
1208 "" if exists("g:netrw_passwd") "Decho
|
|
1209 "" call Decho("g:netrw_passwd <".g:netrw_passwd.">")
|
|
1210 "" endif "Decho
|
|
1211 "" call Decho("b:netrw_fname <".b:netrw_fname.">")
|
|
1212 "" call Dret("NetMethod")
|
7
|
1213 endfun
|
|
1214 " end of NetMethod
|
|
1215
|
|
1216 " ------------------------------------------------------------------------
|
|
1217 " NetUserPass: set username and password for subsequent ftp transfer {{{1
|
|
1218 " Usage: :call NetUserPass() -- will prompt for userid and password
|
|
1219 " :call NetUserPass("uid") -- will prompt for password
|
|
1220 " :call NetUserPass("uid","password") -- sets global userid and password
|
|
1221 fun! NetUserPass(...)
|
|
1222
|
|
1223 " get/set userid
|
|
1224 if a:0 == 0
|
9
|
1225 "" call Dfunc("NetUserPass(a:0<".a:0.">)")
|
7
|
1226 if !exists("g:netrw_uid") || g:netrw_uid == ""
|
|
1227 " via prompt
|
|
1228 let g:netrw_uid= input('Enter username: ')
|
|
1229 endif
|
|
1230 else " from command line
|
9
|
1231 "" call Dfunc("NetUserPass(a:1<".a:1.">) {")
|
7
|
1232 let g:netrw_uid= a:1
|
|
1233 endif
|
|
1234
|
|
1235 " get password
|
|
1236 if a:0 <= 1 " via prompt
|
9
|
1237 "" call Decho("a:0=".a:0." case <=1:")
|
7
|
1238 let g:netrw_passwd= inputsecret("Enter Password: ")
|
|
1239 else " from command line
|
9
|
1240 "" call Decho("a:0=".a:0." case >1: a:2<".a:2.">")
|
7
|
1241 let g:netrw_passwd=a:2
|
|
1242 endif
|
9
|
1243 "" call Dret("NetUserPass")
|
7
|
1244 endfun
|
|
1245 " end NetUserPass
|
|
1246
|
|
1247 " ------------------------------------------------------------------------
|
|
1248 " NetOptionSave: save options and set to "standard" form {{{1
|
|
1249 fun!s:NetOptionSave()
|
9
|
1250 "" call Dfunc("NetOptionSave()")
|
7
|
1251
|
|
1252 " Get Temporary Filename
|
|
1253 let s:aikeep = &ai
|
|
1254 let s:cinkeep = &cin
|
|
1255 let s:cinokeep = &cino
|
|
1256 let s:comkeep = &com
|
|
1257 let s:cpokeep = &cpo
|
|
1258 let s:dirkeep = getcwd()
|
|
1259 let s:gdkeep = &gd
|
|
1260 let s:twkeep = &tw
|
|
1261 set cino =
|
|
1262 set com =
|
|
1263 set cpo -=aA
|
|
1264 set nocin noai
|
|
1265 set tw =0
|
|
1266 if has("win32") && !has("win95")
|
|
1267 let s:swfkeep= &swf
|
|
1268 set noswf
|
9
|
1269 "" call Decho("setting s:swfkeep to <".&swf.">")
|
7
|
1270 endif
|
|
1271
|
9
|
1272 "" call Dret("NetOptionSave")
|
7
|
1273 endfun
|
|
1274
|
|
1275 " ------------------------------------------------------------------------
|
|
1276 " NetOptionRestore: restore options {{{1
|
|
1277 fun! s:NetOptionRestore()
|
9
|
1278 "" call Dfunc("NetOptionRestore()")
|
7
|
1279
|
|
1280 let &ai = s:aikeep
|
|
1281 let &cin = s:cinkeep
|
|
1282 let &cino = s:cinokeep
|
|
1283 let &com = s:comkeep
|
|
1284 let &cpo = s:cpokeep
|
|
1285 exe "lcd ".s:dirkeep
|
|
1286 let &gd = s:gdkeep
|
|
1287 let &tw = s:twkeep
|
|
1288 if exists("s:swfkeep")
|
|
1289 let &swf= s:swfkeep
|
|
1290 unlet s:swfkeep
|
|
1291 endif
|
|
1292 unlet s:aikeep
|
|
1293 unlet s:cinkeep
|
|
1294 unlet s:cinokeep
|
|
1295 unlet s:comkeep
|
|
1296 unlet s:cpokeep
|
|
1297 unlet s:gdkeep
|
|
1298 unlet s:twkeep
|
|
1299 unlet s:dirkeep
|
|
1300
|
9
|
1301 "" call Dret("NetOptionRestore")
|
7
|
1302 endfun
|
|
1303
|
|
1304 " ------------------------------------------------------------------------
|
|
1305 " NetReadFixup: this sort of function is typically written by the user {{{1
|
9
|
1306 " to handle extra junk that their system's ftp dumps
|
|
1307 " into the transfer. This function is provided as an
|
|
1308 " example and as a fix for a Windows 95 problem: in my
|
|
1309 " experience, win95's ftp always dumped four blank lines
|
|
1310 " at the end of the transfer.
|
7
|
1311 if has("win95") && g:netrw_win95ftp
|
|
1312 fun! NetReadFixup(method, line1, line2)
|
9
|
1313 "" call Dfunc("NetReadFixup(method<".a:method."> line1=".a:line1." line2=".a:line2.")")
|
7
|
1314 if method == 3 " ftp (no <.netrc>)
|
|
1315 let fourblanklines= line2 - 3
|
|
1316 silent fourblanklines.",".line2."g/^\s*/d"
|
|
1317 endif
|
9
|
1318 "" call Dret("NetReadFixup")
|
7
|
1319 endfun
|
|
1320 endif
|
|
1321
|
9
|
1322 " ---------------------------------------------------------------------
|
|
1323 " NetSort: Piet Delport's BISort2() function, modified to take a range
|
|
1324 fun! <SID>NetSort() range
|
|
1325 let i = a:firstline + 1
|
|
1326 while i <= a:lastline
|
|
1327 " find insertion point via binary search
|
|
1328 let i_val = getline(i)
|
|
1329 let lo = a:firstline
|
|
1330 let hi = i
|
|
1331 while lo < hi
|
|
1332 let mid = (lo + hi) / 2
|
|
1333 let mid_val = getline(mid)
|
|
1334 if i_val < mid_val
|
|
1335 let hi = mid
|
|
1336 else
|
|
1337 let lo = mid + 1
|
|
1338 if i_val == mid_val | break | endif
|
|
1339 endif
|
|
1340 endwhile
|
|
1341 " do insert
|
|
1342 if lo < i
|
|
1343 exec i.'d_'
|
|
1344 call append(lo - 1, i_val)
|
|
1345 endif
|
|
1346 let i = i + 1
|
|
1347 endwhile
|
|
1348 endfun
|
|
1349
|
7
|
1350 " ------------------------------------------------------------------------
|
|
1351 " Restore {{{1
|
|
1352 let &cpo= s:save_cpo
|
|
1353 unlet s:save_cpo
|
|
1354 " vim:ts=8 fdm=marker
|