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