Mercurial > vim
comparison runtime/plugin/netrw.vim @ 11:4424b47a0797
updated for version 7.0003
author | vimboss |
---|---|
date | Wed, 30 Jun 2004 16:16:41 +0000 |
parents | 4e2284e71352 |
children | bdeee1504ac1 |
comparison
equal
deleted
inserted
replaced
10:4e2284e71352 | 11:4424b47a0797 |
---|---|
1 " netrw.vim: Handles file transfer and remote directory listing across a network | 1 " netrw.vim: Handles file transfer and remote directory listing across a network |
2 " Last Change: Jun 24, 2004 | 2 " Last Change: Jun 24, 2004 |
3 " Maintainer: Charles E. Campbell, Jr. PhD <drchipNOSPAM at campbellfamily.biz> | 3 " Maintainer: Charles E. Campbell, Jr. PhD <drchipNOSPAM at campbellfamily.biz> |
4 " Version: 47c NOT RELEASED | 4 " Version: 47f NOT RELEASED |
5 " License: Vim License (see vim's :help license) | 5 " License: Vim License (see vim's :help license) |
6 " | 6 " |
7 " But be doers of the word, and not only hearers, deluding your own selves | 7 " But be doers of the word, and not only hearers, deluding your own selves |
8 " (James 1:22 RSV) | 8 " (James 1:22 RSV) |
9 " =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | 9 " =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- |
10 | 10 |
11 " Exit quickly when already loaded or when 'compatible' is set. {{{1 | 11 " Exit quickly when already loaded or when 'compatible' is set. {{{1 |
12 if exists("loaded_netrw") || &cp | 12 if exists("loaded_netrw") || &cp |
13 finish | 13 finish |
14 endif | 14 endif |
15 let loaded_netrw = "v47c" | 15 let loaded_netrw = "v47f NOT RELEASED" |
16 let s:save_cpo = &cpo | 16 let s:save_cpo = &cpo |
17 set cpo&vim | 17 set cpo&vim |
18 | 18 |
19 " --------------------------------------------------------------------- | 19 " --------------------------------------------------------------------- |
20 " Default values for global netrw variables {{{1 | 20 " Default values for global netrw variables {{{1 |
28 if has("win32") | 28 if has("win32") |
29 let g:netrw_cygwin= 1 | 29 let g:netrw_cygwin= 1 |
30 else | 30 else |
31 let g:netrw_cygwin= 0 | 31 let g:netrw_cygwin= 0 |
32 endif | 32 endif |
33 endif | |
34 if !exists("g:netrw_list_cmd") | |
35 if executable("ssh") | |
36 " provide a default listing command | |
37 let g:netrw_list_cmd= "ssh HOSTNAME ls -FLa" | |
38 else | |
39 call Decho("ssh is not executable, can't do remote directory exploring") | |
40 let g:netrw_list_cmd= "" | |
41 endif | |
42 endif | |
43 if !exists("g:netrw_rm_cmd") | |
44 let g:netrw_rm_cmd = "ssh HOSTNAME rm" | |
45 endif | |
46 if !exists("g:netrw_rmf_cmd") | |
47 let g:netrw_rmf_cmd = "ssh HOSTNAME rm -f" | |
48 endif | |
49 if !exists("g:netrw_rmdir_cmd") | |
50 let g:netrw_rmdir_cmd = "ssh HOSTNAME rmdir" | |
51 endif | |
52 if !exists("g:netrw_rename_cmd") | |
53 let g:netrw_rename_cmd= "ssh HOSTNAME mv" | |
54 endif | |
55 if exists("g:netrw_silent") && g:netrw_silent != 0 | |
56 let g:netrw_silentxfer= "silent " | |
57 else | |
58 let g:netrw_silentxfer= "" | |
59 endif | |
60 if !exists("g:netrw_winsize") | |
61 let g:netrw_winsize= "" | |
62 endif | |
63 if !exists("g:netrw_list_hide") | |
64 let g:netrw_list_hide= "" | |
33 endif | 65 endif |
34 | 66 |
35 " --------------------------------------------------------------------- | 67 " --------------------------------------------------------------------- |
36 " Default values for global protocol variables {{{1 | 68 " Default values for global protocol variables {{{1 |
37 if !exists("g:netrw_rcp_cmd") | 69 if !exists("g:netrw_rcp_cmd") |
66 let g:netrw_fetch_cmd = "fetch -o" | 98 let g:netrw_fetch_cmd = "fetch -o" |
67 else | 99 else |
68 let g:netrw_fetch_cmd = "" | 100 let g:netrw_fetch_cmd = "" |
69 endif | 101 endif |
70 endif | 102 endif |
71 if !exists("g:netrw_list_cmd") | |
72 if executable("ssh") | |
73 let g:netrw_list_cmd= "ssh HOSTNAME ls -FLa" | |
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 | |
85 | 103 |
86 if has("win32") | 104 if has("win32") |
87 \ && exists("g:netrw_use_nt_rcp") | 105 \ && exists("g:netrw_use_nt_rcp") |
88 \ && g:netrw_use_nt_rcp | 106 \ && g:netrw_use_nt_rcp |
89 \ && executable( $SystemRoot .'/system32/rcp.exe') | 107 \ && executable( $SystemRoot .'/system32/rcp.exe') |
122 com! -nargs=* NetUserPass call NetUserPass(<f-args>) | 140 com! -nargs=* NetUserPass call NetUserPass(<f-args>) |
123 | 141 |
124 " ------------------------------------------------------------------------ | 142 " ------------------------------------------------------------------------ |
125 " NetSavePosn: saves position of cursor on screen {{{1 | 143 " NetSavePosn: saves position of cursor on screen {{{1 |
126 fun! s:NetSavePosn() | 144 fun! s:NetSavePosn() |
127 " call Dfunc("NetSavePosn()") | 145 call Dfunc("NetSavePosn()") |
128 " Save current line and column | 146 " Save current line and column |
129 let s:netrw_winnr= winnr() | 147 let s:netrw_winnr= winnr() |
130 let s:netrw_line = line(".") | 148 let s:netrw_line = line(".") |
131 let s:netrw_col = virtcol(".") | 149 let s:netrw_col = virtcol(".") |
132 | 150 |
133 " Save top-of-screen line | 151 " Save top-of-screen line |
134 norm! H0 | 152 norm! H0 |
135 let s:netrw_hline= line(".") | 153 let s:netrw_hline= line(".") |
136 | 154 |
137 call s:NetRestorePosn() | 155 call s:NetRestorePosn() |
138 " call Dret("NetSavePosn : winnr=".s:netrw_winnr." line=".s:netrw_line." col=".s:netrw_col." hline=".s:netrw_hline) | 156 call Dret("NetSavePosn : winnr=".s:netrw_winnr." line=".s:netrw_line." col=".s:netrw_col." hline=".s:netrw_hline) |
139 endfun | 157 endfun |
140 | 158 |
141 " ------------------------------------------------------------------------ | 159 " ------------------------------------------------------------------------ |
142 " NetRestorePosn: restores the cursor and file position as saved by NetSavePosn() {{{1 | 160 " NetRestorePosn: restores the cursor and file position as saved by NetSavePosn() {{{1 |
143 fun! <SID>NetRestorePosn() | 161 fun! <SID>NetRestorePosn() |
144 " call Dfunc("NetRestorePosn() winnr=".s:netrw_winnr." line=".s:netrw_line." col=".s:netrw_col." hline=".s:netrw_hline) | 162 call Dfunc("NetRestorePosn() winnr=".s:netrw_winnr." line=".s:netrw_line." col=".s:netrw_col." hline=".s:netrw_hline) |
145 | 163 |
146 exe "silent! ".s:netrw_winnr."wincmd w" | 164 exe "silent! ".s:netrw_winnr."wincmd w" |
147 if v:shell_error == 0 | 165 if v:shell_error == 0 |
148 " as suggested by Bram M: redraw on no error | 166 " as suggested by Bram M: redraw on no error |
149 " allows protocol error messages to remain visible | 167 " allows protocol error messages to remain visible |
152 " restore top-of-screen line | 170 " restore top-of-screen line |
153 exe "norm! ".s:netrw_hline."G0z\<CR>" | 171 exe "norm! ".s:netrw_hline."G0z\<CR>" |
154 " restore position | 172 " restore position |
155 exe "norm! ".s:netrw_line."G0".s:netrw_col."\<bar>" | 173 exe "norm! ".s:netrw_line."G0".s:netrw_col."\<bar>" |
156 | 174 |
157 " call Dret("NetRestorePosn") | 175 call Dret("NetRestorePosn") |
158 endfun | 176 endfun |
159 | 177 |
160 " ------------------------------------------------------------------------ | 178 " ------------------------------------------------------------------------ |
161 " NetRead: responsible for reading a file over the net {{{1 | 179 " NetRead: responsible for reading a file over the net {{{1 |
162 fun! s:NetRead(...) | 180 fun! s:NetRead(...) |
163 " call Dfunc("NetRead(a:1<".a:1.">)") | 181 call Dfunc("NetRead(a:1<".a:1.">)") |
164 | 182 |
165 " save options | 183 " save options |
166 call s:NetOptionSave() | 184 call s:NetOptionSave() |
167 | 185 |
168 " Special Exception: if a file is named "0r", then | 186 " Special Exception: if a file is named "0r", then |
180 endif | 198 endif |
181 | 199 |
182 " get name of a temporary file | 200 " get name of a temporary file |
183 let tmpfile= tempname() | 201 let tmpfile= tempname() |
184 | 202 |
185 " call Decho("ichoice=".ichoice." readcmd<".readcmd.">") | 203 call Decho("ichoice=".ichoice." readcmd<".readcmd.">") |
186 while ichoice <= a:0 | 204 while ichoice <= a:0 |
187 | 205 |
188 " attempt to repeat with previous host-file-etc | 206 " attempt to repeat with previous host-file-etc |
189 if exists("b:netrw_lastfile") && a:0 == 0 | 207 if exists("b:netrw_lastfile") && a:0 == 0 |
190 " call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">") | 208 call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">") |
191 let choice = b:netrw_lastfile | 209 let choice = b:netrw_lastfile |
192 let ichoice= ichoice + 1 | 210 let ichoice= ichoice + 1 |
193 | 211 |
194 else | 212 else |
195 exe "let choice= a:" . ichoice | 213 exe "let choice= a:" . ichoice |
196 " call Decho("no lastfile: choice<" . choice . ">") | 214 call Decho("no lastfile: choice<" . choice . ">") |
197 | 215 |
198 " Reconstruct Choice if choice starts with '"' | 216 " Reconstruct Choice if choice starts with '"' |
199 if match(choice,"?") == 0 | 217 if match(choice,"?") == 0 |
200 echo 'NetRead Usage:' | 218 echo 'NetRead Usage:' |
201 echo ':Nread machine:path uses rcp' | 219 echo ':Nread machine:path uses rcp' |
209 echo ':Nread rsync://machine[:port]/path uses rsync' | 227 echo ':Nread rsync://machine[:port]/path uses rsync' |
210 echo ':Nread scp://[user@]machine[[:#]port]/path uses scp' | 228 echo ':Nread scp://[user@]machine[[:#]port]/path uses scp' |
211 echo ':Nread sftp://[user@]machine[[:#]port]/path uses sftp' | 229 echo ':Nread sftp://[user@]machine[[:#]port]/path uses sftp' |
212 break | 230 break |
213 elseif match(choice,"^\"") != -1 | 231 elseif match(choice,"^\"") != -1 |
214 " call Decho("reconstructing choice") | 232 call Decho("reconstructing choice") |
215 if match(choice,"\"$") != -1 | 233 if match(choice,"\"$") != -1 |
216 " case "..." | 234 " case "..." |
217 let choice=strpart(choice,1,strlen(choice)-2) | 235 let choice=strpart(choice,1,strlen(choice)-2) |
218 else | 236 else |
219 " case "... ... ..." | 237 " case "... ... ..." |
223 while match(choice,"\"$") == -1 | 241 while match(choice,"\"$") == -1 |
224 let wholechoice = wholechoice . " " . choice | 242 let wholechoice = wholechoice . " " . choice |
225 let ichoice = ichoice + 1 | 243 let ichoice = ichoice + 1 |
226 if ichoice > a:0 | 244 if ichoice > a:0 |
227 echoerr "Unbalanced string in filename '". wholechoice ."'" | 245 echoerr "Unbalanced string in filename '". wholechoice ."'" |
228 " call Dret("NetRead") | 246 call Dret("NetRead") |
229 return | 247 return |
230 endif | 248 endif |
231 let choice= a:{ichoice} | 249 let choice= a:{ichoice} |
232 endwhile | 250 endwhile |
233 let choice= strpart(wholechoice,1,strlen(wholechoice)-1) . " " . strpart(choice,0,strlen(choice)-1) | 251 let choice= strpart(wholechoice,1,strlen(wholechoice)-1) . " " . strpart(choice,0,strlen(choice)-1) |
234 endif | 252 endif |
235 endif | 253 endif |
236 endif | 254 endif |
237 | 255 |
238 " call Decho("choice<" . choice . ">") | 256 call Decho("choice<" . choice . ">") |
239 let ichoice= ichoice + 1 | 257 let ichoice= ichoice + 1 |
240 | 258 |
241 " fix up windows urls | 259 " fix up windows urls |
242 if has("win32") | 260 if has("win32") |
243 let choice = substitute(choice,'\\','/','ge') | 261 let choice = substitute(choice,'\\','/','ge') |
244 " call Decho("fixing up windows url to <".choice."> tmpfile<".tmpfile) | 262 call Decho("fixing up windows url to <".choice."> tmpfile<".tmpfile) |
245 | 263 |
246 exe 'lcd ' . fnamemodify(tmpfile,':h') | 264 exe 'lcd ' . fnamemodify(tmpfile,':h') |
247 let tmpfile = fnamemodify(tmpfile,':t') | 265 let tmpfile = fnamemodify(tmpfile,':t') |
248 endif | 266 endif |
249 | 267 |
250 " Determine method of read (ftp, rcp, etc) | 268 " Determine method of read (ftp, rcp, etc) |
251 call s:NetMethod(choice) | 269 call s:NetMethod(choice) |
252 | 270 |
253 " Check if NetList() should be handling this request | 271 " Check if NetBrowse() should be handling this request |
254 " call Decho("checking if netlist: choice<".choice."> netrw_list_cmd<".g:netrw_list_cmd.">") | 272 call Decho("checking if netlist: choice<".choice."> netrw_list_cmd<".g:netrw_list_cmd.">") |
255 if choice =~ "^.*/$" | 273 if choice =~ "^.*/$" |
256 if strlen(g:netrw_list_cmd) > 0 | 274 if strlen(g:netrw_list_cmd) > 0 |
257 keepjumps call s:NetList(choice) | 275 keepjumps call s:NetBrowse(choice) |
258 " call Dret("NetRead") | 276 call Dret("NetRead") |
259 else | 277 else |
260 echoerr "sorry, can't do a remote listing; ssh isn't executable" | 278 echoerr "sorry, can't do a remote listing; ssh isn't executable" |
261 endif | 279 endif |
262 return | 280 return |
263 endif | 281 endif |
267 " ============ | 285 " ============ |
268 | 286 |
269 "......................................... | 287 "......................................... |
270 " rcp: NetRead Method #1 | 288 " rcp: NetRead Method #1 |
271 if b:netrw_method == 1 " read with rcp | 289 if b:netrw_method == 1 " read with rcp |
272 " call Decho("read via rcp (method #1)") | 290 call Decho("read via rcp (method #1)") |
273 " ER: noting done with g:netrw_uid yet? | 291 " ER: noting done with g:netrw_uid yet? |
274 " ER: on Win2K" rcp machine[.user]:file tmpfile | 292 " ER: on Win2K" rcp machine[.user]:file tmpfile |
275 " ER: if machine contains '.' adding .user is required (use $USERNAME) | 293 " ER: if machine contains '.' adding .user is required (use $USERNAME) |
276 " ER: the tmpfile is full path: rcp sees C:\... as host C | 294 " ER: the tmpfile is full path: rcp sees C:\... as host C |
277 if s:netrw_has_nt_rcp == 1 | 295 if s:netrw_has_nt_rcp == 1 |
286 let uid_machine = g:netrw_uid .'@'. g:netrw_machine | 304 let uid_machine = g:netrw_uid .'@'. g:netrw_machine |
287 else | 305 else |
288 let uid_machine = g:netrw_machine | 306 let uid_machine = g:netrw_machine |
289 endif | 307 endif |
290 endif | 308 endif |
291 " call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".uid_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile) | 309 call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".uid_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile) |
292 exe g:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".uid_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile | 310 exe g:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".uid_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile |
293 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) | 311 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) |
294 let b:netrw_lastfile = choice | 312 let b:netrw_lastfile = choice |
295 | 313 |
296 "......................................... | 314 "......................................... |
297 " ftp + <.netrc>: NetRead Method #2 | 315 " ftp + <.netrc>: NetRead Method #2 |
298 elseif b:netrw_method == 2 " read with ftp + <.netrc> | 316 elseif b:netrw_method == 2 " read with ftp + <.netrc> |
299 " call Decho("read via ftp+.netrc (method #2)") | 317 call Decho("read via ftp+.netrc (method #2)") |
300 let netrw_fname= b:netrw_fname | 318 let netrw_fname= b:netrw_fname |
301 new | 319 new |
302 set ff=unix | 320 set ff=unix |
303 exe "put ='".g:netrw_ftpmode."'" | 321 exe "put ='".g:netrw_ftpmode."'" |
304 exe "put ='get ".netrw_fname." ".tmpfile."'" | 322 exe "put ='get ".netrw_fname." ".tmpfile."'" |
305 if exists("g:netrw_port") && g:netrw_port != "" | 323 if exists("g:netrw_port") && g:netrw_port != "" |
306 " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port) | 324 call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port) |
307 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port | 325 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port |
308 else | 326 else |
309 " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine) | 327 call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine) |
310 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine | 328 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine |
311 endif | 329 endif |
312 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) | 330 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) |
313 if getline(1) !~ "^$" | 331 if getline(1) !~ "^$" |
314 echoerr getline(1) | 332 echoerr getline(1) |
319 | 337 |
320 "......................................... | 338 "......................................... |
321 " ftp + machine,id,passwd,filename: NetRead Method #3 | 339 " ftp + machine,id,passwd,filename: NetRead Method #3 |
322 elseif b:netrw_method == 3 " read with ftp + machine, id, passwd, and fname | 340 elseif b:netrw_method == 3 " read with ftp + machine, id, passwd, and fname |
323 " Construct execution string (four lines) which will be passed through filter | 341 " Construct execution string (four lines) which will be passed through filter |
324 " call Decho("read via ftp+mipf (method #3)") | 342 call Decho("read via ftp+mipf (method #3)") |
325 let netrw_fname= b:netrw_fname | 343 let netrw_fname= b:netrw_fname |
326 new | 344 new |
327 set ff=unix | 345 set ff=unix |
328 if exists("g:netrw_port") && g:netrw_port != "" | 346 if exists("g:netrw_port") && g:netrw_port != "" |
329 put ='open '.g:netrw_machine.' '.g:netrw_port | 347 put ='open '.g:netrw_machine.' '.g:netrw_port |
345 | 363 |
346 " perform ftp: | 364 " perform ftp: |
347 " -i : turns off interactive prompting from ftp | 365 " -i : turns off interactive prompting from ftp |
348 " -n unix : DON'T use <.netrc>, even though it exists | 366 " -n unix : DON'T use <.netrc>, even though it exists |
349 " -n win32: quit being obnoxious about password | 367 " -n win32: quit being obnoxious about password |
350 " call Decho('performing ftp -i -n') | 368 call Decho('performing ftp -i -n') |
351 norm 1Gdd | 369 norm 1Gdd |
352 " call Decho("executing: %!".g:netrw_ftp_cmd." -i -n") | 370 call Decho("executing: %!".g:netrw_ftp_cmd." -i -n") |
353 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n" | 371 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n" |
354 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) | 372 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) |
355 if getline(1) !~ "^$" | 373 if getline(1) !~ "^$" |
356 echoerr getline(1) | 374 echoerr getline(1) |
357 endif | 375 endif |
360 let b:netrw_lastfile = choice | 378 let b:netrw_lastfile = choice |
361 | 379 |
362 "......................................... | 380 "......................................... |
363 " scp: NetRead Method #4 | 381 " scp: NetRead Method #4 |
364 elseif b:netrw_method == 4 " read with scp | 382 elseif b:netrw_method == 4 " read with scp |
365 " call Decho("read via scp (method #4)") | 383 call Decho("read via scp (method #4)") |
366 if exists("g:netrw_port") && g:netrw_port != "" | 384 if exists("g:netrw_port") && g:netrw_port != "" |
367 let useport= " -P ".g:netrw_port | 385 let useport= " -P ".g:netrw_port |
368 else | 386 else |
369 let useport= "" | 387 let useport= "" |
370 endif | 388 endif |
371 if g:netrw_cygwin == 1 | 389 if g:netrw_cygwin == 1 |
372 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e') | 390 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e') |
373 " call Decho("executing: !".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile) | 391 call Decho("executing: !".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile) |
374 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile | 392 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile |
375 else | 393 else |
376 " call Decho("executing: !".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile) | 394 call Decho("executing: !".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile) |
377 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile | 395 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile |
378 endif | 396 endif |
379 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) | 397 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) |
380 let b:netrw_lastfile = choice | 398 let b:netrw_lastfile = choice |
381 | 399 |
382 "......................................... | 400 "......................................... |
383 elseif b:netrw_method == 5 " read with http (wget) | 401 elseif b:netrw_method == 5 " read with http (wget) |
384 " call Decho("read via http (method #5)") | 402 call Decho("read via http (method #5)") |
385 if g:netrw_http_cmd == "" | 403 if g:netrw_http_cmd == "" |
386 echoerr "neither wget nor fetch command is available" | 404 echoerr "neither wget nor fetch command is available" |
387 exit | 405 exit |
388 endif | 406 endif |
389 | 407 |
390 if match(b:netrw_fname,"#") == -1 | 408 if match(b:netrw_fname,"#") == -1 |
391 " simple wget | 409 " simple wget |
392 " call Decho("executing: !".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.escape(b:netrw_fname,' ?&')) | 410 call Decho("executing: !".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.escape(b:netrw_fname,' ?&')) |
393 exe g:netrw_silentxfer."!".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.escape(b:netrw_fname,' ?&') | 411 exe g:netrw_silentxfer."!".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.escape(b:netrw_fname,' ?&') |
394 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) | 412 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) |
395 | 413 |
396 else | 414 else |
397 " wget plus a jump to an in-page marker (ie. http://abc/def.html#aMarker) | 415 " wget plus a jump to an in-page marker (ie. http://abc/def.html#aMarker) |
398 let netrw_html= substitute(b:netrw_fname,"#.*$","","") | 416 let netrw_html= substitute(b:netrw_fname,"#.*$","","") |
399 let netrw_tag = substitute(b:netrw_fname,"^.*#","","") | 417 let netrw_tag = substitute(b:netrw_fname,"^.*#","","") |
400 " call Decho("netrw_html<".netrw_html.">") | 418 call Decho("netrw_html<".netrw_html.">") |
401 " call Decho("netrw_tag <".netrw_tag.">") | 419 call Decho("netrw_tag <".netrw_tag.">") |
402 " call Decho("executing: !".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_html) | 420 call Decho("executing: !".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_html) |
403 exe g:netrw_silentxfer."!".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_html | 421 exe g:netrw_silentxfer."!".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_html |
404 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) | 422 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) |
405 " call Decho('<\s*a\s*name=\s*"'.netrw_tag.'"/') | 423 call Decho('<\s*a\s*name=\s*"'.netrw_tag.'"/') |
406 exe 'norm! 1G/<\s*a\s*name=\s*"'.netrw_tag.'"/'."\<CR>" | 424 exe 'norm! 1G/<\s*a\s*name=\s*"'.netrw_tag.'"/'."\<CR>" |
407 endif | 425 endif |
408 let b:netrw_lastfile = choice | 426 let b:netrw_lastfile = choice |
409 | 427 |
410 "......................................... | 428 "......................................... |
411 " cadaver: NetRead Method #6 | 429 " cadaver: NetRead Method #6 |
412 elseif b:netrw_method == 6 " read with cadaver | 430 elseif b:netrw_method == 6 " read with cadaver |
413 " call Decho("read via cadaver (method #6)") | 431 call Decho("read via cadaver (method #6)") |
414 | 432 |
415 " Construct execution string (four lines) which will be passed through filter | 433 " Construct execution string (four lines) which will be passed through filter |
416 let netrw_fname= b:netrw_fname | 434 let netrw_fname= b:netrw_fname |
417 new | 435 new |
418 set ff=unix | 436 set ff=unix |
430 put ='get '.netrw_fname.' '.tmpfile | 448 put ='get '.netrw_fname.' '.tmpfile |
431 endif | 449 endif |
432 | 450 |
433 " perform cadaver operation: | 451 " perform cadaver operation: |
434 norm 1Gdd | 452 norm 1Gdd |
435 " call Decho("executing: %!".g:netrw_dav_cmd) | 453 call Decho("executing: %!".g:netrw_dav_cmd) |
436 exe g:netrw_silentxfer."%!".g:netrw_dav_cmd | 454 exe g:netrw_silentxfer."%!".g:netrw_dav_cmd |
437 bd! | 455 bd! |
438 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) | 456 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) |
439 let b:netrw_lastfile = choice | 457 let b:netrw_lastfile = choice |
440 | 458 |
441 "......................................... | 459 "......................................... |
442 " rsync: NetRead Method #7 | 460 " rsync: NetRead Method #7 |
443 elseif b:netrw_method == 7 " read with rsync | 461 elseif b:netrw_method == 7 " read with rsync |
444 " call Decho("read via rsync (method #7)") | 462 call Decho("read via rsync (method #7)") |
445 if g:netrw_cygwin == 1 | 463 if g:netrw_cygwin == 1 |
446 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e') | 464 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e') |
447 " call Decho("executing: !".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile) | 465 call Decho("executing: !".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile) |
448 exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile | 466 exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile |
449 else | 467 else |
450 " call Decho("executing: !".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile) | 468 call Decho("executing: !".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile) |
451 exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile | 469 exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile |
452 endif | 470 endif |
453 let result = s:NetGetFile(readcmd,tmpfile, b:netrw_method) | 471 let result = s:NetGetFile(readcmd,tmpfile, b:netrw_method) |
454 let b:netrw_lastfile = choice | 472 let b:netrw_lastfile = choice |
455 | 473 |
464 if exists("g:netrw_option") && g:netrw_option == ":http" | 482 if exists("g:netrw_option") && g:netrw_option == ":http" |
465 let netrw_option= "http" | 483 let netrw_option= "http" |
466 else | 484 else |
467 let netrw_option= "ftp" | 485 let netrw_option= "ftp" |
468 endif | 486 endif |
469 " call Decho("read via fetch for ".netrw_option) | 487 call Decho("read via fetch for ".netrw_option) |
470 | 488 |
471 if exists("g:netrw_uid") && g:netrw_uid != "" && exists("g:netrw_passwd") && g:netrw_passwd != "" | 489 if exists("g:netrw_uid") && g:netrw_uid != "" && exists("g:netrw_passwd") && g:netrw_passwd != "" |
472 " call Decho("executing: !".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_uid.':'.g:netrw_passwd.'@'.g:netrw_machine."/".escape(b:netrw_fname,' ?&')) | 490 call Decho("executing: !".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_uid.':'.g:netrw_passwd.'@'.g:netrw_machine."/".escape(b:netrw_fname,' ?&')) |
473 exe g:netrw_silentxfer."!".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_uid.':'.g:netrw_passwd.'@'.g:netrw_machine."/".escape(b:netrw_fname,' ?&') | 491 exe g:netrw_silentxfer."!".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_uid.':'.g:netrw_passwd.'@'.g:netrw_machine."/".escape(b:netrw_fname,' ?&') |
474 else | 492 else |
475 " call Decho("executing: !".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_machine."/".escape(b:netrw_fname,' ?&')) | 493 call Decho("executing: !".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_machine."/".escape(b:netrw_fname,' ?&')) |
476 exe g:netrw_silentxfer."!".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_machine."/".escape(b:netrw_fname,' ?&') | 494 exe g:netrw_silentxfer."!".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_machine."/".escape(b:netrw_fname,' ?&') |
477 endif | 495 endif |
478 | 496 |
479 let result = s:NetGetFile(readcmd,tmpfile, b:netrw_method) | 497 let result = s:NetGetFile(readcmd,tmpfile, b:netrw_method) |
480 let b:netrw_lastfile = choice | 498 let b:netrw_lastfile = choice |
481 | 499 |
482 "......................................... | 500 "......................................... |
483 " sftp: NetRead Method #9 | 501 " sftp: NetRead Method #9 |
484 elseif b:netrw_method == 9 " read with sftp | 502 elseif b:netrw_method == 9 " read with sftp |
485 " call Decho("read via sftp (method #4)") | 503 call Decho("read via sftp (method #4)") |
486 if g:netrw_cygwin == 1 | 504 if g:netrw_cygwin == 1 |
487 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e') | 505 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e') |
488 " call Decho("!".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile) | 506 call Decho("!".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile) |
489 " call Decho("executing: !".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile) | 507 call Decho("executing: !".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile) |
490 exe "!".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile | 508 exe "!".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile |
491 else | 509 else |
492 " call Decho("executing: !".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile) | 510 call Decho("executing: !".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile) |
493 exe g:netrw_silentxfer."!".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile | 511 exe g:netrw_silentxfer."!".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile |
494 endif | 512 endif |
495 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) | 513 let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) |
496 let b:netrw_lastfile = choice | 514 let b:netrw_lastfile = choice |
497 | 515 |
500 echo "***warning*** unable to comply with your request<" . choice . ">" | 518 echo "***warning*** unable to comply with your request<" . choice . ">" |
501 endif | 519 endif |
502 endwhile | 520 endwhile |
503 | 521 |
504 " cleanup | 522 " cleanup |
505 " call Decho("cleanup") | 523 call Decho("cleanup") |
506 if exists("b:netrw_method") | 524 if exists("b:netrw_method") |
507 unlet b:netrw_method | 525 unlet b:netrw_method |
508 unlet g:netrw_machine | 526 unlet g:netrw_machine |
509 unlet b:netrw_fname | 527 unlet b:netrw_fname |
510 endif | 528 endif |
511 call s:NetOptionRestore() | 529 call s:NetOptionRestore() |
512 | 530 |
513 " call Dret("NetRead") | 531 call Dret("NetRead") |
514 endfun | 532 endfun |
515 " end of NetRead | 533 " end of NetRead |
516 | 534 |
517 " ------------------------------------------------------------------------ | 535 " ------------------------------------------------------------------------ |
518 " NetGetFile: Function to read file "fname" with command "readcmd". {{{1 | 536 " NetGetFile: Function to read file "fname" with command "readcmd". {{{1 |
519 fun! s:NetGetFile(readcmd, fname, method) | 537 fun! s:NetGetFile(readcmd, fname, method) |
520 " call Dfunc("NetGetFile(readcmd<".a:readcmd.">,fname<".a:fname."> method<".a:method.">)") | 538 call Dfunc("NetGetFile(readcmd<".a:readcmd.">,fname<".a:fname."> method<".a:method.">)") |
521 | 539 |
522 if exists("*NetReadFixup") | 540 if exists("*NetReadFixup") |
523 " for the use of NetReadFixup (not otherwise used internally) | 541 " for the use of NetReadFixup (not otherwise used internally) |
524 let line2= line("$") | 542 let line2= line("$") |
525 endif | 543 endif |
526 | 544 |
527 " transform paths from / to \ for Windows, unless the shell is bash | 545 " transform paths from / to \ for Windows, unless the shell is bash |
528 if &term == "win32" | 546 if &term == "win32" |
529 if &shell == "bash" | 547 if &shell == "bash" |
530 let fname=a:fname | 548 let fname=a:fname |
531 " call Decho("(win32 && bash) fname<".fname.">") | 549 call Decho("(win32 && bash) fname<".fname.">") |
532 else | 550 else |
533 let fname=substitute(a:fname,'/','\\\\','ge') | 551 let fname=substitute(a:fname,'/','\\\\','ge') |
534 " call Decho("(win32 && !bash) fname<".fname.">") | 552 call Decho("(win32 && !bash) fname<".fname.">") |
535 endif | 553 endif |
536 else | 554 else |
537 let fname= a:fname | 555 let fname= a:fname |
538 " call Decho("(copied) fname<".fname.">") | 556 call Decho("(copied) fname<".fname.">") |
539 endif | 557 endif |
540 | 558 |
541 " get the file, but disable undo when reading a new buffer | 559 " get the file, but disable undo when reading a new buffer |
542 if a:readcmd[0] == '0' | 560 if a:readcmd[0] == '0' |
543 let use_e_cmd = 0 " 1 when using ':edit' | 561 let use_e_cmd = 0 " 1 when using ':edit' |
592 $del | 610 $del |
593 endif | 611 endif |
594 let &ul= oldul | 612 let &ul= oldul |
595 endif | 613 endif |
596 elseif filereadable(fname) | 614 elseif filereadable(fname) |
597 " call Decho("exe<".a:readcmd." ".v:cmdarg." ".fname.">") | 615 call Decho("exe<".a:readcmd." ".v:cmdarg." ".fname.">") |
598 exe a:readcmd." ".v:cmdarg." ".fname | 616 exe a:readcmd." ".v:cmdarg." ".fname |
599 else | 617 else |
600 " call Dret("NetGetFile") | 618 call Dret("NetGetFile") |
601 return | 619 return |
602 endif | 620 endif |
603 | 621 |
604 " User-provided (ie. optional) fix-it-up command | 622 " User-provided (ie. optional) fix-it-up command |
605 if exists("*NetReadFixup") | 623 if exists("*NetReadFixup") |
607 if a:readcmd == "r" | 625 if a:readcmd == "r" |
608 let line2= line("$") - line2 + line1 | 626 let line2= line("$") - line2 + line1 |
609 else | 627 else |
610 let line2= line("$") - line2 | 628 let line2= line("$") - line2 |
611 endif | 629 endif |
612 " call Decho("calling NetReadFixup(method<".a:method."> line1=".line1." line2=".line2.")") | 630 call Decho("calling NetReadFixup(method<".a:method."> line1=".line1." line2=".line2.")") |
613 call NetReadFixup(a:method, line1, line2) | 631 call NetReadFixup(a:method, line1, line2) |
614 endif | 632 endif |
615 | 633 |
616 " call Decho("readcmd<".a:readcmd."> cmdarg<".v:cmdarg."> fname<".a:fname."> readable=".filereadable(a:fname)) | 634 call Decho("readcmd<".a:readcmd."> cmdarg<".v:cmdarg."> fname<".a:fname."> readable=".filereadable(a:fname)) |
617 | 635 |
618 " insure that we have the right filetype and that its being displayed | 636 " insure that we have the right filetype and that its being displayed |
619 filetype detect | 637 filetype detect |
620 redraw! | 638 redraw! |
621 " call Dret("NetGetFile") | 639 call Dret("NetGetFile") |
622 endfun | 640 endfun |
623 | 641 |
624 " ------------------------------------------------------------------------ | 642 " ------------------------------------------------------------------------ |
625 " NetWrite: responsible for writing a file over the net {{{1 | 643 " NetWrite: responsible for writing a file over the net {{{1 |
626 fun! s:NetWrite(...) range | 644 fun! s:NetWrite(...) range |
627 " call Dfunc("NetWrite(a:0=".a:0.")") | 645 call Dfunc("NetWrite(a:0=".a:0.")") |
628 | 646 |
629 " option handling | 647 " option handling |
630 let mod= 0 | 648 let mod= 0 |
631 call s:NetOptionSave() | 649 call s:NetOptionSave() |
632 | 650 |
644 | 662 |
645 while ichoice <= a:0 | 663 while ichoice <= a:0 |
646 | 664 |
647 " attempt to repeat with previous host-file-etc | 665 " attempt to repeat with previous host-file-etc |
648 if exists("b:netrw_lastfile") && a:0 == 0 | 666 if exists("b:netrw_lastfile") && a:0 == 0 |
649 " call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">") | 667 call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">") |
650 let choice = b:netrw_lastfile | 668 let choice = b:netrw_lastfile |
651 let ichoice= ichoice + 1 | 669 let ichoice= ichoice + 1 |
652 else | 670 else |
653 exe "let choice= a:" . ichoice | 671 exe "let choice= a:" . ichoice |
654 | 672 |
679 while match(choice,"\"$") == -1 | 697 while match(choice,"\"$") == -1 |
680 let wholechoice= wholechoice . " " . choice | 698 let wholechoice= wholechoice . " " . choice |
681 let ichoice = ichoice + 1 | 699 let ichoice = ichoice + 1 |
682 if choice > a:0 | 700 if choice > a:0 |
683 echoerr "Unbalanced string in filename '". wholechoice ."'" | 701 echoerr "Unbalanced string in filename '". wholechoice ."'" |
684 " call Dret("NetWrite") | 702 call Dret("NetWrite") |
685 return | 703 return |
686 endif | 704 endif |
687 let choice= a:{ichoice} | 705 let choice= a:{ichoice} |
688 endwhile | 706 endwhile |
689 let choice= strpart(wholechoice,1,strlen(wholechoice)-1) . " " . strpart(choice,0,strlen(choice)-1) | 707 let choice= strpart(wholechoice,1,strlen(wholechoice)-1) . " " . strpart(choice,0,strlen(choice)-1) |
690 endif | 708 endif |
691 endif | 709 endif |
692 endif | 710 endif |
693 " call Decho("choice<" . choice . ">") | 711 call Decho("choice<" . choice . ">") |
694 let ichoice= ichoice + 1 | 712 let ichoice= ichoice + 1 |
695 | 713 |
696 " fix up windows urls | 714 " fix up windows urls |
697 if has("win32") | 715 if has("win32") |
698 let choice= substitute(choice,'\\','/','ge') | 716 let choice= substitute(choice,'\\','/','ge') |
709 " ============= | 727 " ============= |
710 | 728 |
711 "......................................... | 729 "......................................... |
712 " rcp: NetWrite Method #1 | 730 " rcp: NetWrite Method #1 |
713 if b:netrw_method == 1 " write with rcp | 731 if b:netrw_method == 1 " write with rcp |
714 " Decho "write via rcp (method #1)" | 732 Decho "write via rcp (method #1)" |
715 if s:netrw_has_nt_rcp == 1 | 733 if s:netrw_has_nt_rcp == 1 |
716 if exists("g:netrw_uid") && ( g:netrw_uid != "" ) | 734 if exists("g:netrw_uid") && ( g:netrw_uid != "" ) |
717 let uid_machine = g:netrw_machine .'.'. g:netrw_uid | 735 let uid_machine = g:netrw_machine .'.'. g:netrw_uid |
718 else | 736 else |
719 let uid_machine = g:netrw_machine .'.'. $USERNAME | 737 let uid_machine = g:netrw_machine .'.'. $USERNAME |
723 let uid_machine = g:netrw_uid .'@'. g:netrw_machine | 741 let uid_machine = g:netrw_uid .'@'. g:netrw_machine |
724 else | 742 else |
725 let uid_machine = g:netrw_machine | 743 let uid_machine = g:netrw_machine |
726 endif | 744 endif |
727 endif | 745 endif |
728 " call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".tmpfile." ".uid_machine.":".escape(b:netrw_fname,' ?&')) | 746 call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".tmpfile." ".uid_machine.":".escape(b:netrw_fname,' ?&')) |
729 exe g:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".tmpfile." ".uid_machine.":".escape(b:netrw_fname,' ?&') | 747 exe g:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".tmpfile." ".uid_machine.":".escape(b:netrw_fname,' ?&') |
730 let b:netrw_lastfile = choice | 748 let b:netrw_lastfile = choice |
731 | 749 |
732 "......................................... | 750 "......................................... |
733 " ftp + <.netrc>: NetWrite Method #2 | 751 " ftp + <.netrc>: NetWrite Method #2 |
734 elseif b:netrw_method == 2 " write with ftp + <.netrc> | 752 elseif b:netrw_method == 2 " write with ftp + <.netrc> |
735 let netrw_fname = b:netrw_fname | 753 let netrw_fname = b:netrw_fname |
736 new | 754 new |
737 set ff=unix | 755 set ff=unix |
738 exe "put ='".g:netrw_ftpmode."'" | 756 exe "put ='".g:netrw_ftpmode."'" |
739 " call Decho(" NetWrite: put ='".g:netrw_ftpmode."'") | 757 call Decho(" NetWrite: put ='".g:netrw_ftpmode."'") |
740 exe "put ='put ".tmpfile." ".netrw_fname."'" | 758 exe "put ='put ".tmpfile." ".netrw_fname."'" |
741 " call Decho("put ='put ".tmpfile." ".netrw_fname."'") | 759 call Decho("put ='put ".tmpfile." ".netrw_fname."'") |
742 if exists("g:netrw_port") && g:netrw_port != "" | 760 if exists("g:netrw_port") && g:netrw_port != "" |
743 " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port) | 761 call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port) |
744 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port | 762 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port |
745 else | 763 else |
746 " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine) | 764 call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine) |
747 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine | 765 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine |
748 endif | 766 endif |
749 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) | 767 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) |
750 if getline(1) !~ "^$" | 768 if getline(1) !~ "^$" |
751 echoerr getline(1) | 769 echoerr getline(1) |
777 | 795 |
778 " perform ftp: | 796 " perform ftp: |
779 " -i : turns off interactive prompting from ftp | 797 " -i : turns off interactive prompting from ftp |
780 " -n unix : DON'T use <.netrc>, even though it exists | 798 " -n unix : DON'T use <.netrc>, even though it exists |
781 " -n win32: quit being obnoxious about password | 799 " -n win32: quit being obnoxious about password |
782 " call Decho('performing ftp -i -n') | 800 call Decho('performing ftp -i -n') |
783 norm 1Gdd | 801 norm 1Gdd |
784 " call Decho("executing: %!".g:netrw_ftp_cmd." -i -n") | 802 call Decho("executing: %!".g:netrw_ftp_cmd." -i -n") |
785 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n" | 803 exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n" |
786 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) | 804 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) |
787 if getline(1) !~ "^$" | 805 if getline(1) !~ "^$" |
788 echoerr getline(1) | 806 echoerr getline(1) |
789 let mod=1 | 807 let mod=1 |
798 else | 816 else |
799 let useport= "" | 817 let useport= "" |
800 endif | 818 endif |
801 if g:netrw_cygwin == 1 | 819 if g:netrw_cygwin == 1 |
802 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e') | 820 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e') |
803 " call Decho("executing: !".g:netrw_scp_cmd.useport." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')) | 821 call Decho("executing: !".g:netrw_scp_cmd.useport." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')) |
804 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&') | 822 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&') |
805 else | 823 else |
806 " call Decho("executing: !".g:netrw_scp_cmd.useport." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')) | 824 call Decho("executing: !".g:netrw_scp_cmd.useport." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')) |
807 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&') | 825 exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&') |
808 endif | 826 endif |
809 let b:netrw_lastfile = choice | 827 let b:netrw_lastfile = choice |
810 | 828 |
811 "......................................... | 829 "......................................... |
814 echoerr "***warning*** currently <netrw.vim> does not support writing using http:" | 832 echoerr "***warning*** currently <netrw.vim> does not support writing using http:" |
815 | 833 |
816 "......................................... | 834 "......................................... |
817 " dav: NetWrite Method #6 | 835 " dav: NetWrite Method #6 |
818 elseif b:netrw_method == 6 " write with cadaver | 836 elseif b:netrw_method == 6 " write with cadaver |
819 " call Decho("write via cadaver (method #6)") | 837 call Decho("write via cadaver (method #6)") |
820 | 838 |
821 " Construct execution string (four lines) which will be passed through filter | 839 " Construct execution string (four lines) which will be passed through filter |
822 let netrw_fname= b:netrw_fname | 840 let netrw_fname= b:netrw_fname |
823 new | 841 new |
824 set ff=unix | 842 set ff=unix |
836 put ='put '.tmpfile.' '.netrw_fname | 854 put ='put '.tmpfile.' '.netrw_fname |
837 endif | 855 endif |
838 | 856 |
839 " perform cadaver operation: | 857 " perform cadaver operation: |
840 norm 1Gdd | 858 norm 1Gdd |
841 " call Decho("executing: %!".g:netrw_dav_cmd) | 859 call Decho("executing: %!".g:netrw_dav_cmd) |
842 exe g:netrw_silentxfer."%!".g:netrw_dav_cmd | 860 exe g:netrw_silentxfer."%!".g:netrw_dav_cmd |
843 bd! | 861 bd! |
844 let b:netrw_lastfile = choice | 862 let b:netrw_lastfile = choice |
845 | 863 |
846 "......................................... | 864 "......................................... |
847 " rsync: NetWrite Method #7 | 865 " rsync: NetWrite Method #7 |
848 elseif b:netrw_method == 7 " write with rsync | 866 elseif b:netrw_method == 7 " write with rsync |
849 if g:netrw_cygwin == 1 | 867 if g:netrw_cygwin == 1 |
850 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e') | 868 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e') |
851 " call Decho("executing: !".g:netrw_rsync_cmd." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')) | 869 call Decho("executing: !".g:netrw_rsync_cmd." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')) |
852 exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&') | 870 exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&') |
853 else | 871 else |
854 " call Decho("executing: !".g:netrw_rsync_cmd." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')) | 872 call Decho("executing: !".g:netrw_rsync_cmd." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')) |
855 exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&') | 873 exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&') |
856 endif | 874 endif |
857 let b:netrw_lastfile = choice | 875 let b:netrw_lastfile = choice |
858 | 876 |
859 "......................................... | 877 "......................................... |
867 endif | 885 endif |
868 new | 886 new |
869 set ff=unix | 887 set ff=unix |
870 put ='put '.tmpfile.' '.netrw_fname | 888 put ='put '.tmpfile.' '.netrw_fname |
871 norm 1Gdd | 889 norm 1Gdd |
872 " call Decho("executing: %!".g:netrw_sftp_cmd.' '.uid_machine) | 890 call Decho("executing: %!".g:netrw_sftp_cmd.' '.uid_machine) |
873 exe g:netrw_silentxfer."%!".g:netrw_sftp_cmd.' '.uid_machine | 891 exe g:netrw_silentxfer."%!".g:netrw_sftp_cmd.' '.uid_machine |
874 bd! | 892 bd! |
875 let b:netrw_lastfile= choice | 893 let b:netrw_lastfile= choice |
876 | 894 |
877 "......................................... | 895 "......................................... |
879 echo "***warning*** unable to comply with your request<" . choice . ">" | 897 echo "***warning*** unable to comply with your request<" . choice . ">" |
880 endif | 898 endif |
881 endwhile | 899 endwhile |
882 | 900 |
883 " cleanup | 901 " cleanup |
884 " call Decho("cleanup") | 902 call Decho("cleanup") |
885 let result=delete(tmpfile) | 903 let result=delete(tmpfile) |
886 call s:NetOptionRestore() | 904 call s:NetOptionRestore() |
887 | 905 |
888 if a:firstline == 1 && a:lastline == line("$") | 906 if a:firstline == 1 && a:lastline == line("$") |
889 let &mod= mod " usually equivalent to set nomod | 907 let &mod= mod " usually equivalent to set nomod |
890 endif | 908 endif |
891 | 909 |
892 " call Dret("NetWrite") | 910 call Dret("NetWrite") |
893 endfun | 911 endfun |
894 " end of NetWrite | 912 " end of NetWrite |
895 | 913 |
896 " ------------------------------------------------------------------------ | 914 " ------------------------------------------------------------------------ |
897 " NetList: This function uses the command in g:netrw_list_cmd to get a list {{{1 | 915 " Remote Directory Browsing Support: {{{1 |
916 " NetBrowse: This function uses the command in g:netrw_list_cmd to get a list {{{2 | |
898 " of the contents of a remote directory. It is assumed that the | 917 " of the contents of a remote directory. It is assumed that the |
899 " g:netrw_list_cmd has a string, HOSTNAME, that needs to be substituted | 918 " g:netrw_list_cmd has a string, HOSTNAME, that needs to be substituted |
900 " with the requested remote hostname first. | 919 " with the requested remote hostname first. |
901 fun! <SID>NetList(dirname) | 920 fun! <SID>NetBrowse(dirname) |
902 " call Dfunc("NetList(dirname<".a:dirname.">)") | 921 call Dfunc("NetBrowse(dirname<".a:dirname.">)") |
922 | |
923 " sanity check | |
924 if !exists("g:netrw_list_cmd") || g:netrw_list_cmd == '' | |
925 echoerr "***netrw*** this system doesn't support remote directory listing" | |
926 call Dret("NetBrowse 0") | |
927 return 0 | |
928 endif | |
903 | 929 |
904 " make this buffer modifiable | 930 " make this buffer modifiable |
905 setlocal ma | 931 setlocal ma |
906 | 932 |
907 " analyze a:dirname and g:netrw_list_cmd | 933 " analyze a:dirname and g:netrw_list_cmd |
908 let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/]\+\)/\(.*\)$' | 934 let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/]\+\)/\(.*\)$' |
909 if a:dirname !~ dirpat | 935 if a:dirname !~ dirpat |
910 echoerr "NetList: I don't understand your dirname<".a:dirname.">" | 936 echoerr "NetBrowse: I don't understand your dirname<".a:dirname.">" |
911 " call Dret("NetList 0 : badly formatted dirname") | 937 call Dret("NetBrowse 0 : badly formatted dirname") |
912 return 0 | 938 return 0 |
913 endif | 939 endif |
914 let method = substitute(a:dirname,dirpat,'\1','') | 940 let method = substitute(a:dirname,dirpat,'\1','') |
915 let user = substitute(a:dirname,dirpat,'\2','') | 941 let user = substitute(a:dirname,dirpat,'\2','') |
916 let machine = substitute(a:dirname,dirpat,'\3','') | 942 let machine = substitute(a:dirname,dirpat,'\3','') |
917 let path = substitute(a:dirname,dirpat,'\4','') | 943 let path = substitute(a:dirname,dirpat,'\4','') |
918 let fname = substitute(a:dirname,'^.*/\ze.','','') | 944 let fname = substitute(a:dirname,'^.*/\ze.','','') |
919 " call Decho("set up method <".method .">") | 945 call Decho("set up method <".method .">") |
920 " call Decho("set up user <".user .">") | 946 call Decho("set up user <".user .">") |
921 " call Decho("set up machine<".machine.">") | 947 call Decho("set up machine<".machine.">") |
922 " call Decho("set up path <".path .">") | 948 call Decho("set up path <".path .">") |
923 " call Decho("set up fname <".fname .">") | 949 call Decho("set up fname <".fname .">") |
924 | 950 |
925 let listcmd = substitute(g:netrw_list_cmd,'\<HOSTNAME\>',user.machine,'') | 951 let listcmd = substitute(g:netrw_list_cmd,'\<HOSTNAME\>',user.machine,'') |
926 " call Decho("set up listcmd<".listcmd.">") | 952 call Decho("set up listcmd<".listcmd.">") |
927 | 953 |
928 if fname =~ '@$' && fname !~ '^"' | 954 if fname =~ '@$' && fname !~ '^"' |
929 " call Decho("attempt transfer of symlink as file") | 955 call Decho("attempt transfer of symlink as file") |
930 call s:NetList(substitute(a:dirname,'@$','','e')) | 956 call s:NetBrowse(substitute(a:dirname,'@$','','e')) |
931 redraw! | 957 redraw! |
932 " call Dret("NetList 0 : symlink") | 958 call Dret("NetBrowse 0 : symlink") |
933 return 0 | 959 return 0 |
934 | 960 |
935 elseif fname !~ '/$' && fname !~ '^"' | 961 elseif fname !~ '/$' && fname !~ '^"' |
936 " looks like a regular file, attempt transfer | 962 " looks like a regular file, attempt transfer |
937 " call Decho("attempt transfer as regular file<".a:dirname.">") | 963 call Decho("attempt transfer as regular file<".a:dirname.">") |
938 | 964 |
939 " remove any filetype indicator from end of dirname, except for the | 965 " remove any filetype indicator from end of dirname, except for the |
940 " "this is a directory" indicator (/). There shouldn't be one of those, | 966 " "this is a directory" indicator (/). There shouldn't be one of those, |
941 " anyway. | 967 " anyway. |
942 let path= substitute(path,'[*=@|]$','','e') | 968 let path= substitute(path,'[*=@|]$','','e') |
943 " call Decho("new path<".path.">") | 969 call Decho("new path<".path.">") |
944 | 970 |
945 " remote-read the requested file into current buffer | 971 " remote-read the requested file into current buffer |
946 enew! | 972 enew! |
947 exe "file ".method."://".machine."/".path | 973 exe "file ".method."://".user.machine."/".path |
948 exe "silent doau BufReadPre ".fname | 974 exe "silent doau BufReadPre ".fname |
949 silent call s:NetRead(method."://".machine."/".path) | 975 silent call s:NetRead(method."://".user.machine."/".path) |
950 exe "silent doau BufReadPost ".fname | 976 exe "silent doau BufReadPost ".fname |
951 1d | 977 1d |
952 set nomod | 978 set nomod |
953 | 979 |
954 " call Dret("NetList 0 : file<".fname.">") | 980 call Dret("NetBrowse 0 : file<".fname.">") |
955 return 0 | 981 return 0 |
956 endif | 982 endif |
957 | 983 |
958 " --------------------------------------------------------------------- | 984 " --------------------------------------------------------------------- |
959 " Perform Directory Listing: | 985 " Perform Directory Listing: |
960 " call Decho("Perform directory listing...") | 986 call Decho("Perform directory listing...") |
961 " set up new buffer and map | 987 " set up new buffer and map |
962 let bufname = method.'://'.user.machine.'/'.path | 988 let bufname = method.'://'.user.machine.'/'.path |
963 let bufnamenr = bufnr(bufname) | 989 let bufnamenr = bufnr(bufname) |
964 " call Decho("bufname<".bufname."> bufnamenr=".bufnamenr) | 990 call Decho("bufname<".bufname."> bufnamenr=".bufnamenr) |
965 if bufnamenr != -1 | 991 if bufnamenr != -1 |
966 " buffer already exists, switch to it! | 992 " buffer already exists, switch to it! |
967 exe "b ".bufnamenr | 993 exe "b ".bufnamenr |
968 if line("$") >= 5 | 994 if line("$") >= 5 |
969 " call Dret("NetList 1") | 995 call Dret("NetBrowse 1") |
970 return 1 | 996 return 1 |
971 endif | 997 endif |
972 else | 998 else |
973 enew! | 999 enew! |
974 endif | 1000 endif |
975 setlocal bt=nofile bh=wipe nobl | 1001 setlocal bt=nofile bh=wipe nobl |
976 exe 'file '.bufname | 1002 exe 'file '.bufname |
977 set bt=nowrite bh=hide nobl | 1003 set bt=nowrite bh=hide nobl |
978 nnoremap <buffer> <cr> :exe "norm! 0"<bar>call <SID>NetList(<SID>NetListChgDir(expand("%")))<cr> | 1004 nnoremap <buffer> <silent> <cr> :exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),expand("<cWORD>")))<cr> |
1005 nnoremap <buffer> <silent> <c-l> :exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'./'))<cr> | |
1006 nnoremap <buffer> <silent> - :exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'../'))<cr> | |
1007 nnoremap <buffer> <silent> a :let g:netrw_list_showall=1<bar>exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'./'))<cr> | |
1008 nnoremap <buffer> <silent> o :exe g:netrw_winsize."wincmd s"<bar>exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),expand("<cWORD>")))<cr> | |
1009 nnoremap <buffer> <silent> v :exe g:netrw_winsize."wincmd v"<bar>exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),expand("<cWORD>")))<cr> | |
1010 nnoremap <buffer> <silent> x :exe "norm! 0"<bar>call <SID>NetBrowseX(<SID>NetBrowseChgDir(expand("%"),expand("<cWORD>")))<cr> | |
1011 exe 'nnoremap <buffer> <silent> <del> :exe "norm! 0"<bar>call <SID>NetBrowseRm("'.user.machine.'","'.path.'")<cr>' | |
1012 exe 'vnoremap <buffer> <silent> <del> :call <SID>NetBrowseRm("'.user.machine.'","'.path.'")<cr>' | |
1013 exe 'nnoremap <buffer> <silent> D :exe "norm! 0"<bar>call <SID>NetBrowseRm("'.user.machine.'","'.path.'")<cr>' | |
1014 exe 'vnoremap <buffer> <silent> D :call <SID>NetBrowseRm("'.user.machine.'","'.path.'")<cr>' | |
1015 exe 'nnoremap <buffer> <silent> R :exe "norm! 0"<bar>call <SID>NetBrowseRename("'.user.machine.'","'.path.'")<cr>' | |
1016 nnoremap <buffer> ? :he netrw-dir<cr> | |
979 setlocal ma | 1017 setlocal ma |
980 | 1018 |
981 " call Decho("executing: r! ".listcmd." '".path."'") | 1019 call Decho("executing: r! ".listcmd." '".path."'") |
982 keepjumps put ='\" ==============================' | 1020 keepjumps put ='\" ==============================' |
983 keepjumps put ='\" Netrw Remote Directory Listing' | 1021 keepjumps put ='\" Netrw Remote Directory Listing' |
984 keepjumps put ='\" '.bufname | 1022 keepjumps put ='\" '.bufname |
1023 let g:netrw_bannercnt= 5 | |
1024 if g:netrw_list_hide != "" && !exists("g:netrw_list_showall") | |
1025 keepjumps put ='\" Hiding: '.g:netrw_list_hide | |
1026 let g:netrw_bannercnt= g:netrw_bannercnt + 1 | |
1027 endif | |
985 keepjumps put ='\" ==============================' | 1028 keepjumps put ='\" ==============================' |
986 exe "silent r! ".listcmd." '".path."'" | 1029 exe "silent r! ".listcmd." '".path."'" |
987 keepjumps 1d | 1030 keepjumps 1d |
988 set ft=netrwlist | 1031 set ft=netrwlist |
989 if line("$") >= 5 | 1032 if line("$") >= g:netrw_bannercnt |
990 keepjumps silent 5,$s/^\(.*\)\([/@]\)$/ \2\1/e | 1033 if !exists("g:netrw_list_showall") |
991 keepjumps silent 5,$call s:NetSort() | 1034 if g:netrw_list_hide != "" |
992 keepjumps silent 5,$s/^ \(.\)\(.*\)$/\2\1/e | 1035 call s:NetrwListHide() |
993 keepjumps 5 | 1036 endif |
1037 else | |
1038 unlet g:netrw_list_showall | |
1039 endif | |
1040 exe 'keepjumps silent '.g:netrw_bannercnt.',$s/^\(.*\)\([/@]\)$/ \2\1/e' | |
1041 exe 'keepjumps silent '.g:netrw_bannercnt.',$call s:NetSort()' | |
1042 exe 'keepjumps silent '.g:netrw_bannercnt.',$s/^ \(.\)\(.*\)$/\2\1/e' | |
1043 exe 'keepjumps '.g:netrw_bannercnt | |
994 endif | 1044 endif |
995 let prvbuf= bufnr(bufname) | 1045 let prvbuf= bufnr(bufname) |
996 if prvbuf != -1 | 1046 if prvbuf != -1 |
997 exe "silent! b ".prvbuf | 1047 exe "silent! b ".prvbuf |
998 endif | 1048 endif |
999 | 1049 |
1000 setlocal noma nomod | 1050 setlocal noma nomod |
1001 | 1051 |
1002 " call Dret("NetList 1") | 1052 call Dret("NetBrowse 1") |
1003 return 1 | 1053 return 1 |
1004 endfun | 1054 endfun |
1005 | 1055 |
1006 " --------------------------------------------------------------------- | 1056 " --------------------------------------------------------------------- |
1007 " NetListCombine: | 1057 " NetBrowseChgDir: {{{2 |
1008 fun! <SID>NetListChgDir(dirname) | 1058 fun! <SID>NetBrowseChgDir(dirname,newdir) |
1009 let newdir= expand("<cWORD>") | 1059 call Dfunc("NetBrowseChgDir(dirname<".a:dirname."> newdir<".a:newdir.">)") |
1010 " call Dfunc("NetListChgDir(dirname<".a:dirname.">) newdir<".newdir.">") | |
1011 | 1060 |
1012 let dirname= a:dirname | 1061 let dirname= a:dirname |
1062 let newdir = a:newdir | |
1013 | 1063 |
1014 if newdir !~ '/$' | 1064 if newdir !~ '/$' |
1015 " handling a file | 1065 " handling a file |
1016 let dirname= dirname.newdir | 1066 let dirname= dirname.newdir |
1017 " call Decho("handling a file: dirname<".dirname.">") | 1067 call Decho("handling a file: dirname<".dirname.">") |
1018 | 1068 |
1019 elseif newdir == './' | 1069 elseif newdir == './' |
1020 " refresh the directory list | 1070 " refresh the directory list |
1021 " call Decho("refresh directory listing") | 1071 call Decho("refresh directory listing") |
1072 set ma | |
1022 %d | 1073 %d |
1023 | 1074 |
1024 elseif newdir == '../' | 1075 elseif newdir == '../' |
1025 " go up one directory | 1076 " go up one directory |
1026 let trailer= substitute(a:dirname,'^\(\w\+://\%(\w\+@\)\=\w\+/\)\(.*\)$','\2','') | 1077 let trailer= substitute(a:dirname,'^\(\w\+://\%(\w\+@\)\=\w\+/\)\(.*\)$','\2','') |
1031 | 1082 |
1032 else | 1083 else |
1033 " strip off a directory name from dirname | 1084 " strip off a directory name from dirname |
1034 let dirname= substitute(dirname,'^\(.*/\)[^/]\+/','\1','') | 1085 let dirname= substitute(dirname,'^\(.*/\)[^/]\+/','\1','') |
1035 endif | 1086 endif |
1036 " call Decho("go up one dir: dirname<".dirname."> trailer<".trailer.">") | 1087 call Decho("go up one dir: dirname<".dirname."> trailer<".trailer.">") |
1037 | 1088 |
1038 else | 1089 else |
1039 " go down one directory | 1090 " go down one directory |
1040 let dirname= dirname.newdir | 1091 let dirname= dirname.newdir |
1041 " call Decho("go down one dir: dirname<".dirname."> newdir<".newdir.">") | 1092 call Decho("go down one dir: dirname<".dirname."> newdir<".newdir.">") |
1042 endif | 1093 endif |
1043 | 1094 |
1044 " call Dret("NetListChgDir <".dirname.">") | 1095 call Dret("NetBrowseChgDir <".dirname.">") |
1045 return dirname | 1096 return dirname |
1097 endfun | |
1098 | |
1099 " --------------------------------------------------------------------- | |
1100 " NetBrowseRm: remove a remote file or directory {{{2 | |
1101 fun! <SID>NetBrowseRm(usrhost,path) range | |
1102 call Dfunc("NetBrowseRm(usrhost<".a:usrhost."> path<".a:path.">)") | |
1103 call Decho("firstline=".a:firstline." lastline=".a:lastline) | |
1104 | |
1105 " preparation for removing multiple files/directories | |
1106 let ctr= a:firstline | |
1107 | |
1108 " remove multiple files and directories | |
1109 while ctr <= a:lastline | |
1110 exe ctr | |
1111 | |
1112 norm! 0 | |
1113 let rmfile= a:path.expand("<cWORD>") | |
1114 call Decho("rmfile<".rmfile.">") | |
1115 | |
1116 if rmfile !~ '^"' && (rmfile =~ '@$' || rmfile !~ '/$') | |
1117 " attempt to remove file | |
1118 let netrw_rm_cmd= substitute(g:netrw_rm_cmd,'HOSTNAME',a:usrhost,'').' '.rmfile | |
1119 call Decho("attempt to remove file: system(".netrw_rm_cmd.")") | |
1120 call inputsave() | |
1121 let ok= input("Confirm deletion of file<".rmfile."> ","y") | |
1122 call inputrestore() | |
1123 if ok == "y" | |
1124 let ret= system(netrw_rm_cmd) | |
1125 call Decho("returned=".ret." errcode=".v:shell_error) | |
1126 endif | |
1127 | |
1128 else | |
1129 " attempt to remove directory | |
1130 let netrw_rmdir_cmd= substitute(g:netrw_rmdir_cmd,'HOSTNAME',a:usrhost,'').' '.rmfile | |
1131 call Decho("attempt to remove dir: system(".netrw_rmdir_cmd.")") | |
1132 call inputsave() | |
1133 let ok= input("Confirm deletion of directory<".rmfile."> ","y") | |
1134 call inputrestore() | |
1135 | |
1136 if ok == "y" | |
1137 let ret= system(netrw_rmdir_cmd) | |
1138 call Decho("returned=".ret." errcode=".v:shell_error) | |
1139 | |
1140 if v:shell_error != 0 | |
1141 let netrw_rmf_cmd= substitute(g:netrw_rmf_cmd,'HOSTNAME',a:usrhost,'').' '.substitute(rmfile,'/$','','e') | |
1142 call Decho("2nd attempt to remove dir: system(".netrw_rmf_cmd.")") | |
1143 let ret= system(netrw_rmf_cmd) | |
1144 call Decho("returned=".ret." errcode=".v:shell_error) | |
1145 | |
1146 if v:shell_error != 0 | |
1147 echoerr "unable to remove directory<".rmfile."> -- is it empty?" | |
1148 endif | |
1149 endif | |
1150 endif | |
1151 endif | |
1152 | |
1153 let ctr= ctr + 1 | |
1154 endwhile | |
1155 | |
1156 " refresh the directory | |
1157 let curline= line(".")-1 | |
1158 call Decho("refresh the directory") | |
1159 call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'./')) | |
1160 exe curline | |
1161 | |
1162 call Dret("NetBrowseRm") | |
1163 endfun | |
1164 | |
1165 " --------------------------------------------------------------------- | |
1166 " NetBrowseRename: rename a remote file or directory {{{2 | |
1167 fun! <SID>NetBrowseRename(usrhost,path) | |
1168 call Dfunc("NetBrowseRename(usrhost<".a:usrhost."> path<".a:path.">)") | |
1169 | |
1170 " preparation for removing multiple files/directories | |
1171 let ctr = a:firstline | |
1172 let rename_cmd = substitute(g:netrw_rename_cmd,'\<HOSTNAME\>',a:usrhost,'') | |
1173 | |
1174 " attempt to rename files/directories | |
1175 while ctr <= a:lastline | |
1176 exe ctr | |
1177 | |
1178 norm! 0 | |
1179 let oldname= a:path.expand("<cWORD>") | |
1180 call Decho("oldname<".oldname.">") | |
1181 | |
1182 call inputsave() | |
1183 let newname= input("Moving ".a:usrhost."'s ".oldname." to : ",oldname) | |
1184 call inputrestore() | |
1185 | |
1186 let ret= system(rename_cmd." ".oldname." ".newname) | |
1187 call Decho("executing system(".rename_cmd." ".oldname." ".newname) | |
1188 | |
1189 let ctr= ctr + 1 | |
1190 endwhile | |
1191 | |
1192 " refresh the directory | |
1193 let curline= line(".") | |
1194 call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'./')) | |
1195 exe curline | |
1196 call Dret("NetBrowseRename") | |
1197 endfun | |
1198 | |
1199 " --------------------------------------------------------------------- | |
1200 " NetBrowseX: allows users to write custom functions to operate on {{{2 | |
1201 " files given their extension | |
1202 fun! <SID>NetBrowseX(fname) | |
1203 call Dfunc("NetBrowseX(".a:fname.")") | |
1204 | |
1205 let exten= substitute(a:fname,'.*\.\(.\{-}\)','\1','e') | |
1206 call Decho("exten<".exten."> "."NetrwFileHandler_".exten."():exists=".exists("*NetrwFileHandler_".exten)) | |
1207 if exten != "" && exists("*NetrwFileHandler_".exten) | |
1208 exe "call NetrwFileHandler_".exten.'("'.a:fname.'")' | |
1209 endif | |
1210 call Dret("NetBrowseX") | |
1211 endfun | |
1212 | |
1213 " --------------------------------------------------------------------- | |
1214 " NetrwListHide: uses [range]g~...~d to delete files that match comma {{{2 | |
1215 " separated patterns given in g:netrw_list_hide | |
1216 fun! <SID>NetrwListHide() | |
1217 call Dfunc("NetrwListHide() listhide<".g:netrw_list_hide.">") | |
1218 | |
1219 let listhide= g:netrw_list_hide | |
1220 while listhide != "" | |
1221 if listhide =~ ',' | |
1222 let hide = substitute(listhide,',.*$','','e') | |
1223 let listhide = substitute(listhide,'^.\{-},\(.*\)$','\1','e') | |
1224 else | |
1225 let hide = listhide | |
1226 let listhide= "" | |
1227 endif | |
1228 call Decho("pruning <".hide."> listhide<".listhide.">") | |
1229 exe 'keepjumps silent '.g:netrw_bannercnt.',$g~'.hide.'~d' | |
1230 endwhile | |
1231 | |
1232 call Dret("NetrwListHide") | |
1046 endfun | 1233 endfun |
1047 | 1234 |
1048 " ------------------------------------------------------------------------ | 1235 " ------------------------------------------------------------------------ |
1049 " NetMethod: determine method of transfer {{{1 | 1236 " NetMethod: determine method of transfer {{{1 |
1050 " method == 1: rcp | 1237 " method == 1: rcp |
1055 " 6: cadaver | 1242 " 6: cadaver |
1056 " 7: rsync | 1243 " 7: rsync |
1057 " 8: fetch | 1244 " 8: fetch |
1058 " 9: sftp | 1245 " 9: sftp |
1059 fun! s:NetMethod(choice) " globals: method machine id passwd fname | 1246 fun! s:NetMethod(choice) " globals: method machine id passwd fname |
1060 " call Dfunc("NetMethod(a:choice<".a:choice.">)") | 1247 call Dfunc("NetMethod(a:choice<".a:choice.">)") |
1061 | 1248 |
1062 " initialization | 1249 " initialization |
1063 let b:netrw_method = 0 | 1250 let b:netrw_method = 0 |
1064 let g:netrw_machine = "" | 1251 let g:netrw_machine = "" |
1065 let b:netrw_fname = "" | 1252 let b:netrw_fname = "" |
1087 let davurm = '^dav://\([^/]\{-}\)/\(.*\)\=$' | 1274 let davurm = '^dav://\([^/]\{-}\)/\(.*\)\=$' |
1088 let rsyncurm = '^rsync://\([^/]\{-}\)/\(.*\)\=$' | 1275 let rsyncurm = '^rsync://\([^/]\{-}\)/\(.*\)\=$' |
1089 let fetchurm = '^fetch://\(\([^/@]\{-}\)@\)\=\([^/#:]\{-}\)\(:http\)\=/\(.*\)$' | 1276 let fetchurm = '^fetch://\(\([^/@]\{-}\)@\)\=\([^/#:]\{-}\)\(:http\)\=/\(.*\)$' |
1090 let sftpurm = '^sftp://\([^/]\{-}\)/\(.*\)\=$' | 1277 let sftpurm = '^sftp://\([^/]\{-}\)/\(.*\)\=$' |
1091 | 1278 |
1092 " call Decho("determine method:") | 1279 call Decho("determine method:") |
1093 " Determine Method | 1280 " Determine Method |
1094 " rcp://user@hostname/...path-to-file | 1281 " rcp://user@hostname/...path-to-file |
1095 if match(a:choice,rcpurm) == 0 | 1282 if match(a:choice,rcpurm) == 0 |
1096 " call Decho("rcp://...") | 1283 call Decho("rcp://...") |
1097 let b:netrw_method = 1 | 1284 let b:netrw_method = 1 |
1098 let userid = substitute(a:choice,rcpurm,'\2',"") | 1285 let userid = substitute(a:choice,rcpurm,'\2',"") |
1099 let g:netrw_machine= substitute(a:choice,rcpurm,'\3',"") | 1286 let g:netrw_machine= substitute(a:choice,rcpurm,'\3',"") |
1100 let b:netrw_fname = substitute(a:choice,rcpurm,'\4',"") | 1287 let b:netrw_fname = substitute(a:choice,rcpurm,'\4',"") |
1101 if userid != "" | 1288 if userid != "" |
1102 let g:netrw_uid= userid | 1289 let g:netrw_uid= userid |
1103 endif | 1290 endif |
1104 | 1291 |
1105 " scp://user@hostname/...path-to-file | 1292 " scp://user@hostname/...path-to-file |
1106 elseif match(a:choice,scpurm) == 0 | 1293 elseif match(a:choice,scpurm) == 0 |
1107 " call Decho("scp://...") | 1294 call Decho("scp://...") |
1108 let b:netrw_method = 4 | 1295 let b:netrw_method = 4 |
1109 let g:netrw_machine= substitute(a:choice,scpurm,'\1',"") | 1296 let g:netrw_machine= substitute(a:choice,scpurm,'\1',"") |
1110 let b:netrw_port = substitute(a:choice,scpurm,'\2',"") | 1297 let b:netrw_port = substitute(a:choice,scpurm,'\2',"") |
1111 let b:netrw_fname = substitute(a:choice,scpurm,'\3',"") | 1298 let b:netrw_fname = substitute(a:choice,scpurm,'\3',"") |
1112 | 1299 |
1113 " http://user@hostname/...path-to-file | 1300 " http://user@hostname/...path-to-file |
1114 elseif match(a:choice,httpurm) == 0 | 1301 elseif match(a:choice,httpurm) == 0 |
1115 " call Decho("http://...") | 1302 call Decho("http://...") |
1116 let b:netrw_method = 5 | 1303 let b:netrw_method = 5 |
1117 let g:netrw_machine= substitute(a:choice,httpurm,'\1',"") | 1304 let g:netrw_machine= substitute(a:choice,httpurm,'\1',"") |
1118 let b:netrw_fname = substitute(a:choice,httpurm,'\2',"") | 1305 let b:netrw_fname = substitute(a:choice,httpurm,'\2',"") |
1119 | 1306 |
1120 " dav://hostname[:port]/..path-to-file.. | 1307 " dav://hostname[:port]/..path-to-file.. |
1121 elseif match(a:choice,davurm) == 0 | 1308 elseif match(a:choice,davurm) == 0 |
1122 " call Decho("dav://...") | 1309 call Decho("dav://...") |
1123 let b:netrw_method= 6 | 1310 let b:netrw_method= 6 |
1124 let g:netrw_machine= substitute(a:choice,davurm,'\1',"") | 1311 let g:netrw_machine= substitute(a:choice,davurm,'\1',"") |
1125 let b:netrw_fname = substitute(a:choice,davurm,'\2',"") | 1312 let b:netrw_fname = substitute(a:choice,davurm,'\2',"") |
1126 | 1313 |
1127 " rsync://user@hostname/...path-to-file | 1314 " rsync://user@hostname/...path-to-file |
1128 elseif match(a:choice,rsyncurm) == 0 | 1315 elseif match(a:choice,rsyncurm) == 0 |
1129 " call Decho("rsync://...") | 1316 call Decho("rsync://...") |
1130 let b:netrw_method = 7 | 1317 let b:netrw_method = 7 |
1131 let g:netrw_machine= substitute(a:choice,rsyncurm,'\1',"") | 1318 let g:netrw_machine= substitute(a:choice,rsyncurm,'\1',"") |
1132 let b:netrw_fname = substitute(a:choice,rsyncurm,'\2',"") | 1319 let b:netrw_fname = substitute(a:choice,rsyncurm,'\2',"") |
1133 | 1320 |
1134 " ftp://[user@]hostname[[:#]port]/...path-to-file | 1321 " ftp://[user@]hostname[[:#]port]/...path-to-file |
1135 elseif match(a:choice,ftpurm) == 0 | 1322 elseif match(a:choice,ftpurm) == 0 |
1136 " call Decho("ftp://...") | 1323 call Decho("ftp://...") |
1137 let userid = substitute(a:choice,ftpurm,'\2',"") | 1324 let userid = substitute(a:choice,ftpurm,'\2',"") |
1138 let g:netrw_machine= substitute(a:choice,ftpurm,'\3',"") | 1325 let g:netrw_machine= substitute(a:choice,ftpurm,'\3',"") |
1139 let g:netrw_port = substitute(a:choice,ftpurm,'\4',"") | 1326 let g:netrw_port = substitute(a:choice,ftpurm,'\4',"") |
1140 let b:netrw_fname = substitute(a:choice,ftpurm,'\5',"") | 1327 let b:netrw_fname = substitute(a:choice,ftpurm,'\5',"") |
1141 if g:netrw_port != "" | 1328 if g:netrw_port != "" |
1159 let b:netrw_method= 3 | 1346 let b:netrw_method= 3 |
1160 endif | 1347 endif |
1161 endif | 1348 endif |
1162 | 1349 |
1163 elseif match(a:choice,fetchurm) == 0 | 1350 elseif match(a:choice,fetchurm) == 0 |
1164 " call Decho("fetch://...") | 1351 call Decho("fetch://...") |
1165 let b:netrw_method = 8 | 1352 let b:netrw_method = 8 |
1166 let g:netrw_userid = substitute(a:choice,fetchurm,'\2',"") | 1353 let g:netrw_userid = substitute(a:choice,fetchurm,'\2',"") |
1167 let g:netrw_machine= substitute(a:choice,fetchurm,'\3',"") | 1354 let g:netrw_machine= substitute(a:choice,fetchurm,'\3',"") |
1168 let b:netrw_option = substitute(a:choice,fetchurm,'\4',"") | 1355 let b:netrw_option = substitute(a:choice,fetchurm,'\4',"") |
1169 let b:netrw_fname = substitute(a:choice,fetchurm,'\5',"") | 1356 let b:netrw_fname = substitute(a:choice,fetchurm,'\5',"") |
1170 | 1357 |
1171 " Issue an ftp : "machine id password [path/]filename" | 1358 " Issue an ftp : "machine id password [path/]filename" |
1172 elseif match(a:choice,mipf) == 0 | 1359 elseif match(a:choice,mipf) == 0 |
1173 " call Decho("(ftp) host id pass file") | 1360 call Decho("(ftp) host id pass file") |
1174 let b:netrw_method = 3 | 1361 let b:netrw_method = 3 |
1175 let g:netrw_machine = substitute(a:choice,mipf,'\1',"") | 1362 let g:netrw_machine = substitute(a:choice,mipf,'\1',"") |
1176 let g:netrw_uid = substitute(a:choice,mipf,'\2',"") | 1363 let g:netrw_uid = substitute(a:choice,mipf,'\2',"") |
1177 let g:netrw_passwd = substitute(a:choice,mipf,'\3',"") | 1364 let g:netrw_passwd = substitute(a:choice,mipf,'\3',"") |
1178 let b:netrw_fname = substitute(a:choice,mipf,'\4',"") | 1365 let b:netrw_fname = substitute(a:choice,mipf,'\4',"") |
1179 | 1366 |
1180 " Issue an ftp: "hostname [path/]filename" | 1367 " Issue an ftp: "hostname [path/]filename" |
1181 elseif match(a:choice,mf) == 0 | 1368 elseif match(a:choice,mf) == 0 |
1182 " call Decho("(ftp) host file") | 1369 call Decho("(ftp) host file") |
1183 if exists("g:netrw_uid") && exists("g:netrw_passwd") | 1370 if exists("g:netrw_uid") && exists("g:netrw_passwd") |
1184 let b:netrw_method = 3 | 1371 let b:netrw_method = 3 |
1185 let g:netrw_machine = substitute(a:choice,mf,'\1',"") | 1372 let g:netrw_machine = substitute(a:choice,mf,'\1',"") |
1186 let b:netrw_fname = substitute(a:choice,mf,'\2',"") | 1373 let b:netrw_fname = substitute(a:choice,mf,'\2',"") |
1187 | 1374 |
1191 let b:netrw_fname = substitute(a:choice,mf,'\2',"") | 1378 let b:netrw_fname = substitute(a:choice,mf,'\2',"") |
1192 endif | 1379 endif |
1193 | 1380 |
1194 " sftp://user@hostname/...path-to-file | 1381 " sftp://user@hostname/...path-to-file |
1195 elseif match(a:choice,sftpurm) == 0 | 1382 elseif match(a:choice,sftpurm) == 0 |
1196 " call Decho("sftp://...") | 1383 call Decho("sftp://...") |
1197 let b:netrw_method = 9 | 1384 let b:netrw_method = 9 |
1198 let g:netrw_machine= substitute(a:choice,sftpurm,'\1',"") | 1385 let g:netrw_machine= substitute(a:choice,sftpurm,'\1',"") |
1199 let b:netrw_fname = substitute(a:choice,sftpurm,'\2',"") | 1386 let b:netrw_fname = substitute(a:choice,sftpurm,'\2',"") |
1200 | 1387 |
1201 " Issue an rcp: hostname:filename" (this one should be last) | 1388 " Issue an rcp: hostname:filename" (this one should be last) |
1202 elseif match(a:choice,rcphf) == 0 | 1389 elseif match(a:choice,rcphf) == 0 |
1203 " call Decho("(rcp) [user@]host:file) rcphf<".rcphf.">") | 1390 call Decho("(rcp) [user@]host:file) rcphf<".rcphf.">") |
1204 let b:netrw_method = 1 | 1391 let b:netrw_method = 1 |
1205 let userid = substitute(a:choice,rcphf,'\2',"") | 1392 let userid = substitute(a:choice,rcphf,'\2',"") |
1206 let g:netrw_machine= substitute(a:choice,rcphf,'\3',"") | 1393 let g:netrw_machine= substitute(a:choice,rcphf,'\3',"") |
1207 let b:netrw_fname = substitute(a:choice,rcphf,'\4',"") | 1394 let b:netrw_fname = substitute(a:choice,rcphf,'\4',"") |
1208 " call Decho('\1<'.substitute(a:choice,rcphf,'\1',"").">") | 1395 call Decho('\1<'.substitute(a:choice,rcphf,'\1',"").">") |
1209 " call Decho('\2<'.substitute(a:choice,rcphf,'\2',"").">") | 1396 call Decho('\2<'.substitute(a:choice,rcphf,'\2',"").">") |
1210 " call Decho('\3<'.substitute(a:choice,rcphf,'\3',"").">") | 1397 call Decho('\3<'.substitute(a:choice,rcphf,'\3',"").">") |
1211 " call Decho('\4<'.substitute(a:choice,rcphf,'\4',"").">") | 1398 call Decho('\4<'.substitute(a:choice,rcphf,'\4',"").">") |
1212 if userid != "" | 1399 if userid != "" |
1213 let g:netrw_uid= userid | 1400 let g:netrw_uid= userid |
1214 endif | 1401 endif |
1215 if has("win32") | 1402 if has("win32") |
1216 " don't let PCs try <.netrc> | 1403 " don't let PCs try <.netrc> |
1220 else | 1407 else |
1221 echoerr "***error*** cannot determine method" | 1408 echoerr "***error*** cannot determine method" |
1222 let b:netrw_method = -1 | 1409 let b:netrw_method = -1 |
1223 endif | 1410 endif |
1224 | 1411 |
1225 " call Decho("a:choice <".a:choice.">") | 1412 call Decho("a:choice <".a:choice.">") |
1226 " call Decho("b:netrw_method <".b:netrw_method.">") | 1413 call Decho("b:netrw_method <".b:netrw_method.">") |
1227 " call Decho("g:netrw_machine<".g:netrw_machine.">") | 1414 call Decho("g:netrw_machine<".g:netrw_machine.">") |
1228 " call Decho("g:netrw_port <".g:netrw_port.">") | 1415 call Decho("g:netrw_port <".g:netrw_port.">") |
1229 " if exists("g:netrw_uid") "Decho | 1416 if exists("g:netrw_uid") "Decho |
1230 " call Decho("g:netrw_uid <".g:netrw_uid.">") | 1417 call Decho("g:netrw_uid <".g:netrw_uid.">") |
1231 " endif "Decho | 1418 endif "Decho |
1232 " if exists("g:netrw_passwd") "Decho | 1419 if exists("g:netrw_passwd") "Decho |
1233 " call Decho("g:netrw_passwd <".g:netrw_passwd.">") | 1420 call Decho("g:netrw_passwd <".g:netrw_passwd.">") |
1234 " endif "Decho | 1421 endif "Decho |
1235 " call Decho("b:netrw_fname <".b:netrw_fname.">") | 1422 call Decho("b:netrw_fname <".b:netrw_fname.">") |
1236 " call Dret("NetMethod") | 1423 call Dret("NetMethod") |
1237 endfun | 1424 endfun |
1238 " end of NetMethod | 1425 " end of NetMethod |
1239 | 1426 |
1240 " ------------------------------------------------------------------------ | 1427 " ------------------------------------------------------------------------ |
1241 " NetUserPass: set username and password for subsequent ftp transfer {{{1 | 1428 " NetUserPass: set username and password for subsequent ftp transfer {{{1 |
1244 " :call NetUserPass("uid","password") -- sets global userid and password | 1431 " :call NetUserPass("uid","password") -- sets global userid and password |
1245 fun! NetUserPass(...) | 1432 fun! NetUserPass(...) |
1246 | 1433 |
1247 " get/set userid | 1434 " get/set userid |
1248 if a:0 == 0 | 1435 if a:0 == 0 |
1249 " call Dfunc("NetUserPass(a:0<".a:0.">)") | 1436 call Dfunc("NetUserPass(a:0<".a:0.">)") |
1250 if !exists("g:netrw_uid") || g:netrw_uid == "" | 1437 if !exists("g:netrw_uid") || g:netrw_uid == "" |
1251 " via prompt | 1438 " via prompt |
1252 let g:netrw_uid= input('Enter username: ') | 1439 let g:netrw_uid= input('Enter username: ') |
1253 endif | 1440 endif |
1254 else " from command line | 1441 else " from command line |
1255 " call Dfunc("NetUserPass(a:1<".a:1.">) {") | 1442 call Dfunc("NetUserPass(a:1<".a:1.">) {") |
1256 let g:netrw_uid= a:1 | 1443 let g:netrw_uid= a:1 |
1257 endif | 1444 endif |
1258 | 1445 |
1259 " get password | 1446 " get password |
1260 if a:0 <= 1 " via prompt | 1447 if a:0 <= 1 " via prompt |
1261 " call Decho("a:0=".a:0." case <=1:") | 1448 call Decho("a:0=".a:0." case <=1:") |
1262 let g:netrw_passwd= inputsecret("Enter Password: ") | 1449 let g:netrw_passwd= inputsecret("Enter Password: ") |
1263 else " from command line | 1450 else " from command line |
1264 " call Decho("a:0=".a:0." case >1: a:2<".a:2.">") | 1451 call Decho("a:0=".a:0." case >1: a:2<".a:2.">") |
1265 let g:netrw_passwd=a:2 | 1452 let g:netrw_passwd=a:2 |
1266 endif | 1453 endif |
1267 " call Dret("NetUserPass") | 1454 call Dret("NetUserPass") |
1268 endfun | 1455 endfun |
1269 " end NetUserPass | 1456 " end NetUserPass |
1270 | 1457 |
1271 " ------------------------------------------------------------------------ | 1458 " ------------------------------------------------------------------------ |
1272 " NetOptionSave: save options and set to "standard" form {{{1 | 1459 " NetOptionSave: save options and set to "standard" form {{{1 |
1273 fun!s:NetOptionSave() | 1460 fun!s:NetOptionSave() |
1274 " call Dfunc("NetOptionSave()") | 1461 call Dfunc("NetOptionSave()") |
1275 | 1462 |
1276 " Get Temporary Filename | 1463 " Get Temporary Filename |
1277 let s:aikeep = &ai | 1464 let s:aikeep = &ai |
1278 let s:cinkeep = &cin | 1465 let s:cinkeep = &cin |
1279 let s:cinokeep = &cino | 1466 let s:cinokeep = &cino |
1288 set nocin noai | 1475 set nocin noai |
1289 set tw =0 | 1476 set tw =0 |
1290 if has("win32") && !has("win95") | 1477 if has("win32") && !has("win95") |
1291 let s:swfkeep= &swf | 1478 let s:swfkeep= &swf |
1292 set noswf | 1479 set noswf |
1293 " call Decho("setting s:swfkeep to <".&swf.">") | 1480 call Decho("setting s:swfkeep to <".&swf.">") |
1294 endif | 1481 endif |
1295 | 1482 |
1296 " call Dret("NetOptionSave") | 1483 call Dret("NetOptionSave") |
1297 endfun | 1484 endfun |
1298 | 1485 |
1299 " ------------------------------------------------------------------------ | 1486 " ------------------------------------------------------------------------ |
1300 " NetOptionRestore: restore options {{{1 | 1487 " NetOptionRestore: restore options {{{1 |
1301 fun! s:NetOptionRestore() | 1488 fun! s:NetOptionRestore() |
1302 " call Dfunc("NetOptionRestore()") | 1489 call Dfunc("NetOptionRestore()") |
1303 | 1490 |
1304 let &ai = s:aikeep | 1491 let &ai = s:aikeep |
1305 let &cin = s:cinkeep | 1492 let &cin = s:cinkeep |
1306 let &cino = s:cinokeep | 1493 let &cino = s:cinokeep |
1307 let &com = s:comkeep | 1494 let &com = s:comkeep |
1320 unlet s:cpokeep | 1507 unlet s:cpokeep |
1321 unlet s:gdkeep | 1508 unlet s:gdkeep |
1322 unlet s:twkeep | 1509 unlet s:twkeep |
1323 unlet s:dirkeep | 1510 unlet s:dirkeep |
1324 | 1511 |
1325 " call Dret("NetOptionRestore") | 1512 call Dret("NetOptionRestore") |
1326 endfun | 1513 endfun |
1327 | 1514 |
1328 " ------------------------------------------------------------------------ | 1515 " ------------------------------------------------------------------------ |
1329 " NetReadFixup: this sort of function is typically written by the user {{{1 | 1516 " NetReadFixup: this sort of function is typically written by the user {{{1 |
1330 " to handle extra junk that their system's ftp dumps | 1517 " to handle extra junk that their system's ftp dumps |
1332 " example and as a fix for a Windows 95 problem: in my | 1519 " example and as a fix for a Windows 95 problem: in my |
1333 " experience, win95's ftp always dumped four blank lines | 1520 " experience, win95's ftp always dumped four blank lines |
1334 " at the end of the transfer. | 1521 " at the end of the transfer. |
1335 if has("win95") && g:netrw_win95ftp | 1522 if has("win95") && g:netrw_win95ftp |
1336 fun! NetReadFixup(method, line1, line2) | 1523 fun! NetReadFixup(method, line1, line2) |
1337 " call Dfunc("NetReadFixup(method<".a:method."> line1=".a:line1." line2=".a:line2.")") | 1524 call Dfunc("NetReadFixup(method<".a:method."> line1=".a:line1." line2=".a:line2.")") |
1338 if method == 3 " ftp (no <.netrc>) | 1525 if method == 3 " ftp (no <.netrc>) |
1339 let fourblanklines= line2 - 3 | 1526 let fourblanklines= line2 - 3 |
1340 silent fourblanklines.",".line2."g/^\s*/d" | 1527 silent fourblanklines.",".line2."g/^\s*/d" |
1341 endif | 1528 endif |
1342 " call Dret("NetReadFixup") | 1529 call Dret("NetReadFixup") |
1343 endfun | 1530 endfun |
1344 endif | 1531 endif |
1345 | 1532 |
1346 " --------------------------------------------------------------------- | 1533 " --------------------------------------------------------------------- |
1347 " NetSort: Piet Delport's BISort2() function, modified to take a range | 1534 " NetSort: Piet Delport's BISort2() function, modified to take a range |