1121
|
1 " netrw.vim: Handles file transfer and remote directory listing across
|
|
2 " AUTOLOAD SECTION
|
2034
|
3 " Date: Dec 28, 2009
|
|
4 " Version: 136
|
1121
|
5 " Maintainer: Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>
|
482
|
6 " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
|
2034
|
7 " Copyright: Copyright (C) 1999-2009 Charles E. Campbell, Jr. {{{1
|
482
|
8 " Permission is hereby granted to use and distribute this code,
|
|
9 " with or without modifications, provided that this copyright
|
|
10 " notice is copied with it. Like anything else that's free,
|
559
|
11 " netrw.vim, netrwPlugin.vim, and netrwSettings.vim are provided
|
1621
|
12 " *as is* and come with no warranty of any kind, either
|
559
|
13 " expressed or implied. By using this plugin, you agree that
|
|
14 " in no event will the copyright holder be liable for any damages
|
|
15 " resulting from the use of this software.
|
1621
|
16 "redraw!|call DechoSep()|call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
482
|
17 "
|
|
18 " But be doers of the Word, and not only hearers, deluding your own selves {{{1
|
|
19 " (James 1:22 RSV)
|
|
20 " =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
1121
|
21 " Load Once: {{{1
|
559
|
22 if &cp || exists("g:loaded_netrw")
|
|
23 finish
|
|
24 endif
|
2034
|
25 let g:loaded_netrw = "v136"
|
|
26 if v:version < 702
|
|
27 echohl WarningMsg
|
|
28 echo "***warning*** this version of netrw needs vim 7.2"
|
|
29 echohl Normal
|
|
30 finish
|
|
31 endif
|
1121
|
32 if !exists("s:NOTE")
|
|
33 let s:NOTE = 0
|
|
34 let s:WARNING = 1
|
|
35 let s:ERROR = 2
|
|
36 endif
|
1621
|
37
|
|
38 " sanity checks
|
519
|
39 if v:version < 700
|
1121
|
40 call netrw#ErrorMsg(s:WARNING,"you need vim version 7.0 or later for version ".g:loaded_netrw." of netrw",1)
|
519
|
41 finish
|
|
42 endif
|
1621
|
43
|
559
|
44 let s:keepcpo= &cpo
|
1121
|
45 setlocal cpo&vim
|
|
46 "DechoTabOn
|
|
47 "call Decho("doing autoload/netrw.vim version ".g:loaded_netrw)
|
482
|
48
|
650
|
49 " ======================
|
|
50 " Netrw Variables: {{{1
|
|
51 " ======================
|
|
52
|
482
|
53 " ---------------------------------------------------------------------
|
2034
|
54 " NetrwInit: initializes variables if they haven't been defined {{{2
|
|
55 " Loosely, varname = value.
|
|
56 fun s:NetrwInit(varname,value)
|
|
57 if !exists(a:varname)
|
|
58 if type(a:value) == 0
|
|
59 exe "let ".a:varname."=".a:value
|
|
60 elseif type(a:value) == 1
|
|
61 exe "let ".a:varname."="."'".a:value."'"
|
|
62 else
|
|
63 exe "let ".a:varname."=".a:value
|
|
64 endif
|
|
65 endif
|
|
66 endfun
|
|
67
|
|
68 " ---------------------------------------------------------------------
|
1121
|
69 " Netrw Constants: {{{2
|
2034
|
70 call s:NetrwInit("g:netrw_dirhist_cnt",0)
|
1121
|
71 if !exists("s:LONGLIST")
|
2034
|
72 call s:NetrwInit("s:THINLIST",0)
|
|
73 call s:NetrwInit("s:LONGLIST",1)
|
|
74 call s:NetrwInit("s:WIDELIST",2)
|
|
75 call s:NetrwInit("s:TREELIST",3)
|
|
76 call s:NetrwInit("s:MAXLIST" ,4)
|
1121
|
77 endif
|
|
78
|
|
79 " ---------------------------------------------------------------------
|
650
|
80 " Default values for netrw's global protocol variables {{{2
|
559
|
81 if !exists("g:netrw_dav_cmd")
|
2034
|
82 if executable("cadaver")
|
559
|
83 let g:netrw_dav_cmd = "cadaver"
|
2034
|
84 elseif executable("curl")
|
|
85 let g:netrw_dav_cmd = "curl"
|
|
86 else
|
|
87 let g:netrw_dav_cmd = ""
|
|
88 endif
|
559
|
89 endif
|
|
90 if !exists("g:netrw_fetch_cmd")
|
|
91 if executable("fetch")
|
|
92 let g:netrw_fetch_cmd = "fetch -o"
|
|
93 else
|
|
94 let g:netrw_fetch_cmd = ""
|
|
95 endif
|
|
96 endif
|
|
97 if !exists("g:netrw_ftp_cmd")
|
|
98 let g:netrw_ftp_cmd = "ftp"
|
|
99 endif
|
|
100 if !exists("g:netrw_http_cmd")
|
1698
|
101 if executable("elinks")
|
|
102 let g:netrw_http_cmd = "elinks"
|
2034
|
103 call s:NetrwInit("g:netrw_http_xcmd","-source >")
|
1698
|
104 elseif executable("links")
|
|
105 let g:netrw_http_cmd = "links"
|
2034
|
106 call s:NetrwInit("g:netrw_http_xcmd","-source >")
|
1698
|
107 elseif executable("curl")
|
2034
|
108 let g:netrw_http_cmd = "curl"
|
|
109 call s:NetrwInit("g:netrw_http_xcmd","-o")
|
1121
|
110 elseif executable("wget")
|
2034
|
111 let g:netrw_http_cmd = "wget"
|
|
112 call s:NetrwInit("g:netrw_http_xcmd","-q -O")
|
559
|
113 elseif executable("fetch")
|
2034
|
114 let g:netrw_http_cmd = "fetch"
|
|
115 call s:NetrwInit("g:netrw_http_xcmd","-o")
|
559
|
116 else
|
|
117 let g:netrw_http_cmd = ""
|
|
118 endif
|
|
119 endif
|
2034
|
120 call s:NetrwInit("g:netrw_rcp_cmd" , "rcp")
|
|
121 call s:NetrwInit("g:netrw_rsync_cmd", "rsync")
|
|
122 call s:NetrwInit("g:netrw_scp_cmd" , "scp -q")
|
|
123 call s:NetrwInit("g:netrw_sftp_cmd" , "sftp")
|
|
124 call s:NetrwInit("g:netrw_ssh_cmd" , "ssh")
|
559
|
125
|
719
|
126 if (has("win32") || has("win95") || has("win64") || has("win16"))
|
559
|
127 \ && exists("g:netrw_use_nt_rcp")
|
|
128 \ && g:netrw_use_nt_rcp
|
|
129 \ && executable( $SystemRoot .'/system32/rcp.exe')
|
|
130 let s:netrw_has_nt_rcp = 1
|
|
131 let s:netrw_rcpmode = '-b'
|
1121
|
132 else
|
559
|
133 let s:netrw_has_nt_rcp = 0
|
|
134 let s:netrw_rcpmode = ''
|
|
135 endif
|
|
136
|
|
137 " ---------------------------------------------------------------------
|
650
|
138 " Default values for netrw's global variables {{{2
|
1621
|
139 " Cygwin Detection ------- {{{3
|
|
140 if !exists("g:netrw_cygwin")
|
|
141 if has("win32") || has("win95") || has("win64") || has("win16")
|
|
142 if &shell =~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$'
|
|
143 let g:netrw_cygwin= 1
|
|
144 else
|
|
145 let g:netrw_cygwin= 0
|
|
146 endif
|
|
147 else
|
|
148 let g:netrw_cygwin= 0
|
|
149 endif
|
|
150 endif
|
650
|
151 " Default values - a-c ---------- {{{3
|
2034
|
152 call s:NetrwInit("g:netrw_alto" , &sb)
|
|
153 call s:NetrwInit("g:netrw_altv" , &spr)
|
|
154 call s:NetrwInit("g:netrw_banner" , 1)
|
|
155 call s:NetrwInit("g:netrw_browse_split", 0)
|
|
156 call s:NetrwInit("g:netrw_chgwin" , -1)
|
|
157 call s:NetrwInit("g:netrw_compress" , "gzip")
|
|
158 call s:NetrwInit("g:netrw_ctags" , "ctags")
|
|
159 if !exists("g:netrw_cursorline")
|
|
160 let g:netrw_cursorline= 1
|
|
161 let s:netrw_usercul = &cursorline
|
|
162 let s:netrw_usercuc = &cursorcolumn
|
1621
|
163 endif
|
|
164 " Default values - d-g ---------- {{{3
|
2034
|
165 call s:NetrwInit("g:netrw_dirhist_cnt" , 0)
|
|
166 call s:NetrwInit("g:netrw_decompress" , '{ ".gz" : "gunzip", ".bz2" : "bunzip2", ".zip" : "unzip", ".tar" : "tar -xf"}')
|
|
167 call s:NetrwInit("g:netrw_dirhistmax" , 10)
|
|
168 call s:NetrwInit("g:netrw_fastbrowse" , 1)
|
|
169 call s:NetrwInit("g:netrw_ftp_browse_reject", '^total\s\+\d\+$\|^Trying\s\+\d\+.*$\|^KERBEROS_V\d rejected\|^Security extensions not\|No such file\|: connect to address [0-9a-fA-F:]*: No route to host$')
|
482
|
170 if !exists("g:netrw_ftp_list_cmd")
|
1121
|
171 if has("unix") || (exists("g:netrw_cygwin") && g:netrw_cygwin)
|
|
172 let g:netrw_ftp_list_cmd = "ls -lF"
|
|
173 let g:netrw_ftp_timelist_cmd = "ls -tlF"
|
|
174 let g:netrw_ftp_sizelist_cmd = "ls -slF"
|
482
|
175 else
|
1121
|
176 let g:netrw_ftp_list_cmd = "dir"
|
|
177 let g:netrw_ftp_timelist_cmd = "dir"
|
|
178 let g:netrw_ftp_sizelist_cmd = "dir"
|
482
|
179 endif
|
|
180 endif
|
2034
|
181 call s:NetrwInit("g:netrw_ftpmode",'binary')
|
650
|
182 " Default values - h-lh ---------- {{{3
|
2034
|
183 call s:NetrwInit("g:netrw_hide",1)
|
1121
|
184 if !exists("g:netrw_ignorenetrc")
|
|
185 if &shell =~ '\c\<\%(cmd\|4nt\)\.exe$'
|
|
186 let g:netrw_ignorenetrc= 1
|
|
187 else
|
|
188 let g:netrw_ignorenetrc= 0
|
|
189 endif
|
|
190 endif
|
2034
|
191 call s:NetrwInit("g:netrw_keepdir",1)
|
559
|
192 if !exists("g:netrw_list_cmd")
|
1121
|
193 if g:netrw_scp_cmd =~ '^pscp' && executable("pscp")
|
|
194 " provide a 'pscp' listing command
|
|
195 if (has("win32") || has("win95") || has("win64") || has("win16")) && filereadable("c:\\private.ppk")
|
|
196 let g:netrw_scp_cmd ="pscp -i C:\\private.ppk"
|
|
197 endif
|
|
198 let g:netrw_list_cmd= g:netrw_scp_cmd." -ls USEPORT HOSTNAME:"
|
|
199 elseif executable(g:netrw_ssh_cmd)
|
559
|
200 " provide a default listing command
|
1121
|
201 let g:netrw_list_cmd= g:netrw_ssh_cmd." USEPORT HOSTNAME ls -FLa"
|
559
|
202 else
|
1121
|
203 " call Decho(g:netrw_ssh_cmd." is not executable")
|
559
|
204 let g:netrw_list_cmd= ""
|
|
205 endif
|
|
206 endif
|
2034
|
207 call s:NetrwInit("g:netrw_list_hide","")
|
650
|
208 " Default values - lh-lz ---------- {{{3
|
1621
|
209 if !exists("g:netrw_localcopycmd")
|
|
210 if has("win32") || has("win95") || has("win64") || has("win16")
|
|
211 if g:netrw_cygwin
|
|
212 let g:netrw_localcopycmd= "cp"
|
|
213 else
|
|
214 let g:netrw_localcopycmd= "copy"
|
|
215 endif
|
|
216 elseif has("unix") || has("macunix")
|
|
217 let g:netrw_localcopycmd= "cp"
|
|
218 else
|
|
219 let g:netrw_localcopycmd= ""
|
|
220 endif
|
|
221 endif
|
2034
|
222 call s:NetrwInit("g:netrw_local_mkdir","mkdir")
|
1621
|
223 if !exists("g:netrw_localmovecmd")
|
|
224 if has("win32") || has("win95") || has("win64") || has("win16")
|
|
225 if g:netrw_cygwin
|
|
226 let g:netrw_localmovecmd= "mv"
|
|
227 else
|
|
228 let g:netrw_localmovecmd= "move"
|
|
229 endif
|
|
230 elseif has("unix") || has("macunix")
|
|
231 let g:netrw_localmovecmd= "mv"
|
|
232 else
|
|
233 let g:netrw_localmovecmd= ""
|
|
234 endif
|
|
235 endif
|
2034
|
236 call s:NetrwInit("g:netrw_local_rmdir", "rmdir")
|
|
237 call s:NetrwInit("g:netrw_liststyle" , s:THINLIST)
|
|
238 " sanity checks
|
1121
|
239 if g:netrw_liststyle < 0 || g:netrw_liststyle >= s:MAXLIST
|
|
240 let g:netrw_liststyle= s:THINLIST
|
559
|
241 endif
|
1121
|
242 if g:netrw_liststyle == s:LONGLIST && g:netrw_scp_cmd !~ '^pscp'
|
559
|
243 let g:netrw_list_cmd= g:netrw_list_cmd." -l"
|
|
244 endif
|
650
|
245 " Default values - m-r ---------- {{{3
|
2034
|
246 call s:NetrwInit("g:netrw_markfileesc" , '*./[\~')
|
|
247 call s:NetrwInit("g:netrw_maxfilenamelen", 32)
|
|
248 call s:NetrwInit("g:netrw_menu" , 1)
|
|
249 call s:NetrwInit("g:netrw_mkdir_cmd" , g:netrw_ssh_cmd." USEPORT HOSTNAME mkdir")
|
|
250 call s:NetrwInit("g:netrw_mousemaps" , (exists("&mouse") && &mouse =~ '[anh]'))
|
|
251 call s:NetrwInit("g:netrw_retmap" , 0)
|
|
252 if has("unix") || (exists("g:netrw_cygwin") && g:netrw_cygwin)
|
|
253 call s:NetrwInit("g:netrw_chgperm" , "chmod PERM FILENAME")
|
|
254 elseif has("win32") || has("win95") || has("win64") || has("win16")
|
|
255 call s:NetrwInit("g:netrw_chgperm" , "cacls FILENAME /e /p PERM")
|
|
256 else
|
|
257 call s:NetrwInit("g:netrw_chgperm" , "chmod PERM FILENAME")
|
1121
|
258 endif
|
2034
|
259 call s:NetrwInit("g:netrw_preview" , 0)
|
|
260 call s:NetrwInit("g:netrw_scpport" , "-P")
|
|
261 call s:NetrwInit("g:netrw_sshport" , "-p")
|
|
262 call s:NetrwInit("g:netrw_rename_cmd" , g:netrw_ssh_cmd." USEPORT HOSTNAME mv")
|
|
263 call s:NetrwInit("g:netrw_rm_cmd" , g:netrw_ssh_cmd." USEPORT HOSTNAME rm")
|
|
264 call s:NetrwInit("g:netrw_rmdir_cmd" , g:netrw_ssh_cmd." USEPORT HOSTNAME rmdir")
|
|
265 call s:NetrwInit("g:netrw_rmf_cmd" , g:netrw_ssh_cmd." USEPORT HOSTNAME rm -f")
|
|
266 " Default values - s ---------- {{{3
|
|
267 " g:netrw_sepchr: picking a character that doesn't appear in filenames that can be used to separate priority from filename
|
|
268 call s:NetrwInit("g:netrw_sepchr" , (&enc == "euc-jp")? "\<Char-0x01>" : "\<Char-0xff>")
|
|
269 call s:NetrwInit("s:netrw_silentxfer" , (exists("g:netrw_silent") && g:netrw_silent != 0)? "silent " : "")
|
|
270 call s:NetrwInit("g:netrw_sort_by" , "name") " alternatives: date , size
|
|
271 call s:NetrwInit("g:netrw_sort_options" , "")
|
|
272 call s:NetrwInit("g:netrw_sort_direction", "normal") " alternative: reverse (z y x ...)
|
|
273 if !exists("g:netrw_sort_sequence")
|
|
274 if has("unix")
|
|
275 let g:netrw_sort_sequence= '[\/]$,\<core\%(\.\d\+\)\=\>,\.h$,\.c$,\.cpp$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$'
|
1621
|
276 else
|
2034
|
277 let g:netrw_sort_sequence= '[\/]$,\.h$,\.c$,\.cpp$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$'
|
1621
|
278 endif
|
|
279 endif
|
2034
|
280 call s:NetrwInit("g:netrw_special_syntax" , 0)
|
|
281 call s:NetrwInit("g:netrw_ssh_browse_reject", '^total\s\+\d\+$')
|
|
282 call s:NetrwInit("g:netrw_use_noswf" , 0)
|
650
|
283 " Default values - t-w ---------- {{{3
|
2034
|
284 call s:NetrwInit("g:netrw_timefmt","%c")
|
|
285 call s:NetrwInit("g:netrw_xstrlen",0)
|
|
286 call s:NetrwInit("g:NetrwTopLvlMenu","Netrw.")
|
|
287 call s:NetrwInit("g:netrw_use_errorwindow",1)
|
|
288 call s:NetrwInit("g:netrw_win95ftp",1)
|
|
289 call s:NetrwInit("g:netrw_winsize","")
|
559
|
290 " ---------------------------------------------------------------------
|
650
|
291 " Default values for netrw's script variables: {{{2
|
2034
|
292 call s:NetrwInit("g:netrw_fname_escape",' ?&;%')
|
|
293 call s:NetrwInit("g:netrw_glob_escape",'[]*?`{~$')
|
|
294 call s:NetrwInit("g:netrw_tmpfile_escape",' &;')
|
|
295 call s:NetrwInit("s:netrw_map_escape","<|\n\r\\\<C-V>\"")
|
482
|
296
|
|
297 " BufEnter event ignored by decho when following variable is true
|
|
298 " Has a side effect that doau BufReadPost doesn't work, so
|
|
299 " files read by network transfer aren't appropriately highlighted.
|
|
300 "let g:decho_bufenter = 1 "Decho
|
|
301
|
650
|
302 " ==============================
|
|
303 " Netrw Utility Functions: {{{1
|
|
304 " ==============================
|
|
305
|
482
|
306 " ------------------------------------------------------------------------
|
1621
|
307 " s:NetrwOptionSave: save options and set to "standard" form {{{2
|
|
308 " 06/08/07 : removed call to NetrwSafeOptions(), either placed
|
|
309 " immediately after NetrwOptionSave() calls in NetRead
|
|
310 " and NetWrite, or after the s:NetrwEnew() call in
|
|
311 " NetrwBrowse.
|
|
312 " vt: normally its "w:" or "s:" (a variable type)
|
|
313 fun! s:NetrwOptionSave(vt)
|
2034
|
314 " call Dfunc("s:NetrwOptionSave(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")."<".bufname(bufnr("%")).">"." winnr($)=".winnr("$"))
|
1621
|
315
|
|
316 " call Decho(a:vt."netrw_optionsave".(exists("{a:vt}netrw_optionsave")? ("=".{a:vt}netrw_optionsave) : " doesn't exist"))
|
|
317 if !exists("{a:vt}netrw_optionsave")
|
|
318 let {a:vt}netrw_optionsave= 1
|
1121
|
319 else
|
1621
|
320 " call Dret("s:NetrwOptionSave : options already saved")
|
1121
|
321 return
|
|
322 endif
|
1621
|
323 " call Decho("fo=".&fo.(exists("&acd")? " acd=".&acd : " acd doesn't exist"))
|
1121
|
324
|
|
325 " Save current settings and current directory
|
|
326 let s:yykeep = @@
|
|
327 if exists("&l:acd")
|
1621
|
328 let {a:vt}netrw_acdkeep = &l:acd
|
|
329 endif
|
|
330 let {a:vt}netrw_aikeep = &l:ai
|
|
331 let {a:vt}netrw_awkeep = &l:aw
|
|
332 let {a:vt}netrw_cikeep = &l:ci
|
|
333 let {a:vt}netrw_cinkeep = &l:cin
|
|
334 let {a:vt}netrw_cinokeep = &l:cino
|
|
335 let {a:vt}netrw_comkeep = &l:com
|
|
336 let {a:vt}netrw_cpokeep = &l:cpo
|
1121
|
337 if g:netrw_keepdir
|
1621
|
338 let {a:vt}netrw_dirkeep = getcwd()
|
|
339 endif
|
|
340 let {a:vt}netrw_fokeep = &l:fo " formatoptions
|
|
341 let {a:vt}netrw_gdkeep = &l:gd " gdefault
|
|
342 let {a:vt}netrw_hidkeep = &l:hidden
|
|
343 let {a:vt}netrw_magickeep = &l:magic
|
|
344 let {a:vt}netrw_repkeep = &l:report
|
|
345 let {a:vt}netrw_spellkeep = &l:spell
|
|
346 let {a:vt}netrw_twkeep = &l:tw " textwidth
|
|
347 let {a:vt}netrw_wigkeep = &l:wig " wildignore
|
1121
|
348 if has("win32") && !has("win95")
|
1668
|
349 let {a:vt}netrw_swfkeep = &l:swf " swapfile
|
1621
|
350 endif
|
|
351 if &go =~ 'a' | silent! let {a:vt}netrw_regstar = @* | endif
|
|
352 silent! let {a:vt}netrw_regslash= @/
|
|
353
|
|
354 " call Dret("s:NetrwOptionSave : win#".winnr()." buf#".bufnr("%"))
|
1121
|
355 endfun
|
|
356
|
|
357 " ------------------------------------------------------------------------
|
1621
|
358 " s:NetrwOptionRestore: restore options {{{2
|
|
359 fun! s:NetrwOptionRestore(vt)
|
2034
|
360 " call Dfunc("s:NetrwOptionRestore(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")." winnr($)=".winnr("$"))
|
1621
|
361 if !exists("{a:vt}netrw_optionsave")
|
1668
|
362 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap)
|
1621
|
363 " call Dret("s:NetrwOptionRestore : ".a:vt."netrw_optionsave doesn't exist")
|
1121
|
364 return
|
|
365 endif
|
1621
|
366 unlet {a:vt}netrw_optionsave
|
1121
|
367
|
|
368 if exists("&acd")
|
1621
|
369 if exists("{a:vt}netrw_acdkeep")
|
|
370 " call Decho("g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd)
|
|
371 let curdir = getcwd()
|
|
372 let &l:acd = {a:vt}netrw_acdkeep
|
|
373 unlet {a:vt}netrw_acdkeep
|
|
374 if &l:acd
|
|
375 " call Decho("exe keepjumps lcd ".fnameescape(curdir)) " NOTE: was g:netrw_fname_escape for some reason
|
|
376 try
|
|
377 if !exists("&l:acd") && !&l:acd
|
|
378 exe 'keepjumps lcd '.fnameescape(curdir)
|
|
379 endif
|
|
380 catch /^Vim\%((\a\+)\)\=:E472/
|
|
381 call netrw#ErrorMsg(s:ERROR,"unable to change directory to <".curdir."> (permissions?)",61)
|
|
382 endtry
|
|
383 endif
|
|
384 endif
|
|
385 endif
|
|
386 if exists("{a:vt}netrw_aikeep") |let &l:ai = {a:vt}netrw_aikeep |unlet {a:vt}netrw_aikeep |endif
|
|
387 if exists("{a:vt}netrw_awkeep") |let &l:aw = {a:vt}netrw_awkeep |unlet {a:vt}netrw_awkeep |endif
|
|
388 if exists("{a:vt}netrw_cikeep") |let &l:ci = {a:vt}netrw_cikeep |unlet {a:vt}netrw_cikeep |endif
|
|
389 if exists("{a:vt}netrw_cinkeep") |let &l:cin = {a:vt}netrw_cinkeep |unlet {a:vt}netrw_cinkeep |endif
|
|
390 if exists("{a:vt}netrw_cinokeep") |let &l:cino = {a:vt}netrw_cinokeep |unlet {a:vt}netrw_cinokeep |endif
|
|
391 if exists("{a:vt}netrw_comkeep") |let &l:com = {a:vt}netrw_comkeep |unlet {a:vt}netrw_comkeep |endif
|
|
392 if exists("{a:vt}netrw_cpokeep") |let &l:cpo = {a:vt}netrw_cpokeep |unlet {a:vt}netrw_cpokeep |endif
|
|
393 if exists("{a:vt}netrw_dirkeep") && isdirectory({a:vt}netrw_dirkeep) && g:netrw_keepdir
|
|
394 let dirkeep = substitute({a:vt}netrw_dirkeep,'\\','/','g')
|
|
395 if exists("{a:vt}netrw_dirkeep") |exe "keepjumps lcd ".fnameescape(dirkeep)|unlet {a:vt}netrw_dirkeep |endif
|
|
396 endif
|
|
397 if exists("{a:vt}netrw_fokeep") |let &l:fo = {a:vt}netrw_fokeep |unlet {a:vt}netrw_fokeep |endif
|
|
398 if exists("{a:vt}netrw_gdkeep") |let &l:gd = {a:vt}netrw_gdkeep |unlet {a:vt}netrw_gdkeep |endif
|
|
399 if exists("{a:vt}netrw_hidkeep") |let &l:hidden = {a:vt}netrw_hidkeep |unlet {a:vt}netrw_hidkeep |endif
|
|
400 if exists("{a:vt}netrw_magic") |let &l:magic = {a:vt}netrw_magic |unlet {a:vt}netrw_magic |endif
|
|
401 if exists("{a:vt}netrw_repkeep") |let &l:report = {a:vt}netrw_repkeep |unlet {a:vt}netrw_repkeep |endif
|
|
402 if exists("{a:vt}netrw_spellkeep")|let &l:spell = {a:vt}netrw_spellkeep |unlet {a:vt}netrw_spellkeep|endif
|
|
403 if exists("{a:vt}netrw_twkeep") |let &l:tw = {a:vt}netrw_twkeep |unlet {a:vt}netrw_twkeep |endif
|
|
404 if exists("{a:vt}netrw_wigkeep") |let &l:wig = {a:vt}netrw_wigkeep |unlet {a:vt}netrw_wigkeep |endif
|
|
405 if exists("s:yykeep") |let @@ = s:yykeep |unlet s:yykeep |endif
|
|
406 if exists("{a:vt}netrw_swfkeep")
|
1121
|
407 if &directory == ""
|
|
408 " user hasn't specified a swapfile directory;
|
|
409 " netrw will temporarily set the swapfile directory
|
|
410 " to the current directory as returned by getcwd().
|
|
411 let &l:directory = getcwd()
|
1621
|
412 silent! let &l:swf = {a:vt}netrw_swfkeep
|
1121
|
413 setlocal directory=
|
1621
|
414 unlet {a:vt}netrw_swfkeep
|
|
415 elseif &l:swf != {a:vt}netrw_swfkeep
|
|
416 " following line causes a Press ENTER in windows -- can't seem to work around it!!!
|
|
417 silent! let &l:swf= {a:vt}netrw_swfkeep
|
|
418 unlet {a:vt}netrw_swfkeep
|
|
419 endif
|
|
420 endif
|
|
421 if exists("{a:vt}netrw_regstar") |silent! let @*= {a:vt}netrw_regstar |unlet {a:vt}netrw_regstar |endif
|
|
422 if exists("{a:vt}netrw_regslash")|silent! let @/= {a:vt}netrw_regslash|unlet {a:vt}netrw_regslash|endif
|
|
423
|
|
424 " call Decho("g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd)
|
|
425 " call Decho("fo=".&fo.(exists("&acd")? " acd=".&acd : " acd doesn't exist"))
|
1668
|
426 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap)
|
1621
|
427 " call Dret("s:NetrwOptionRestore : win#".winnr()." buf#".bufnr("%"))
|
1121
|
428 endfun
|
|
429
|
|
430 " ---------------------------------------------------------------------
|
1621
|
431 " s:NetrwSafeOptions: sets options to help netrw do its job {{{2
|
1121
|
432 fun! s:NetrwSafeOptions()
|
2034
|
433 " call Dfunc("s:NetrwSafeOptions() win#".winnr()." buf#".bufnr("%")."<".bufname(bufnr("%"))."> winnr($)=".winnr("$"))
|
|
434 " call Decho("win#".winnr()."'s ft=".&ft)
|
1121
|
435 setlocal cino=
|
|
436 setlocal com=
|
|
437 setlocal cpo-=aA
|
1621
|
438 if exists("&acd") | setlocal noacd | endif
|
|
439 setlocal nocin noai noci magic nospell nohid wig= noaw
|
|
440 setlocal fo=nroql2
|
1121
|
441 setlocal tw=0
|
|
442 setlocal report=10000
|
2034
|
443 setlocal isk+=@ isk+=* isk+=/
|
1121
|
444 if g:netrw_use_noswf && has("win32") && !has("win95")
|
|
445 setlocal noswf
|
|
446 endif
|
2034
|
447
|
|
448 " allow the user to override safe options
|
|
449 if &ft == "netrw"
|
|
450 silent keepalt keepjumps doau FileType netrw
|
|
451 endif
|
|
452
|
1621
|
453 " call Decho("fo=".&fo.(exists("&acd")? " acd=".&acd : " acd doesn't exist"))
|
1121
|
454 " call Dret("s:NetrwSafeOptions")
|
|
455 endfun
|
|
456
|
1621
|
457 " ---------------------------------------------------------------------
|
|
458 " netrw#NetrwClean: remove netrw {{{2
|
|
459 " supports :NetrwClean -- remove netrw from first directory on runtimepath
|
|
460 " :NetrwClean! -- remove netrw from all directories on runtimepath
|
|
461 fun! netrw#NetrwClean(sys)
|
|
462 " call Dfunc("netrw#NetrwClean(sys=".a:sys.")")
|
|
463
|
|
464 if a:sys
|
|
465 let choice= confirm("Remove personal and system copies of netrw?","&Yes\n&No")
|
|
466 else
|
|
467 let choice= confirm("Remove personal copy of netrw?","&Yes\n&No")
|
|
468 endif
|
|
469 " call Decho("choice=".choice)
|
|
470 let diddel= 0
|
|
471 let diddir= ""
|
|
472
|
|
473 if choice == 1
|
|
474 for dir in split(&rtp,',')
|
|
475 if filereadable(dir."/plugin/netrwPlugin.vim")
|
|
476 " call Decho("removing netrw-related files from ".dir)
|
1668
|
477 if s:NetrwDelete(dir."/plugin/netrwPlugin.vim") |call netrw#ErrorMsg(1,"unable to remove ".dir."/plugin/netrwPlugin.vim",55) |endif
|
|
478 if s:NetrwDelete(dir."/autoload/netrwFileHandlers.vim")|call netrw#ErrorMsg(1,"unable to remove ".dir."/autoload/netrwFileHandlers.vim",55)|endif
|
|
479 if s:NetrwDelete(dir."/autoload/netrwSettings.vim") |call netrw#ErrorMsg(1,"unable to remove ".dir."/autoload/netrwSettings.vim",55) |endif
|
|
480 if s:NetrwDelete(dir."/autoload/netrw.vim") |call netrw#ErrorMsg(1,"unable to remove ".dir."/autoload/netrw.vim",55) |endif
|
|
481 if s:NetrwDelete(dir."/syntax/netrw.vim") |call netrw#ErrorMsg(1,"unable to remove ".dir."/syntax/netrw.vim",55) |endif
|
|
482 if s:NetrwDelete(dir."/syntax/netrwlist.vim") |call netrw#ErrorMsg(1,"unable to remove ".dir."/syntax/netrwlist.vim",55) |endif
|
1621
|
483 let diddir= dir
|
|
484 let diddel= diddel + 1
|
|
485 if !a:sys|break|endif
|
|
486 endif
|
|
487 endfor
|
|
488 endif
|
|
489
|
|
490 echohl WarningMsg
|
|
491 if diddel == 0
|
|
492 echomsg "netrw is either not installed or not removable"
|
|
493 elseif diddel == 1
|
|
494 echomsg "removed one copy of netrw from <".diddir.">"
|
|
495 else
|
|
496 echomsg "removed ".diddel." copies of netrw"
|
|
497 endif
|
|
498 echohl None
|
|
499
|
|
500 " call Dret("netrw#NetrwClean")
|
|
501 endfun
|
|
502
|
2034
|
503 " ---------------------------------------------------------------------
|
|
504 " netrw#Nread: {{{2
|
|
505 fun! netrw#Nread(mode,fname)
|
|
506 " call Dfunc("netrw#Nread(mode=".a:mode." fname<".a:fname.">)")
|
|
507 call netrw#NetrwSavePosn()
|
|
508 call netrw#NetRead(a:mode,a:fname)
|
|
509 call netrw#NetrwRestorePosn()
|
|
510 " call Dret("netrw#Nread")
|
|
511 endfun
|
|
512
|
1121
|
513 " ------------------------------------------------------------------------
|
650
|
514 " Netrw Transfer Functions: {{{1
|
|
515 " ===============================
|
|
516
|
482
|
517 " ------------------------------------------------------------------------
|
1621
|
518 " netrw#NetRead: responsible for reading a file over the net {{{2
|
1121
|
519 " mode: =0 read remote file and insert before current line
|
|
520 " =1 read remote file and insert after current line
|
|
521 " =2 replace with remote file
|
|
522 " =3 obtain file, but leave in temporary format
|
719
|
523 fun! netrw#NetRead(mode,...)
|
1121
|
524 " call Dfunc("netrw#NetRead(mode=".a:mode.",...) a:0=".a:0." ".g:loaded_netrw)
|
|
525
|
2034
|
526 " NetRead: save options {{{3
|
1621
|
527 call s:NetrwOptionSave("w:")
|
|
528 call s:NetrwSafeOptions()
|
719
|
529
|
2034
|
530 " NetRead: interpret mode into a readcmd {{{3
|
719
|
531 if a:mode == 0 " read remote file before current line
|
482
|
532 let readcmd = "0r"
|
719
|
533 elseif a:mode == 1 " read file after current line
|
482
|
534 let readcmd = "r"
|
719
|
535 elseif a:mode == 2 " replace with remote file
|
|
536 let readcmd = "%r"
|
1121
|
537 elseif a:mode == 3 " skip read of file (leave as temporary)
|
|
538 let readcmd = "t"
|
719
|
539 else
|
|
540 exe a:mode
|
|
541 let readcmd = "r"
|
482
|
542 endif
|
719
|
543 let ichoice = (a:0 == 0)? 0 : 1
|
|
544 " call Decho("readcmd<".readcmd."> ichoice=".ichoice)
|
|
545
|
2034
|
546 " NetRead: get temporary filename {{{3
|
1121
|
547 let tmpfile= s:GetTempfile("")
|
|
548 if tmpfile == ""
|
|
549 " call Dret("netrw#NetRead : unable to get a tempfile!")
|
482
|
550 return
|
|
551 endif
|
719
|
552
|
482
|
553 while ichoice <= a:0
|
719
|
554
|
482
|
555 " attempt to repeat with previous host-file-etc
|
|
556 if exists("b:netrw_lastfile") && a:0 == 0
|
|
557 " call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">")
|
|
558 let choice = b:netrw_lastfile
|
|
559 let ichoice= ichoice + 1
|
719
|
560
|
482
|
561 else
|
|
562 exe "let choice= a:" . ichoice
|
|
563 " call Decho("no lastfile: choice<" . choice . ">")
|
719
|
564
|
482
|
565 if match(choice,"?") == 0
|
|
566 " give help
|
|
567 echomsg 'NetRead Usage:'
|
|
568 echomsg ':Nread machine:path uses rcp'
|
|
569 echomsg ':Nread "machine path" uses ftp with <.netrc>'
|
|
570 echomsg ':Nread "machine id password path" uses ftp'
|
|
571 echomsg ':Nread dav://machine[:port]/path uses cadaver'
|
|
572 echomsg ':Nread fetch://machine/path uses fetch'
|
|
573 echomsg ':Nread ftp://[user@]machine[:port]/path uses ftp autodetects <.netrc>'
|
|
574 echomsg ':Nread http://[user@]machine/path uses http wget'
|
|
575 echomsg ':Nread rcp://[user@]machine/path uses rcp'
|
|
576 echomsg ':Nread rsync://machine[:port]/path uses rsync'
|
|
577 echomsg ':Nread scp://[user@]machine[[:#]port]/path uses scp'
|
|
578 echomsg ':Nread sftp://[user@]machine[[:#]port]/path uses sftp'
|
1121
|
579 sleep 4
|
482
|
580 break
|
|
581
|
1121
|
582 elseif match(choice,'^"') != -1
|
482
|
583 " Reconstruct Choice if choice starts with '"'
|
|
584 " call Decho("reconstructing choice")
|
1121
|
585 if match(choice,'"$') != -1
|
482
|
586 " case "..."
|
|
587 let choice=strpart(choice,1,strlen(choice)-2)
|
|
588 else
|
|
589 " case "... ... ..."
|
|
590 let choice = strpart(choice,1,strlen(choice)-1)
|
|
591 let wholechoice = ""
|
719
|
592
|
1121
|
593 while match(choice,'"$') == -1
|
482
|
594 let wholechoice = wholechoice . " " . choice
|
|
595 let ichoice = ichoice + 1
|
|
596 if ichoice > a:0
|
|
597 if !exists("g:netrw_quiet")
|
1121
|
598 call netrw#ErrorMsg(s:ERROR,"Unbalanced string in filename '". wholechoice ."'",3)
|
482
|
599 endif
|
1121
|
600 " call Dret("netrw#NetRead :2 getcwd<".getcwd().">")
|
482
|
601 return
|
|
602 endif
|
|
603 let choice= a:{ichoice}
|
|
604 endwhile
|
|
605 let choice= strpart(wholechoice,1,strlen(wholechoice)-1) . " " . strpart(choice,0,strlen(choice)-1)
|
|
606 endif
|
|
607 endif
|
|
608 endif
|
|
609
|
|
610 " call Decho("choice<" . choice . ">")
|
|
611 let ichoice= ichoice + 1
|
719
|
612
|
2034
|
613 " NetRead: Determine method of read (ftp, rcp, etc) {{{3
|
1621
|
614 call s:NetrwMethod(choice)
|
2034
|
615 if !exists("b:netrw_method") || b:netrw_method < 0
|
|
616 " call Dfunc("netrw#NetRead : unsupported method")
|
|
617 return
|
|
618 endif
|
1121
|
619 let tmpfile= s:GetTempfile(b:netrw_fname) " apply correct suffix
|
719
|
620
|
1621
|
621 " Check if NetrwBrowse() should be handling this request
|
|
622 " call Decho("checking if NetrwBrowse() should handle choice<".choice."> with netrw_list_cmd<".g:netrw_list_cmd.">")
|
1121
|
623 if choice =~ "^.*[\/]$" && b:netrw_method != 5 && choice !~ '^http://'
|
819
|
624 " call Decho("yes, choice matches '^.*[\/]$'")
|
1621
|
625 keepjumps call s:NetrwBrowse(0,choice)
|
1121
|
626 " call Dret("netrw#NetRead :3 getcwd<".getcwd().">")
|
482
|
627 return
|
|
628 endif
|
559
|
629
|
482
|
630 " ============
|
2034
|
631 " NetRead: Perform Protocol-Based Read {{{3
|
650
|
632 " ===========================
|
559
|
633 if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1
|
|
634 echo "(netrw) Processing your read request..."
|
|
635 endif
|
719
|
636
|
482
|
637 ".........................................
|
2034
|
638 " NetRead: (rcp) NetRead Method #1 {{{3
|
482
|
639 if b:netrw_method == 1 " read with rcp
|
|
640 " call Decho("read via rcp (method #1)")
|
857
|
641 " ER: nothing done with g:netrw_uid yet?
|
482
|
642 " ER: on Win2K" rcp machine[.user]:file tmpfile
|
|
643 " ER: if machine contains '.' adding .user is required (use $USERNAME)
|
|
644 " ER: the tmpfile is full path: rcp sees C:\... as host C
|
|
645 if s:netrw_has_nt_rcp == 1
|
|
646 if exists("g:netrw_uid") && ( g:netrw_uid != "" )
|
|
647 let uid_machine = g:netrw_machine .'.'. g:netrw_uid
|
|
648 else
|
|
649 " Any way needed it machine contains a '.'
|
|
650 let uid_machine = g:netrw_machine .'.'. $USERNAME
|
|
651 endif
|
|
652 else
|
|
653 if exists("g:netrw_uid") && ( g:netrw_uid != "" )
|
|
654 let uid_machine = g:netrw_uid .'@'. g:netrw_machine
|
|
655 else
|
|
656 let uid_machine = g:netrw_machine
|
|
657 endif
|
|
658 endif
|
1668
|
659 " call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".shellescape(uid_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1))
|
2034
|
660 exe s:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".shellescape(uid_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1)
|
1621
|
661 let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)
|
482
|
662 let b:netrw_lastfile = choice
|
719
|
663
|
482
|
664 ".........................................
|
2034
|
665 " NetRead: (ftp + <.netrc>) NetRead Method #2 {{{3
|
482
|
666 elseif b:netrw_method == 2 " read with ftp + <.netrc>
|
559
|
667 " call Decho("read via ftp+.netrc (method #2)")
|
820
|
668 let netrw_fname= b:netrw_fname
|
1621
|
669 call s:SaveBufVars()|new|call s:RestoreBufVars()
|
1698
|
670 let filtbuf= bufnr("%")
|
482
|
671 setlocal ff=unix
|
1698
|
672 put =g:netrw_ftpmode
|
|
673 " call Decho("filter input: ".getline(line("$")))
|
1121
|
674 if exists("g:netrw_ftpextracmd")
|
1698
|
675 put =g:netrw_ftpextracmd
|
|
676 " call Decho("filter input: ".getline(line("$")))
|
1121
|
677 endif
|
1698
|
678 call setline(line("$")+1,'get "'.netrw_fname.'" '.tmpfile)
|
|
679 " call Decho("filter input: ".getline(line("$")))
|
482
|
680 if exists("g:netrw_port") && g:netrw_port != ""
|
1668
|
681 " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine." ".g:netrw_port,1))
|
|
682 exe s:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine." ".g:netrw_port,1)
|
482
|
683 else
|
1668
|
684 " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1))
|
|
685 exe s:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)
|
482
|
686 endif
|
|
687 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
|
|
688 if getline(1) !~ "^$" && !exists("g:netrw_quiet") && getline(1) !~ '^Trying '
|
1668
|
689 let debugkeep = &debug
|
1121
|
690 setlocal debug=msg
|
|
691 call netrw#ErrorMsg(s:ERROR,getline(1),4)
|
1668
|
692 let &debug = debugkeep
|
482
|
693 endif
|
1702
|
694 call s:SaveBufVars()
|
|
695 bd!
|
2034
|
696 if bufname("%") == "" && getline("$") == "" && line('$') == 1
|
|
697 " needed when one sources a file in a nolbl setting window via ftp
|
1702
|
698 q!
|
|
699 endif
|
|
700 call s:RestoreBufVars()
|
1621
|
701 let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)
|
482
|
702 let b:netrw_lastfile = choice
|
719
|
703
|
482
|
704 ".........................................
|
2034
|
705 " NetRead: (ftp + machine,id,passwd,filename) NetRead Method #3 {{{3
|
482
|
706 elseif b:netrw_method == 3 " read with ftp + machine, id, passwd, and fname
|
|
707 " Construct execution string (four lines) which will be passed through filter
|
|
708 " call Decho("read via ftp+mipf (method #3)")
|
719
|
709 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
|
1621
|
710 call s:SaveBufVars()|new|call s:RestoreBufVars()
|
1698
|
711 let filtbuf= bufnr("%")
|
482
|
712 setlocal ff=unix
|
|
713 if exists("g:netrw_port") && g:netrw_port != ""
|
|
714 put ='open '.g:netrw_machine.' '.g:netrw_port
|
1621
|
715 " call Decho("filter input: ".getline('.'))
|
482
|
716 else
|
|
717 put ='open '.g:netrw_machine
|
1621
|
718 " call Decho("filter input: ".getline('.'))
|
482
|
719 endif
|
719
|
720
|
482
|
721 if exists("g:netrw_ftp") && g:netrw_ftp == 1
|
|
722 put =g:netrw_uid
|
1621
|
723 " call Decho("filter input: ".getline('.'))
|
|
724 put ='\"'.s:netrw_passwd.'\"'
|
|
725 " call Decho("filter input: ".getline('.'))
|
482
|
726 else
|
1621
|
727 put ='user \"'.g:netrw_uid.'\" \"'.s:netrw_passwd.'\"'
|
|
728 " call Decho("filter input: ".getline('.'))
|
482
|
729 endif
|
719
|
730
|
482
|
731 if exists("g:netrw_ftpmode") && g:netrw_ftpmode != ""
|
|
732 put =g:netrw_ftpmode
|
1621
|
733 " call Decho("filter input: ".getline('.'))
|
482
|
734 endif
|
1121
|
735 if exists("g:netrw_ftpextracmd")
|
1698
|
736 put =g:netrw_ftpextracmd
|
1621
|
737 " call Decho("filter input: ".getline('.'))
|
1121
|
738 endif
|
559
|
739 put ='get \"'.netrw_fname.'\" '.tmpfile
|
1621
|
740 " call Decho("filter input: ".getline('.'))
|
719
|
741
|
482
|
742 " perform ftp:
|
|
743 " -i : turns off interactive prompting from ftp
|
|
744 " -n unix : DON'T use <.netrc>, even though it exists
|
|
745 " -n win32: quit being obnoxious about password
|
|
746 norm! 1Gdd
|
|
747 " call Decho("executing: %!".g:netrw_ftp_cmd." -i -n")
|
1621
|
748 exe s:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n"
|
482
|
749 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
|
|
750 if getline(1) !~ "^$"
|
|
751 " call Decho("error<".getline(1).">")
|
|
752 if !exists("g:netrw_quiet")
|
1121
|
753 call netrw#ErrorMsg(s:ERROR,getline(1),5)
|
482
|
754 endif
|
|
755 endif
|
1621
|
756 call s:SaveBufVars()|bd!|call s:RestoreBufVars()
|
|
757 let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)
|
482
|
758 let b:netrw_lastfile = choice
|
719
|
759
|
482
|
760 ".........................................
|
2034
|
761 " NetRead: (scp) NetRead Method #4 {{{3
|
482
|
762 elseif b:netrw_method == 4 " read with scp
|
|
763 " call Decho("read via scp (method #4)")
|
|
764 if exists("g:netrw_port") && g:netrw_port != ""
|
1209
|
765 let useport= " ".g:netrw_scpport." ".g:netrw_port
|
482
|
766 else
|
|
767 let useport= ""
|
|
768 endif
|
2034
|
769 " call Decho("exe ".s:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1))
|
1668
|
770 exe s:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1)
|
1621
|
771 let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)
|
482
|
772 let b:netrw_lastfile = choice
|
719
|
773
|
482
|
774 ".........................................
|
2034
|
775 " NetRead: (http) NetRead Method #5 (wget) {{{3
|
650
|
776 elseif b:netrw_method == 5
|
482
|
777 " call Decho("read via http (method #5)")
|
|
778 if g:netrw_http_cmd == ""
|
|
779 if !exists("g:netrw_quiet")
|
1121
|
780 call netrw#ErrorMsg(s:ERROR,"neither the wget nor the fetch command is available",6)
|
482
|
781 endif
|
1121
|
782 " call Dret("netrw#NetRead :4 getcwd<".getcwd().">")
|
559
|
783 return
|
482
|
784 endif
|
719
|
785
|
1698
|
786 if match(b:netrw_fname,"#") == -1 || exists("g:netrw_http_xcmd")
|
|
787 " using g:netrw_http_cmd (usually elinks, links, curl, wget, or fetch)
|
1668
|
788 " call Decho('using '.g:netrw_http_cmd.' (# not in b:netrw_fname<'.b:netrw_fname.">)")
|
1698
|
789 if exists("g:netrw_http_xcmd")
|
|
790 " call Decho("exe ".s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape("http://".g:netrw_machine.b:netrw_fname,1)." ".g:netrw_http_xcmd." ".shellescape(tmpfile,1))
|
|
791 exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape("http://".g:netrw_machine.b:netrw_fname,1)." ".g:netrw_http_xcmd." ".shellescape(tmpfile,1)
|
|
792 else
|
|
793 " call Decho("exe ".s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("http://".g:netrw_machine.b:netrw_fname,1))
|
|
794 exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("http://".g:netrw_machine.b:netrw_fname,1)
|
|
795 endif
|
1621
|
796 let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)
|
719
|
797
|
482
|
798 else
|
1698
|
799 " wget/curl/fetch plus a jump to an in-page marker (ie. http://abc/def.html#aMarker)
|
1621
|
800 " call Decho(("wget/curl plus jump (# in b:netrw_fname<".b:netrw_fname.">)")
|
1668
|
801 let netrw_html= substitute(b:netrw_fname,"#.*$","","")
|
|
802 let netrw_tag = substitute(b:netrw_fname,"^.*#","","")
|
482
|
803 " call Decho("netrw_html<".netrw_html.">")
|
|
804 " call Decho("netrw_tag <".netrw_tag.">")
|
1668
|
805 " call Decho("exe ".s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("http://".g:netrw_machine.netrw_html,1))
|
|
806 exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("http://".g:netrw_machine.netrw_html,1)
|
1621
|
807 let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)
|
482
|
808 " call Decho('<\s*a\s*name=\s*"'.netrw_tag.'"/')
|
|
809 exe 'norm! 1G/<\s*a\s*name=\s*"'.netrw_tag.'"/'."\<CR>"
|
|
810 endif
|
|
811 let b:netrw_lastfile = choice
|
1121
|
812 setlocal ro
|
719
|
813
|
482
|
814 ".........................................
|
2034
|
815 " NetRead: (dav) NetRead Method #6 {{{3
|
650
|
816 elseif b:netrw_method == 6
|
482
|
817 " call Decho("read via cadaver (method #6)")
|
719
|
818
|
2034
|
819 if !executable(g:netrw_dav_cmd)
|
|
820 call netrw#ErrorMsg(s:ERROR,g:netrw_dav_cmd." is not executable",73)
|
|
821 " call Dret("netrw#NetRead : ".g:netrw_dav_cmd." not executable")
|
|
822 return
|
|
823 endif
|
|
824 if g:netrw_dav_cmd =~ "curl"
|
|
825 " call Decho("exe ".s:netrw_silentxfer."!".g:netrw_dav_cmd." ".shellescape("dav://".g:netrw_machine.b:netrw_fname,1)." ".shellescape(tmpfile,1))
|
|
826 exe s:netrw_silentxfer."!".g:netrw_dav_cmd." ".shellescape("dav://".g:netrw_machine.b:netrw_fname,1)." ".shellescape(tmpfile,1)
|
482
|
827 else
|
2034
|
828 " Construct execution string (four lines) which will be passed through filter
|
|
829 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
|
|
830 new
|
|
831 setlocal ff=unix
|
|
832 if exists("g:netrw_port") && g:netrw_port != ""
|
|
833 put ='open '.g:netrw_machine.' '.g:netrw_port
|
|
834 else
|
|
835 put ='open '.g:netrw_machine
|
|
836 endif
|
|
837 put ='user '.g:netrw_uid.' '.s:netrw_passwd
|
|
838 put ='get '.netrw_fname.' '.tmpfile
|
|
839 put ='quit'
|
|
840
|
|
841 " perform cadaver operation:
|
|
842 norm! 1Gdd
|
482
|
843 " call Decho("executing: %!".g:netrw_dav_cmd)
|
2034
|
844 exe s:netrw_silentxfer."%!".g:netrw_dav_cmd
|
|
845 bd!
|
|
846 endif
|
1621
|
847 let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)
|
482
|
848 let b:netrw_lastfile = choice
|
719
|
849
|
482
|
850 ".........................................
|
2034
|
851 " NetRead: (rsync) NetRead Method #7 {{{3
|
650
|
852 elseif b:netrw_method == 7
|
482
|
853 " call Decho("read via rsync (method #7)")
|
1668
|
854 " call Decho("exe ".s:netrw_silentxfer."!".g:netrw_rsync_cmd." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1))
|
|
855 exe s:netrw_silentxfer."!".g:netrw_rsync_cmd." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".shellescape(tmpfile,1)
|
1621
|
856 let result = s:NetrwGetFile(readcmd,tmpfile, b:netrw_method)
|
482
|
857 let b:netrw_lastfile = choice
|
719
|
858
|
482
|
859 ".........................................
|
2034
|
860 " NetRead: (fetch) NetRead Method #8 {{{3
|
482
|
861 " fetch://[user@]host[:http]/path
|
650
|
862 elseif b:netrw_method == 8
|
1121
|
863 " call Decho("read via fetch (method #8)")
|
482
|
864 if g:netrw_fetch_cmd == ""
|
|
865 if !exists("g:netrw_quiet")
|
1121
|
866 call netrw#ErrorMsg(s:ERROR,"fetch command not available",7)
|
482
|
867 endif
|
559
|
868 " call Dret("NetRead")
|
482
|
869 endif
|
|
870 if exists("g:netrw_option") && g:netrw_option == ":http"
|
|
871 let netrw_option= "http"
|
|
872 else
|
|
873 let netrw_option= "ftp"
|
|
874 endif
|
|
875 " call Decho("read via fetch for ".netrw_option)
|
719
|
876
|
1621
|
877 if exists("g:netrw_uid") && g:netrw_uid != "" && exists("s:netrw_passwd") && s:netrw_passwd != ""
|
1668
|
878 " call Decho("exe ".s:netrw_silentxfer."!".g:netrw_fetch_cmd." ".shellescape(tmpfile,1)." ".shellescape(netrw_option."://".g:netrw_uid.':'.s:netrw_passwd.'@'.g:netrw_machine."/".b:netrw_fname,1))
|
|
879 exe s:netrw_silentxfer."!".g:netrw_fetch_cmd." ".shellescape(tmpfile,1)." ".shellescape(netrw_option."://".g:netrw_uid.':'.s:netrw_passwd.'@'.g:netrw_machine."/".b:netrw_fname,1)
|
482
|
880 else
|
1668
|
881 " call Decho("exe ".s:netrw_silentxfer."!".g:netrw_fetch_cmd." ".shellescape(tmpfile,1)." ".shellescape(netrw_option."://".g:netrw_machine."/".b:netrw_fname,1))
|
|
882 exe s:netrw_silentxfer."!".g:netrw_fetch_cmd." ".shellescape(tmpfile,1)." ".shellescape(netrw_option."://".g:netrw_machine."/".b:netrw_fname,1)
|
1621
|
883 endif
|
|
884
|
|
885 let result = s:NetrwGetFile(readcmd,tmpfile, b:netrw_method)
|
482
|
886 let b:netrw_lastfile = choice
|
1121
|
887 setlocal ro
|
719
|
888
|
482
|
889 ".........................................
|
2034
|
890 " NetRead: (sftp) NetRead Method #9 {{{3
|
650
|
891 elseif b:netrw_method == 9
|
1121
|
892 " call Decho("read via sftp (method #9)")
|
1668
|
893 " call Decho("exe ".s:netrw_silentxfer."!".g:netrw_sftp_cmd." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".tmpfile)
|
|
894 exe s:netrw_silentxfer."!".g:netrw_sftp_cmd." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)." ".tmpfile
|
1621
|
895 let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method)
|
482
|
896 let b:netrw_lastfile = choice
|
719
|
897
|
482
|
898 ".........................................
|
2034
|
899 " NetRead: Complain {{{3
|
650
|
900 else
|
1121
|
901 call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . choice . ">",8)
|
482
|
902 endif
|
|
903 endwhile
|
719
|
904
|
2034
|
905 " NetRead: cleanup {{{3
|
482
|
906 if exists("b:netrw_method")
|
1121
|
907 " call Decho("cleanup b:netrw_method and b:netrw_fname")
|
482
|
908 unlet b:netrw_method
|
|
909 unlet b:netrw_fname
|
|
910 endif
|
1121
|
911 if s:FileReadable(tmpfile) && tmpfile !~ '.tar.bz2$' && tmpfile !~ '.tar.gz$' && tmpfile !~ '.zip' && tmpfile !~ '.tar' && readcmd != 't'
|
|
912 " call Decho("cleanup by deleting tmpfile<".tmpfile.">")
|
2034
|
913 call s:NetrwDelete(tmpfile)
|
1621
|
914 endif
|
|
915 call s:NetrwOptionRestore("w:")
|
1121
|
916
|
|
917 " call Dret("netrw#NetRead :5 getcwd<".getcwd().">")
|
482
|
918 endfun
|
|
919
|
|
920 " ------------------------------------------------------------------------
|
1621
|
921 " netrw#NetWrite: responsible for writing a file over the net {{{2
|
482
|
922 fun! netrw#NetWrite(...) range
|
1121
|
923 " call Dfunc("netrw#NetWrite(a:0=".a:0.") ".g:loaded_netrw)
|
719
|
924
|
2034
|
925 " NetWrite: option handling {{{3
|
482
|
926 let mod= 0
|
1621
|
927 call s:NetrwOptionSave("w:")
|
|
928 call s:NetrwSafeOptions()
|
719
|
929
|
2034
|
930 " NetWrite: Get Temporary Filename {{{3
|
1121
|
931 let tmpfile= s:GetTempfile("")
|
|
932 if tmpfile == ""
|
|
933 " call Dret("netrw#NetWrite : unable to get a tempfile!")
|
482
|
934 return
|
|
935 endif
|
719
|
936
|
482
|
937 if a:0 == 0
|
|
938 let ichoice = 0
|
|
939 else
|
|
940 let ichoice = 1
|
|
941 endif
|
719
|
942
|
1121
|
943 let curbufname= expand("%")
|
|
944 " call Decho("curbufname<".curbufname.">")
|
559
|
945 if &binary
|
1121
|
946 " For binary writes, always write entire file.
|
|
947 " (line numbers don't really make sense for that).
|
|
948 " Also supports the writing of tar and zip files.
|
1668
|
949 " call Decho("(write entire file) silent exe w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile))
|
|
950 silent exe "w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile)
|
1121
|
951 elseif g:netrw_cygwin
|
|
952 " write (selected portion of) file to temporary
|
|
953 let cygtmpfile= substitute(tmpfile,'/cygdrive/\(.\)','\1:','')
|
1668
|
954 " call Decho("(write selected portion) silent exe ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(cygtmpfile))
|
|
955 silent exe a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(cygtmpfile)
|
559
|
956 else
|
|
957 " write (selected portion of) file to temporary
|
1668
|
958 " call Decho("(write selected portion) silent exe ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile))
|
|
959 silent exe a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile)
|
559
|
960 endif
|
719
|
961
|
1121
|
962 if curbufname == ""
|
|
963 " if the file is [No Name], and one attempts to Nwrite it, the buffer takes
|
|
964 " on the temporary file's name. Deletion of the temporary file during
|
|
965 " cleanup then causes an error message.
|
|
966 0file!
|
|
967 endif
|
|
968
|
2034
|
969 " NetWrite: while choice loop: {{{3
|
482
|
970 while ichoice <= a:0
|
719
|
971
|
1121
|
972 " Process arguments: {{{4
|
482
|
973 " attempt to repeat with previous host-file-etc
|
|
974 if exists("b:netrw_lastfile") && a:0 == 0
|
|
975 " call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">")
|
|
976 let choice = b:netrw_lastfile
|
|
977 let ichoice= ichoice + 1
|
|
978 else
|
|
979 exe "let choice= a:" . ichoice
|
719
|
980
|
482
|
981 " Reconstruct Choice if choice starts with '"'
|
|
982 if match(choice,"?") == 0
|
|
983 echomsg 'NetWrite Usage:"'
|
|
984 echomsg ':Nwrite machine:path uses rcp'
|
|
985 echomsg ':Nwrite "machine path" uses ftp with <.netrc>'
|
|
986 echomsg ':Nwrite "machine id password path" uses ftp'
|
|
987 echomsg ':Nwrite dav://[user@]machine/path uses cadaver'
|
|
988 echomsg ':Nwrite fetch://[user@]machine/path uses fetch'
|
|
989 echomsg ':Nwrite ftp://machine[#port]/path uses ftp (autodetects <.netrc>)'
|
|
990 echomsg ':Nwrite rcp://machine/path uses rcp'
|
|
991 echomsg ':Nwrite rsync://[user@]machine/path uses rsync'
|
|
992 echomsg ':Nwrite scp://[user@]machine[[:#]port]/path uses scp'
|
|
993 echomsg ':Nwrite sftp://[user@]machine/path uses sftp'
|
1121
|
994 sleep 4
|
482
|
995 break
|
719
|
996
|
482
|
997 elseif match(choice,"^\"") != -1
|
|
998 if match(choice,"\"$") != -1
|
|
999 " case "..."
|
|
1000 let choice=strpart(choice,1,strlen(choice)-2)
|
|
1001 else
|
|
1002 " case "... ... ..."
|
|
1003 let choice = strpart(choice,1,strlen(choice)-1)
|
|
1004 let wholechoice = ""
|
719
|
1005
|
482
|
1006 while match(choice,"\"$") == -1
|
|
1007 let wholechoice= wholechoice . " " . choice
|
|
1008 let ichoice = ichoice + 1
|
|
1009 if choice > a:0
|
|
1010 if !exists("g:netrw_quiet")
|
1121
|
1011 call netrw#ErrorMsg(s:ERROR,"Unbalanced string in filename '". wholechoice ."'",13)
|
482
|
1012 endif
|
1121
|
1013 " call Dret("netrw#NetWrite")
|
482
|
1014 return
|
|
1015 endif
|
|
1016 let choice= a:{ichoice}
|
|
1017 endwhile
|
|
1018 let choice= strpart(wholechoice,1,strlen(wholechoice)-1) . " " . strpart(choice,0,strlen(choice)-1)
|
|
1019 endif
|
|
1020 endif
|
|
1021 endif
|
|
1022 let ichoice= ichoice + 1
|
1121
|
1023 " call Decho("choice<" . choice . "> ichoice=".ichoice)
|
|
1024
|
|
1025 " Determine method of write (ftp, rcp, etc) {{{4
|
1621
|
1026 call s:NetrwMethod(choice)
|
2034
|
1027 if !exists("b:netrw_method") || b:netrw_method < 0
|
|
1028 " call Dfunc("netrw#NetWrite : unsupported method")
|
|
1029 return
|
|
1030 endif
|
719
|
1031
|
482
|
1032 " =============
|
2034
|
1033 " NetWrite: Perform Protocol-Based Write {{{3
|
650
|
1034 " ============================
|
559
|
1035 if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1
|
|
1036 echo "(netrw) Processing your write request..."
|
1621
|
1037 " call Decho("(netrw) Processing your write request...")
|
559
|
1038 endif
|
719
|
1039
|
482
|
1040 ".........................................
|
2034
|
1041 " NetWrite: (rcp) NetWrite Method #1 {{{3
|
650
|
1042 if b:netrw_method == 1
|
559
|
1043 " call Decho("write via rcp (method #1)")
|
482
|
1044 if s:netrw_has_nt_rcp == 1
|
|
1045 if exists("g:netrw_uid") && ( g:netrw_uid != "" )
|
|
1046 let uid_machine = g:netrw_machine .'.'. g:netrw_uid
|
|
1047 else
|
|
1048 let uid_machine = g:netrw_machine .'.'. $USERNAME
|
|
1049 endif
|
|
1050 else
|
|
1051 if exists("g:netrw_uid") && ( g:netrw_uid != "" )
|
|
1052 let uid_machine = g:netrw_uid .'@'. g:netrw_machine
|
|
1053 else
|
|
1054 let uid_machine = g:netrw_machine
|
|
1055 endif
|
|
1056 endif
|
1668
|
1057 " call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".shellescape(tmpfile,1)." ".shellescape(uid_machine.":".b:netrw_fname,1))
|
|
1058 exe s:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".shellescape(tmpfile,1)." ".shellescape(uid_machine.":".b:netrw_fname,1)
|
482
|
1059 let b:netrw_lastfile = choice
|
719
|
1060
|
482
|
1061 ".........................................
|
2034
|
1062 " NetWrite: (ftp + <.netrc>) NetWrite Method #2 {{{3
|
650
|
1063 elseif b:netrw_method == 2
|
1121
|
1064 " call Decho("write via ftp+.netrc (method #2)")
|
2034
|
1065 let netrw_fname = b:netrw_fname
|
|
1066
|
|
1067 " formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead
|
|
1068 let bhkeep = &l:bh
|
|
1069 let curbuf = bufnr("%")
|
|
1070 setlocal bh=hide
|
|
1071 enew
|
|
1072
|
1621
|
1073 " call Decho("filter input window#".winnr())
|
482
|
1074 setlocal ff=unix
|
1698
|
1075 put =g:netrw_ftpmode
|
|
1076 " call Decho("filter input: ".getline('$'))
|
1121
|
1077 if exists("g:netrw_ftpextracmd")
|
1698
|
1078 put =g:netrw_ftpextracmd
|
|
1079 " call Decho("filter input: ".getline("$"))
|
|
1080 endif
|
|
1081 call setline(line("$")+1,'put "'.tmpfile.'" "'.netrw_fname.'"')
|
|
1082 " call Decho("filter input: ".getline("$"))
|
482
|
1083 if exists("g:netrw_port") && g:netrw_port != ""
|
1668
|
1084 " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1))
|
|
1085 exe s:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1)
|
482
|
1086 else
|
1621
|
1087 " call Decho("filter input window#".winnr())
|
1668
|
1088 " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1))
|
|
1089 exe s:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)
|
482
|
1090 endif
|
|
1091 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
|
|
1092 if getline(1) !~ "^$"
|
|
1093 if !exists("g:netrw_quiet")
|
1121
|
1094 call netrw#ErrorMsg(s:ERROR,getline(1),14)
|
482
|
1095 endif
|
|
1096 let mod=1
|
|
1097 endif
|
2034
|
1098
|
|
1099 " remove enew buffer (quietly)
|
|
1100 let filtbuf= bufnr("%")
|
|
1101 exe curbuf."b!"
|
|
1102 let &l:bh = bhkeep
|
|
1103 exe filtbuf."bw!"
|
|
1104
|
482
|
1105 let b:netrw_lastfile = choice
|
719
|
1106
|
482
|
1107 ".........................................
|
2034
|
1108 " NetWrite: (ftp + machine, id, passwd, filename) NetWrite Method #3 {{{3
|
650
|
1109 elseif b:netrw_method == 3
|
2034
|
1110 " Construct execution string (three or more lines) which will be passed through filter
|
1121
|
1111 " call Decho("read via ftp+mipf (method #3)")
|
2034
|
1112 let netrw_fname = b:netrw_fname
|
|
1113 let bhkeep = &l:bh
|
|
1114
|
|
1115 " formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead
|
|
1116 let curbuf = bufnr("%")
|
|
1117 setlocal bh=hide
|
|
1118 enew
|
482
|
1119 setlocal ff=unix
|
2034
|
1120
|
482
|
1121 if exists("g:netrw_port") && g:netrw_port != ""
|
|
1122 put ='open '.g:netrw_machine.' '.g:netrw_port
|
1621
|
1123 " call Decho("filter input: ".getline('.'))
|
482
|
1124 else
|
|
1125 put ='open '.g:netrw_machine
|
1621
|
1126 " call Decho("filter input: ".getline('.'))
|
482
|
1127 endif
|
|
1128 if exists("g:netrw_ftp") && g:netrw_ftp == 1
|
|
1129 put =g:netrw_uid
|
1621
|
1130 " call Decho("filter input: ".getline('.'))
|
|
1131 put ='\"'.s:netrw_passwd.'\"'
|
|
1132 " call Decho("filter input: ".getline('.'))
|
482
|
1133 else
|
1621
|
1134 put ='user \"'.g:netrw_uid.'\" \"'.s:netrw_passwd.'\"'
|
|
1135 " call Decho("filter input: ".getline('.'))
|
482
|
1136 endif
|
2034
|
1137 put =g:netrw_ftpmode
|
|
1138 " call Decho("filter input: ".getline('$'))
|
|
1139 if exists("g:netrw_ftpextracmd")
|
|
1140 put =g:netrw_ftpextracmd
|
|
1141 " call Decho("filter input: ".getline("$"))
|
|
1142 endif
|
1121
|
1143 put ='put \"'.tmpfile.'\" \"'.netrw_fname.'\"'
|
1621
|
1144 " call Decho("filter input: ".getline('.'))
|
482
|
1145 " save choice/id/password for future use
|
|
1146 let b:netrw_lastfile = choice
|
719
|
1147
|
482
|
1148 " perform ftp:
|
|
1149 " -i : turns off interactive prompting from ftp
|
|
1150 " -n unix : DON'T use <.netrc>, even though it exists
|
|
1151 " -n win32: quit being obnoxious about password
|
|
1152 norm! 1Gdd
|
|
1153 " call Decho("executing: %!".g:netrw_ftp_cmd." -i -n")
|
1621
|
1154 exe s:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n"
|
482
|
1155 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
|
|
1156 if getline(1) !~ "^$"
|
|
1157 if !exists("g:netrw_quiet")
|
1121
|
1158 call netrw#ErrorMsg(s:ERROR,getline(1),15)
|
482
|
1159 endif
|
|
1160 let mod=1
|
|
1161 endif
|
2034
|
1162
|
|
1163 " remove enew buffer (quietly)
|
|
1164 let filtbuf= bufnr("%")
|
|
1165 exe curbuf."b!"
|
|
1166 let &l:bh= bhkeep
|
|
1167 exe filtbuf."bw!"
|
719
|
1168
|
482
|
1169 ".........................................
|
2034
|
1170 " NetWrite: (scp) NetWrite Method #4 {{{3
|
650
|
1171 elseif b:netrw_method == 4
|
1121
|
1172 " call Decho("write via scp (method #4)")
|
482
|
1173 if exists("g:netrw_port") && g:netrw_port != ""
|
1668
|
1174 let useport= " ".g:netrw_scpport." ".fnameescape(g:netrw_port)
|
482
|
1175 else
|
|
1176 let useport= ""
|
|
1177 endif
|
1668
|
1178 " call Decho("exe ".s:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".shellescape(tmpfile,1)." ".shellescape(g:netrw_machine.":".b:netrw_fname,1))
|
|
1179 exe s:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".shellescape(tmpfile,1)." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)
|
482
|
1180 let b:netrw_lastfile = choice
|
719
|
1181
|
482
|
1182 ".........................................
|
2034
|
1183 " NetWrite: (http) NetWrite Method #5 {{{3
|
482
|
1184 elseif b:netrw_method == 5
|
1121
|
1185 " call Decho("write via http (method #5)")
|
482
|
1186 if !exists("g:netrw_quiet")
|
1121
|
1187 call netrw#ErrorMsg(s:ERROR,"currently <netrw.vim> does not support writing using http:",16)
|
482
|
1188 endif
|
719
|
1189
|
482
|
1190 ".........................................
|
2034
|
1191 " NetWrite: (dav) NetWrite Method #6 (cadaver) {{{3
|
650
|
1192 elseif b:netrw_method == 6
|
482
|
1193 " call Decho("write via cadaver (method #6)")
|
719
|
1194
|
482
|
1195 " Construct execution string (four lines) which will be passed through filter
|
2034
|
1196 let netrw_fname = escape(b:netrw_fname,g:netrw_fname_escape)
|
|
1197 let bhkeep = &l:bh
|
|
1198
|
|
1199 " formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead
|
|
1200 let curbuf = bufnr("%")
|
|
1201 setlocal bh=hide
|
|
1202 enew
|
|
1203
|
482
|
1204 setlocal ff=unix
|
|
1205 if exists("g:netrw_port") && g:netrw_port != ""
|
|
1206 put ='open '.g:netrw_machine.' '.g:netrw_port
|
|
1207 else
|
|
1208 put ='open '.g:netrw_machine
|
|
1209 endif
|
1621
|
1210 if exists("g:netrw_uid") && exists("s:netrw_passwd")
|
|
1211 put ='user '.g:netrw_uid.' '.s:netrw_passwd
|
|
1212 endif
|
1121
|
1213 put ='put '.tmpfile.' '.netrw_fname
|
719
|
1214
|
482
|
1215 " perform cadaver operation:
|
|
1216 norm! 1Gdd
|
|
1217 " call Decho("executing: %!".g:netrw_dav_cmd)
|
1621
|
1218 exe s:netrw_silentxfer."%!".g:netrw_dav_cmd
|
2034
|
1219
|
|
1220 " remove enew buffer (quietly)
|
|
1221 let filtbuf= bufnr("%")
|
|
1222 exe curbuf."b!"
|
|
1223 let &l:bh = bhkeep
|
|
1224 exe filtbuf."bw!"
|
|
1225
|
482
|
1226 let b:netrw_lastfile = choice
|
719
|
1227
|
482
|
1228 ".........................................
|
2034
|
1229 " NetWrite: (rsync) NetWrite Method #7 {{{3
|
650
|
1230 elseif b:netrw_method == 7
|
1121
|
1231 " call Decho("write via rsync (method #7)")
|
1668
|
1232 " call Decho("executing: !".g:netrw_rsync_cmd." ".shellescape(tmpfile,1)." ".shellescape(g:netrw_machine.":".b:netrw_fname,1))
|
|
1233 exe s:netrw_silentxfer."!".g:netrw_rsync_cmd." ".shellescape(tmpfile,1)." ".shellescape(g:netrw_machine.":".b:netrw_fname,1)
|
482
|
1234 let b:netrw_lastfile = choice
|
719
|
1235
|
482
|
1236 ".........................................
|
2034
|
1237 " NetWrite: (sftp) NetWrite Method #9 {{{3
|
650
|
1238 elseif b:netrw_method == 9
|
1121
|
1239 " call Decho("read via sftp (method #9)")
|
719
|
1240 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
|
482
|
1241 if exists("g:netrw_uid") && ( g:netrw_uid != "" )
|
|
1242 let uid_machine = g:netrw_uid .'@'. g:netrw_machine
|
|
1243 else
|
|
1244 let uid_machine = g:netrw_machine
|
|
1245 endif
|
2034
|
1246
|
|
1247 " formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead
|
|
1248 let bhkeep = &l:bh
|
|
1249 let curbuf = bufnr("%")
|
|
1250 setlocal bh=hide
|
|
1251 enew
|
|
1252
|
482
|
1253 setlocal ff=unix
|
2034
|
1254 call setline(1,'put "'.escape(tmpfile,'\').'" '.netrw_fname)
|
1621
|
1255 " call Decho("filter input: ".getline('.'))
|
1668
|
1256 " call Decho("executing: %!".g:netrw_sftp_cmd.' '.shellescape(uid_machine,1))
|
|
1257 exe s:netrw_silentxfer."%!".g:netrw_sftp_cmd.' '.shellescape(uid_machine,1)
|
2034
|
1258 let filtbuf= bufnr("%")
|
|
1259 exe curbuf."b!"
|
|
1260 let &l:bh = bhkeep
|
|
1261 exe filtbuf."bw!"
|
|
1262 let b:netrw_lastfile = choice
|
719
|
1263
|
482
|
1264 ".........................................
|
2034
|
1265 " NetWrite: Complain {{{3
|
650
|
1266 else
|
1121
|
1267 call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . choice . ">",17)
|
482
|
1268 endif
|
|
1269 endwhile
|
719
|
1270
|
2034
|
1271 " NetWrite: Cleanup: {{{3
|
482
|
1272 " call Decho("cleanup")
|
1121
|
1273 if s:FileReadable(tmpfile)
|
|
1274 " call Decho("tmpfile<".tmpfile."> readable, will now delete it")
|
1668
|
1275 call s:NetrwDelete(tmpfile)
|
1121
|
1276 endif
|
1621
|
1277 call s:NetrwOptionRestore("w:")
|
719
|
1278
|
482
|
1279 if a:firstline == 1 && a:lastline == line("$")
|
1121
|
1280 " restore modifiability; usually equivalent to set nomod
|
|
1281 let &mod= mod
|
482
|
1282 endif
|
519
|
1283
|
2034
|
1284 " restore equalalways
|
1121
|
1285 " call Dret("netrw#NetWrite")
|
482
|
1286 endfun
|
|
1287
|
519
|
1288 " ---------------------------------------------------------------------
|
1621
|
1289 " netrw#NetSource: source a remotely hosted vim script {{{2
|
1121
|
1290 " uses NetRead to get a copy of the file into a temporarily file,
|
|
1291 " then sources that file,
|
|
1292 " then removes that file.
|
|
1293 fun! netrw#NetSource(...)
|
|
1294 " call Dfunc("netrw#NetSource() a:0=".a:0)
|
|
1295 if a:0 > 0 && a:1 == '?'
|
|
1296 " give help
|
|
1297 echomsg 'NetSource Usage:'
|
|
1298 echomsg ':Nsource dav://machine[:port]/path uses cadaver'
|
|
1299 echomsg ':Nsource fetch://machine/path uses fetch'
|
|
1300 echomsg ':Nsource ftp://[user@]machine[:port]/path uses ftp autodetects <.netrc>'
|
|
1301 echomsg ':Nsource http://[user@]machine/path uses http wget'
|
|
1302 echomsg ':Nsource rcp://[user@]machine/path uses rcp'
|
|
1303 echomsg ':Nsource rsync://machine[:port]/path uses rsync'
|
|
1304 echomsg ':Nsource scp://[user@]machine[[:#]port]/path uses scp'
|
|
1305 echomsg ':Nsource sftp://[user@]machine[[:#]port]/path uses sftp'
|
|
1306 sleep 4
|
650
|
1307 else
|
1121
|
1308 let i= 1
|
|
1309 while i <= a:0
|
|
1310 call netrw#NetRead(3,a:{i})
|
1698
|
1311 " call Decho("(netrw#NetSource) s:netread_tmpfile<".s:netrw_tmpfile.">")
|
1121
|
1312 if s:FileReadable(s:netrw_tmpfile)
|
1698
|
1313 " call Decho("(netrw#NetSource) exe so ".fnameescape(s:netrw_tmpfile))
|
|
1314 exe "so ".fnameescape(s:netrw_tmpfile)
|
|
1315 " call Decho("(netrw#NetSource) delete(".s:netrw_tmpfile.")")
|
1121
|
1316 call delete(s:netrw_tmpfile)
|
|
1317 unlet s:netrw_tmpfile
|
|
1318 else
|
|
1319 call netrw#ErrorMsg(s:ERROR,"unable to source <".a:{i}.">!",48)
|
719
|
1320 endif
|
1121
|
1321 let i= i + 1
|
|
1322 endwhile
|
719
|
1323 endif
|
1121
|
1324 " call Dret("netrw#NetSource")
|
482
|
1325 endfun
|
|
1326
|
1121
|
1327 " ===========================================
|
1621
|
1328 " s:NetrwGetFile: Function to read temporary file "tfile" with command "readcmd". {{{2
|
1121
|
1329 " readcmd == %r : replace buffer with newly read file
|
|
1330 " == 0r : read file at top of buffer
|
|
1331 " == r : read file after current line
|
|
1332 " == t : leave file in temporary form (ie. don't read into buffer)
|
1621
|
1333 fun! s:NetrwGetFile(readcmd, tfile, method)
|
|
1334 " call Dfunc("NetrwGetFile(readcmd<".a:readcmd.">,tfile<".a:tfile."> method<".a:method.">)")
|
1121
|
1335
|
|
1336 " readcmd=='t': simply do nothing
|
|
1337 if a:readcmd == 't'
|
1668
|
1338 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap)
|
1621
|
1339 " call Dret("NetrwGetFile : skip read of <".a:tfile.">")
|
482
|
1340 return
|
|
1341 endif
|
|
1342
|
1121
|
1343 " get name of remote filename (ie. url and all)
|
|
1344 let rfile= bufname("%")
|
|
1345 " call Decho("rfile<".rfile.">")
|
|
1346
|
|
1347 if exists("*NetReadFixup")
|
|
1348 " for the use of NetReadFixup (not otherwise used internally)
|
|
1349 let line2= line("$")
|
482
|
1350 endif
|
|
1351
|
1121
|
1352 if a:readcmd[0] == '%'
|
|
1353 " get file into buffer
|
|
1354 " call Decho("get file into buffer")
|
|
1355
|
|
1356 " rename the current buffer to the temp file (ie. tfile)
|
|
1357 if g:netrw_cygwin
|
|
1358 let tfile= substitute(a:tfile,'/cygdrive/\(.\)','\1:','')
|
482
|
1359 else
|
1121
|
1360 let tfile= a:tfile
|
482
|
1361 endif
|
1668
|
1362 " call Decho("exe silent! keepalt file ".fnameescape(tfile))
|
|
1363 exe "silent! keepalt file ".fnameescape(tfile)
|
1121
|
1364
|
|
1365 " edit temporary file (ie. read the temporary file in)
|
|
1366 if rfile =~ '\.zip$'
|
|
1367 " call Decho("handling remote zip file with zip#Browse(tfile<".tfile.">)")
|
|
1368 call zip#Browse(tfile)
|
|
1369 elseif rfile =~ '\.tar$'
|
|
1370 " call Decho("handling remote tar file with tar#Browse(tfile<".tfile.">)")
|
|
1371 call tar#Browse(tfile)
|
|
1372 elseif rfile =~ '\.tar\.gz'
|
|
1373 " call Decho("handling remote gzip-compressed tar file")
|
|
1374 call tar#Browse(tfile)
|
|
1375 elseif rfile =~ '\.tar\.bz2'
|
|
1376 " call Decho("handling remote bz2-compressed tar file")
|
|
1377 call tar#Browse(tfile)
|
482
|
1378 else
|
1121
|
1379 " call Decho("edit temporary file")
|
|
1380 e!
|
482
|
1381 endif
|
|
1382
|
1121
|
1383 " rename buffer back to remote filename
|
1668
|
1384 " call Decho("exe silent! keepalt file ".fnameescape(rfile))
|
|
1385 exe "silent! keepalt file ".fnameescape(rfile)
|
2034
|
1386 filetype detect
|
1121
|
1387 " call Dredir("renamed buffer back to remote filename<".rfile."> : expand(%)<".expand("%").">","ls!")
|
|
1388 let line1 = 1
|
|
1389 let line2 = line("$")
|
|
1390
|
|
1391 elseif s:FileReadable(a:tfile)
|
|
1392 " read file after current line
|
|
1393 " call Decho("read file<".a:tfile."> after current line")
|
|
1394 let curline = line(".")
|
|
1395 let lastline= line("$")
|
1668
|
1396 " call Decho("exe<".a:readcmd." ".fnameescape(v:cmdarg)." ".fnameescape(a:tfile)."> line#".curline)
|
|
1397 exe a:readcmd." ".fnameescape(v:cmdarg)." ".fnameescape(a:tfile)
|
1121
|
1398 let line1= curline + 1
|
|
1399 let line2= line("$") - lastline + 1
|
482
|
1400
|
|
1401 else
|
1121
|
1402 " not readable
|
1668
|
1403 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap)
|
1121
|
1404 " call Decho("tfile<".a:tfile."> not readable")
|
|
1405 call netrw#ErrorMsg(s:WARNING,"file <".a:tfile."> not readable",9)
|
1621
|
1406 " call Dret("NetrwGetFile : tfile<".a:tfile."> not readable")
|
1121
|
1407 return
|
482
|
1408 endif
|
|
1409
|
1121
|
1410 " User-provided (ie. optional) fix-it-up command
|
|
1411 if exists("*NetReadFixup")
|
|
1412 " call Decho("calling NetReadFixup(method<".a:method."> line1=".line1." line2=".line2.")")
|
|
1413 call NetReadFixup(a:method, line1, line2)
|
|
1414 " else " Decho
|
|
1415 " call Decho("NetReadFixup() not called, doesn't exist (line1=".line1." line2=".line2.")")
|
766
|
1416 endif
|
|
1417
|
2034
|
1418 if has("gui") && has("menu") && has("gui_running") && &go =~ 'm' && g:netrw_menu
|
1621
|
1419 " update the Buffers menu
|
|
1420 call s:UpdateBuffersMenu()
|
766
|
1421 endif
|
|
1422
|
1121
|
1423 " call Decho("readcmd<".a:readcmd."> cmdarg<".v:cmdarg."> tfile<".a:tfile."> readable=".s:FileReadable(a:tfile))
|
|
1424
|
|
1425 " make sure file is being displayed
|
1621
|
1426 " redraw!
|
|
1427
|
1668
|
1428 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap)
|
1621
|
1429 " call Dret("NetrwGetFile")
|
482
|
1430 endfun
|
|
1431
|
1121
|
1432 " ------------------------------------------------------------------------
|
1621
|
1433 " s:NetrwMethod: determine method of transfer {{{2
|
2034
|
1434 " Input:
|
|
1435 " choice = url [protocol:]//[userid@]hostname[:port]/[path-to-file]
|
|
1436 " Output:
|
|
1437 " b:netrw_method= 1: rcp
|
|
1438 " 2: ftp + <.netrc>
|
|
1439 " 3: ftp + machine, id, password, and [path]filename
|
|
1440 " 4: scp
|
|
1441 " 5: http (wget)
|
|
1442 " 6: dav
|
|
1443 " 7: rsync
|
|
1444 " 8: fetch
|
|
1445 " 9: sftp
|
|
1446 " g:netrw_machine= hostname
|
|
1447 " b:netrw_fname = filename
|
|
1448 " g:netrw_port = optional port number (for ftp)
|
|
1449 " g:netrw_choice = copy of input url (choice)
|
|
1450 fun! s:NetrwMethod(choice)
|
1621
|
1451 " call Dfunc("NetrwMethod(a:choice<".a:choice.">)")
|
719
|
1452
|
2034
|
1453 " record current g:netrw_machine, if any
|
|
1454 " curmachine used if protocol == ftp and no .netrc
|
|
1455 if exists("g:netrw_machine")
|
|
1456 let curmachine= g:netrw_machine
|
|
1457 " call Decho("curmachine<".curmachine.">")
|
|
1458 else
|
|
1459 let curmachine= "N O T A HOST"
|
|
1460 endif
|
|
1461
|
482
|
1462 " initialization
|
|
1463 let b:netrw_method = 0
|
|
1464 let g:netrw_machine = ""
|
|
1465 let b:netrw_fname = ""
|
|
1466 let g:netrw_port = ""
|
719
|
1467 let g:netrw_choice = a:choice
|
|
1468
|
482
|
1469 " Patterns:
|
|
1470 " mipf : a:machine a:id password filename Use ftp
|
1621
|
1471 " mf : a:machine filename Use ftp + <.netrc> or g:netrw_uid s:netrw_passwd
|
|
1472 " ftpurm : ftp://[user@]host[[#:]port]/filename Use ftp + <.netrc> or g:netrw_uid s:netrw_passwd
|
482
|
1473 " rcpurm : rcp://[user@]host/filename Use rcp
|
|
1474 " rcphf : [user@]host:filename Use rcp
|
|
1475 " scpurm : scp://[user@]host[[#:]port]/filename Use scp
|
|
1476 " httpurm : http://[user@]host/filename Use wget
|
2034
|
1477 " davurm : dav[s]://host[:port]/path Use cadaver/curl
|
482
|
1478 " rsyncurm : rsync://host[:port]/path Use rsync
|
|
1479 " fetchurm : fetch://[user@]host[:http]/filename Use fetch (defaults to ftp, override for http)
|
|
1480 " sftpurm : sftp://[user@]host/filename Use scp
|
|
1481 let mipf = '^\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)$'
|
|
1482 let mf = '^\(\S\+\)\s\+\(\S\+\)$'
|
|
1483 let ftpurm = '^ftp://\(\([^/@]\{-}\)@\)\=\([^/#:]\{-}\)\([#:]\d\+\)\=/\(.*\)$'
|
|
1484 let rcpurm = '^rcp://\%(\([^/@]\{-}\)@\)\=\([^/]\{-}\)/\(.*\)$'
|
|
1485 let rcphf = '^\(\(\h\w*\)@\)\=\(\h\w*\):\([^@]\+\)$'
|
559
|
1486 let scpurm = '^scp://\([^/#:]\+\)\%([#:]\(\d\+\)\)\=/\(.*\)$'
|
482
|
1487 let httpurm = '^http://\([^/]\{-}\)\(/.*\)\=$'
|
1621
|
1488 let davurm = '^davs\=://\([^/]\+\)/\(.*/\)\([-_.~[:alnum:]]\+\)$'
|
482
|
1489 let rsyncurm = '^rsync://\([^/]\{-}\)/\(.*\)\=$'
|
|
1490 let fetchurm = '^fetch://\(\([^/@]\{-}\)@\)\=\([^/#:]\{-}\)\(:http\)\=/\(.*\)$'
|
|
1491 let sftpurm = '^sftp://\([^/]\{-}\)/\(.*\)\=$'
|
719
|
1492
|
482
|
1493 " call Decho("determine method:")
|
|
1494 " Determine Method
|
|
1495 " rcp://user@hostname/...path-to-file
|
|
1496 if match(a:choice,rcpurm) == 0
|
|
1497 " call Decho("rcp://...")
|
|
1498 let b:netrw_method = 1
|
|
1499 let userid = substitute(a:choice,rcpurm,'\1',"")
|
|
1500 let g:netrw_machine = substitute(a:choice,rcpurm,'\2',"")
|
|
1501 let b:netrw_fname = substitute(a:choice,rcpurm,'\3',"")
|
|
1502 if userid != ""
|
|
1503 let g:netrw_uid= userid
|
|
1504 endif
|
719
|
1505
|
482
|
1506 " scp://user@hostname/...path-to-file
|
|
1507 elseif match(a:choice,scpurm) == 0
|
|
1508 " call Decho("scp://...")
|
519
|
1509 let b:netrw_method = 4
|
482
|
1510 let g:netrw_machine = substitute(a:choice,scpurm,'\1',"")
|
|
1511 let g:netrw_port = substitute(a:choice,scpurm,'\2',"")
|
|
1512 let b:netrw_fname = substitute(a:choice,scpurm,'\3',"")
|
719
|
1513
|
482
|
1514 " http://user@hostname/...path-to-file
|
|
1515 elseif match(a:choice,httpurm) == 0
|
|
1516 " call Decho("http://...")
|
|
1517 let b:netrw_method = 5
|
|
1518 let g:netrw_machine= substitute(a:choice,httpurm,'\1',"")
|
|
1519 let b:netrw_fname = substitute(a:choice,httpurm,'\2',"")
|
719
|
1520
|
482
|
1521 " dav://hostname[:port]/..path-to-file..
|
|
1522 elseif match(a:choice,davurm) == 0
|
|
1523 " call Decho("dav://...")
|
|
1524 let b:netrw_method= 6
|
|
1525 if a:choice =~ '^s'
|
|
1526 let g:netrw_machine= 'https://'.substitute(a:choice,davurm,'\1/\2',"")
|
|
1527 else
|
|
1528 let g:netrw_machine= 'http://'.substitute(a:choice,davurm,'\1/\2',"")
|
|
1529 endif
|
|
1530 let b:netrw_fname = substitute(a:choice,davurm,'\3',"")
|
719
|
1531
|
482
|
1532 " rsync://user@hostname/...path-to-file
|
|
1533 elseif match(a:choice,rsyncurm) == 0
|
|
1534 " call Decho("rsync://...")
|
|
1535 let b:netrw_method = 7
|
|
1536 let g:netrw_machine= substitute(a:choice,rsyncurm,'\1',"")
|
|
1537 let b:netrw_fname = substitute(a:choice,rsyncurm,'\2',"")
|
719
|
1538
|
482
|
1539 " ftp://[user@]hostname[[:#]port]/...path-to-file
|
|
1540 elseif match(a:choice,ftpurm) == 0
|
|
1541 " call Decho("ftp://...")
|
519
|
1542 let userid = substitute(a:choice,ftpurm,'\2',"")
|
482
|
1543 let g:netrw_machine= substitute(a:choice,ftpurm,'\3',"")
|
|
1544 let g:netrw_port = substitute(a:choice,ftpurm,'\4',"")
|
|
1545 let b:netrw_fname = substitute(a:choice,ftpurm,'\5',"")
|
2034
|
1546 " call Decho("g:netrw_machine<".g:netrw_machine.">")
|
482
|
1547 if userid != ""
|
|
1548 let g:netrw_uid= userid
|
|
1549 endif
|
2034
|
1550 if exists("s:netrw_passwd") && curmachine != g:netrw_machine
|
|
1551 " if there's a change in hostname, require password re-entry
|
|
1552 unlet s:netrw_passwd
|
|
1553 endif
|
1621
|
1554 if exists("g:netrw_uid") && exists("s:netrw_passwd")
|
482
|
1555 let b:netrw_method = 3
|
|
1556 else
|
1121
|
1557 if s:FileReadable(expand("$HOME/.netrc")) && !g:netrw_ignorenetrc
|
482
|
1558 let b:netrw_method= 2
|
|
1559 else
|
|
1560 if !exists("g:netrw_uid") || g:netrw_uid == ""
|
|
1561 call NetUserPass()
|
1621
|
1562 elseif !exists("s:netrw_passwd") || s:netrw_passwd == ""
|
482
|
1563 call NetUserPass(g:netrw_uid)
|
1621
|
1564 " else just use current g:netrw_uid and s:netrw_passwd
|
482
|
1565 endif
|
|
1566 let b:netrw_method= 3
|
|
1567 endif
|
|
1568 endif
|
719
|
1569
|
482
|
1570 elseif match(a:choice,fetchurm) == 0
|
|
1571 " call Decho("fetch://...")
|
|
1572 let b:netrw_method = 8
|
|
1573 let g:netrw_userid = substitute(a:choice,fetchurm,'\2',"")
|
|
1574 let g:netrw_machine= substitute(a:choice,fetchurm,'\3',"")
|
|
1575 let b:netrw_option = substitute(a:choice,fetchurm,'\4',"")
|
|
1576 let b:netrw_fname = substitute(a:choice,fetchurm,'\5',"")
|
719
|
1577
|
482
|
1578 " Issue an ftp : "machine id password [path/]filename"
|
|
1579 elseif match(a:choice,mipf) == 0
|
|
1580 " call Decho("(ftp) host id pass file")
|
|
1581 let b:netrw_method = 3
|
|
1582 let g:netrw_machine = substitute(a:choice,mipf,'\1',"")
|
|
1583 let g:netrw_uid = substitute(a:choice,mipf,'\2',"")
|
1621
|
1584 let s:netrw_passwd = substitute(a:choice,mipf,'\3',"")
|
482
|
1585 let b:netrw_fname = substitute(a:choice,mipf,'\4',"")
|
719
|
1586
|
482
|
1587 " Issue an ftp: "hostname [path/]filename"
|
|
1588 elseif match(a:choice,mf) == 0
|
|
1589 " call Decho("(ftp) host file")
|
1621
|
1590 if exists("g:netrw_uid") && exists("s:netrw_passwd")
|
482
|
1591 let b:netrw_method = 3
|
|
1592 let g:netrw_machine = substitute(a:choice,mf,'\1',"")
|
|
1593 let b:netrw_fname = substitute(a:choice,mf,'\2',"")
|
719
|
1594
|
1121
|
1595 elseif s:FileReadable(expand("$HOME/.netrc"))
|
482
|
1596 let b:netrw_method = 2
|
|
1597 let g:netrw_machine = substitute(a:choice,mf,'\1',"")
|
|
1598 let b:netrw_fname = substitute(a:choice,mf,'\2',"")
|
|
1599 endif
|
719
|
1600
|
482
|
1601 " sftp://user@hostname/...path-to-file
|
|
1602 elseif match(a:choice,sftpurm) == 0
|
|
1603 " call Decho("sftp://...")
|
|
1604 let b:netrw_method = 9
|
|
1605 let g:netrw_machine= substitute(a:choice,sftpurm,'\1',"")
|
|
1606 let b:netrw_fname = substitute(a:choice,sftpurm,'\2',"")
|
719
|
1607
|
482
|
1608 " Issue an rcp: hostname:filename" (this one should be last)
|
|
1609 elseif match(a:choice,rcphf) == 0
|
|
1610 " call Decho("(rcp) [user@]host:file) rcphf<".rcphf.">")
|
1621
|
1611 let b:netrw_method = 1
|
|
1612 let userid = substitute(a:choice,rcphf,'\2',"")
|
|
1613 let g:netrw_machine = substitute(a:choice,rcphf,'\3',"")
|
|
1614 let b:netrw_fname = substitute(a:choice,rcphf,'\4',"")
|
482
|
1615 " call Decho('\1<'.substitute(a:choice,rcphf,'\1',"").">")
|
|
1616 " call Decho('\2<'.substitute(a:choice,rcphf,'\2',"").">")
|
|
1617 " call Decho('\3<'.substitute(a:choice,rcphf,'\3',"").">")
|
|
1618 " call Decho('\4<'.substitute(a:choice,rcphf,'\4',"").">")
|
|
1619 if userid != ""
|
|
1620 let g:netrw_uid= userid
|
|
1621 endif
|
719
|
1622
|
482
|
1623 else
|
|
1624 if !exists("g:netrw_quiet")
|
2034
|
1625 call netrw#ErrorMsg(s:WARNING,"cannot determine method (format: protocol://[user@]hostname[:port]/[path])",45)
|
482
|
1626 endif
|
|
1627 let b:netrw_method = -1
|
|
1628 endif
|
|
1629
|
|
1630 " remove any leading [:#] from port number
|
|
1631 if g:netrw_port != ""
|
|
1632 let g:netrw_port = substitute(g:netrw_port,'[#:]\+','','')
|
|
1633 endif
|
719
|
1634
|
482
|
1635 " call Decho("a:choice <".a:choice.">")
|
|
1636 " call Decho("b:netrw_method <".b:netrw_method.">")
|
|
1637 " call Decho("g:netrw_machine<".g:netrw_machine.">")
|
|
1638 " call Decho("g:netrw_port <".g:netrw_port.">")
|
|
1639 " if exists("g:netrw_uid") "Decho
|
|
1640 " call Decho("g:netrw_uid <".g:netrw_uid.">")
|
|
1641 " endif "Decho
|
1621
|
1642 " if exists("s:netrw_passwd") "Decho
|
|
1643 " call Decho("s:netrw_passwd <".s:netrw_passwd.">")
|
482
|
1644 " endif "Decho
|
|
1645 " call Decho("b:netrw_fname <".b:netrw_fname.">")
|
1621
|
1646 " call Dret("NetrwMethod : b:netrw_method=".b:netrw_method)
|
482
|
1647 endfun
|
|
1648
|
|
1649 " ------------------------------------------------------------------------
|
1121
|
1650 " NetReadFixup: this sort of function is typically written by the user {{{2
|
|
1651 " to handle extra junk that their system's ftp dumps
|
|
1652 " into the transfer. This function is provided as an
|
|
1653 " example and as a fix for a Windows 95 problem: in my
|
|
1654 " experience, win95's ftp always dumped four blank lines
|
|
1655 " at the end of the transfer.
|
|
1656 if has("win95") && exists("g:netrw_win95ftp") && g:netrw_win95ftp
|
|
1657 fun! NetReadFixup(method, line1, line2)
|
|
1658 " call Dfunc("NetReadFixup(method<".a:method."> line1=".a:line1." line2=".a:line2.")")
|
2034
|
1659
|
|
1660 " sanity checks -- attempt to convert inputs to integers
|
|
1661 let method = a:method + 0
|
|
1662 let line1 = a:line1 + 0
|
|
1663 let line2 = a:line2 + 0
|
|
1664 if type(method) != 0 || type(line1) != 0 || type(line2) != 0 || method < 0 || line1 <= 0 || line2 <= 0
|
|
1665 " call Dret("NetReadFixup")
|
|
1666 return
|
|
1667 endif
|
|
1668
|
1121
|
1669 if method == 3 " ftp (no <.netrc>)
|
|
1670 let fourblanklines= line2 - 3
|
2034
|
1671 if fourblanklines >= line1
|
|
1672 exe "silent ".fourblanklines.",".line2."g/^\s*$/d"
|
|
1673 call histdel("/",-1)
|
|
1674 endif
|
|
1675 endif
|
|
1676
|
1121
|
1677 " call Dret("NetReadFixup")
|
|
1678 endfun
|
|
1679 endif
|
|
1680
|
|
1681 " ---------------------------------------------------------------------
|
650
|
1682 " NetUserPass: set username and password for subsequent ftp transfer {{{2
|
482
|
1683 " Usage: :call NetUserPass() -- will prompt for userid and password
|
|
1684 " :call NetUserPass("uid") -- will prompt for password
|
|
1685 " :call NetUserPass("uid","password") -- sets global userid and password
|
|
1686 fun! NetUserPass(...)
|
|
1687
|
|
1688 " get/set userid
|
|
1689 if a:0 == 0
|
|
1690 " call Dfunc("NetUserPass(a:0<".a:0.">)")
|
|
1691 if !exists("g:netrw_uid") || g:netrw_uid == ""
|
|
1692 " via prompt
|
|
1693 let g:netrw_uid= input('Enter username: ')
|
|
1694 endif
|
|
1695 else " from command line
|
|
1696 " call Dfunc("NetUserPass(a:1<".a:1.">) {")
|
|
1697 let g:netrw_uid= a:1
|
|
1698 endif
|
|
1699
|
|
1700 " get password
|
|
1701 if a:0 <= 1 " via prompt
|
|
1702 " call Decho("a:0=".a:0." case <=1:")
|
1621
|
1703 let s:netrw_passwd= inputsecret("Enter Password: ")
|
482
|
1704 else " from command line
|
|
1705 " call Decho("a:0=".a:0." case >1: a:2<".a:2.">")
|
1621
|
1706 let s:netrw_passwd=a:2
|
482
|
1707 endif
|
559
|
1708
|
482
|
1709 " call Dret("NetUserPass")
|
|
1710 endfun
|
|
1711
|
1121
|
1712 " ===========================================
|
|
1713 " Shared Browsing Support: {{{1
|
|
1714 " ===========================================
|
|
1715
|
|
1716 " ---------------------------------------------------------------------
|
|
1717 " s:BrowserMaps: {{{2
|
|
1718 fun! s:BrowserMaps(islocal)
|
|
1719 " call Dfunc("s:BrowserMaps(islocal=".a:islocal.") b:netrw_curdir<".b:netrw_curdir.">")
|
|
1720 if a:islocal
|
1698
|
1721 " call Decho("make local maps")
|
1621
|
1722 nnoremap <buffer> <silent> <cr> :call netrw#LocalBrowseCheck(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord()))<cr>
|
|
1723 nnoremap <buffer> <silent> - :exe "norm! 0"<bar>call netrw#LocalBrowseCheck(<SID>NetrwBrowseChgDir(1,'../'))<cr>
|
|
1724 nnoremap <buffer> <silent> a :call <SID>NetrwHide(1)<cr>
|
2034
|
1725 nnoremap <buffer> <silent> mb :<c-u>call <SID>NetrwBookHistHandler(0,b:netrw_curdir)<cr>
|
1621
|
1726 nnoremap <buffer> <silent> mc :<c-u>call <SID>NetrwMarkFileCopy(1)<cr>
|
|
1727 nnoremap <buffer> <silent> md :<c-u>call <SID>NetrwMarkFileDiff(1)<cr>
|
|
1728 nnoremap <buffer> <silent> me :<c-u>call <SID>NetrwMarkFileEdit(1)<cr>
|
|
1729 nnoremap <buffer> <silent> mf :<c-u>call <SID>NetrwMarkFile(1,<SID>NetrwGetWord())<cr>
|
|
1730 nnoremap <buffer> <silent> mg :<c-u>call <SID>NetrwMarkFileGrep(1)<cr>
|
|
1731 nnoremap <buffer> <silent> mh :<c-u>call <SID>NetrwMarkHideSfx(1)<cr>
|
|
1732 nnoremap <buffer> <silent> mm :<c-u>call <SID>NetrwMarkFileMove(1)<cr>
|
|
1733 nnoremap <buffer> <silent> mp :<c-u>call <SID>NetrwMarkFilePrint(1)<cr>
|
|
1734 nnoremap <buffer> <silent> mr :<c-u>call <SID>NetrwMarkFileRegexp(1)<cr>
|
|
1735 nnoremap <buffer> <silent> ms :<c-u>call <SID>NetrwMarkFileSource(1)<cr>
|
|
1736 nnoremap <buffer> <silent> mT :<c-u>call <SID>NetrwMarkFileTag(1)<cr>
|
|
1737 nnoremap <buffer> <silent> mt :<c-u>call <SID>NetrwMarkFileTgt(1)<cr>
|
|
1738 nnoremap <buffer> <silent> mu :<c-u>call <SID>NetrwUnMarkFile(1)<cr>
|
|
1739 nnoremap <buffer> <silent> mx :<c-u>call <SID>NetrwMarkFileExe(1)<cr>
|
|
1740 nnoremap <buffer> <silent> mz :<c-u>call <SID>NetrwMarkFileCompress(1)<cr>
|
2034
|
1741 nnoremap <buffer> <silent> gb :<c-u>call <SID>NetrwBookHistHandler(1,b:netrw_curdir)<cr>
|
1621
|
1742 nnoremap <buffer> <silent> gh :<c-u>call <SID>NetrwHidden(1)<cr>
|
2034
|
1743 nnoremap <buffer> <silent> gp :<c-u>call <SID>NetrwChgPerm(1,b:netrw_curdir)<cr>
|
1621
|
1744 nnoremap <buffer> <silent> c :exe "keepjumps lcd ".fnameescape(b:netrw_curdir)<cr>
|
1121
|
1745 nnoremap <buffer> <silent> C :let g:netrw_chgwin= winnr()<cr>
|
1621
|
1746 nnoremap <buffer> <silent> d :call <SID>NetrwMakeDir("")<cr>
|
|
1747 nnoremap <buffer> <silent> i :call <SID>NetrwListStyle(1)<cr>
|
2034
|
1748 nnoremap <buffer> <silent> I :call <SID>NetrwBannerCtrl(1)<cr>
|
1621
|
1749 nnoremap <buffer> <silent> o :call <SID>NetrwSplit(3)<cr>
|
|
1750 nnoremap <buffer> <silent> O :call <SID>NetrwObtain(1)<cr>
|
|
1751 nnoremap <buffer> <silent> p :call <SID>NetrwPreview(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord(),1))<cr>
|
|
1752 nnoremap <buffer> <silent> P :call <SID>NetrwPrevWinOpen(1)<cr>
|
2034
|
1753 nnoremap <buffer> <silent> qb :<c-u>call <SID>NetrwBookHistHandler(2,b:netrw_curdir)<cr>
|
|
1754 nnoremap <buffer> <silent> mB :<c-u>call <SID>NetrwBookHistHandler(6,b:netrw_curdir)<cr>
|
1621
|
1755 nnoremap <buffer> <silent> qf :<c-u>call <SID>NetrwFileInfo(1,<SID>NetrwGetWord())<cr>
|
|
1756 nnoremap <buffer> <silent> r :let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetrwRefresh(1,<SID>NetrwBrowseChgDir(1,'./'))<cr>
|
|
1757 nnoremap <buffer> <silent> s :call <SID>NetrwSortStyle(1)<cr>
|
1121
|
1758 nnoremap <buffer> <silent> S :call <SID>NetSortSequence(1)<cr>
|
1621
|
1759 nnoremap <buffer> <silent> t :call <SID>NetrwSplit(4)<cr>
|
2034
|
1760 nnoremap <buffer> <silent> T :call <SID>NetrwSplit(4)<bar>norm! gT<cr>
|
|
1761 nnoremap <buffer> <silent> u :<c-u>call <SID>NetrwBookHistHandler(4,expand("%"))<cr>
|
|
1762 nnoremap <buffer> <silent> U :<c-u>call <SID>NetrwBookHistHandler(5,expand("%"))<cr>
|
1621
|
1763 nnoremap <buffer> <silent> v :call <SID>NetrwSplit(5)<cr>
|
|
1764 nnoremap <buffer> <silent> x :call netrw#NetrwBrowseX(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord(),0),0)"<cr>
|
1668
|
1765 nnoremap <buffer> <silent> % :call <SID>NetrwOpenFile(1)<cr>
|
1621
|
1766 if !hasmapto('<Plug>NetrwHideEdit')
|
|
1767 nmap <buffer> <unique> <c-h> <Plug>NetrwHideEdit
|
|
1768 endif
|
|
1769 nnoremap <buffer> <silent> <Plug>NetrwHideEdit :call <SID>NetrwHideEdit(1)<cr>
|
|
1770 if !hasmapto('<Plug>NetrwRefresh')
|
|
1771 nmap <buffer> <unique> <c-l> <Plug>NetrwRefresh
|
|
1772 endif
|
|
1773 nnoremap <buffer> <silent> <Plug>NetrwRefresh :call <SID>NetrwRefresh(1,<SID>NetrwBrowseChgDir(1,'./'))<cr>
|
1121
|
1774 if s:didstarstar || !mapcheck("<s-down>","n")
|
|
1775 nnoremap <buffer> <silent> <s-down> :Nexplore<cr>
|
|
1776 endif
|
|
1777 if s:didstarstar || !mapcheck("<s-up>","n")
|
|
1778 nnoremap <buffer> <silent> <s-up> :Pexplore<cr>
|
|
1779 endif
|
1698
|
1780 let mapsafecurdir = escape(b:netrw_curdir, s:netrw_map_escape)
|
1621
|
1781 if g:netrw_mousemaps == 1
|
|
1782 nnoremap <buffer> <silent> <leftmouse> <leftmouse>:call <SID>NetrwLeftmouse(1)<cr>
|
|
1783 nnoremap <buffer> <silent> <middlemouse> <leftmouse>:call <SID>NetrwPrevWinOpen(1)<cr>
|
|
1784 nnoremap <buffer> <silent> <s-leftmouse> <leftmouse>:call <SID>NetrwMarkFile(1,<SID>NetrwGetWord())<cr>
|
1698
|
1785 exe 'nnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
|
|
1786 exe 'vnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
|
|
1787 endif
|
|
1788 exe 'nnoremap <buffer> <silent> <del> :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
|
|
1789 exe 'vnoremap <buffer> <silent> <del> :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
|
|
1790 exe 'nnoremap <buffer> <silent> D :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
|
|
1791 exe 'vnoremap <buffer> <silent> D :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>'
|
|
1792 exe 'nnoremap <buffer> <silent> R :call <SID>NetrwLocalRename("'.mapsafecurdir.'")<cr>'
|
|
1793 exe 'vnoremap <buffer> <silent> R :call <SID>NetrwLocalRename("'.mapsafecurdir.'")<cr>'
|
1621
|
1794 exe 'nnoremap <buffer> <silent> <Leader>m :call <SID>NetrwMakeDir("")<cr>'
|
|
1795 nnoremap <buffer> <F1> :he netrw-quickhelp<cr>
|
1121
|
1796
|
|
1797 else " remote
|
1698
|
1798 " call Decho("make remote maps")
|
1121
|
1799 call s:RemotePathAnalysis(b:netrw_curdir)
|
1621
|
1800 nnoremap <buffer> <silent> <cr> :call <SID>NetrwBrowse(0,<SID>NetrwBrowseChgDir(0,<SID>NetrwGetWord()))<cr>
|
|
1801 nnoremap <buffer> <silent> <c-l> :call <SID>NetrwRefresh(0,<SID>NetrwBrowseChgDir(0,'./'))<cr>
|
|
1802 nnoremap <buffer> <silent> - :exe "norm! 0"<bar>call <SID>NetrwBrowse(0,<SID>NetrwBrowseChgDir(0,'../'))<cr>
|
|
1803 nnoremap <buffer> <silent> a :call <SID>NetrwHide(0)<cr>
|
2034
|
1804 nnoremap <buffer> <silent> mb :<c-u>call <SID>NetrwBookHistHandler(0,b:netrw_curdir)<cr>
|
1621
|
1805 nnoremap <buffer> <silent> mc :<c-u>call <SID>NetrwMarkFileCopy(0)<cr>
|
|
1806 nnoremap <buffer> <silent> md :<c-u>call <SID>NetrwMarkFileDiff(0)<cr>
|
|
1807 nnoremap <buffer> <silent> me :<c-u>call <SID>NetrwMarkFileEdit(0)<cr>
|
|
1808 nnoremap <buffer> <silent> mf :<c-u>call <SID>NetrwMarkFile(0,<SID>NetrwGetWord())<cr>
|
|
1809 nnoremap <buffer> <silent> mg :<c-u>call <SID>NetrwMarkFileGrep(0)<cr>
|
|
1810 nnoremap <buffer> <silent> mh :<c-u>call <SID>NetrwMarkHideSfx(0)<cr>
|
|
1811 nnoremap <buffer> <silent> mm :<c-u>call <SID>NetrwMarkFileMove(0)<cr>
|
|
1812 nnoremap <buffer> <silent> mp :<c-u>call <SID>NetrwMarkFilePrint(0)<cr>
|
|
1813 nnoremap <buffer> <silent> mr :<c-u>call <SID>NetrwMarkFileRegexp(0)<cr>
|
|
1814 nnoremap <buffer> <silent> ms :<c-u>call <SID>NetrwMarkFileSource(0)<cr>
|
|
1815 nnoremap <buffer> <silent> mT :<c-u>call <SID>NetrwMarkFileTag(0)<cr>
|
|
1816 nnoremap <buffer> <silent> mt :<c-u>call <SID>NetrwMarkFileTgt(0)<cr>
|
|
1817 nnoremap <buffer> <silent> mu :<c-u>call <SID>NetrwUnMarkFile(0)<cr>
|
|
1818 nnoremap <buffer> <silent> mx :<c-u>call <SID>NetrwMarkFileExe(0)<cr>
|
|
1819 nnoremap <buffer> <silent> mz :<c-u>call <SID>NetrwMarkFileCompress(0)<cr>
|
2034
|
1820 nnoremap <buffer> <silent> gb :<c-u>call <SID>NetrwBookHistHandler(1,b:netrw_cur)<cr>
|
1621
|
1821 nnoremap <buffer> <silent> gh :<c-u>call <SID>NetrwHidden(0)<cr>
|
2034
|
1822 nnoremap <buffer> <silent> gp :<c-u>call <SID>NetrwChgPerm(0,b:netrw_curdir)<cr>
|
1121
|
1823 nnoremap <buffer> <silent> C :let g:netrw_chgwin= winnr()<cr>
|
1621
|
1824 nnoremap <buffer> <silent> i :call <SID>NetrwListStyle(0)<cr>
|
2034
|
1825 nnoremap <buffer> <silent> I :call <SID>NetrwBannerCtrl(1)<cr>
|
1621
|
1826 nnoremap <buffer> <silent> o :call <SID>NetrwSplit(0)<cr>
|
|
1827 nnoremap <buffer> <silent> O :call <SID>NetrwObtain(0)<cr>
|
|
1828 nnoremap <buffer> <silent> p :call <SID>NetrwPreview(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord(),1))<cr>
|
|
1829 nnoremap <buffer> <silent> P :call <SID>NetrwPrevWinOpen(0)<cr>
|
2034
|
1830 nnoremap <buffer> <silent> qb :<c-u>call <SID>NetrwBookHistHandler(2,b:netrw_curdir)<cr>
|
|
1831 nnoremap <buffer> <silent> mB :<c-u>call <SID>NetrwBookHistHandler(6,b:netrw_curdir)<cr>
|
1621
|
1832 nnoremap <buffer> <silent> qf :<c-u>call <SID>NetrwFileInfo(0,<SID>NetrwGetWord())<cr>
|
|
1833 nnoremap <buffer> <silent> r :let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'<bar>exe "norm! 0"<bar>call <SID>NetrwBrowse(0,<SID>NetrwBrowseChgDir(0,'./'))<cr>
|
|
1834 nnoremap <buffer> <silent> s :call <SID>NetrwSortStyle(0)<cr>
|
1121
|
1835 nnoremap <buffer> <silent> S :call <SID>NetSortSequence(0)<cr>
|
1621
|
1836 nnoremap <buffer> <silent> t :call <SID>NetrwSplit(1)<cr>
|
2034
|
1837 nnoremap <buffer> <silent> T :call <SID>NetrwSplit(1)<bar>norm! gT<cr>
|
|
1838 nnoremap <buffer> <silent> u :<c-u>call <SID>NetrwBookHistHandler(4,b:netrw_curdir)<cr>
|
|
1839 nnoremap <buffer> <silent> U :<c-u>call <SID>NetrwBookHistHandler(5,b:netrw_curdir)<cr>
|
1621
|
1840 nnoremap <buffer> <silent> v :call <SID>NetrwSplit(2)<cr>
|
|
1841 nnoremap <buffer> <silent> x :call netrw#NetrwBrowseX(<SID>NetrwBrowseChgDir(0,<SID>NetrwGetWord()),1)<cr>
|
1668
|
1842 nnoremap <buffer> <silent> % :call <SID>NetrwOpenFile(0)<cr>
|
1621
|
1843 if !hasmapto('<Plug>NetrwHideEdit')
|
|
1844 nmap <buffer> <c-h> <Plug>NetrwHideEdit
|
|
1845 endif
|
|
1846 nnoremap <buffer> <silent> <Plug>NetrwHideEdit :call <SID>NetrwHideEdit(0)<cr>
|
|
1847 if !hasmapto('<Plug>NetrwRefresh')
|
|
1848 nmap <buffer> <c-l> <Plug>NetrwRefresh
|
|
1849 endif
|
1698
|
1850
|
|
1851 let mapsafepath = escape(s:path, s:netrw_map_escape)
|
|
1852 let mapsafeusermach = escape(s:user.s:machine, s:netrw_map_escape)
|
|
1853
|
1621
|
1854 nnoremap <buffer> <silent> <Plug>NetrwRefresh :call <SID>NetrwRefresh(0,<SID>NetrwBrowseChgDir(0,'./'))<cr>
|
|
1855 if g:netrw_mousemaps == 1
|
|
1856 nnoremap <buffer> <silent> <leftmouse> <leftmouse>:call <SID>NetrwLeftmouse(0)<cr>
|
|
1857 nnoremap <buffer> <silent> <middlemouse> <leftmouse>:call <SID>NetrwPrevWinOpen(0)<cr>
|
|
1858 nnoremap <buffer> <silent> <s-leftmouse> <leftmouse>:call <SID>NetrwMarkFile(0,<SID>NetrwGetWord())<cr>
|
1698
|
1859 exe 'nnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
|
|
1860 exe 'vnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
|
|
1861 endif
|
|
1862 exe 'nnoremap <buffer> <silent> <del> :call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
|
|
1863 exe 'vnoremap <buffer> <silent> <del> :call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
|
|
1864 exe 'nnoremap <buffer> <silent> d :call <SID>NetrwMakeDir("'.mapsafeusermach.'")<cr>'
|
|
1865 exe 'nnoremap <buffer> <silent> D :call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
|
|
1866 exe 'vnoremap <buffer> <silent> D :call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
|
|
1867 exe 'nnoremap <buffer> <silent> R :call <SID>NetrwRemoteRename("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
|
|
1868 exe 'vnoremap <buffer> <silent> R :call <SID>NetrwRemoteRename("'.mapsafeusermach.'","'.mapsafepath.'")<cr>'
|
1668
|
1869 nnoremap <buffer> <F1> :he netrw-quickhelp<cr>
|
1121
|
1870 endif
|
1621
|
1871 call s:SetRexDir(a:islocal,b:netrw_curdir)
|
1121
|
1872 " call Dret("s:BrowserMaps")
|
|
1873 endfun
|
|
1874
|
|
1875 " ---------------------------------------------------------------------
|
1621
|
1876 " s:ExplorePatHls: converts an Explore pattern into a regular expression search pattern {{{2
|
|
1877 fun! s:ExplorePatHls(pattern)
|
|
1878 " call Dfunc("s:ExplorePatHls(pattern<".a:pattern.">)")
|
|
1879 let repat= substitute(a:pattern,'^**/\{1,2}','','')
|
|
1880 " call Decho("repat<".repat.">")
|
|
1881 let repat= escape(repat,'][.\')
|
|
1882 " call Decho("repat<".repat.">")
|
|
1883 let repat= '\<'.substitute(repat,'\*','\\(\\S\\+ \\)*\\S\\+','g').'\>'
|
|
1884 " call Dret("s:ExplorePatHls repat<".repat.">")
|
|
1885 return repat
|
1121
|
1886 endfun
|
|
1887
|
|
1888 " ---------------------------------------------------------------------
|
2034
|
1889 " s:NetrwBookHistHandler: {{{2
|
1621
|
1890 " 0: (user: <mb>) bookmark current directory
|
|
1891 " 1: (user: <gb>) change to the bookmarked directory
|
|
1892 " 2: (user: <qb>) list bookmarks
|
|
1893 " 3: (browsing) record current directory history
|
|
1894 " 4: (user: <u>) go up (previous) bookmark
|
|
1895 " 5: (user: <U>) go down (next) bookmark
|
|
1896 " 6: (user: <mB>) delete bookmark
|
2034
|
1897 fun! s:NetrwBookHistHandler(chg,curdir)
|
|
1898 " call Dfunc("NetrwBookHistHandler(chg=".a:chg." curdir<".a:curdir.">) cnt=".v:count." histcnt=".g:netrw_dirhist_cnt." histmax=".g:netrw_dirhistmax)
|
1121
|
1899
|
|
1900 if a:chg == 0
|
|
1901 " bookmark the current directory
|
|
1902 " call Decho("(user: <b>) bookmark the current directory")
|
2034
|
1903 if !exists("g:netrw_bookmarklist")
|
|
1904 let g:netrw_bookmarklist= []
|
|
1905 endif
|
|
1906 if index(g:netrw_bookmarklist,a:curdir) == -1
|
|
1907 " curdir not currently in g:netrw_bookmarklist, so include it
|
|
1908 call add(g:netrw_bookmarklist,a:curdir)
|
|
1909 call sort(g:netrw_bookmarklist)
|
1121
|
1910 endif
|
|
1911 echo "bookmarked the current directory"
|
|
1912
|
|
1913 elseif a:chg == 1
|
|
1914 " change to the bookmarked directory
|
2034
|
1915 " call Decho("(user: <".v:count."mb>) change to the bookmarked directory")
|
|
1916 if exists("g:netrw_bookmarklist[v:count-1]")
|
|
1917 exe "e ".fnameescape(g:netrw_bookmarklist[v:count-1])
|
1121
|
1918 else
|
|
1919 echomsg "Sorry, bookmark#".v:count." doesn't exist!"
|
|
1920 endif
|
|
1921
|
|
1922 elseif a:chg == 2
|
1621
|
1923 " redraw!
|
1121
|
1924 let didwork= 0
|
|
1925 " list user's bookmarks
|
|
1926 " call Decho("(user: <q>) list user's bookmarks")
|
2034
|
1927 if exists("g:netrw_bookmarklist")
|
|
1928 " call Decho('list '.len(g:netrw_bookmarklist).' bookmarks')
|
|
1929 let cnt= 1
|
|
1930 for bmd in g:netrw_bookmarklist
|
|
1931 " call Decho("Netrw Bookmark#".cnt.": ".g:netrw_bookmarklist[cnt-1])
|
|
1932 echo "Netrw Bookmark#".cnt.": ".g:netrw_bookmarklist[cnt-1]
|
|
1933 let didwork = 1
|
|
1934 let cnt = cnt + 1
|
|
1935 endfor
|
1121
|
1936 endif
|
|
1937
|
|
1938 " list directory history
|
2034
|
1939 let cnt = g:netrw_dirhist_cnt
|
1121
|
1940 let first = 1
|
|
1941 let histcnt = 0
|
2034
|
1942 while ( first || cnt != g:netrw_dirhist_cnt )
|
|
1943 " call Decho("first=".first." cnt=".cnt." dirhist_cnt=".g:netrw_dirhist_cnt)
|
1121
|
1944 let histcnt= histcnt + 1
|
2034
|
1945 if exists("g:netrw_dirhist_{cnt}")
|
|
1946 " call Decho("Netrw History#".histcnt.": ".g:netrw_dirhist_{cnt})
|
|
1947 echo "Netrw History#".histcnt.": ".g:netrw_dirhist_{cnt}
|
1121
|
1948 let didwork= 1
|
|
1949 endif
|
|
1950 let first = 0
|
|
1951 let cnt = ( cnt - 1 ) % g:netrw_dirhistmax
|
|
1952 if cnt < 0
|
|
1953 let cnt= cnt + g:netrw_dirhistmax
|
|
1954 endif
|
|
1955 endwhile
|
|
1956 if didwork
|
|
1957 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
1958 endif
|
|
1959
|
|
1960 elseif a:chg == 3
|
|
1961 " saves most recently visited directories (when they differ)
|
|
1962 " call Decho("(browsing) record curdir history")
|
2034
|
1963 if !exists("g:netrw_dirhist_cnt") || !exists("g:netrw_dirhist_{g:netrw_dirhist_cnt}") || g:netrw_dirhist_{g:netrw_dirhist_cnt} != a:curdir
|
|
1964 let g:netrw_dirhist_cnt = ( g:netrw_dirhist_cnt + 1 ) % g:netrw_dirhistmax
|
|
1965 let g:netrw_dirhist_{g:netrw_dirhist_cnt} = a:curdir
|
|
1966 " call Decho("save dirhist#".g:netrw_dirhist_cnt."<".g:netrw_dirhist_{g:netrw_dirhist_cnt}.">")
|
1121
|
1967 endif
|
|
1968
|
|
1969 elseif a:chg == 4
|
|
1970 " u: change to the previous directory stored on the history list
|
|
1971 " call Decho("(user: <u>) chg to prev dir from history")
|
2034
|
1972 let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt - 1 ) % g:netrw_dirhistmax
|
|
1973 if g:netrw_dirhist_cnt < 0
|
|
1974 let g:netrw_dirhist_cnt= g:netrw_dirhist_cnt + g:netrw_dirhistmax
|
|
1975 endif
|
|
1976 if exists("g:netrw_dirhist_{g:netrw_dirhist_cnt}")
|
|
1977 " call Decho("changedir u#".g:netrw_dirhist_cnt."<".g:netrw_dirhist_{g:netrw_dirhist_cnt}.">")
|
1121
|
1978 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir")
|
|
1979 setlocal ma noro
|
1621
|
1980 " call Decho("setlocal ma noro")
|
1121
|
1981 %d
|
|
1982 setlocal nomod
|
1621
|
1983 " call Decho("setlocal nomod")
|
1121
|
1984 endif
|
2034
|
1985 " " call Decho("exe e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt}))
|
|
1986 exe "e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt})
|
1121
|
1987 else
|
2034
|
1988 let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt + 1 ) % g:netrw_dirhistmax
|
1121
|
1989 echo "Sorry, no predecessor directory exists yet"
|
|
1990 endif
|
|
1991
|
|
1992 elseif a:chg == 5
|
|
1993 " U: change to the subsequent directory stored on the history list
|
|
1994 " call Decho("(user: <U>) chg to next dir from history")
|
2034
|
1995 let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt + 1 ) % g:netrw_dirhistmax
|
|
1996 if exists("g:netrw_dirhist_{g:netrw_dirhist_cnt}")
|
|
1997 " call Decho("changedir U#".g:netrw_dirhist_cnt."<".g:netrw_dirhist_{g:netrw_dirhist_cnt}.">")
|
1121
|
1998 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir")
|
|
1999 setlocal ma noro
|
1621
|
2000 " call Decho("setlocal ma noro")
|
1121
|
2001 %d
|
1621
|
2002 " call Decho("removed all lines from buffer (%d)")
|
1121
|
2003 setlocal nomod
|
1621
|
2004 " call Decho("setlocal nomod")
|
1121
|
2005 endif
|
2034
|
2006 " call Decho("exe e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt}))
|
|
2007 exe "e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhist_cnt})
|
1121
|
2008 else
|
2034
|
2009 let g:netrw_dirhist_cnt= ( g:netrw_dirhist_cnt - 1 ) % g:netrw_dirhistmax
|
|
2010 if g:netrw_dirhist_cnt < 0
|
|
2011 let g:netrw_dirhist_cnt= g:netrw_dirhist_cnt + g:netrw_dirhistmax
|
1121
|
2012 endif
|
|
2013 echo "Sorry, no successor directory exists yet"
|
|
2014 endif
|
1621
|
2015
|
|
2016 elseif a:chg == 6
|
2034
|
2017 " delete the v:count'th bookmark
|
|
2018 " call Decho("delete bookmark#".v:count."<".g:netrw_bookmarklist[v:count-1].">")
|
|
2019 let savefile= s:NetrwHome()."/.netrwbook"
|
|
2020 if filereadable(savefile)
|
|
2021 call s:NetrwBookHistSave() " done here to merge bookmarks first
|
|
2022 call delete(savefile)
|
|
2023 endif
|
|
2024 call remove(g:netrw_bookmarklist,v:count-1)
|
1621
|
2025 endif
|
|
2026 call s:NetrwBookmarkMenu()
|
2034
|
2027 " call Dret("NetrwBookHistHandler")
|
|
2028 endfun
|
|
2029
|
|
2030 " ---------------------------------------------------------------------
|
|
2031 " s:NetrwBookHistRead: this function reads bookmarks and history {{{2
|
|
2032 " Sister function: s:NetrwBookHistSave()
|
|
2033 fun! s:NetrwBookHistRead()
|
|
2034 " call Dfunc("s:NetrwBookHistRead()")
|
|
2035 if !exists("s:netrw_initbookhist")
|
|
2036 let home = s:NetrwHome()
|
|
2037 let savefile= home."/.netrwbook"
|
|
2038 if filereadable(savefile)
|
|
2039 " call Decho("sourcing .netrwbook")
|
|
2040 exe "so ".savefile
|
|
2041 endif
|
|
2042 let savefile= home."/.netrwhist"
|
|
2043 if filereadable(savefile)
|
|
2044 " call Decho("sourcing .netrwhist")
|
|
2045 exe "so ".savefile
|
|
2046 endif
|
|
2047 let s:netrw_initbookhist= 1
|
|
2048 au VimLeave * call s:NetrwBookHistSave()
|
|
2049 endif
|
|
2050 " call Dret("s:NetrwBookHistRead")
|
|
2051 endfun
|
|
2052
|
|
2053 " ---------------------------------------------------------------------
|
|
2054 " s:NetrwBookHistSave: this function saves bookmarks and history {{{2
|
|
2055 " Sister function: s:NetrwBookHistRead()
|
|
2056 " I used to do this via viminfo but that appears to
|
|
2057 " be unreliable for long-term storage
|
|
2058 " COMBAK: does $HOME work under windows???
|
|
2059 fun! s:NetrwBookHistSave()
|
|
2060 " call Dfunc("s:NetrwBookHistSave() dirhistmax=".g:netrw_dirhistmax)
|
|
2061 let savefile= s:NetrwHome()."/.netrwhist"
|
|
2062 1split
|
|
2063 call s:NetrwEnew()
|
|
2064 setlocal cino= com= cpo-=aA fo=nroql2 tw=0 report=10000 noswf
|
|
2065 setlocal nocin noai noci magic nospell nohid wig= noaw
|
|
2066 setlocal ma noro write
|
|
2067 if exists("&acd") | setlocal noacd | endif
|
|
2068 silent %d
|
|
2069
|
|
2070 " save .netrwhist -- no attempt to merge
|
|
2071 silent! file .netrwhist
|
|
2072 call setline(1,"let g:netrw_dirhistmax =".g:netrw_dirhistmax)
|
|
2073 call setline(2,"let g:netrw_dirhist_cnt =".g:netrw_dirhist_cnt)
|
|
2074 let lastline = line("$")
|
|
2075 let cnt = 1
|
|
2076 while cnt <= g:netrw_dirhist_cnt
|
|
2077 call setline((cnt+lastline),'let g:netrw_dirhist_'.cnt."='".g:netrw_dirhist_{cnt}."'")
|
|
2078 let cnt= cnt + 1
|
|
2079 endwhile
|
|
2080 exe "silent! w! ".savefile
|
|
2081
|
|
2082 silent %d
|
|
2083 if exists("g:netrw_bookmarklist") && g:netrw_bookmarklist != []
|
|
2084 " merge and write .netrwbook
|
|
2085 let savefile= s:NetrwHome()."/.netrwbook"
|
|
2086
|
|
2087 if filereadable(savefile)
|
|
2088 let booklist= deepcopy(g:netrw_bookmarklist)
|
|
2089 exe "silent so ".savefile
|
|
2090 for bdm in booklist
|
|
2091 if index(g:netrw_bookmarklist,bdm) == -1
|
|
2092 call add(g:netrw_bookmarklist,bdm)
|
|
2093 endif
|
|
2094 endfor
|
|
2095 call sort(g:netrw_bookmarklist)
|
|
2096 exe "silent! w! ".savefile
|
|
2097 endif
|
|
2098
|
|
2099 " construct and save .netrwbook
|
|
2100 call setline(1,"let g:netrw_bookmarklist= ".string(g:netrw_bookmarklist))
|
|
2101 exe "silent! w! ".savefile
|
|
2102 endif
|
|
2103 let bgone= bufnr("%")
|
|
2104 q!
|
|
2105 exe bgone."bwipe!"
|
|
2106
|
|
2107 " call Dret("s:NetrwBookHistSave")
|
1621
|
2108 endfun
|
|
2109
|
|
2110 " ---------------------------------------------------------------------
|
|
2111 " s:NetrwBrowse: This function uses the command in g:netrw_list_cmd to provide a {{{2
|
|
2112 " list of the contents of a local or remote directory. It is assumed that the
|
|
2113 " g:netrw_list_cmd has a string, USEPORT HOSTNAME, that needs to be substituted
|
|
2114 " with the requested remote hostname first.
|
|
2115 fun! s:NetrwBrowse(islocal,dirname)
|
|
2116 if !exists("w:netrw_liststyle")|let w:netrw_liststyle= g:netrw_liststyle|endif
|
|
2117 " call Dfunc("s:NetrwBrowse(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".w:netrw_liststyle." ".g:loaded_netrw." buf#".bufnr("%")."<".bufname("%").">")
|
|
2118 " call Decho("tab#".tabpagenr()." win#".winnr())
|
|
2119 " call Dredir("ls!")
|
2034
|
2120 if !exists("s:netrw_initbookhist")
|
|
2121 call s:NetrwBookHistRead()
|
|
2122 endif
|
|
2123 " call FOTEST(7)
|
|
2124
|
|
2125 " simplify the dirname (especially for ".."s in dirnames)
|
|
2126 if a:dirname !~ '^\a\+://'
|
|
2127 let dirname= simplify(a:dirname)
|
|
2128 else
|
|
2129 let dirname= a:dirname
|
|
2130 endif
|
|
2131 " call FOTEST(8)
|
1621
|
2132
|
|
2133 if exists("s:netrw_skipbrowse")
|
|
2134 unlet s:netrw_skipbrowse
|
1668
|
2135 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap)
|
1621
|
2136 " call Dret("s:NetrwBrowse : s:netrw_skipbrowse=".s:netrw_skipbrowse)
|
|
2137 return
|
|
2138 endif
|
|
2139 if !exists("*shellescape")
|
|
2140 call netrw#ErrorMsg(s:ERROR,"netrw can't run -- your vim is missing shellescape()",69)
|
|
2141 " call Dret("s:NetrwBrowse : missing shellescape()")
|
|
2142 return
|
|
2143 endif
|
|
2144 if !exists("*fnameescape")
|
|
2145 call netrw#ErrorMsg(s:ERROR,"netrw can't run -- your vim is missing fnameescape()",70)
|
|
2146 " call Dret("s:NetrwBrowse : missing fnameescape()")
|
|
2147 return
|
|
2148 endif
|
|
2149
|
|
2150 call s:NetrwOptionSave("w:")
|
2034
|
2151 " call FOTEST(9)
|
1621
|
2152
|
|
2153 " re-instate any marked files
|
|
2154 if exists("s:netrwmarkfilelist_{bufnr('%')}")
|
|
2155 " call Decho("clearing marked files")
|
|
2156 exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/"
|
|
2157 endif
|
2034
|
2158 " call FOTEST(10)
|
1621
|
2159
|
|
2160 if a:islocal && exists("w:netrw_acdkeep") && w:netrw_acdkeep
|
|
2161 " call Decho("handle w:netrw_acdkeep:")
|
2034
|
2162 " call Decho("keepjumps lcd ".fnameescape(dirname)." (due to w:netrw_acdkeep=".w:netrw_acdkeep." - acd=".&acd.")")
|
|
2163 exe 'keepjumps lcd '.fnameescape(dirname)
|
|
2164 call s:NetrwSafeOptions()
|
1621
|
2165 " call Decho("getcwd<".getcwd().">")
|
|
2166
|
2034
|
2167 elseif !a:islocal && dirname !~ '[\/]$' && dirname !~ '^"'
|
1621
|
2168 " looks like a regular file, attempt transfer
|
2034
|
2169 " call Decho("attempt transfer as regular file<".dirname.">")
|
1621
|
2170
|
|
2171 " remove any filetype indicator from end of dirname, except for the {{{3
|
|
2172 " "this is a directory" indicator (/).
|
|
2173 " There shouldn't be one of those here, anyway.
|
2034
|
2174 let path= substitute(dirname,'[*=@|]\r\=$','','e')
|
1621
|
2175 " call Decho("new path<".path.">")
|
2034
|
2176 call s:RemotePathAnalysis(dirname)
|
1621
|
2177
|
|
2178 " remote-read the requested file into current buffer {{{3
|
|
2179 mark '
|
2034
|
2180 call s:NetrwEnew(dirname)
|
|
2181 call s:NetrwSafeOptions()
|
1621
|
2182 setlocal ma noro
|
|
2183 " call Decho("setlocal ma noro")
|
2034
|
2184 let b:netrw_curdir= dirname
|
1668
|
2185 " call Decho("exe silent! keepalt file ".fnameescape(s:method."://".s:user.s:machine."/".s:path)." (bt=".&bt.")")
|
|
2186 exe "silent! keepalt file ".fnameescape(s:method."://".s:user.s:machine."/".s:path)
|
|
2187 exe "silent keepalt doau BufReadPre ".fnameescape(s:fname)
|
1621
|
2188 silent call netrw#NetRead(2,s:method."://".s:user.s:machine."/".s:path)
|
|
2189 if s:path !~ '.tar.bz2$' && s:path !~ '.tar.gz'
|
|
2190 " netrw.vim and tar.vim have already handled decompression of the tarball; avoiding gzip.vim error
|
1668
|
2191 exe "silent keepalt doau BufReadPost ".fnameescape(s:fname)
|
1621
|
2192 endif
|
|
2193
|
|
2194 " save certain window-oriented variables into buffer-oriented variables {{{3
|
|
2195 call s:SetBufWinVars()
|
|
2196 call s:NetrwOptionRestore("w:")
|
|
2197 setlocal ma nomod
|
|
2198
|
1668
|
2199 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap)
|
1621
|
2200 " call Dret("s:NetrwBrowse : file<".s:fname.">")
|
|
2201 return
|
|
2202 endif
|
2034
|
2203 " call FOTEST(11)
|
1621
|
2204
|
|
2205 " use buffer-oriented WinVars if buffer ones exist but window ones don't {{{3
|
|
2206 call s:UseBufWinVars()
|
|
2207
|
|
2208 " set up some variables {{{3
|
|
2209 let b:netrw_browser_active = 1
|
2034
|
2210 let dirname = dirname
|
1621
|
2211 let s:last_sort_by = g:netrw_sort_by
|
|
2212
|
|
2213 " set up menu {{{3
|
|
2214 call s:NetrwMenu(1)
|
2034
|
2215 " call FOTEST(12)
|
1621
|
2216
|
|
2217 " set up buffer {{{3
|
|
2218 let reusing= s:NetrwGetBuffer(a:islocal,dirname)
|
|
2219 " maintain markfile highlighting
|
|
2220 if exists("s:netrwmarkfilemtch_{bufnr('%')}") && s:netrwmarkfilemtch_{bufnr("%")} != ""
|
|
2221 " call Decho("bufnr(%)=".bufnr('%'))
|
|
2222 " call Decho("exe 2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/")
|
|
2223 exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/"
|
|
2224 else
|
|
2225 " call Decho("2match none")
|
|
2226 2match none
|
|
2227 endif
|
|
2228 if reusing
|
|
2229 call s:NetrwOptionRestore("w:")
|
|
2230 setlocal noma nomod nowrap
|
1668
|
2231 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap)
|
1621
|
2232 " call Dret("s:NetrwBrowse : re-using buffer")
|
|
2233 return
|
|
2234 endif
|
2034
|
2235 "" call FOTEST(13) " PROBLEM WITH LISTING
|
1621
|
2236
|
|
2237 " set b:netrw_curdir to the new directory name {{{3
|
|
2238 " call Decho("set b:netrw_curdir to the new directory name:")
|
|
2239 let b:netrw_curdir= dirname
|
|
2240 if b:netrw_curdir =~ '[/\\]$'
|
|
2241 let b:netrw_curdir= substitute(b:netrw_curdir,'[/\\]$','','e')
|
|
2242 endif
|
|
2243 if b:netrw_curdir == ''
|
|
2244 if has("amiga")
|
|
2245 " On the Amiga, the empty string connotes the current directory
|
|
2246 let b:netrw_curdir= getcwd()
|
|
2247 else
|
|
2248 " under unix, when the root directory is encountered, the result
|
|
2249 " from the preceding substitute is an empty string.
|
|
2250 let b:netrw_curdir= '/'
|
|
2251 endif
|
|
2252 endif
|
|
2253 if !a:islocal && b:netrw_curdir !~ '/$'
|
|
2254 let b:netrw_curdir= b:netrw_curdir.'/'
|
|
2255 endif
|
|
2256 " call Decho("b:netrw_curdir<".b:netrw_curdir.">")
|
2034
|
2257 "" call FOTEST(14) " PROBLEM WITH LISTING
|
1621
|
2258
|
|
2259 " ------------
|
|
2260 " (local only) {{{3
|
|
2261 " ------------
|
|
2262 if a:islocal
|
|
2263 " call Decho("local only:")
|
|
2264
|
|
2265 " Set up ShellCmdPost handling. Append current buffer to browselist
|
|
2266 call s:LocalFastBrowser()
|
|
2267
|
|
2268 " handle g:netrw_keepdir: set vim's current directory to netrw's notion of the current directory {{{3
|
|
2269 if !g:netrw_keepdir
|
|
2270 " call Decho("handle g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd)
|
|
2271 " call Decho("l:acd".(exists("&l:acd")? "=".&l:acd : " doesn't exist"))
|
|
2272 if !exists("&l:acd") || !&l:acd
|
|
2273 " call Decho('exe keepjumps lcd '.fnameescape(b:netrw_curdir))
|
|
2274 try
|
|
2275 exe 'keepjumps lcd '.fnameescape(b:netrw_curdir)
|
|
2276 catch /^Vim\%((\a\+)\)\=:E472/
|
|
2277 call netrw#ErrorMsg(s:ERROR,"unable to change directory to <".b:netrw_curdir."> (permissions?)",61)
|
|
2278 if exists("w:netrw_prvdir")
|
|
2279 let b:netrw_curdir= w:netrw_prvdir
|
|
2280 else
|
|
2281 call s:NetrwOptionRestore("w:")
|
|
2282 setlocal noma nomod nowrap
|
|
2283 let b:netrw_curdir= dirname
|
1668
|
2284 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap)
|
1621
|
2285 " call Dret("s:NetrwBrowse : reusing buffer#".(exists("bufnum")? bufnum : 'N/A')."<".dirname."> getcwd<".getcwd().">")
|
|
2286 return
|
|
2287 endif
|
|
2288 endtry
|
|
2289 endif
|
|
2290 endif
|
|
2291
|
|
2292 " --------------------------------
|
|
2293 " remote handling: {{{3
|
|
2294 " --------------------------------
|
|
2295 else
|
|
2296 " call Decho("remote only:")
|
|
2297
|
2034
|
2298 " analyze dirname and g:netrw_list_cmd {{{4
|
|
2299 " call Decho("b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "doesn't exist")."> dirname<".dirname.">")
|
|
2300 if dirname =~ "^NetrwTreeListing\>"
|
1621
|
2301 let dirname= b:netrw_curdir
|
2034
|
2302 " call Decho("(dirname was ".dirname.") dirname<".dirname.">")
|
1621
|
2303 elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir")
|
|
2304 let dirname= substitute(b:netrw_curdir,'\\','/','g')
|
|
2305 if dirname !~ '/$'
|
|
2306 let dirname= dirname.'/'
|
|
2307 endif
|
|
2308 let b:netrw_curdir = dirname
|
|
2309 " call Decho("(liststyle is TREELIST) dirname<".dirname.">")
|
|
2310 else
|
2034
|
2311 let dirname = substitute(dirname,'\\','/','g')
|
1621
|
2312 " call Decho("(normal) dirname<".dirname.">")
|
|
2313 endif
|
|
2314
|
|
2315 let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/]\+\)/\(.*\)$'
|
|
2316 if dirname !~ dirpat
|
|
2317 if !exists("g:netrw_quiet")
|
|
2318 call netrw#ErrorMsg(s:ERROR,"netrw doesn't understand your dirname<".dirname.">",20)
|
|
2319 endif
|
|
2320 call s:NetrwOptionRestore("w:")
|
|
2321 setlocal noma nomod nowrap
|
1668
|
2322 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap)
|
1621
|
2323 " call Dret("s:NetrwBrowse : badly formatted dirname<".dirname.">")
|
|
2324 return
|
|
2325 endif
|
|
2326 let b:netrw_curdir= dirname
|
|
2327 " call Decho("b:netrw_curdir<".b:netrw_curdir."> (remote)")
|
|
2328 endif " (additional remote handling)
|
2034
|
2329 "" call FOTEST(15) " PROBLEM WITH LISTING
|
1621
|
2330
|
|
2331 " -----------------------
|
|
2332 " Directory Listing: {{{3
|
|
2333 " -----------------------
|
|
2334 call s:BrowserMaps(a:islocal)
|
2034
|
2335 "" call FOTEST(16) " PROBLEM WITH LISTING
|
1621
|
2336 call s:PerformListing(a:islocal)
|
2034
|
2337 " call FOTEST(17)
|
|
2338
|
|
2339 " The s:LocalBrowseShellCmdRefresh() function is called by an autocmd
|
|
2340 " installed by s:LocalFastBrowser() when g:netrw_fastbrowse <= 1 (ie. slow, medium speed).
|
|
2341 " However, s:NetrwBrowse() causes the ShellCmdPost event itself to fire once; setting
|
|
2342 " the variable below avoids that second refresh of the screen. The s:LocalBrowseShellCmdRefresh()
|
|
2343 " function gets called due to that autocmd; it notices that the following variable is set
|
|
2344 " and skips the refresh and sets s:locbrowseshellcmd to zero. Oct 13, 2008
|
|
2345 let s:locbrowseshellcmd= 1
|
1621
|
2346
|
1668
|
2347 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap)
|
1621
|
2348 " call Dret("s:NetrwBrowse : did PerformListing")
|
|
2349 return
|
|
2350 endfun
|
|
2351
|
|
2352 " ---------------------------------------------------------------------
|
|
2353 " s:NetrwFileInfo: supports qf (query for file information) {{{2
|
|
2354 fun! s:NetrwFileInfo(islocal,fname)
|
|
2355 " call Dfunc("s:NetrwFileInfo(islocal=".a:islocal." fname<".a:fname.">)")
|
|
2356 if a:islocal
|
|
2357 if (has("unix") || has("macunix")) && executable("/bin/ls")
|
|
2358 if exists("b:netrw_curdir")
|
|
2359 " call Decho('using ls with b:netrw_curdir<'.b:netrw_curdir.'>')
|
|
2360 if b:netrw_curdir =~ '/$'
|
|
2361 echo system("/bin/ls -lsad ".shellescape(b:netrw_curdir.a:fname))
|
|
2362 else
|
|
2363 echo system("/bin/ls -lsad ".shellescape(b:netrw_curdir."/".a:fname))
|
|
2364 endif
|
|
2365 else
|
|
2366 " call Decho('using ls '.a:fname." using cwd<".getcwd().">")
|
|
2367 echo system("/bin/ls -lsad ".shellescape(a:fname))
|
|
2368 endif
|
|
2369 else
|
|
2370 " use vim functions to return information about file below cursor
|
|
2371 " call Decho("using vim functions to query for file info")
|
|
2372 if !isdirectory(a:fname) && !filereadable(a:fname) && a:fname =~ '[*@/]'
|
|
2373 let fname= substitute(a:fname,".$","","")
|
|
2374 else
|
|
2375 let fname= a:fname
|
|
2376 endif
|
|
2377 let t = getftime(fname)
|
|
2378 let sz = getfsize(fname)
|
|
2379 echo a:fname.": ".sz." ".strftime(g:netrw_timefmt,getftime(fname))
|
|
2380 " call Decho(fname.": ".sz." ".strftime(g:netrw_timefmt,getftime(fname)))
|
|
2381 endif
|
|
2382 else
|
|
2383 echo "sorry, \"qf\" not supported yet for remote files"
|
|
2384 endif
|
|
2385 " call Dret("s:NetrwFileInfo")
|
1121
|
2386 endfun
|
|
2387
|
|
2388 " ---------------------------------------------------------------------
|
1621
|
2389 " s:NetrwGetBuffer: {{{2
|
|
2390 " returns 0=cleared buffer
|
|
2391 " 1=re-used buffer
|
|
2392 fun! s:NetrwGetBuffer(islocal,dirname)
|
|
2393 " call Dfunc("s:NetrwGetBuffer(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".g:netrw_liststyle)
|
|
2394 let dirname= a:dirname
|
|
2395
|
|
2396 " re-use buffer if possible {{{3
|
|
2397 " call Decho("--re-use a buffer if possible--")
|
|
2398 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST
|
|
2399 " find NetrwTreeList buffer if there is one
|
2034
|
2400 " call Decho("find NetrwTreeList buffer if there is one")
|
1621
|
2401 if exists("w:netrw_treebufnr") && w:netrw_treebufnr > 0
|
|
2402 " call Decho(" re-use w:netrw_treebufnr=".w:netrw_treebufnr)
|
|
2403 let eikeep= &ei
|
|
2404 set ei=all
|
|
2405 exe "b ".w:netrw_treebufnr
|
|
2406 let &ei= eikeep
|
2034
|
2407 " call Dret("s:NetrwGetBuffer : bufnum#".w:netrw_treebufnr."<NetrwTreeListing>")
|
1621
|
2408 return
|
|
2409 endif
|
|
2410 let bufnum= -1
|
|
2411 " call Decho(" liststyle=TREE but w:netrw_treebufnr doesn't exist")
|
|
2412
|
|
2413 else
|
|
2414 " find buffer number of buffer named precisely the same as dirname {{{3
|
|
2415 " call Decho("--find buffer numnber of buffer named precisely the same as dirname--")
|
|
2416 " call Dredir("ls!")
|
|
2417
|
|
2418 " get dirname and associated buffer number
|
|
2419 let bufnum = bufnr(escape(dirname,'\'))
|
|
2420 " call Decho(" find buffer<".dirname.">'s number ")
|
|
2421 " call Decho(" bufnr(dirname<".escape(dirname,'\').">)=".bufnum)
|
|
2422
|
|
2423 if bufnum < 0 && dirname !~ '/$'
|
2034
|
2424 " try appending a trailing /
|
1621
|
2425 " call Decho(" try appending a trailing / to dirname<".dirname.">")
|
|
2426 let bufnum= bufnr(escape(dirname.'/','\'))
|
|
2427 if bufnum > 0
|
|
2428 let dirname= dirname.'/'
|
|
2429 endif
|
|
2430 endif
|
|
2431
|
|
2432 if bufnum < 0 && dirname =~ '/$'
|
2034
|
2433 " try removing a trailing /
|
1621
|
2434 " call Decho(" try removing a trailing / from dirname<".dirname.">")
|
|
2435 let bufnum= bufnr(escape(substitute(dirname,'/$','',''),'\'))
|
|
2436 if bufnum > 0
|
|
2437 let dirname= substitute(dirname,'/$','','')
|
|
2438 endif
|
|
2439 endif
|
|
2440
|
|
2441 " call Decho(" findbuf1: bufnum=bufnr('".dirname."')=".bufnum." bufname(".bufnum.")<".bufname(bufnum)."> (initial)")
|
|
2442 " note: !~ was used just below, but that means using ../ to go back would match (ie. abc/def/ and abc/ matches)
|
|
2443 if bufnum > 0 && bufname(bufnum) != dirname && bufname(bufnum) != '.'
|
|
2444 " handle approximate matches
|
2034
|
2445 " call Decho(" handling approx match: bufnum#".bufnum."<".bufname(bufnum)."> approx-dirname<".dirname.">")
|
1621
|
2446 let ibuf = 1
|
|
2447 let buflast = bufnr("$")
|
|
2448 " call Decho(" findbuf2: buflast=".buflast)
|
|
2449 while ibuf <= buflast
|
|
2450 let bname= substitute(bufname(ibuf),'\\','/','g')
|
1668
|
2451 let bname= substitute(bname,'.\zs/$','','')
|
2034
|
2452 " call Decho(" findbuf3: while [ibuf=",ibuf."]<=[buflast=".buflast."]: dirname<".dirname."> bufname(".ibuf.")<".bname.">")
|
|
2453 if bname != '' && dirname =~ '/'.bname.'/\=$' && dirname !~ '^/'
|
|
2454 " call Decho(" findbuf3: passes test 1 : dirname<".dirname.'> =~ /'.bname.'/\=$ && dirname !~ ^/')
|
|
2455 break
|
|
2456 endif
|
|
2457 if bname =~ '^'.dirname.'/\=$'
|
|
2458 " call Decho(' findbuf3: passes test 2 : bname<'.bname.'>=~^'.dirname.'/\=$')
|
|
2459 break
|
|
2460 endif
|
|
2461 if dirname =~ '^'.bname.'/$'
|
|
2462 " call Decho(' findbuf3: passes test 3 : dirname<'.dirname.'>=~^'.bname.'/$')
|
|
2463 break
|
|
2464 endif
|
1621
|
2465 let ibuf= ibuf + 1
|
|
2466 endwhile
|
|
2467 if ibuf > buflast
|
|
2468 let bufnum= -1
|
|
2469 else
|
|
2470 let bufnum= ibuf
|
|
2471 endif
|
|
2472 " call Decho(" findbuf4: bufnum=".bufnum." (ibuf=".ibuf." buflast=".buflast.")")
|
|
2473 endif
|
|
2474 endif
|
|
2475
|
|
2476 " get enew buffer and name it -or- re-use buffer {{{3
|
|
2477 " call Decho("--get enew buffer and name it OR re-use buffer-- (bufnum=".bufnum.")")
|
|
2478 mark '
|
|
2479 if bufnum < 0 || !bufexists(bufnum)
|
|
2480 call s:NetrwEnew(dirname)
|
|
2481 " call Decho(" got enew buffer#".bufnr("%")." (altbuf<".expand("#").">)")
|
|
2482 " name the buffer
|
|
2483 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST
|
|
2484 " Got enew buffer; transform into a NetrwTreeListing
|
|
2485 " call Decho("--transform enew buffer#".bufnr("%")." into a NetrwTreeListing --")
|
|
2486 if !exists("s:netrw_treelistnum")
|
|
2487 let s:netrw_treelistnum= 1
|
|
2488 else
|
|
2489 let s:netrw_treelistnum= s:netrw_treelistnum + 1
|
|
2490 endif
|
|
2491 let w:netrw_treebufnr= bufnr("%")
|
1668
|
2492 " call Decho(" exe silent! keepalt file NetrwTreeListing ".fnameescape(s:netrw_treelistnum))
|
|
2493 exe 'silent! keepalt file NetrwTreeListing\ '.fnameescape(s:netrw_treelistnum)
|
1621
|
2494 nnoremap <silent> <buffer> [ :silent call <SID>TreeListMove('[')<cr>
|
|
2495 nnoremap <silent> <buffer> ] :silent call <SID>TreeListMove(']')<cr>
|
|
2496 nnoremap <silent> <buffer> [[ :silent call <SID>TreeListMove('[')<cr>
|
|
2497 nnoremap <silent> <buffer> ]] :silent call <SID>TreeListMove(']')<cr>
|
|
2498 " call Decho(" tree listing#".s:netrw_treelistnum." bufnr=".w:netrw_treebufnr)
|
|
2499 else
|
|
2500 " let v:errmsg= "" " Decho
|
|
2501 let escdirname= fnameescape(dirname)
|
|
2502 " call Decho(" errmsg<".v:errmsg."> bufnr(".escdirname.")=".bufnr(escdirname)."<".bufname(bufnr(escdirname)).">")
|
1698
|
2503 " call Decho(' exe silent! keepalt file '.escdirname)
|
|
2504 exe 'silent! keepalt file '.escdirname
|
1621
|
2505 " call Decho(" errmsg<".v:errmsg."> bufnr(".escdirname.")=".bufnr(escdirname)."<".bufname(bufnr(escdirname)).">")
|
|
2506 endif
|
|
2507 " call Decho(" named enew buffer#".bufnr("%")."<".bufname("%").">")
|
|
2508
|
|
2509 else " Re-use the buffer
|
|
2510 " call Decho("--re-use buffer#".bufnum.": --")
|
|
2511 let eikeep= &ei
|
|
2512 set ei=all
|
|
2513 if getline(2) =~ '^" Netrw Directory Listing'
|
|
2514 " call Decho(" re-use buffer#".bufnum."<".((bufnum > 0)? bufname(bufnum) : "")."> using: keepalt b ".bufnum)
|
|
2515 exe "keepalt b ".bufnum
|
|
2516 else
|
|
2517 " call Decho(" reusing buffer#".bufnum."<".((bufnum > 0)? bufname(bufnum) : "")."> using: b ".bufnum)
|
|
2518 exe "b ".bufnum
|
|
2519 endif
|
|
2520 if bufname("%") == '.'
|
1668
|
2521 " call Decho("exe silent! keepalt file ".fnameescape(getcwd()))
|
|
2522 exe "silent! keepalt file ".fnameescape(getcwd())
|
1621
|
2523 endif
|
|
2524 let &ei= eikeep
|
|
2525 if line("$") <= 1
|
|
2526 call s:NetrwListSettings(a:islocal)
|
|
2527 " call Dret("s:NetrwGetBuffer 0 : re-using buffer#".bufnr("%").", but its empty, so refresh it")
|
|
2528 return 0
|
|
2529 elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST
|
|
2530 " call Decho("--re-use tree listing--")
|
|
2531 " call Decho(" clear buffer<".expand("%")."> with :%d")
|
|
2532 silent %d
|
|
2533 call s:NetrwListSettings(a:islocal)
|
|
2534 " call Dret("s:NetrwGetBuffer 0 : re-using buffer#".bufnr("%").", but treelist mode always needs a refresh")
|
|
2535 return 0
|
|
2536 else
|
|
2537 " call Dret("s:NetrwGetBuffer 1 : buf#".bufnr("%"))
|
|
2538 return 1
|
|
2539 endif
|
|
2540 endif
|
|
2541
|
|
2542 " do netrw settings: make this buffer not-a-file, modifiable, not line-numbered, etc {{{3
|
|
2543 " fastbrowse Local Remote Hiding a buffer implies it may be re-used (fast)
|
|
2544 " slow 0 D D Deleting a buffer implies it will not be re-used (slow)
|
|
2545 " med 1 D H
|
|
2546 " fast 2 H H
|
|
2547 " call Decho("--do netrw settings: make this buffer not-a-file, modifiable, not line-numbered, etc--")
|
|
2548 let fname= expand("%")
|
|
2549 call s:NetrwListSettings(a:islocal)
|
1668
|
2550 " call Decho("exe keepalt file ".fnameescape(fname))
|
|
2551 exe "keepalt file ".fnameescape(fname)
|
1621
|
2552
|
|
2553 " delete all lines from buffer {{{3
|
|
2554 " call Decho("--delete all lines from buffer--")
|
|
2555 " call Decho(" clear buffer<".expand("%")."> with :%d")
|
|
2556 keepalt silent! %d
|
|
2557
|
|
2558 " call Dret("s:NetrwGetBuffer 0 : buf#".bufnr("%"))
|
|
2559 return 0
|
|
2560 endfun
|
|
2561
|
|
2562 " ---------------------------------------------------------------------
|
|
2563 " s:NetrwGetcwd: get the current directory. {{{2
|
|
2564 " Change backslashes to forward slashes, if any.
|
|
2565 " If doesc is true, escape certain troublesome characters
|
|
2566 fun! s:NetrwGetcwd(doesc)
|
|
2567 " call Dfunc("NetrwGetcwd(doesc=".a:doesc.")")
|
|
2568 let curdir= substitute(getcwd(),'\\','/','ge')
|
|
2569 if curdir !~ '[\/]$'
|
|
2570 let curdir= curdir.'/'
|
|
2571 endif
|
|
2572 if a:doesc
|
|
2573 let curdir= fnameescape(curdir)
|
|
2574 endif
|
|
2575 " call Dret("NetrwGetcwd <".curdir.">")
|
|
2576 return curdir
|
|
2577 endfun
|
|
2578
|
|
2579 " ---------------------------------------------------------------------
|
|
2580 " s:NetrwGetWord: it gets the directory/file named under the cursor {{{2
|
|
2581 fun! s:NetrwGetWord()
|
|
2582 " call Dfunc("s:NetrwGetWord() line#".line(".")." liststyle=".g:netrw_liststyle." virtcol=".virtcol("."))
|
|
2583 call s:UseBufWinVars()
|
|
2584
|
|
2585 " insure that w:netrw_liststyle is set up
|
|
2586 if !exists("w:netrw_liststyle")
|
|
2587 if exists("g:netrw_liststyle")
|
|
2588 let w:netrw_liststyle= g:netrw_liststyle
|
|
2589 else
|
|
2590 let w:netrw_liststyle= s:THINLIST
|
|
2591 endif
|
|
2592 " call Decho("w:netrw_liststyle=".w:netrw_liststyle)
|
|
2593 endif
|
|
2594
|
|
2595 if exists("w:netrw_bannercnt") && line(".") < w:netrw_bannercnt
|
|
2596 " Active Banner support
|
|
2597 " call Decho("active banner handling")
|
|
2598 norm! 0
|
|
2599 let dirname= "./"
|
|
2600 let curline= getline('.')
|
|
2601
|
|
2602 if curline =~ '"\s*Sorted by\s'
|
|
2603 norm s
|
|
2604 let s:netrw_skipbrowse= 1
|
|
2605 echo 'Pressing "s" also works'
|
|
2606
|
|
2607 elseif curline =~ '"\s*Sort sequence:'
|
|
2608 let s:netrw_skipbrowse= 1
|
|
2609 echo 'Press "S" to edit sorting sequence'
|
|
2610
|
|
2611 elseif curline =~ '"\s*Quick Help:'
|
|
2612 norm ?
|
|
2613 let s:netrw_skipbrowse= 1
|
|
2614 echo 'Pressing "?" also works'
|
|
2615
|
|
2616 elseif curline =~ '"\s*\%(Hiding\|Showing\):'
|
|
2617 norm a
|
|
2618 let s:netrw_skipbrowse= 1
|
|
2619 echo 'Pressing "a" also works'
|
|
2620
|
|
2621 elseif line("$") > w:netrw_bannercnt
|
|
2622 exe 'silent keepjumps '.w:netrw_bannercnt
|
|
2623 endif
|
|
2624
|
|
2625 elseif w:netrw_liststyle == s:THINLIST
|
|
2626 " call Decho("thin column handling")
|
|
2627 norm! 0
|
|
2628 let dirname= getline('.')
|
|
2629
|
|
2630 elseif w:netrw_liststyle == s:LONGLIST
|
|
2631 " call Decho("long column handling")
|
|
2632 norm! 0
|
|
2633 let dirname= substitute(getline('.'),'^\(\%(\S\+ \)*\S\+\).\{-}$','\1','e')
|
|
2634
|
|
2635 elseif w:netrw_liststyle == s:TREELIST
|
|
2636 " call Decho("treelist handling")
|
|
2637 let dirname= substitute(getline('.'),'^\(| \)*','','e')
|
|
2638
|
|
2639 else
|
|
2640 " call Decho("obtain word from wide listing")
|
|
2641 let dirname= getline('.')
|
|
2642
|
|
2643 if !exists("b:netrw_cpf")
|
|
2644 let b:netrw_cpf= 0
|
|
2645 exe 'silent keepjumps '.w:netrw_bannercnt.',$g/^./if virtcol("$") > b:netrw_cpf|let b:netrw_cpf= virtcol("$")|endif'
|
2034
|
2646 call histdel("/",-1)
|
1621
|
2647 " call Decho("computed cpf=".b:netrw_cpf)
|
|
2648 endif
|
|
2649
|
|
2650 " call Decho("buf#".bufnr("%")."<".bufname("%").">")
|
|
2651 let filestart = (virtcol(".")/b:netrw_cpf)*b:netrw_cpf
|
|
2652 " call Decho("filestart= ([virtcol=".virtcol(".")."]/[b:netrw_cpf=".b:netrw_cpf."])*b:netrw_cpf=".filestart." bannercnt=".w:netrw_bannercnt)
|
|
2653 " call Decho("1: dirname<".dirname.">")
|
|
2654 if filestart == 0
|
|
2655 norm! 0ma
|
|
2656 else
|
|
2657 call cursor(line("."),filestart+1)
|
|
2658 norm! ma
|
|
2659 endif
|
|
2660 let rega= @a
|
1668
|
2661 let eofname= filestart + b:netrw_cpf + 1
|
|
2662 if eofname <= col("$")
|
|
2663 call cursor(line("."),filestart+b:netrw_cpf+1)
|
|
2664 norm! "ay`a
|
|
2665 else
|
|
2666 norm! "ay$
|
|
2667 endif
|
1621
|
2668 let dirname = @a
|
|
2669 let @a = rega
|
|
2670 " call Decho("2: dirname<".dirname.">")
|
|
2671 let dirname= substitute(dirname,'\s\+$','','e')
|
|
2672 " call Decho("3: dirname<".dirname.">")
|
|
2673 endif
|
|
2674
|
|
2675 " symlinks are indicated by a trailing "@". Remove it before further processing.
|
|
2676 let dirname= substitute(dirname,"@$","","")
|
|
2677
|
|
2678 " executables are indicated by a trailing "*". Remove it before further processing.
|
|
2679 let dirname= substitute(dirname,"\*$","","")
|
|
2680
|
|
2681 " call Dret("s:NetrwGetWord <".dirname.">")
|
|
2682 return dirname
|
|
2683 endfun
|
|
2684
|
|
2685 " ---------------------------------------------------------------------
|
|
2686 " s:NetrwListSettings: {{{2
|
|
2687 fun! s:NetrwListSettings(islocal)
|
|
2688 " call Dfunc("s:NetrwListSettings(islocal=".a:islocal.")")
|
|
2689 let fname= bufname("%")
|
1668
|
2690 " call Decho("setlocal bt=nofile nobl ma nonu nowrap noro")
|
1621
|
2691 setlocal bt=nofile nobl ma nonu nowrap noro
|
1668
|
2692 " call Decho("exe keepalt file ".fnameescape(fname))
|
|
2693 exe "keepalt file ".fnameescape(fname)
|
1621
|
2694 if g:netrw_use_noswf
|
|
2695 setlocal noswf
|
|
2696 endif
|
|
2697 " call Dredir("ls!")
|
|
2698 " call Decho("exe setlocal ts=".g:netrw_maxfilenamelen)
|
|
2699 exe "setlocal ts=".g:netrw_maxfilenamelen
|
|
2700 setlocal isk+=.,~,-
|
|
2701 if g:netrw_fastbrowse > a:islocal
|
|
2702 setlocal bh=hide
|
|
2703 else
|
|
2704 setlocal bh=delete
|
|
2705 endif
|
|
2706 " call Dret("s:NetrwListSettings")
|
|
2707 endfun
|
|
2708
|
|
2709 " ---------------------------------------------------------------------
|
|
2710 " s:NetrwListStyle: {{{2
|
|
2711 " islocal=0: remote browsing
|
|
2712 " =1: local browsing
|
|
2713 fun! s:NetrwListStyle(islocal)
|
|
2714 " call Dfunc("NetrwListStyle(islocal=".a:islocal.") w:netrw_liststyle=".w:netrw_liststyle)
|
|
2715 let fname = s:NetrwGetWord()
|
|
2716 if !exists("w:netrw_liststyle")|let w:netrw_liststyle= g:netrw_liststyle|endif
|
|
2717 let w:netrw_liststyle = (w:netrw_liststyle + 1) % s:MAXLIST
|
|
2718 " call Decho("fname<".fname.">")
|
|
2719 " call Decho("chgd w:netrw_liststyle to ".w:netrw_liststyle)
|
|
2720 " call Decho("b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "doesn't exist").">")
|
|
2721
|
|
2722 if w:netrw_liststyle == s:THINLIST
|
|
2723 " use one column listing
|
|
2724 " call Decho("use one column list")
|
|
2725 let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge')
|
|
2726
|
|
2727 elseif w:netrw_liststyle == s:LONGLIST
|
|
2728 " use long list
|
|
2729 " call Decho("use long list")
|
|
2730 let g:netrw_list_cmd = g:netrw_list_cmd." -l"
|
|
2731
|
|
2732 elseif w:netrw_liststyle == s:WIDELIST
|
|
2733 " give wide list
|
|
2734 " call Decho("use wide list")
|
|
2735 let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge')
|
|
2736
|
|
2737 elseif w:netrw_liststyle == s:TREELIST
|
|
2738 " call Decho("use tree list")
|
|
2739 let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge')
|
|
2740
|
|
2741 else
|
|
2742 call netrw#ErrorMsg(s:WARNING,"bad value for g:netrw_liststyle (=".w:netrw_liststyle.")",46)
|
|
2743 let g:netrw_liststyle = s:THINLIST
|
|
2744 let w:netrw_liststyle = g:netrw_liststyle
|
|
2745 let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge')
|
|
2746 endif
|
|
2747 setlocal ma noro
|
|
2748 " call Decho("setlocal ma noro")
|
|
2749
|
|
2750 " clear buffer - this will cause NetrwBrowse/LocalBrowseCheck to do a refresh
|
|
2751 " call Decho("clear buffer<".expand("%")."> with :%d")
|
|
2752 %d
|
|
2753
|
|
2754 " refresh the listing
|
|
2755 let svpos= netrw#NetrwSavePosn()
|
|
2756 call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
|
|
2757 call netrw#NetrwRestorePosn(svpos)
|
2034
|
2758 if w:netrw_liststyle != s:WIDELIST
|
|
2759 if g:netrw_cursorline == 2
|
|
2760 setlocal cursorline
|
|
2761 let &cursorcolumn= s:netrw_usercuc
|
|
2762 elseif g:netrw_cursorline
|
|
2763 setlocal cursorline
|
|
2764 " call Decho("setlocal cursorline")
|
|
2765 endif
|
|
2766 else
|
|
2767 if g:netrw_cursorline == 2
|
|
2768 setlocal cursorline cursorcolumn
|
|
2769 " call Decho("setlocal cursorline cursorcolumn")
|
|
2770 elseif g:netrw_cursorline
|
|
2771 let &cursorline= s:netrw_usercul
|
|
2772 endif
|
|
2773 endif
|
1621
|
2774
|
|
2775 " keep cursor on the filename
|
|
2776 silent keepjumps $
|
|
2777 let result= search('\%(^\%(|\+\s\)\=\|\s\{2,}\)\zs'.escape(fname,'.\[]*$^').'\%(\s\{2,}\|$\)','bc')
|
|
2778 " call Decho("search result=".result." w:netrw_bannercnt=".(exists("w:netrw_bannercnt")? w:netrw_bannercnt : 'N/A'))
|
|
2779 if result <= 0 && exists("w:netrw_bannercnt")
|
|
2780 exe "keepjumps ".w:netrw_bannercnt
|
|
2781 endif
|
|
2782
|
|
2783 " call Dret("NetrwListStyle".(exists("w:netrw_liststyle")? ' : w:netrw_liststyle='.w:netrw_liststyle : ""))
|
|
2784 endfun
|
|
2785
|
|
2786 " ---------------------------------------------------------------------
|
2034
|
2787 " s:NetrwBannerCtrl: toggles the display of the banner {{{2
|
|
2788 fun! s:NetrwBannerCtrl(islocal)
|
|
2789 " call Dfunc("s:NetrwBannerCtrl(islocal=".a:islocal.") g:netrw_banner=".g:netrw_banner)
|
|
2790
|
|
2791 " toggle the banner (enable/suppress)
|
|
2792 let g:netrw_banner= !g:netrw_banner
|
|
2793
|
|
2794 " refresh the listing
|
|
2795 let svpos= netrw#NetrwSavePosn()
|
|
2796 call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
|
|
2797
|
|
2798 " keep cursor on the filename
|
|
2799 let fname= s:NetrwGetWord()
|
|
2800 silent keepjumps $
|
|
2801 let result= search('\%(^\%(|\+\s\)\=\|\s\{2,}\)\zs'.escape(fname,'.\[]*$^').'\%(\s\{2,}\|$\)','bc')
|
|
2802 " call Decho("search result=".result." w:netrw_bannercnt=".(exists("w:netrw_bannercnt")? w:netrw_bannercnt : 'N/A'))
|
|
2803 if result <= 0 && exists("w:netrw_bannercnt")
|
|
2804 exe "keepjumps ".w:netrw_bannercnt
|
|
2805 endif
|
|
2806 " call Dret("s:NetrwBannerCtrl : g:netrw_banner=".g:netrw_banner)
|
|
2807 endfun
|
|
2808
|
|
2809 " ---------------------------------------------------------------------
|
1621
|
2810 " s:NetrwBookmarkMenu: Uses menu priorities {{{2
|
|
2811 " .2.[cnt] for bookmarks, and
|
|
2812 " .3.[cnt] for history
|
|
2813 " (see s:NetrwMenu())
|
|
2814 fun! s:NetrwBookmarkMenu()
|
1121
|
2815 if !exists("s:netrw_menucnt")
|
|
2816 return
|
|
2817 endif
|
2034
|
2818 " call Dfunc("NetrwBookmarkMenu() histcnt=".g:netrw_dirhist_cnt." menucnt=".s:netrw_menucnt)
|
1621
|
2819
|
|
2820 " the following test assures that gvim is running, has menus available, and has menus enabled.
|
|
2821 if has("gui") && has("menu") && has("gui_running") && &go =~ 'm' && g:netrw_menu
|
1121
|
2822 if exists("g:NetrwTopLvlMenu")
|
1621
|
2823 " call Decho("removing ".g:NetrwTopLvlMenu."Bookmarks menu item(s)")
|
|
2824 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Bookmarks'
|
2034
|
2825 exe 'silent! unmenu '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Bookmark\ Delete'
|
|
2826 endif
|
|
2827 if !exists("s:netrw_initbookhist")
|
|
2828 call s:NetrwBookHistRead()
|
1121
|
2829 endif
|
|
2830
|
|
2831 " show bookmarked places
|
2034
|
2832 if exists("g:netrw_bookmarklist") && g:netrw_bookmarklist != []
|
|
2833 let cnt= 1
|
|
2834 for bmd in g:netrw_bookmarklist
|
|
2835 " call Decho('silent! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmark.'.bmd.' :e '.bmd)
|
|
2836 let bmd= escape(bmd,'. ')
|
|
2837
|
|
2838 " show bookmarks for goto menu
|
|
2839 exe 'silent! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmarks.'.bmd.' :e '.bmd."\<cr>"
|
|
2840
|
|
2841 " show bookmarks for deletion menu
|
|
2842 exe 'silent! menu '.g:NetrwMenuPriority.".8.2.".cnt." ".g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Bookmark\ Delete.'.bmd.' '.cnt."mB"
|
|
2843 let cnt= cnt + 1
|
|
2844 endfor
|
|
2845
|
|
2846 endif
|
1121
|
2847
|
|
2848 " show directory browsing history
|
2034
|
2849 let cnt = g:netrw_dirhist_cnt
|
1121
|
2850 let first = 1
|
|
2851 let histcnt = 0
|
2034
|
2852 while ( first || cnt != g:netrw_dirhist_cnt )
|
1121
|
2853 let histcnt = histcnt + 1
|
2034
|
2854 let priority = g:netrw_dirhist_cnt + histcnt
|
|
2855 if exists("g:netrw_dirhist_{cnt}")
|
|
2856 let histdir= escape(g:netrw_dirhist_{cnt},'./&? ')
|
|
2857 " call Decho('silent! menu '.g:NetrwMenuPriority.".3.".priority." ".g:NetrwTopLvlMenu.'History.'.histdir.' :e '.histdir)
|
|
2858 exe 'silent! menu '.g:NetrwMenuPriority.".3.".priority." ".g:NetrwTopLvlMenu.'History.'.histdir.' :e '.histdir."\<cr>"
|
1121
|
2859 endif
|
|
2860 let first = 0
|
|
2861 let cnt = ( cnt - 1 ) % g:netrw_dirhistmax
|
|
2862 if cnt < 0
|
|
2863 let cnt= cnt + g:netrw_dirhistmax
|
|
2864 endif
|
|
2865 endwhile
|
2034
|
2866
|
1121
|
2867 endif
|
1621
|
2868 " call Dret("NetrwBookmarkMenu")
|
1121
|
2869 endfun
|
|
2870
|
|
2871 " ---------------------------------------------------------------------
|
1621
|
2872 " s:NetrwBrowseChgDir: constructs a new directory based on the current {{{2
|
|
2873 " directory and a new directory name. Also, if the
|
|
2874 " "new directory name" is actually a file,
|
|
2875 " NetrwBrowseChgDir() edits the file.
|
|
2876 fun! s:NetrwBrowseChgDir(islocal,newdir,...)
|
|
2877 " call Dfunc("s:NetrwBrowseChgDir(islocal=".a:islocal."> newdir<".a:newdir.">) a:0=".a:0." curpos<".string(getpos("."))."> b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "").">")
|
|
2878
|
|
2879 if !exists("b:netrw_curdir")
|
|
2880 " Don't try to change-directory: this can happen, for example, when netrw#ErrorMsg has been called
|
|
2881 " and the current window is the NetrwMessage window.
|
|
2882 " call Decho("(NetrwBrowseChgDir) b:netrw_curdir doesn't exist!")
|
|
2883 " call Decho("getcwd<".getcwd().">")
|
|
2884 " call Dredir("ls!")
|
|
2885 " call Dret("s:NetrwBrowseChgDir")
|
|
2886 return
|
|
2887 endif
|
|
2888
|
2034
|
2889 " check if the status bar was clicked on instead of a file/directory name
|
|
2890 call feedkeys("\<LeftMouse>")
|
|
2891 let c= getchar()
|
|
2892 let mouse_lnum = v:mouse_lnum
|
|
2893 let wlastline = line('w$')
|
|
2894 let lastline = line('$')
|
|
2895 " call Decho("v:mouse_lnum=".mouse_lnum." line(w$)=".wlastline." line($)=".lastline)
|
|
2896 if mouse_lnum == wlastline + 1
|
|
2897 " call Decho("appears to be a status bar leftmouse click")
|
|
2898 " appears to be a status bar leftmouse click
|
|
2899 return
|
|
2900 endif
|
|
2901
|
1621
|
2902 call s:NetrwOptionSave("s:")
|
|
2903 call s:NetrwSafeOptions()
|
|
2904 let nbcd_curpos = netrw#NetrwSavePosn()
|
|
2905 let s:nbcd_curpos_{bufnr('%')} = nbcd_curpos
|
|
2906 let dirname = substitute(b:netrw_curdir,'\\','/','ge')
|
|
2907 let newdir = a:newdir
|
|
2908 let dolockout = 0
|
|
2909
|
|
2910 " set up o/s-dependent directory recognition pattern
|
|
2911 if has("amiga")
|
|
2912 let dirpat= '[\/:]$'
|
1121
|
2913 else
|
1621
|
2914 let dirpat= '[\/]$'
|
|
2915 endif
|
|
2916 " call Decho("dirname<".dirname."> dirpat<".dirpat.">")
|
|
2917
|
|
2918 if dirname !~ dirpat
|
|
2919 " apparently vim is "recognizing" that it is in a directory and
|
|
2920 " is removing the trailing "/". Bad idea, so I put it back.
|
|
2921 let dirname= dirname.'/'
|
|
2922 " call Decho("adjusting dirname<".dirname.">")
|
|
2923 endif
|
|
2924
|
|
2925 if newdir !~ dirpat
|
|
2926 " ------------
|
|
2927 " edit a file:
|
|
2928 " ------------
|
|
2929 " call Decho('case "handling a file": newdir<'.newdir.'> !~ dirpat<'.dirpat.">")
|
|
2930 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") && newdir !~ '^\(/\|\a:\)'
|
|
2931 let dirname= s:NetrwTreeDir()
|
|
2932 if dirname =~ '/$'
|
|
2933 let dirname= dirname.newdir
|
|
2934 else
|
|
2935 let dirname= s:NetrwTreeDir()."/".newdir
|
|
2936 endif
|
2034
|
2937 " call Decho("dirname<".dirname.">")
|
1621
|
2938 " call Decho("tree listing")
|
|
2939 elseif newdir =~ '^\(/\|\a:\)'
|
|
2940 let dirname= newdir
|
1121
|
2941 else
|
1621
|
2942 let dirname= s:ComposePath(dirname,newdir)
|
|
2943 endif
|
|
2944 " call Decho("handling a file: dirname<".dirname."> (a:0=".a:0.")")
|
|
2945 " this lets NetrwBrowseX avoid the edit
|
|
2946 if a:0 < 1
|
|
2947 " call Decho("set up windows for editing<".fnameescape(dirname)."> didsplit=".(exists("s:didsplit")? s:didsplit : "doesn't exist"))
|
|
2948 call s:NetrwOptionRestore("s:")
|
|
2949 if !exists("s:didsplit")
|
|
2950 if g:netrw_browse_split == 1
|
|
2951 new
|
2034
|
2952 if !&ea
|
|
2953 wincmd _
|
|
2954 endif
|
1621
|
2955 elseif g:netrw_browse_split == 2
|
|
2956 rightb vert new
|
2034
|
2957 if !&ea
|
|
2958 wincmd |
|
|
2959 endif
|
1621
|
2960 elseif g:netrw_browse_split == 3
|
|
2961 tabnew
|
|
2962 elseif g:netrw_browse_split == 4
|
|
2963 if s:NetrwPrevWinOpen(2) == 3
|
|
2964 " call Dret("s:NetrwBrowseChgDir")
|
|
2965 return
|
|
2966 endif
|
|
2967 else
|
|
2968 " handling a file, didn't split, so remove menu
|
|
2969 " call Decho("handling a file+didn't split, so remove menu")
|
|
2970 call s:NetrwMenu(0)
|
|
2971 " optional change to window
|
|
2972 if g:netrw_chgwin >= 1
|
|
2973 exe "keepjumps ".g:netrw_chgwin."wincmd w"
|
|
2974 endif
|
|
2975 endif
|
|
2976 endif
|
|
2977 " the point where netrw actually edits the (local) file
|
|
2978 " if its local only: LocalBrowseCheck() doesn't edit a file, but NetrwBrowse() will
|
|
2979 if a:islocal
|
|
2980 " call Decho("edit local file: exe e! ".fnameescape(dirname))
|
|
2981 exe "e! ".fnameescape(dirname)
|
|
2982 else
|
|
2983 " call Decho("remote file: NetrwBrowse will edit it")
|
|
2984 endif
|
|
2985 let dolockout= 1
|
2034
|
2986
|
|
2987 " handle g:Netrw_funcref -- call external-to-netrw functions
|
|
2988 " This code will handle g:Netrw_funcref as an individual function reference
|
|
2989 " or as a list of function references. It will ignore anything that's not
|
|
2990 " a function reference. See :help Funcref for information about function references.
|
|
2991 if exists("g:Netrw_funcref")
|
|
2992 if type(g:Netrw_funcref) == 2
|
|
2993 call g:Netrw_funcref()
|
|
2994 elseif type(g:Netrw_funcref) == 3
|
|
2995 for Fncref in g:Netrw_funcref
|
|
2996 if type(FncRef) == 2
|
|
2997 call FncRef()
|
|
2998 endif
|
|
2999 endfor
|
|
3000 endif
|
|
3001 endif
|
1621
|
3002 endif
|
|
3003
|
|
3004 elseif newdir =~ '^/'
|
|
3005 " ---------------------------------
|
|
3006 " just go to the new directory spec
|
|
3007 " ---------------------------------
|
|
3008 " call Decho('case "just go to new directory spec": newdir<'.newdir.'>')
|
|
3009 let dirname= newdir
|
|
3010 call s:SetRexDir(a:islocal,dirname)
|
|
3011 call s:NetrwOptionRestore("s:")
|
|
3012
|
|
3013 elseif newdir == './'
|
|
3014 " --------------------------
|
|
3015 " refresh the directory list
|
|
3016 " --------------------------
|
|
3017 " call Decho('case "refresh directory listing": newdir == "./"')
|
|
3018 call s:SetRexDir(a:islocal,dirname)
|
|
3019
|
|
3020 elseif newdir == '../'
|
|
3021 " -------------------
|
|
3022 " go up one directory
|
|
3023 " -------------------
|
|
3024 " call Decho('case "go up one directory": newdir == "../"')
|
|
3025
|
|
3026 if w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict")
|
|
3027 " force a refresh
|
|
3028 " call Decho("clear buffer<".expand("%")."> with :%d")
|
|
3029 setlocal noro ma
|
|
3030 " call Decho("setlocal noro ma")
|
|
3031 keepjumps %d
|
|
3032 endif
|
|
3033
|
|
3034 if has("amiga")
|
|
3035 " amiga
|
|
3036 " call Decho('case "go up one directory": newdir == "../" and amiga')
|
|
3037 if a:islocal
|
|
3038 let dirname= substitute(dirname,'^\(.*[/:]\)\([^/]\+$\)','\1','')
|
|
3039 let dirname= substitute(dirname,'/$','','')
|
|
3040 else
|
|
3041 let dirname= substitute(dirname,'^\(.*[/:]\)\([^/]\+/$\)','\1','')
|
|
3042 endif
|
|
3043 " call Decho("amiga: dirname<".dirname."> (go up one dir)")
|
|
3044
|
|
3045 else
|
|
3046 " unix or cygwin
|
|
3047 " call Decho('case "go up one directory": newdir == "../" and unix or cygwin')
|
|
3048 if a:islocal
|
|
3049 let dirname= substitute(dirname,'^\(.*\)/\([^/]\+\)/$','\1','')
|
|
3050 if dirname == ""
|
|
3051 let dirname= '/'
|
|
3052 endif
|
|
3053 else
|
|
3054 let dirname= substitute(dirname,'^\(\a\+://.\{-}/\{1,2}\)\(.\{-}\)\([^/]\+\)/$','\1\2','')
|
|
3055 endif
|
|
3056 " call Decho("unix: dirname<".dirname."> (go up one dir)")
|
|
3057 endif
|
|
3058 call s:SetRexDir(a:islocal,dirname)
|
|
3059
|
|
3060 elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict")
|
|
3061 " call Decho('case liststyle is TREELIST and w:netrw_treedict exists')
|
|
3062 " force a refresh (for TREELIST, wait for NetrwTreeDir() to force the refresh)
|
|
3063 setlocal noro ma
|
|
3064 " call Decho("setlocal noro ma")
|
|
3065 if !(exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir"))
|
|
3066 " call Decho("clear buffer<".expand("%")."> with :%d")
|
|
3067 keepjumps %d
|
|
3068 endif
|
|
3069 let treedir = s:NetrwTreeDir()
|
|
3070 let s:treecurpos = nbcd_curpos
|
|
3071 let haskey= 0
|
|
3072 " call Decho("w:netrw_treedict<".string(w:netrw_treedict).">")
|
|
3073
|
|
3074 " search treedict for tree dir as-is
|
|
3075 if has_key(w:netrw_treedict,treedir)
|
|
3076 " call Decho('....searched for treedir<'.treedir.'> : found it!')
|
|
3077 let haskey= 1
|
|
3078 else
|
|
3079 " call Decho('....searched for treedir<'.treedir.'> : not found')
|
|
3080 endif
|
|
3081
|
|
3082 " search treedict for treedir with a / appended
|
|
3083 if !haskey && treedir !~ '/$'
|
|
3084 if has_key(w:netrw_treedict,treedir."/")
|
|
3085 let treedir= treedir."/"
|
|
3086 " call Decho('....searched.for treedir<'.treedir.'> found it!')
|
|
3087 let haskey = 1
|
|
3088 else
|
|
3089 " call Decho('....searched for treedir<'.treedir.'/> : not found')
|
|
3090 endif
|
|
3091 endif
|
|
3092
|
|
3093 " search treedict for treedir with any trailing / elided
|
|
3094 if !haskey && treedir =~ '/$'
|
|
3095 let treedir= substitute(treedir,'/$','','')
|
|
3096 if has_key(w:netrw_treedict,treedir)
|
|
3097 " call Decho('....searched.for treedir<'.treedir.'> found it!')
|
|
3098 let haskey = 1
|
|
3099 else
|
|
3100 " call Decho('....searched for treedir<'.treedir.'> : not found')
|
|
3101 endif
|
|
3102 endif
|
|
3103
|
|
3104 if haskey
|
|
3105 " close tree listing for selected subdirectory
|
|
3106 " call Decho("closing selected subdirectory<".dirname.">")
|
|
3107 call remove(w:netrw_treedict,treedir)
|
2034
|
3108 " call Decho("removed entry<".treedir."> from treedict")
|
1621
|
3109 " call Decho("yielding treedict<".string(w:netrw_treedict).">")
|
2034
|
3110 let dirname = w:netrw_treetop
|
1621
|
3111 else
|
|
3112 " go down one directory
|
|
3113 let dirname= substitute(treedir,'/*$','/','')
|
|
3114 " call Decho("go down one dir: treedir<".treedir.">")
|
|
3115 endif
|
|
3116 call s:SetRexDir(a:islocal,dirname)
|
2034
|
3117 let s:treeforceredraw = 1
|
1621
|
3118
|
|
3119 else
|
|
3120 " go down one directory
|
|
3121 let dirname= s:ComposePath(dirname,newdir)
|
|
3122 " call Decho("go down one dir: dirname<".dirname."> newdir<".newdir.">")
|
|
3123 call s:SetRexDir(a:islocal,dirname)
|
|
3124 endif
|
|
3125
|
|
3126 call s:NetrwOptionRestore("s:")
|
|
3127 if dolockout
|
|
3128 " call Decho("doing modification lockout settings: ma nomod noro")
|
|
3129 setlocal ma nomod noro
|
|
3130 " call Decho("setlocal ma nomod noro")
|
|
3131 endif
|
|
3132
|
|
3133 " call Dret("s:NetrwBrowseChgDir <".dirname."> : curpos<".string(getpos(".")).">")
|
|
3134 return dirname
|
1121
|
3135 endfun
|
|
3136
|
|
3137 " ---------------------------------------------------------------------
|
2034
|
3138 " s:NetrwBrowseX: (implements "x") executes a special "viewer" script or program for the {{{2
|
|
3139 " given filename; typically this means given their extension.
|
|
3140 " 0=local, 1=remote
|
1621
|
3141 fun! netrw#NetrwBrowseX(fname,remote)
|
|
3142 " call Dfunc("NetrwBrowseX(fname<".a:fname."> remote=".a:remote.")")
|
|
3143
|
2034
|
3144 " special core dump handler
|
|
3145 if a:fname =~ '/core\(\.\d\+\)\=$'
|
|
3146 if exists("g:Netrw_corehandler")
|
|
3147 if type(g:Netrw_corehandler) == 2
|
|
3148 " g:Netrw_corehandler is a function reference (see :help Funcref)
|
|
3149 " call Decho("g:Netrw_corehandler is a funcref")
|
|
3150 call g:Netrw_corehandler(a:fname)
|
|
3151 elseif type(g:netrw_corehandler) == 3)
|
|
3152 " g:Netrw_corehandler is a List of function references (see :help Funcref)
|
|
3153 " call Decho("g:Netrw_corehandler is a List")
|
|
3154 for Fncref in g:Netrw_corehandler
|
|
3155 if type(FncRef) == 2
|
|
3156 call FncRef(a:fname)
|
|
3157 endif
|
|
3158 endfor
|
|
3159 endif
|
|
3160 " call Dret("NetrwBrowseX : coredump handler invoked")
|
|
3161 return
|
|
3162 endif
|
|
3163 endif
|
|
3164
|
1621
|
3165 " set up the filename
|
|
3166 " (lower case the extension, make a local copy of a remote file)
|
|
3167 let exten= substitute(a:fname,'.*\.\(.\{-}\)','\1','e')
|
|
3168 if has("win32") || has("win95") || has("win64") || has("win16")
|
|
3169 let exten= substitute(exten,'^.*$','\L&\E','')
|
|
3170 endif
|
2034
|
3171 " call Decho("exten<".exten.">")
|
1621
|
3172
|
|
3173 " seems kde systems often have gnome-open due to dependencies, even though
|
|
3174 " gnome-open's subsidiary display tools are largely absent. Kde systems
|
|
3175 " usually have "kdeinit" running, though... (tnx Mikolaj Machowski)
|
|
3176 if !exists("s:haskdeinit")
|
|
3177 if has("unix")
|
1668
|
3178 let s:haskdeinit= system("ps -e") =~ 'kdeinit'
|
1621
|
3179 if v:shell_error
|
|
3180 let s:haskdeinit = 0
|
|
3181 endif
|
|
3182 else
|
|
3183 let s:haskdeinit= 0
|
|
3184 endif
|
|
3185 " call Decho("setting s:haskdeinit=".s:haskdeinit)
|
|
3186 endif
|
|
3187
|
|
3188 if a:remote == 1
|
|
3189 " create a local copy
|
2034
|
3190 " call Decho("a:remote=".a:remote.": create a local copy of <".a:fname.">")
|
1621
|
3191 setlocal bh=delete
|
2034
|
3192 call netrw#NetRead(3,a:fname)
|
|
3193 " attempt to rename tempfile
|
|
3194 let basename= substitute(a:fname,'^\(.*\)/\(.*\)\.\([^.]*\)$','\2','')
|
|
3195 let newname= substitute(s:netrw_tmpfile,'^\(.*\)/\(.*\)\.\([^.]*\)$','\1/'.basename.'.\3','')
|
|
3196 " call Decho("basename<".basename.">")
|
|
3197 " call Decho("newname <".newname.">")
|
|
3198 if rename(s:netrw_tmpfile,newname) == 0
|
|
3199 " renaming succeeded
|
|
3200 let fname= newname
|
|
3201 else
|
|
3202 " renaming failed
|
|
3203 let fname= s:netrw_tmpfile
|
|
3204 endif
|
1668
|
3205 else
|
|
3206 let fname= a:fname
|
1621
|
3207 endif
|
2034
|
3208 " call Decho("fname<".fname.">")
|
1621
|
3209 " call Decho("exten<".exten."> "."netrwFileHandlers#NFH_".exten."():exists=".exists("*netrwFileHandlers#NFH_".exten))
|
|
3210
|
|
3211 " set up redirection
|
|
3212 if &srr =~ "%s"
|
|
3213 if (has("win32") || has("win95") || has("win64") || has("win16"))
|
|
3214 let redir= substitute(&srr,"%s","nul","")
|
|
3215 else
|
|
3216 let redir= substitute(&srr,"%s","/dev/null","")
|
|
3217 endif
|
|
3218 elseif (has("win32") || has("win95") || has("win64") || has("win16"))
|
|
3219 let redir= &srr . "nul"
|
|
3220 else
|
|
3221 let redir= &srr . "/dev/null"
|
|
3222 endif
|
|
3223 " call Decho("redir{".redir."} srr{".&srr."}")
|
|
3224
|
|
3225 " extract any viewing options. Assumes that they're set apart by quotes.
|
|
3226 if exists("g:netrw_browsex_viewer")
|
2034
|
3227 " call Decho("g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">")
|
1621
|
3228 if g:netrw_browsex_viewer =~ '\s'
|
|
3229 let viewer = substitute(g:netrw_browsex_viewer,'\s.*$','','')
|
|
3230 let viewopt = substitute(g:netrw_browsex_viewer,'^\S\+\s*','','')." "
|
|
3231 let oviewer = ''
|
|
3232 let cnt = 1
|
|
3233 while !executable(viewer) && viewer != oviewer
|
|
3234 let viewer = substitute(g:netrw_browsex_viewer,'^\(\(^\S\+\s\+\)\{'.cnt.'}\S\+\)\(.*\)$','\1','')
|
|
3235 let viewopt = substitute(g:netrw_browsex_viewer,'^\(\(^\S\+\s\+\)\{'.cnt.'}\S\+\)\(.*\)$','\3','')." "
|
|
3236 let cnt = cnt + 1
|
|
3237 let oviewer = viewer
|
|
3238 " call Decho("!exe: viewer<".viewer."> viewopt<".viewopt.">")
|
|
3239 endwhile
|
1121
|
3240 else
|
1621
|
3241 let viewer = g:netrw_browsex_viewer
|
|
3242 let viewopt = ""
|
|
3243 endif
|
|
3244 " call Decho("viewer<".viewer."> viewopt<".viewopt.">")
|
|
3245 endif
|
|
3246
|
|
3247 " execute the file handler
|
|
3248 if exists("g:netrw_browsex_viewer") && g:netrw_browsex_viewer == '-'
|
|
3249 " call Decho("g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">")
|
|
3250 let ret= netrwFileHandlers#Invoke(exten,fname)
|
|
3251
|
|
3252 elseif exists("g:netrw_browsex_viewer") && executable(viewer)
|
|
3253 " call Decho("g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">")
|
1668
|
3254 " call Decho("exe silent !".viewer." ".viewopt.shellescape(fname,1).redir)
|
|
3255 exe "silent !".viewer." ".viewopt.shellescape(fname,1).redir
|
1621
|
3256 let ret= v:shell_error
|
|
3257
|
|
3258 elseif has("win32") || has("win64")
|
2034
|
3259 if executable("start")
|
|
3260 " call Decho('exe silent !start rundll32 url.dll,FileProtocolHandler '.shellescape(fname,1))
|
|
3261 exe 'silent !start rundll32 url.dll,FileProtocolHandler '.shellescape(fname,1)
|
|
3262 elseif executable("rundll32")
|
|
3263 " call Decho('exe silent !rundll32 url.dll,FileProtocolHandler '.shellescape(fname,1))
|
|
3264 exe 'silent !rundll32 url.dll,FileProtocolHandler '.shellescape(fname,1)
|
|
3265 else
|
|
3266 call netrw#ErrorMsg(s:WARNING,"rundll32 not on path",74)
|
|
3267 endif
|
1621
|
3268 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
3269 let ret= v:shell_error
|
|
3270
|
|
3271 elseif has("unix") && executable("gnome-open") && !s:haskdeinit
|
1668
|
3272 " call Decho("exe silent !gnome-open ".shellescape(fname,1)." ".redir)
|
|
3273 exe "silent !gnome-open ".shellescape(fname,1).redir
|
1621
|
3274 let ret= v:shell_error
|
|
3275
|
|
3276 elseif has("unix") && executable("kfmclient") && s:haskdeinit
|
1668
|
3277 " call Decho("exe silent !kfmclient exec ".shellescape(fname,1)." ".redir)
|
|
3278 exe "silent !kfmclient exec ".shellescape(fname,1)." ".redir
|
1621
|
3279 let ret= v:shell_error
|
|
3280
|
|
3281 elseif has("macunix") && executable("open")
|
1668
|
3282 " call Decho("exe silent !open ".shellescape(fname,1)." ".redir)
|
|
3283 exe "silent !open ".shellescape(fname,1)." ".redir
|
1621
|
3284 let ret= v:shell_error
|
|
3285
|
1121
|
3286 else
|
1621
|
3287 " netrwFileHandlers#Invoke() always returns 0
|
|
3288 let ret= netrwFileHandlers#Invoke(exten,fname)
|
|
3289 endif
|
|
3290
|
|
3291 " if unsuccessful, attempt netrwFileHandlers#Invoke()
|
|
3292 if ret
|
|
3293 let ret= netrwFileHandlers#Invoke(exten,fname)
|
|
3294 endif
|
|
3295
|
1668
|
3296 " restoring redraw! after external file handlers
|
|
3297 redraw!
|
1621
|
3298
|
|
3299 " cleanup: remove temporary file,
|
|
3300 " delete current buffer if success with handler,
|
|
3301 " return to prior buffer (directory listing)
|
|
3302 " Feb 12, 2008: had to de-activiate removal of
|
|
3303 " temporary file because it wasn't getting seen.
|
|
3304 " if a:remote == 1 && fname != a:fname
|
|
3305 " call Decho("deleting temporary file<".fname.">")
|
1668
|
3306 " call s:NetrwDelete(fname)
|
1621
|
3307 " endif
|
|
3308
|
|
3309 if a:remote == 1
|
|
3310 setlocal bh=delete bt=nofile
|
|
3311 if g:netrw_use_noswf
|
|
3312 setlocal noswf
|
|
3313 endif
|
|
3314 exe "norm! \<c-o>"
|
|
3315 " redraw!
|
|
3316 endif
|
|
3317
|
|
3318 " call Dret("NetrwBrowseX")
|
1121
|
3319 endfun
|
|
3320
|
|
3321 " ---------------------------------------------------------------------
|
2034
|
3322 " s:NetrwChgPerm: (implements "gp") change file permission {{{2
|
|
3323 fun! s:NetrwChgPerm(islocal,curdir)
|
|
3324 " call Dfunc("s:NetrwChgPerm(islocal=".a:islocal." curdir<".a:curdir.">)")
|
|
3325 call inputsave()
|
|
3326 let newperm= input("Enter new permission: ")
|
|
3327 call inputrestore()
|
|
3328 let chgperm= substitute(g:netrw_chgperm,'\<FILENAME\>',shellescape(expand("<cfile>")),'')
|
|
3329 let chgperm= substitute(chgperm,'\<PERM\>',shellescape(newperm),'')
|
|
3330 " call Decho("chgperm<".chgperm.">")
|
|
3331 call system(chgperm)
|
|
3332 if v:shell_error != 0
|
|
3333 call netrw#ErrorMsg(1,"changing permission on file<".expand("<cfile>")."> seems to have failed",75)
|
|
3334 endif
|
|
3335 if a:islocal
|
|
3336 call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
|
|
3337 endif
|
|
3338 " call Dret("s:NetrwChgPerm")
|
|
3339 endfun
|
|
3340
|
|
3341 " ---------------------------------------------------------------------
|
|
3342 " s:NetrwClearExplore: clear explore variables (if any) {{{2
|
|
3343 fun! s:NetrwClearExplore()
|
|
3344 " call Dfunc("s:NetrwClearExplore()")
|
|
3345 2match none
|
|
3346 if exists("s:explore_match") |unlet s:explore_match |endif
|
|
3347 if exists("s:explore_indx") |unlet s:explore_indx |endif
|
|
3348 if exists("s:netrw_explore_prvdir") |unlet s:netrw_explore_prvdir |endif
|
|
3349 if exists("s:dirstarstar") |unlet s:dirstarstar |endif
|
|
3350 if exists("s:explore_prvdir") |unlet s:explore_prvdir |endif
|
|
3351 if exists("w:netrw_explore_indx") |unlet w:netrw_explore_indx |endif
|
|
3352 if exists("w:netrw_explore_listlen")|unlet w:netrw_explore_listlen|endif
|
|
3353 if exists("w:netrw_explore_list") |unlet w:netrw_explore_list |endif
|
|
3354 if exists("w:netrw_explore_bufnr") |unlet w:netrw_explore_bufnr |endif
|
|
3355 " redraw!
|
|
3356 echo " "
|
|
3357 echo " "
|
|
3358 " call Dret("s:NetrwClearExplore")
|
|
3359 endfun
|
|
3360
|
|
3361 " ---------------------------------------------------------------------
|
1121
|
3362 " netrw#Explore: launch the local browser in the directory of the current file {{{2
|
2034
|
3363 " indx: == -1: Nexplore
|
|
3364 " == -2: Pexplore
|
|
3365 " == +: this is overloaded:
|
|
3366 " * If Nexplore/Pexplore is in use, then this refers to the
|
|
3367 " indx'th item in the w:netrw_explore_list[] of items which
|
|
3368 " matched the */pattern **/pattern *//pattern **//pattern
|
|
3369 " * If Hexplore or Vexplore, then this will override
|
|
3370 " g:netrw_winsize to specify the qty of rows or columns the
|
|
3371 " newly split window should have.
|
|
3372 " dosplit==0: the window will be split iff the current file has been modified
|
|
3373 " dosplit==1: the window will be split before running the local browser
|
|
3374 " style == 0: Explore style == 1: Explore!
|
|
3375 " == 2: Hexplore style == 3: Hexplore!
|
|
3376 " == 4: Vexplore style == 5: Vexplore!
|
|
3377 " == 6: Texplore
|
1121
|
3378 fun! netrw#Explore(indx,dosplit,style,...)
|
1209
|
3379 " call Dfunc("netrw#Explore(indx=".a:indx." dosplit=".a:dosplit." style=".a:style.",a:1<".a:1.">) &modified=".&modified." a:0=".a:0)
|
1121
|
3380 if !exists("b:netrw_curdir")
|
|
3381 let b:netrw_curdir= getcwd()
|
1209
|
3382 " call Decho("set b:netrw_curdir<".b:netrw_curdir."> (used getcwd)")
|
1121
|
3383 endif
|
2034
|
3384 let curdir = b:netrw_curdir
|
|
3385 let curfiledir = substitute(expand("%:p"),'^\(.*[/\\]\)[^/\\]*$','\1','e')
|
|
3386 " call Decho("curdir<".curdir."> curfiledir<".curfiledir.">")
|
|
3387 " call FOTEST(1)
|
1121
|
3388
|
|
3389 " save registers
|
|
3390 silent! let keepregstar = @*
|
|
3391 silent! let keepregplus = @+
|
|
3392 silent! let keepregslash= @/
|
|
3393
|
|
3394 " if dosplit or file has been modified
|
|
3395 if a:dosplit || &modified || a:style == 6
|
|
3396 " call Decho("case: dosplit=".a:dosplit." modified=".&modified." a:style=".a:style)
|
|
3397 call s:SaveWinVars()
|
2034
|
3398 let winsize= g:netrw_winsize
|
|
3399 if a:indx > 0
|
|
3400 let winsize= a:indx
|
|
3401 endif
|
1121
|
3402
|
|
3403 if a:style == 0 " Explore, Sexplore
|
|
3404 " call Decho("style=0: Explore or Sexplore")
|
2034
|
3405 exe winsize."wincmd s"
|
1121
|
3406
|
|
3407 elseif a:style == 1 "Explore!, Sexplore!
|
|
3408 " call Decho("style=1: Explore! or Sexplore!")
|
2034
|
3409 exe winsize."wincmd v"
|
1121
|
3410
|
|
3411 elseif a:style == 2 " Hexplore
|
|
3412 " call Decho("style=2: Hexplore")
|
2034
|
3413 exe "bel ".winsize."wincmd s"
|
1121
|
3414
|
|
3415 elseif a:style == 3 " Hexplore!
|
|
3416 " call Decho("style=3: Hexplore!")
|
2034
|
3417 exe "abo ".winsize."wincmd s"
|
1121
|
3418
|
|
3419 elseif a:style == 4 " Vexplore
|
|
3420 " call Decho("style=4: Vexplore")
|
2034
|
3421 exe "lefta ".winsize."wincmd v"
|
1121
|
3422
|
|
3423 elseif a:style == 5 " Vexplore!
|
|
3424 " call Decho("style=5: Vexplore!")
|
2034
|
3425 exe "rightb ".winsize."wincmd v"
|
1121
|
3426
|
|
3427 elseif a:style == 6 " Texplore
|
|
3428 call s:SaveBufVars()
|
|
3429 " call Decho("style = 6: Texplore")
|
|
3430 tabnew
|
|
3431 call s:RestoreBufVars()
|
|
3432 endif
|
|
3433 call s:RestoreWinVars()
|
|
3434 endif
|
|
3435 norm! 0
|
2034
|
3436 " call FOTEST(2)
|
1121
|
3437
|
1209
|
3438 if a:0 > 0
|
1621
|
3439 " call Decho("case [a:0=".a:0."]>0: a:1<".a:1.">")
|
1209
|
3440 if a:1 =~ '^\~' && (has("unix") || (exists("g:netrw_cygwin") && g:netrw_cygwin))
|
|
3441 let dirname= substitute(a:1,'\~',expand("$HOME"),'')
|
|
3442 " call Decho("using dirname<".dirname."> (case: ~ && unix||cygwin)")
|
|
3443 elseif a:1 == '.'
|
|
3444 let dirname= exists("b:netrw_curdir")? b:netrw_curdir : getcwd()
|
|
3445 if dirname !~ '/$'
|
|
3446 let dirname= dirname."/"
|
|
3447 endif
|
|
3448 " call Decho("using dirname<".dirname."> (case: ".(exists("b:netrw_curdir")? "b:netrw_curdir" : "getcwd()").")")
|
|
3449 elseif a:1 =~ '\$'
|
|
3450 let dirname= expand(a:1)
|
2034
|
3451 " call Decho("using user-specified dirname<".dirname."> with $env-var")
|
1209
|
3452 else
|
|
3453 let dirname= a:1
|
2034
|
3454 " call Decho("using user-specified dirname<".dirname.">")
|
1121
|
3455 endif
|
1621
|
3456 else
|
|
3457 " clear explore
|
2034
|
3458 call s:NetrwClearExplore()
|
1621
|
3459 " call Dret("netrw#Explore : cleared list")
|
|
3460 return
|
|
3461 endif
|
2034
|
3462 " call FOTEST(3)
|
1621
|
3463
|
|
3464 if dirname =~ '/\*\*/'
|
|
3465 " handle .../**/.../filepat
|
|
3466 " call Decho("case Explore .../**/.../filepat")
|
|
3467 let prefixdir= substitute(dirname,'^\(.\{-}\)\*\*.*$','\1','')
|
|
3468 if prefixdir =~ '^/' || (prefixdir =~ '^\a:/' && (has("win32") || has("win95") || has("win64") || has("win16")))
|
|
3469 let b:netrw_curdir = prefixdir
|
|
3470 else
|
|
3471 let b:netrw_curdir= getcwd().'/'.prefixdir
|
|
3472 endif
|
|
3473 let dirname= substitute(dirname,'^.\{-}\(\*\*/.*\)$','\1','')
|
|
3474 let starpat= 4;
|
|
3475 " call Decho("pwd<".getcwd()."> dirname<".dirname.">")
|
|
3476 " call Decho("case Explore ../**/../filepat (starpat=".starpat.")")
|
|
3477
|
|
3478 elseif dirname =~ '^\*//'
|
|
3479 " starpat=1: Explore *//pattern (current directory only search for files containing pattern)
|
|
3480 " call Decho("case Explore *//pattern")
|
|
3481 let pattern= substitute(dirname,'^\*//\(.*\)$','\1','')
|
|
3482 let starpat= 1
|
|
3483 " call Decho("Explore *//pat: (starpat=".starpat.") dirname<".dirname."> -> pattern<".pattern.">")
|
1121
|
3484 if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif
|
1621
|
3485
|
1121
|
3486 elseif dirname =~ '^\*\*//'
|
1621
|
3487 " starpat=2: Explore **//pattern (recursive descent search for files containing pattern)
|
1121
|
3488 " call Decho("case Explore **//pattern")
|
1621
|
3489 let pattern= substitute(dirname,'^\*\*//','','')
|
|
3490 let starpat= 2
|
|
3491 " call Decho("Explore **//pat: (starpat=".starpat.") dirname<".dirname."> -> pattern<".pattern.">")
|
|
3492
|
|
3493 elseif dirname =~ '^\*/'
|
|
3494 " starpat=3: Explore */filepat (search in current directory for filenames matching filepat)
|
|
3495 let starpat= 3
|
|
3496 " call Decho("case Explore */filepat (starpat=".starpat.")")
|
|
3497
|
|
3498 elseif dirname=~ '^\*\*/'
|
|
3499 " starpat=4: Explore **/filepat (recursive descent search for filenames matching filepat)
|
|
3500 let starpat= 4
|
|
3501 " call Decho("case Explore **/filepat (starpat=".starpat.")")
|
2034
|
3502
|
1621
|
3503 else
|
|
3504 let starpat= 0
|
2034
|
3505 " call Decho("default case: starpat=".starpat)
|
|
3506 endif
|
|
3507 " call FOTEST(4)
|
1621
|
3508
|
|
3509 if starpat == 0 && a:indx >= 0
|
|
3510 " [Explore Hexplore Vexplore Sexplore] [dirname]
|
2034
|
3511 " call Decho("case starpat==0 && a:indx=".a:indx.": dirname<".dirname."> Explore Hexplore Vexplore Sexplore")
|
1621
|
3512 if dirname == ""
|
2034
|
3513 let dirname= curfiledir
|
|
3514 " call Decho("empty dirname, using current file's directory<".dirname.">")
|
1621
|
3515 endif
|
|
3516 if dirname =~ '^scp:' || dirname =~ '^ftp:'
|
|
3517 " call Decho("calling NetrwBrowse(0,dirname<".dirname.">)")
|
|
3518 call s:NetrwBrowse(0,dirname)
|
1121
|
3519 else
|
1621
|
3520 if dirname == ""|let dirname= getcwd()|endif
|
|
3521 " call Decho("calling LocalBrowseCheck(dirname<".dirname.">)")
|
|
3522 call netrw#LocalBrowseCheck(dirname)
|
|
3523 endif
|
|
3524
|
2034
|
3525 " call Decho("curdir<".curdir.">")
|
1621
|
3526 if has("win32") || has("win95") || has("win64") || has("win16")
|
2034
|
3527 call search('\<'.substitute(curdir,'^.*[/\\]','','e').'\>','cW')
|
1621
|
3528 else
|
2034
|
3529 call search('\<'.substitute(curdir,'^.*/','','e').'\>','cW')
|
1621
|
3530 endif
|
|
3531
|
|
3532 " starpat=1: Explore *//pattern (current directory only search for files containing pattern)
|
|
3533 " starpat=2: Explore **//pattern (recursive descent search for files containing pattern)
|
|
3534 " starpat=3: Explore */filepat (search in current directory for filenames matching filepat)
|
|
3535 " starpat=4: Explore **/filepat (recursive descent search for filenames matching filepat)
|
|
3536 elseif a:indx <= 0
|
|
3537 " Nexplore, Pexplore, Explore: handle starpat
|
2034
|
3538 " call Decho("case a:indx<=0: Nexplore, Pexplore, <s-down>, <s-up> starpat=".starpat." a:indx=".a:indx)
|
1121
|
3539 if !mapcheck("<s-up>","n") && !mapcheck("<s-down>","n") && exists("b:netrw_curdir")
|
|
3540 " call Decho("set up <s-up> and <s-down> maps")
|
|
3541 let s:didstarstar= 1
|
|
3542 nnoremap <buffer> <silent> <s-up> :Pexplore<cr>
|
|
3543 nnoremap <buffer> <silent> <s-down> :Nexplore<cr>
|
|
3544 endif
|
|
3545
|
|
3546 if has("path_extra")
|
1621
|
3547 " call Decho("starpat=".starpat.": has +path_extra")
|
1121
|
3548 if !exists("w:netrw_explore_indx")
|
|
3549 let w:netrw_explore_indx= 0
|
|
3550 endif
|
2034
|
3551
|
1121
|
3552 let indx = a:indx
|
1621
|
3553 " call Decho("starpat=".starpat.": set indx= [a:indx=".indx."]")
|
2034
|
3554
|
1121
|
3555 if indx == -1
|
1621
|
3556 " Nexplore
|
|
3557 " call Decho("case Nexplore with starpat=".starpat.": (indx=".indx.")")
|
1121
|
3558 if !exists("w:netrw_explore_list") " sanity check
|
|
3559 call netrw#ErrorMsg(s:WARNING,"using Nexplore or <s-down> improperly; see help for netrw-starstar",40)
|
|
3560 silent! let @* = keepregstar
|
|
3561 silent! let @+ = keepregstar
|
|
3562 silent! let @/ = keepregslash
|
|
3563 " call Dret("netrw#Explore")
|
|
3564 return
|
|
3565 endif
|
|
3566 let indx= w:netrw_explore_indx
|
|
3567 if indx < 0 | let indx= 0 | endif
|
|
3568 if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif
|
|
3569 let curfile= w:netrw_explore_list[indx]
|
|
3570 " call Decho("indx=".indx." curfile<".curfile.">")
|
|
3571 while indx < w:netrw_explore_listlen && curfile == w:netrw_explore_list[indx]
|
|
3572 let indx= indx + 1
|
|
3573 " call Decho("indx=".indx." (Nexplore while loop)")
|
|
3574 endwhile
|
|
3575 if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif
|
|
3576 " call Decho("Nexplore: indx= [w:netrw_explore_indx=".w:netrw_explore_indx."]=".indx)
|
|
3577
|
|
3578 elseif indx == -2
|
1621
|
3579 " Pexplore
|
|
3580 " call Decho("case Pexplore with starpat=".starpat.": (indx=".indx.")")
|
1121
|
3581 if !exists("w:netrw_explore_list") " sanity check
|
|
3582 call netrw#ErrorMsg(s:WARNING,"using Pexplore or <s-up> improperly; see help for netrw-starstar",41)
|
|
3583 silent! let @* = keepregstar
|
|
3584 silent! let @+ = keepregstar
|
|
3585 silent! let @/ = keepregslash
|
|
3586 " call Dret("netrw#Explore")
|
|
3587 return
|
|
3588 endif
|
|
3589 let indx= w:netrw_explore_indx
|
|
3590 if indx < 0 | let indx= 0 | endif
|
|
3591 if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif
|
|
3592 let curfile= w:netrw_explore_list[indx]
|
|
3593 " call Decho("indx=".indx." curfile<".curfile.">")
|
|
3594 while indx >= 0 && curfile == w:netrw_explore_list[indx]
|
|
3595 let indx= indx - 1
|
|
3596 " call Decho("indx=".indx." (Pexplore while loop)")
|
|
3597 endwhile
|
|
3598 if indx < 0 | let indx= 0 | endif
|
|
3599 " call Decho("Pexplore: indx= [w:netrw_explore_indx=".w:netrw_explore_indx."]=".indx)
|
|
3600
|
|
3601 else
|
|
3602 " Explore -- initialize
|
|
3603 " build list of files to Explore with Nexplore/Pexplore
|
1621
|
3604 " call Decho("starpat=".starpat.": case Explore: initialize (indx=".indx.")")
|
2034
|
3605 call s:NetrwClearExplore()
|
1121
|
3606 let w:netrw_explore_indx= 0
|
|
3607 if !exists("b:netrw_curdir")
|
|
3608 let b:netrw_curdir= getcwd()
|
|
3609 endif
|
1621
|
3610 " call Decho("starpat=".starpat.": b:netrw_curdir<".b:netrw_curdir.">")
|
|
3611
|
|
3612 " switch on starpat to build the w:netrw_explore_list of files
|
|
3613 if starpat == 1
|
|
3614 " starpat=1: Explore *//pattern (current directory only search for files containing pattern)
|
|
3615 " call Decho("starpat=".starpat.": build *//pattern list")
|
2034
|
3616 " call Decho("pattern<".pattern.">")
|
|
3617 try
|
|
3618 exe "noautocmd vimgrep /".pattern."/gj ".fnameescape(b:netrw_curdir)."/*"
|
|
3619 catch /^Vim\%((\a\+)\)\=:E480/
|
|
3620 call netrw#ErrorMsg(s:WARNING,"no match with pattern<".pattern.">",76)
|
|
3621 " call Dret("netrw#Explore : unable to find pattern<".pattern.">")
|
|
3622 return
|
|
3623 endtry
|
|
3624 let w:netrw_explore_list = s:NetrwExploreListUniq(map(getqflist(),'bufname(v:val.bufnr)'))
|
1621
|
3625 if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif
|
|
3626
|
|
3627 elseif starpat == 2
|
|
3628 " starpat=2: Explore **//pattern (recursive descent search for files containing pattern)
|
|
3629 " call Decho("starpat=".starpat.": build **//pattern list")
|
|
3630 try
|
2034
|
3631 exe "silent noautocmd vimgrep /".pattern."/gj "."**/*"
|
1621
|
3632 catch /^Vim\%((\a\+)\)\=:E480/
|
2034
|
3633 call netrw#ErrorMsg(s:WARNING,'no files matched pattern<'.pattern.'>',45)
|
1121
|
3634 if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif
|
1621
|
3635 silent! let @* = keepregstar
|
|
3636 silent! let @+ = keepregstar
|
|
3637 silent! let @/ = keepregslash
|
|
3638 " call Dret("netrw#Explore : no files matched pattern")
|
|
3639 return
|
|
3640 endtry
|
|
3641 let s:netrw_curdir = b:netrw_curdir
|
|
3642 let w:netrw_explore_list = getqflist()
|
2034
|
3643 let w:netrw_explore_list = s:NetrwExploreListUniq(map(w:netrw_explore_list,'s:netrw_curdir."/".bufname(v:val.bufnr)'))
|
1621
|
3644
|
|
3645 elseif starpat == 3
|
|
3646 " starpat=3: Explore */filepat (search in current directory for filenames matching filepat)
|
|
3647 " call Decho("starpat=".starpat.": build */filepat list")
|
2034
|
3648 let filepat= substitute(dirname,'^\*/','','')
|
|
3649 let filepat= substitute(filepat,'^[%#<]','\\&','')
|
|
3650 " call Decho("b:netrw_curdir<".b:netrw_curdir.">")
|
|
3651 " call Decho("filepat<".filepat.">")
|
|
3652 let w:netrw_explore_list= s:NetrwExploreListUniq(split(expand(b:netrw_curdir."/".filepat),'\n'))
|
|
3653 if &hls | let keepregslash= s:ExplorePatHls(filepat) | endif
|
1621
|
3654
|
|
3655 elseif starpat == 4
|
|
3656 " starpat=4: Explore **/filepat (recursive descent search for filenames matching filepat)
|
|
3657 " call Decho("starpat=".starpat.": build **/filepat list")
|
2034
|
3658 let w:netrw_explore_list= s:NetrwExploreListUniq(split(expand(b:netrw_curdir."/".dirname),'\n'))
|
1621
|
3659 if &hls | let keepregslash= s:ExplorePatHls(dirname) | endif
|
|
3660 endif " switch on starpat to build w:netrw_explore_list
|
1121
|
3661
|
|
3662 let w:netrw_explore_listlen = len(w:netrw_explore_list)
|
1621
|
3663 " call Decho("w:netrw_explore_list<".string(w:netrw_explore_list).">")
|
|
3664 " call Decho("w:netrw_explore_listlen=".w:netrw_explore_listlen)
|
1121
|
3665
|
|
3666 if w:netrw_explore_listlen == 0 || (w:netrw_explore_listlen == 1 && w:netrw_explore_list[0] =~ '\*\*\/')
|
|
3667 call netrw#ErrorMsg(s:WARNING,"no files matched",42)
|
|
3668 silent! let @* = keepregstar
|
|
3669 silent! let @+ = keepregstar
|
|
3670 silent! let @/ = keepregslash
|
|
3671 " call Dret("netrw#Explore : no files matched")
|
|
3672 return
|
482
|
3673 endif
|
1621
|
3674 endif " if indx ... endif
|
1121
|
3675
|
|
3676 " NetrwStatusLine support - for exploring support
|
|
3677 let w:netrw_explore_indx= indx
|
2034
|
3678 " call Decho("w:netrw_explore_list<".join(w:netrw_explore_list,',')."> len=".w:netrw_explore_listlen)
|
1121
|
3679
|
|
3680 " wrap the indx around, but issue a note
|
|
3681 if indx >= w:netrw_explore_listlen || indx < 0
|
|
3682 " call Decho("wrap indx (indx=".indx." listlen=".w:netrw_explore_listlen.")")
|
|
3683 let indx = (indx < 0)? ( w:netrw_explore_listlen - 1 ) : 0
|
|
3684 let w:netrw_explore_indx= indx
|
|
3685 call netrw#ErrorMsg(s:NOTE,"no more files match Explore pattern",43)
|
|
3686 endif
|
|
3687
|
|
3688 exe "let dirfile= w:netrw_explore_list[".indx."]"
|
|
3689 " call Decho("dirfile=w:netrw_explore_list[indx=".indx."]= <".dirfile.">")
|
|
3690 let newdir= substitute(dirfile,'/[^/]*$','','e')
|
|
3691 " call Decho("newdir<".newdir.">")
|
|
3692
|
|
3693 " call Decho("calling LocalBrowseCheck(newdir<".newdir.">)")
|
|
3694 call netrw#LocalBrowseCheck(newdir)
|
|
3695 if !exists("w:netrw_liststyle")
|
|
3696 let w:netrw_liststyle= g:netrw_liststyle
|
|
3697 endif
|
|
3698 if w:netrw_liststyle == s:THINLIST || w:netrw_liststyle == s:LONGLIST
|
|
3699 call search('^'.substitute(dirfile,"^.*/","","").'\>',"W")
|
|
3700 else
|
|
3701 call search('\<'.substitute(dirfile,"^.*/","","").'\>',"w")
|
|
3702 endif
|
|
3703 let w:netrw_explore_mtchcnt = indx + 1
|
|
3704 let w:netrw_explore_bufnr = bufnr("%")
|
|
3705 let w:netrw_explore_line = line(".")
|
|
3706 call s:SetupNetrwStatusLine('%f %h%m%r%=%9*%{NetrwStatusLine()}')
|
|
3707 " call Decho("explore: mtchcnt=".w:netrw_explore_mtchcnt." bufnr=".w:netrw_explore_bufnr." line#".w:netrw_explore_line)
|
|
3708
|
|
3709 else
|
1621
|
3710 " call Decho("your vim does not have +path_extra")
|
1121
|
3711 if !exists("g:netrw_quiet")
|
|
3712 call netrw#ErrorMsg(s:WARNING,"your vim needs the +path_extra feature for Exploring with **!",44)
|
482
|
3713 endif
|
1121
|
3714 silent! let @* = keepregstar
|
|
3715 silent! let @+ = keepregstar
|
|
3716 silent! let @/ = keepregslash
|
|
3717 " call Dret("netrw#Explore : missing +path_extra")
|
|
3718 return
|
|
3719 endif
|
|
3720
|
|
3721 else
|
2034
|
3722 " call Decho("default case: Explore newdir<".dirname.">")
|
1121
|
3723 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && dirname =~ '/'
|
|
3724 silent! unlet w:netrw_treedict
|
|
3725 silent! unlet w:netrw_treetop
|
|
3726 endif
|
|
3727 let newdir= dirname
|
|
3728 if !exists("b:netrw_curdir")
|
|
3729 call netrw#LocalBrowseCheck(getcwd())
|
|
3730 else
|
1621
|
3731 call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,newdir))
|
|
3732 endif
|
|
3733 endif
|
2034
|
3734 " call FOTEST(5)
|
1621
|
3735
|
|
3736 " visual display of **/ **// */ Exploration files
|
2034
|
3737 " call Decho("w:netrw_explore_indx=".(exists("w:netrw_explore_indx")? w:netrw_explore_indx : "doesn't exist"))
|
|
3738 " call Decho("b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "n/a").">")
|
1621
|
3739 if exists("w:netrw_explore_indx") && exists("b:netrw_curdir")
|
2034
|
3740 " call Decho("s:explore_prvdir<".(exists("s:explore_prvdir")? s:explore_prvdir : "-doesn't exist-"))
|
1621
|
3741 if !exists("s:explore_prvdir") || s:explore_prvdir != b:netrw_curdir
|
|
3742 " only update match list if current directory isn't the same as before
|
2034
|
3743 " call Decho("only update match list if current directory not the same as before")
|
1621
|
3744 let s:explore_prvdir = b:netrw_curdir
|
|
3745 let s:explore_match = ""
|
2034
|
3746 let dirlen = s:Strlen(b:netrw_curdir)
|
1621
|
3747 if b:netrw_curdir !~ '/$'
|
|
3748 let dirlen= dirlen + 1
|
|
3749 endif
|
|
3750 let prvfname= ""
|
|
3751 for fname in w:netrw_explore_list
|
|
3752 " call Decho("fname<".fname.">")
|
|
3753 if fname =~ '^'.b:netrw_curdir
|
|
3754 if s:explore_match == ""
|
2034
|
3755 let s:explore_match= '\<'.escape(strpart(fname,dirlen),g:netrw_markfileesc).'\>'
|
1621
|
3756 else
|
2034
|
3757 let s:explore_match= s:explore_match.'\|\<'.escape(strpart(fname,dirlen),g:netrw_markfileesc).'\>'
|
1621
|
3758 endif
|
|
3759 elseif fname !~ '^/' && fname != prvfname
|
|
3760 if s:explore_match == ""
|
2034
|
3761 let s:explore_match= '\<'.escape(fname,g:netrw_markfileesc).'\>'
|
1621
|
3762 else
|
2034
|
3763 let s:explore_match= s:explore_match.'\|\<'.escape(fname,g:netrw_markfileesc).'\>'
|
1621
|
3764 endif
|
|
3765 endif
|
|
3766 let prvfname= fname
|
|
3767 endfor
|
|
3768 " call Decho("explore_match<".s:explore_match.">")
|
|
3769 exe "2match netrwMarkFile /".s:explore_match."/"
|
|
3770 endif
|
|
3771 echo "<s-up>==Pexplore <s-down>==Nexplore"
|
|
3772 else
|
|
3773 2match none
|
|
3774 if exists("s:explore_match") | unlet s:explore_match | endif
|
|
3775 if exists("s:explore_prvdir") | unlet s:explore_prvdir | endif
|
|
3776 echo " "
|
|
3777 " call Decho("cleared explore match list")
|
1121
|
3778 endif
|
2034
|
3779 " call FOTEST(6)
|
1121
|
3780
|
|
3781 silent! let @* = keepregstar
|
|
3782 silent! let @+ = keepregstar
|
|
3783 silent! let @/ = keepregslash
|
|
3784 " call Dret("netrw#Explore : @/<".@/.">")
|
|
3785 endfun
|
|
3786
|
|
3787 " ---------------------------------------------------------------------
|
2034
|
3788 " s:NetrwExploreListUniq: {{{2
|
|
3789 fun! s:NetrwExploreListUniq(explist)
|
|
3790 " call Dfunc("s:NetrwExploreListUniq(explist)")
|
|
3791
|
|
3792 " this assumes that the list is already sorted
|
|
3793 let newexplist= []
|
|
3794 for member in a:explist
|
|
3795 if !exists("uniqmember") || member != uniqmember
|
|
3796 let uniqmember = member
|
|
3797 let newexplist = newexplist + [ member ]
|
|
3798 endif
|
|
3799 endfor
|
|
3800
|
|
3801 " call Dret("s:NetrwExploreListUniq")
|
|
3802 return newexplist
|
|
3803 endfun
|
|
3804
|
|
3805 " ---------------------------------------------------------------------
|
1621
|
3806 " s:NetrwHide: this function is invoked by the "a" map for browsing {{{2
|
|
3807 " and switches the hiding mode. The actual hiding is done by
|
|
3808 " s:NetrwListHide().
|
|
3809 " g:netrw_hide= 0: show all
|
|
3810 " 1: show not-hidden files
|
|
3811 " 2: show hidden files only
|
|
3812 fun! s:NetrwHide(islocal)
|
|
3813 " call Dfunc("NetrwHide(islocal=".a:islocal.") g:netrw_hide=".g:netrw_hide)
|
|
3814 let svpos= netrw#NetrwSavePosn()
|
|
3815
|
|
3816 if exists("s:netrwmarkfilelist_{bufnr('%')}")
|
|
3817 " call Decho(((g:netrw_hide == 1)? "unhide" : "hide")." files in markfilelist<".string(s:netrwmarkfilelist_{bufnr("%")}).">")
|
|
3818 " call Decho("g:netrw_list_hide<".g:netrw_list_hide.">")
|
|
3819
|
|
3820 " hide the files in the markfile list
|
|
3821 for fname in s:netrwmarkfilelist_{bufnr("%")}
|
|
3822 " call Decho("match(g:netrw_list_hide<".g:netrw_list_hide.'> fname<\<'.fname.'\>>)='.match(g:netrw_list_hide,'\<'.fname.'\>')." isk=".&isk)
|
|
3823 if match(g:netrw_list_hide,'\<'.fname.'\>') != -1
|
|
3824 " remove fname from hiding list
|
|
3825 let g:netrw_list_hide= substitute(g:netrw_list_hide,'..\<'.escape(fname,g:netrw_fname_escape).'\>..','','')
|
|
3826 let g:netrw_list_hide= substitute(g:netrw_list_hide,',,',',','g')
|
|
3827 let g:netrw_list_hide= substitute(g:netrw_list_hide,'^,\|,$','','')
|
|
3828 " call Decho("unhide: g:netrw_list_hide<".g:netrw_list_hide.">")
|
|
3829 else
|
|
3830 " append fname to hiding list
|
|
3831 if exists("g:netrw_list_hide") && g:netrw_list_hide != ""
|
|
3832 let g:netrw_list_hide= g:netrw_list_hide.',\<'.escape(fname,g:netrw_fname_escape).'\>'
|
|
3833 else
|
|
3834 let g:netrw_list_hide= '\<'.escape(fname,g:netrw_fname_escape).'\>'
|
|
3835 endif
|
|
3836 " call Decho("hide: g:netrw_list_hide<".g:netrw_list_hide.">")
|
|
3837 endif
|
|
3838 endfor
|
2034
|
3839 call s:NetrwUnmarkList(bufnr("%"),b:netrw_curdir)
|
1621
|
3840 let g:netrw_hide= 1
|
|
3841
|
|
3842 else
|
|
3843
|
|
3844 " switch between show-all/show-not-hidden/show-hidden
|
|
3845 let g:netrw_hide=(g:netrw_hide+1)%3
|
|
3846 exe "norm! 0"
|
|
3847 if g:netrw_hide && g:netrw_list_hide == ""
|
|
3848 call netrw#ErrorMsg(s:WARNING,"your hiding list is empty!",49)
|
|
3849 " call Dret("NetrwHide")
|
|
3850 return
|
|
3851 endif
|
|
3852 endif
|
|
3853
|
|
3854 call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
|
|
3855 call netrw#NetrwRestorePosn(svpos)
|
|
3856 " call Dret("NetrwHide")
|
|
3857 endfun
|
|
3858
|
|
3859 " ---------------------------------------------------------------------
|
|
3860 " s:NetrwHidden: invoked by "gh" {{{2
|
|
3861 fun! s:NetrwHidden(islocal)
|
|
3862 " call Dfunc("s:NetrwHidden()")
|
|
3863 " save current position
|
|
3864 let svpos= netrw#NetrwSavePosn()
|
|
3865
|
|
3866 if g:netrw_list_hide =~ '\(^\|,\)\\(^\\|\\s\\s\\)\\zs\\.\\S\\+'
|
|
3867 " remove pattern from hiding list
|
|
3868 let g:netrw_list_hide= substitute(g:netrw_list_hide,'\(^\|,\)\\(^\\|\\s\\s\\)\\zs\\.\\S\\+','','')
|
2034
|
3869 elseif s:Strlen(g:netrw_list_hide) >= 1
|
1621
|
3870 let g:netrw_list_hide= g:netrw_list_hide . ',\(^\|\s\s\)\zs\.\S\+'
|
|
3871 else
|
|
3872 let g:netrw_list_hide= '\(^\|\s\s\)\zs\.\S\+'
|
|
3873 endif
|
|
3874
|
|
3875 " refresh screen and return to saved position
|
|
3876 call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
|
|
3877 call netrw#NetrwRestorePosn(svpos)
|
|
3878 " call Dret("s:NetrwHidden")
|
|
3879 endfun
|
|
3880
|
|
3881 " ---------------------------------------------------------------------
|
2034
|
3882 " s:NetrwHome: this function determines a "home" for saving bookmarks and history {{{2
|
|
3883 fun! s:NetrwHome()
|
|
3884 if exists("g:netrw_home")
|
|
3885 let home= g:netrw_home
|
|
3886 else
|
|
3887 " go to vim plugin home
|
|
3888 for home in split(&rtp,',') + ['']
|
|
3889 if isdirectory(home) && filewritable(home) | break | endif
|
|
3890 let basehome= substitute(home,'[/\\]\.vim$','','')
|
|
3891 if isdirectory(basehome) && filewritable(basehome)
|
|
3892 let home= basehome."/.vim"
|
|
3893 break
|
|
3894 endif
|
|
3895 endfor
|
|
3896 if home == ""
|
|
3897 " just pick the first directory
|
|
3898 let home= substitute(&rtp,',.*$','','')
|
|
3899 endif
|
|
3900 if (has("win32") || has("win95") || has("win64") || has("win16"))
|
|
3901 let home= substitute(home,'/','\\','g')
|
|
3902 endif
|
|
3903 endif
|
|
3904 " insure that the home directory exists
|
|
3905 if !isdirectory(home)
|
|
3906 if exists("g:netrw_mkdir")
|
|
3907 call system(g:netrw_mkdir." ".shellescape(home))
|
|
3908 else
|
|
3909 call mkdir(home)
|
|
3910 endif
|
|
3911 endif
|
|
3912 let g:netrw_home= home
|
|
3913 return home
|
|
3914 endfun
|
|
3915
|
|
3916 " ---------------------------------------------------------------------
|
1621
|
3917 " s:NetrwLeftmouse: handles the <leftmouse> when in a netrw browsing window {{{2
|
|
3918 fun! s:NetrwLeftmouse(islocal)
|
|
3919 " call Dfunc("s:NetrwLeftmouse(islocal=".a:islocal.")")
|
|
3920 if a:islocal
|
|
3921 if exists("b:netrw_curdir")
|
|
3922 call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,s:NetrwGetWord()))
|
|
3923 endif
|
|
3924 else
|
|
3925 if exists("b:netrw_curdir")
|
|
3926 call s:NetrwBrowse(0,s:NetrwBrowseChgDir(0,s:NetrwGetWord()))
|
|
3927 endif
|
|
3928 endif
|
|
3929 " call Dret("s:NetrwLeftmouse")
|
|
3930 endfun
|
|
3931
|
|
3932 " ---------------------------------------------------------------------
|
|
3933 " s:NetrwListHide: uses [range]g~...~d to delete files that match comma {{{2
|
|
3934 " separated patterns given in g:netrw_list_hide
|
|
3935 fun! s:NetrwListHide()
|
|
3936 " call Dfunc("NetrwListHide() hide=".g:netrw_hide." listhide<".g:netrw_list_hide.">")
|
|
3937
|
|
3938 " find a character not in the "hide" string to use as a separator for :g and :v commands
|
|
3939 " How-it-works: take the hiding command, convert it into a range. Duplicate
|
|
3940 " characters don't matter. Remove all such characters from the '/~...90'
|
|
3941 " string. Use the first character left as a separator character.
|
|
3942 let listhide= g:netrw_list_hide
|
|
3943 let sep = strpart(substitute('/~@#$%^&*{};:,<.>?|1234567890','['.escape(listhide,'-]^\').']','','ge'),1,1)
|
|
3944 " call Decho("sep=".sep)
|
|
3945
|
|
3946 while listhide != ""
|
|
3947 if listhide =~ ','
|
|
3948 let hide = substitute(listhide,',.*$','','e')
|
|
3949 let listhide = substitute(listhide,'^.\{-},\(.*\)$','\1','e')
|
|
3950 else
|
|
3951 let hide = listhide
|
|
3952 let listhide = ""
|
|
3953 endif
|
|
3954
|
|
3955 " Prune the list by hiding any files which match
|
|
3956 if g:netrw_hide == 1
|
|
3957 " call Decho("hiding<".hide."> listhide<".listhide.">")
|
|
3958 exe 'silent keepjumps '.w:netrw_bannercnt.',$g'.sep.hide.sep.'d'
|
|
3959 elseif g:netrw_hide == 2
|
|
3960 " call Decho("showing<".hide."> listhide<".listhide.">")
|
|
3961 exe 'silent keepjumps '.w:netrw_bannercnt.',$g'.sep.hide.sep.'s@^@ /-KEEP-/ @'
|
|
3962 endif
|
|
3963 endwhile
|
|
3964 if g:netrw_hide == 2
|
|
3965 exe 'silent keepjumps '.w:netrw_bannercnt.',$v@^ /-KEEP-/ @d'
|
|
3966 exe 'silent keepjumps '.w:netrw_bannercnt.',$s@^\%( /-KEEP-/ \)\+@@e'
|
|
3967 endif
|
|
3968
|
|
3969 " call Dret("NetrwListHide")
|
|
3970 endfun
|
|
3971
|
|
3972 " ---------------------------------------------------------------------
|
|
3973 " NetrwHideEdit: allows user to edit the file/directory hiding list
|
|
3974 fun! s:NetrwHideEdit(islocal)
|
|
3975 " call Dfunc("NetrwHideEdit(islocal=".a:islocal.")")
|
|
3976
|
|
3977 " save current cursor position
|
|
3978 let svpos= netrw#NetrwSavePosn()
|
|
3979
|
|
3980 " get new hiding list from user
|
|
3981 call inputsave()
|
|
3982 let newhide= input("Edit Hiding List: ",g:netrw_list_hide)
|
|
3983 call inputrestore()
|
|
3984 let g:netrw_list_hide= newhide
|
|
3985 " call Decho("new g:netrw_list_hide<".g:netrw_list_hide.">")
|
|
3986
|
|
3987 " refresh the listing
|
|
3988 silent call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,"./"))
|
|
3989
|
|
3990 " restore cursor position
|
|
3991 call netrw#NetrwRestorePosn(svpos)
|
|
3992
|
|
3993 " call Dret("NetrwHideEdit")
|
|
3994 endfun
|
|
3995
|
|
3996 " ---------------------------------------------------------------------
|
|
3997 " NetSortSequence: allows user to edit the sorting sequence
|
|
3998 fun! s:NetSortSequence(islocal)
|
|
3999 " call Dfunc("NetSortSequence(islocal=".a:islocal.")")
|
|
4000
|
|
4001 let svpos= netrw#NetrwSavePosn()
|
|
4002 call inputsave()
|
|
4003 let newsortseq= input("Edit Sorting Sequence: ",g:netrw_sort_sequence)
|
|
4004 call inputrestore()
|
|
4005
|
|
4006 " refresh the listing
|
|
4007 let g:netrw_sort_sequence= newsortseq
|
|
4008 call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
|
|
4009 call netrw#NetrwRestorePosn(svpos)
|
|
4010
|
|
4011 " call Dret("NetSortSequence")
|
|
4012 endfun
|
|
4013
|
|
4014 " ---------------------------------------------------------------------
|
|
4015 " s:NetrwMakeDir: this function makes a directory (both local and remote) {{{2
|
|
4016 fun! s:NetrwMakeDir(usrhost)
|
|
4017 " call Dfunc("NetrwMakeDir(usrhost<".a:usrhost.">)")
|
|
4018
|
|
4019 " get name of new directory from user. A bare <CR> will skip.
|
|
4020 " if its currently a directory, also request will be skipped, but with
|
|
4021 " a message.
|
|
4022 call inputsave()
|
|
4023 let newdirname= input("Please give directory name: ")
|
|
4024 call inputrestore()
|
|
4025 " call Decho("newdirname<".newdirname.">")
|
|
4026
|
|
4027 if newdirname == ""
|
|
4028 " call Dret("NetrwMakeDir : user aborted with bare <cr>")
|
|
4029 return
|
|
4030 endif
|
|
4031
|
|
4032 if a:usrhost == ""
|
|
4033 " call Decho("local mkdir")
|
|
4034
|
|
4035 " Local mkdir:
|
|
4036 " sanity checks
|
|
4037 let fullnewdir= b:netrw_curdir.'/'.newdirname
|
|
4038 " call Decho("fullnewdir<".fullnewdir.">")
|
|
4039 if isdirectory(fullnewdir)
|
|
4040 if !exists("g:netrw_quiet")
|
|
4041 call netrw#ErrorMsg(s:WARNING,"<".newdirname."> is already a directory!",24)
|
|
4042 endif
|
|
4043 " call Dret("NetrwMakeDir : directory<".newdirname."> exists previously")
|
|
4044 return
|
|
4045 endif
|
|
4046 if s:FileReadable(fullnewdir)
|
|
4047 if !exists("g:netrw_quiet")
|
|
4048 call netrw#ErrorMsg(s:WARNING,"<".newdirname."> is already a file!",25)
|
|
4049 endif
|
|
4050 " call Dret("NetrwMakeDir : file<".newdirname."> exists previously")
|
|
4051 return
|
|
4052 endif
|
|
4053
|
|
4054 " requested new local directory is neither a pre-existing file or
|
|
4055 " directory, so make it!
|
|
4056 if exists("*mkdir")
|
|
4057 call mkdir(fullnewdir,"p")
|
|
4058 else
|
|
4059 let netrw_origdir= s:NetrwGetcwd(1)
|
|
4060 exe 'keepjumps lcd '.fnameescape(b:netrw_curdir)
|
|
4061 " call Decho("netrw_origdir<".netrw_origdir.">: lcd b:netrw_curdir<".fnameescape(b:netrw_curdir).">")
|
1668
|
4062 " call Decho("exe silent! !".g:netrw_local_mkdir.' '.shellescape(newdirname,1))
|
|
4063 exe "silent! !".g:netrw_local_mkdir.' '.shellescape(newdirname,1)
|
1621
|
4064 if !g:netrw_keepdir
|
|
4065 exe 'keepjumps lcd '.fnameescape(netrw_origdir)
|
|
4066 " call Decho("netrw_keepdir=".g:netrw_keepdir.": keepjumps lcd ".fnameescape(netrw_origdir)." getcwd<".getcwd().">")
|
|
4067 endif
|
|
4068 endif
|
|
4069
|
|
4070 if v:shell_error == 0
|
|
4071 " refresh listing
|
|
4072 " call Decho("refresh listing")
|
|
4073 let svpos= netrw#NetrwSavePosn()
|
|
4074 call s:NetrwRefresh(1,s:NetrwBrowseChgDir(1,'./'))
|
|
4075 call netrw#NetrwRestorePosn(svpos)
|
|
4076 elseif !exists("g:netrw_quiet")
|
|
4077 call netrw#ErrorMsg(s:ERROR,"unable to make directory<".newdirname.">",26)
|
|
4078 endif
|
|
4079 " redraw!
|
|
4080
|
|
4081 elseif !exists("b:netrw_method") || b:netrw_method == 4
|
|
4082 " Remote mkdir:
|
|
4083 " call Decho("remote mkdir")
|
|
4084 let mkdircmd = s:MakeSshCmd(g:netrw_mkdir_cmd)
|
|
4085 let newdirname= substitute(b:netrw_curdir,'^\%(.\{-}/\)\{3}\(.*\)$','\1','').newdirname
|
1668
|
4086 " call Decho("exe silent! !".mkdircmd." ".shellescape(newdirname,1))
|
|
4087 exe "silent! !".mkdircmd." ".shellescape(newdirname,1)
|
1621
|
4088 if v:shell_error == 0
|
|
4089 " refresh listing
|
|
4090 let svpos= netrw#NetrwSavePosn()
|
|
4091 call s:NetrwRefresh(0,s:NetrwBrowseChgDir(0,'./'))
|
|
4092 call netrw#NetrwRestorePosn(svpos)
|
|
4093 elseif !exists("g:netrw_quiet")
|
|
4094 call netrw#ErrorMsg(s:ERROR,"unable to make directory<".newdirname.">",27)
|
|
4095 endif
|
|
4096 " redraw!
|
|
4097
|
|
4098 elseif b:netrw_method == 2
|
|
4099 " COMBAK -- future work
|
|
4100 call netrw#ErrorMsg(s:ERROR,"making directories via ftp not currently supported",68)
|
|
4101 elseif b:netrw_method == 3
|
|
4102 " COMBAK -- future work
|
|
4103 call netrw#ErrorMsg(s:ERROR,"making directories via ftp not currently supported",68)
|
|
4104 endif
|
|
4105
|
|
4106 " call Dret("NetrwMakeDir")
|
|
4107 endfun
|
|
4108
|
|
4109 " ---------------------------------------------------------------------
|
|
4110 " s:NetrwMarkFile: (invoked by mf) This function is used to both {{{2
|
|
4111 " mark and unmark files. If a markfile list exists,
|
|
4112 " then the rename and delete functions will use it instead
|
|
4113 " of whatever may happen to be under the cursor at that
|
|
4114 " moment. When the mouse and gui are available,
|
|
4115 " shift-leftmouse may also be used to mark files.
|
1698
|
4116 "
|
|
4117 " Creates two lists
|
|
4118 " s:netrwmarkfilelist -- holds complete paths to all marked files
|
|
4119 " s:netrwmarkfilelist_# -- holds list of marked files in current-buffer's directory (#==bufnr())
|
|
4120 "
|
|
4121 " Creates a marked file match string
|
|
4122 " s:netrwmarfilemtch_# -- used with 2match to display marked files
|
|
4123 "
|
1702
|
4124 " Creates a buffer version of islocal
|
|
4125 " b:netrw_islocal
|
|
4126 "
|
1621
|
4127 fun! s:NetrwMarkFile(islocal,fname)
|
|
4128 " call Dfunc("s:NetrwMarkFile(islocal=".a:islocal." fname<".a:fname.">)")
|
|
4129 let curbufnr= bufnr("%")
|
|
4130 let curdir = b:netrw_curdir
|
2034
|
4131 let trailer = '[@=|\/\*]\=\>'
|
1621
|
4132 if exists("s:netrwmarkfilelist_{curbufnr}")
|
|
4133 " markfile list exists
|
|
4134 " call Decho("starting s:netrwmarkfilelist_{curbufnr}<".string(s:netrwmarkfilelist_{curbufnr}).">")
|
|
4135 " call Decho("starting s:netrwmarkfilemtch_{curbufnr}<".s:netrwmarkfilemtch_{curbufnr}.">")
|
1702
|
4136 let b:netrw_islocal= a:islocal
|
1621
|
4137
|
|
4138 if index(s:netrwmarkfilelist_{curbufnr},a:fname) == -1
|
1702
|
4139 " append filename to buffer's markfilelist
|
1621
|
4140 " call Decho("append filename<".a:fname."> to local markfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr}).">")
|
|
4141 call add(s:netrwmarkfilelist_{curbufnr},a:fname)
|
2034
|
4142 let s:netrwmarkfilemtch_{curbufnr}= s:netrwmarkfilemtch_{curbufnr}.'\|\<'.escape(a:fname,g:netrw_markfileesc."'".g:netrw_markfileesc."'").trailer
|
1621
|
4143
|
|
4144 else
|
1702
|
4145 " remove filename from buffer's markfilelist
|
1621
|
4146 " call Decho("remove filename<".a:fname."> from local markfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr}).">")
|
|
4147 call filter(s:netrwmarkfilelist_{curbufnr},'v:val != a:fname')
|
|
4148 if s:netrwmarkfilelist_{curbufnr} == []
|
|
4149 " local markfilelist is empty; remove it entirely
|
2034
|
4150 " call Decho("markfile list now empty")
|
1621
|
4151 call s:NetrwUnmarkList(curbufnr,curdir)
|
|
4152 else
|
|
4153 " rebuild match list to display markings correctly
|
|
4154 " call Decho("rebuild s:netrwmarkfilemtch_".curbufnr)
|
|
4155 let s:netrwmarkfilemtch_{curbufnr}= ""
|
|
4156 let first = 1
|
|
4157 for fname in s:netrwmarkfilelist_{curbufnr}
|
|
4158 if first
|
2034
|
4159 let s:netrwmarkfilemtch_{curbufnr}= s:netrwmarkfilemtch_{curbufnr}.'\<'.escape(fname,g:netrw_markfileesc."'".g:netrw_markfileesc."'").trailer
|
1621
|
4160 else
|
2034
|
4161 let s:netrwmarkfilemtch_{curbufnr}= s:netrwmarkfilemtch_{curbufnr}.'\|\<'.escape(fname,g:netrw_markfileesc."'".g:netrw_markfileesc."'").trailer
|
1621
|
4162 endif
|
|
4163 let first= 0
|
|
4164 endfor
|
|
4165 " call Decho("ending s:netrwmarkfilelist_"curbufnr."<".string(s:netrwmarkfilelist_{curbufnr}).">")
|
|
4166 " call Decho("ending s:netrwmarkfilemtch_"curbufnr."<".s:netrwmarkfilemtch_{curbufnr}.">")
|
|
4167 endif
|
|
4168 endif
|
|
4169
|
|
4170 else
|
|
4171 " initialize new markfilelist
|
|
4172
|
|
4173 " call Decho("add fname<".a:fname."> to new markfilelist_".curbufnr)
|
|
4174 let s:netrwmarkfilelist_{curbufnr}= []
|
|
4175 call add(s:netrwmarkfilelist_{curbufnr},a:fname)
|
|
4176 " call Decho("ending s:netrwmarkfilelist_{curbufnr}<".string(s:netrwmarkfilelist_{curbufnr}).">")
|
|
4177
|
|
4178 " build initial markfile matching pattern
|
|
4179 if a:fname =~ '/$'
|
|
4180 let s:netrwmarkfilemtch_{curbufnr}= '\<'.escape(a:fname,g:netrw_markfileesc)
|
|
4181 else
|
2034
|
4182 let s:netrwmarkfilemtch_{curbufnr}= '\<'.escape(a:fname,g:netrw_markfileesc).trailer
|
1621
|
4183 endif
|
|
4184 " call Decho("ending s:netrwmarkfilemtch_".curbufnr."<".s:netrwmarkfilemtch_{curbufnr}.">")
|
|
4185 endif
|
|
4186
|
|
4187 " handle global markfilelist
|
|
4188 if exists("s:netrwmarkfilelist")
|
|
4189 let dname= s:ComposePath(b:netrw_curdir,a:fname)
|
|
4190 if index(s:netrwmarkfilelist,dname) == -1
|
|
4191 " append new filename to global markfilelist
|
|
4192 call add(s:netrwmarkfilelist,s:ComposePath(b:netrw_curdir,a:fname))
|
|
4193 " call Decho("append filename<".a:fname."> to global markfilelist<".string(s:netrwmarkfilelist).">")
|
|
4194 else
|
|
4195 " remove new filename from global markfilelist
|
|
4196 " call Decho("filter(".string(s:netrwmarkfilelist).",'v:val != '.".dname.")")
|
|
4197 call filter(s:netrwmarkfilelist,'v:val != "'.dname.'"')
|
|
4198 " call Decho("ending s:netrwmarkfilelist <".string(s:netrwmarkfilelist).">")
|
|
4199 if s:netrwmarkfilelist == []
|
|
4200 unlet s:netrwmarkfilelist
|
|
4201 endif
|
|
4202 endif
|
|
4203 else
|
|
4204 " initialize new global-directory markfilelist
|
|
4205 let s:netrwmarkfilelist= []
|
|
4206 call add(s:netrwmarkfilelist,s:ComposePath(b:netrw_curdir,a:fname))
|
|
4207 " call Decho("init s:netrwmarkfilelist<".string(s:netrwmarkfilelist).">")
|
|
4208 endif
|
|
4209
|
|
4210 " set up 2match'ing to netrwmarkfilemtch list
|
|
4211 if exists("s:netrwmarkfilemtch_{curbufnr}") && s:netrwmarkfilemtch_{curbufnr} != ""
|
|
4212 " call Decho("exe 2match netrwMarkFile /".s:netrwmarkfilemtch_{curbufnr}."/")
|
2034
|
4213 if exists("g:did_drchip_netrwlist_syntax")
|
|
4214 exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{curbufnr}."/"
|
|
4215 endif
|
1621
|
4216 else
|
|
4217 " call Decho("2match none")
|
|
4218 2match none
|
|
4219 endif
|
|
4220 " call Dret("s:NetrwMarkFile : netrwmarkfilelist_".curbufnr."<".(exists("s:netrwmarkfilelist_{curbufnr}")? string(s:netrwmarkfilelist_{curbufnr}) : " doesn't exist").">")
|
|
4221 endfun
|
|
4222
|
|
4223 " ---------------------------------------------------------------------
|
|
4224 " s:NetrwMarkFileCompress: (invoked by mz) This function is used to {{{2
|
|
4225 " compress/decompress files using the programs
|
|
4226 " in g:netrw_compress and g:netrw_uncompress,
|
|
4227 " using g:netrw_compress_suffix to know which to
|
|
4228 " do. By default:
|
|
4229 " g:netrw_compress = "gzip"
|
|
4230 " g:netrw_decompress = { ".gz" : "gunzip" , ".bz2" : "bunzip2" , ".zip" : "unzip" , ".tar" : "tar -xf"}
|
|
4231 fun! s:NetrwMarkFileCompress(islocal)
|
|
4232 " call Dfunc("s:NetrwMarkFileCompress(islocal=".a:islocal.")")
|
|
4233 let svpos = netrw#NetrwSavePosn()
|
|
4234 let curdir = b:netrw_curdir
|
|
4235 let curbufnr = bufnr("%")
|
|
4236
|
|
4237 if exists("s:netrwmarkfilelist_{curbufnr}") && exists("g:netrw_compress") && exists("g:netrw_decompress")
|
|
4238 for fname in s:netrwmarkfilelist_{curbufnr}
|
|
4239 " for every filename in the marked list
|
|
4240 for sfx in sort(keys(g:netrw_decompress))
|
|
4241 if fname =~ '\'.sfx.'$'
|
|
4242 " fname has a suffix indicating that its compressed; apply associated decompression routine
|
2034
|
4243 let exe= netrw#WinPath(g:netrw_decompress[sfx])
|
1621
|
4244 " call Decho("fname<".fname."> is compressed so decompress with <".exe.">")
|
|
4245 if a:islocal
|
|
4246 if g:netrw_keepdir
|
1668
|
4247 let fname= shellescape(s:ComposePath(curdir,fname))
|
1621
|
4248 endif
|
|
4249 else
|
1698
|
4250 let fname= shellescape(b:netrw_curdir.fname,1)
|
1621
|
4251 endif
|
|
4252 if executable(exe)
|
|
4253 if a:islocal
|
|
4254 call system(exe." ".fname)
|
|
4255 else
|
|
4256 call s:RemoteSystem(exe." ".fname)
|
|
4257 endif
|
|
4258 else
|
|
4259 call netrw#ErrorMsg(s:WARNING,"unable to apply<".exe."> to file<".fname.">",50)
|
|
4260 endif
|
|
4261 break
|
|
4262 endif
|
|
4263 endfor
|
|
4264 if exists("exe")
|
|
4265 unlet exe
|
|
4266 elseif a:islocal
|
|
4267 " fname not a compressed file, so compress it
|
2034
|
4268 call system(netrw#WinPath(g:netrw_compress)." ".shellescape(s:ComposePath(b:netrw_curdir,fname)))
|
1621
|
4269 else
|
|
4270 " fname not a compressed file, so compress it
|
2034
|
4271 call s:RemoteSystem(netrw#WinPath(g:netrw_compress)." ".shellescape(fname))
|
1621
|
4272 endif
|
|
4273 endfor
|
|
4274 call s:NetrwUnmarkList(curbufnr,curdir)
|
|
4275 call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
|
|
4276 call netrw#NetrwRestorePosn(svpos)
|
|
4277 endif
|
|
4278 " call Dret("s:NetrwMarkFileCompress")
|
|
4279 endfun
|
|
4280
|
|
4281 " ---------------------------------------------------------------------
|
|
4282 " s:NetrwMarkFileCopy: (invoked by mc) copy marked files to target {{{2
|
|
4283 " If no marked files, then set up directory as the
|
|
4284 " target. Currently does not support copying entire
|
|
4285 " directories. Uses the local-buffer marked file list.
|
|
4286 " Returns 1=success (used by NetrwMarkFileMove())
|
|
4287 " 0=failure
|
|
4288 fun! s:NetrwMarkFileCopy(islocal)
|
|
4289 " call Dfunc("s:NetrwMarkFileCopy(islocal=".a:islocal.") target<".(exists("s:netrwmftgt")? s:netrwmftgt : '---').">")
|
|
4290
|
|
4291 " sanity checks
|
|
4292 if !exists("s:netrwmarkfilelist_{bufnr('%')}") || empty(s:netrwmarkfilelist_{bufnr('%')})
|
|
4293 call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66)
|
|
4294 " call Dret("s:NetrwMarkFileCopy 0")
|
|
4295 return 0
|
|
4296 endif
|
|
4297 " call Decho("sanity chk passed: s:netrwmarkfilelist_".bufnr('%')."<".string(s:netrwmarkfilelist_{bufnr('%')}))
|
|
4298 if !exists("s:netrwmftgt")
|
|
4299 call netrw#ErrorMsg(2,"your marked file target is empty! (:help netrw-mt)",67)
|
|
4300 " call Dret("s:NetrwMarkFileCopy 0")
|
|
4301 return 0
|
|
4302 endif
|
|
4303 " call Decho("sanity chk passed: s:netrwmftgt<".s:netrwmftgt.">")
|
|
4304 let curdir = b:netrw_curdir
|
|
4305 let curbufnr = bufnr("%")
|
|
4306
|
|
4307 if a:islocal && s:netrwmftgt_islocal
|
|
4308 " Copy marked files, local directory to local directory
|
|
4309 " call Decho("copy from local to local")
|
1698
|
4310 let args= join(map(deepcopy(s:netrwmarkfilelist_{bufnr('%')}),"shellescape(b:netrw_curdir.\"/\".v:val)"))
|
1621
|
4311 " call Decho("system(".g:netrw_localcopycmd." ".args." ".shellescape(s:netrwmftgt).")")
|
2034
|
4312 call system(netrw#WinPath(g:netrw_localcopycmd)." ".args." ".shellescape(s:netrwmftgt))
|
1621
|
4313
|
|
4314 elseif a:islocal && !s:netrwmftgt_islocal
|
|
4315 " Copy marked files, local directory to remote directory
|
|
4316 " call Decho("copy from local to remote")
|
|
4317 call s:NetrwUpload(s:netrwmarkfilelist_{bufnr('%')},s:netrwmftgt)
|
|
4318
|
|
4319 elseif !a:islocal && s:netrwmftgt_islocal
|
|
4320 " call Decho("copy from remote to local")
|
|
4321 call netrw#NetrwObtain(a:islocal,s:netrwmarkfilelist_{bufnr('%')},s:netrwmftgt)
|
|
4322
|
|
4323 elseif !a:islocal && !s:netrwmftgt_islocal
|
|
4324 " call Decho("copy from remote to remote")
|
|
4325 let curdir = getcwd()
|
|
4326 let tmpdir = s:GetTempfile("")
|
|
4327 if tmpdir !~ '/'
|
|
4328 let tmpdir= curdir."/".tmpdir
|
|
4329 endif
|
|
4330 if exists("*mkdir")
|
|
4331 call mkdir(tmpdir)
|
|
4332 else
|
1668
|
4333 exe "silent! !".g:netrw_local_mkdir.' '.shellescape(tmpdir,1)
|
1621
|
4334 endif
|
|
4335 if isdirectory(tmpdir)
|
|
4336 exe "keepjumps lcd ".fnameescape(tmpdir)
|
|
4337 call netrw#NetrwObtain(a:islocal,s:netrwmarkfilelist_{bufnr('%')},tmpdir)
|
1698
|
4338 let localfiles= map(deepcopy(s:netrwmarkfilelist_{bufnr('%')}),'substitute(v:val,"^.*/","","")')
|
1621
|
4339 call s:NetrwUpload(localfiles,s:netrwmftgt)
|
|
4340 if getcwd() == tmpdir
|
|
4341 for fname in s:netrwmarkfilelist_{bufnr('%')}
|
1668
|
4342 call s:NetrwDelete(fname)
|
1621
|
4343 endfor
|
|
4344 exe "keepjumps lcd ".fnameescape(curdir)
|
1668
|
4345 exe "silent !".g:netrw_local_rmdir." ".shellescape(tmpdir,1)
|
1621
|
4346 else
|
|
4347 exe "keepjumps lcd ".fnameescape(curdir)
|
|
4348 endif
|
|
4349 endif
|
|
4350 endif
|
|
4351
|
|
4352 " -------
|
|
4353 " cleanup
|
|
4354 " -------
|
|
4355 " call Decho("cleanup")
|
|
4356
|
|
4357 " remove markings from local buffer
|
|
4358 call s:NetrwUnmarkList(curbufnr,curdir)
|
|
4359
|
|
4360 " refresh buffers
|
|
4361 if !s:netrwmftgt_islocal
|
|
4362 call s:NetrwRefreshDir(s:netrwmftgt_islocal,s:netrwmftgt)
|
|
4363 endif
|
|
4364 if a:islocal
|
|
4365 call s:NetrwRefreshDir(a:islocal,b:netrw_curdir)
|
|
4366 endif
|
2034
|
4367 if g:netrw_fastbrowse <= 1
|
|
4368 call s:LocalBrowseShellCmdRefresh()
|
|
4369 endif
|
1621
|
4370
|
|
4371 " call Dret("s:NetrwMarkFileCopy 1")
|
|
4372 return 1
|
|
4373 endfun
|
|
4374
|
|
4375 " ---------------------------------------------------------------------
|
|
4376 " s:NetrwMarkFileDiff: (invoked by md) This function is used to {{{2
|
|
4377 " invoke vim's diff mode on the marked files.
|
|
4378 " Either two or three files can be so handled.
|
|
4379 " Uses the global marked file list.
|
|
4380 fun! s:NetrwMarkFileDiff(islocal)
|
|
4381 " call Dfunc("s:NetrwMarkFileDiff(islocal=".a:islocal.") b:netrw_curdir<".b:netrw_curdir.">")
|
|
4382 let curbufnr= bufnr("%")
|
1698
|
4383
|
1621
|
4384 if exists("s:netrwmarkfilelist_{curbufnr}")
|
|
4385 let cnt = 0
|
|
4386 let curdir = b:netrw_curdir
|
|
4387 for fname in s:netrwmarkfilelist
|
|
4388 let cnt= cnt + 1
|
|
4389 if cnt == 1
|
1698
|
4390 " call Decho("diffthis: fname<".fname.">")
|
|
4391 exe "e ".fnameescape(fname)
|
1621
|
4392 diffthis
|
|
4393 elseif cnt == 2 || cnt == 3
|
|
4394 vsplit
|
|
4395 wincmd l
|
|
4396 " call Decho("diffthis: ".fname)
|
1698
|
4397 exe "e ".fnameescape(fname)
|
1621
|
4398 diffthis
|
|
4399 else
|
|
4400 break
|
|
4401 endif
|
|
4402 endfor
|
|
4403 call s:NetrwUnmarkList(curbufnr,curdir)
|
|
4404 endif
|
1698
|
4405
|
1621
|
4406 " call Dret("s:NetrwMarkFileDiff")
|
|
4407 endfun
|
|
4408
|
|
4409 " ---------------------------------------------------------------------
|
|
4410 " s:NetrwMarkFileEdit: (invoked by me) put marked files on arg list and start editing them {{{2
|
|
4411 " Uses global markfilelist
|
|
4412 fun! s:NetrwMarkFileEdit(islocal)
|
|
4413 " call Dfunc("s:NetrwMarkFileEdit(islocal=".a:islocal.")")
|
|
4414
|
|
4415 let curdir = b:netrw_curdir
|
|
4416 let curbufnr = bufnr("%")
|
|
4417 if exists("s:netrwmarkfilelist_{curbufnr}")
|
|
4418 call s:SetRexDir(a:islocal,curdir)
|
1698
|
4419 let flist= join(map(deepcopy(s:netrwmarkfilelist), "fnameescape(v:val)"))
|
1621
|
4420 " unmark markedfile list
|
|
4421 " call s:NetrwUnmarkList(curbufnr,curdir)
|
|
4422 call s:NetrwUnmarkAll()
|
|
4423 " call Decho("exe silent args ".flist)
|
|
4424 exe "silent args ".flist
|
|
4425 endif
|
|
4426
|
|
4427 " call Dret("s:NetrwMarkFileEdit")
|
|
4428 endfun
|
|
4429
|
|
4430 " ---------------------------------------------------------------------
|
|
4431 " s:NetrwMarkFileExe: (invoked by mx) execute arbitrary command on marked files, one at a time {{{2
|
|
4432 " Uses the local marked-file list.
|
|
4433 fun! s:NetrwMarkFileExe(islocal)
|
|
4434 " call Dfunc("s:NetrwMarkFileExe(islocal=".a:islocal.")")
|
|
4435 let svpos = netrw#NetrwSavePosn()
|
|
4436 let curdir = b:netrw_curdir
|
|
4437 let curbufnr = bufnr("%")
|
|
4438
|
|
4439 if exists("s:netrwmarkfilelist_{curbufnr}")
|
|
4440 " get the command
|
|
4441 call inputsave()
|
|
4442 let cmd= input("Enter command: ","","file")
|
|
4443 call inputrestore()
|
|
4444 " call Decho("cmd<".cmd.">")
|
|
4445
|
|
4446 " apply command to marked files. Substitute: filename -> %
|
|
4447 " If no %, then append a space and the filename to the command
|
|
4448 for fname in s:netrwmarkfilelist_{curbufnr}
|
|
4449 if a:islocal
|
|
4450 if g:netrw_keepdir
|
2034
|
4451 let fname= shellescape(netrw#WinPath(s:ComposePath(curdir,fname)))
|
1621
|
4452 endif
|
|
4453 else
|
2034
|
4454 let fname= shellescape(netrw#WinPath(b:netrw_curdir.fname))
|
1621
|
4455 endif
|
|
4456 if cmd =~ '%'
|
|
4457 let xcmd= substitute(cmd,'%',fname,'g')
|
|
4458 else
|
|
4459 let xcmd= cmd.' '.fname
|
|
4460 endif
|
|
4461 if a:islocal
|
|
4462 " call Decho("local: xcmd<".xcmd.">")
|
|
4463 let ret= system(xcmd)
|
|
4464 else
|
|
4465 " call Decho("remote: xcmd<".xcmd.">")
|
|
4466 let ret= s:RemoteSystem(xcmd)
|
|
4467 endif
|
|
4468 if v:shell_error < 0
|
|
4469 call netrw#ErrorMsg(s:ERROR,"command<".xcmd."> failed, aborting",54)
|
|
4470 break
|
|
4471 else
|
|
4472 echo ret
|
|
4473 endif
|
|
4474 endfor
|
|
4475
|
|
4476 " unmark marked file list
|
|
4477 call s:NetrwUnmarkList(curbufnr,curdir)
|
|
4478
|
|
4479 " refresh the listing
|
|
4480 call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
|
|
4481 call netrw#NetrwRestorePosn(svpos)
|
|
4482 else
|
|
4483 call netrw#ErrorMsg(s:ERROR,"no files marked!",59)
|
|
4484 endif
|
|
4485
|
|
4486 " call Dret("s:NetrwMarkFileExe")
|
|
4487 endfun
|
|
4488
|
|
4489 " ---------------------------------------------------------------------
|
|
4490 " s:NetrwMarkHideSfx: (invoked by mh) (un)hide files having same suffix
|
|
4491 " as the marked file(s) (toggles suffix presence)
|
|
4492 " Uses the local marked file list.
|
|
4493 fun! s:NetrwMarkHideSfx(islocal)
|
|
4494 " call Dfunc("s:NetrwMarkHideSfx(islocal=".a:islocal.")")
|
|
4495 let svpos = netrw#NetrwSavePosn()
|
|
4496 let curbufnr = bufnr("%")
|
|
4497
|
|
4498 " s:netrwmarkfilelist_{curbufnr}: the List of marked files
|
|
4499 if exists("s:netrwmarkfilelist_{curbufnr}")
|
|
4500
|
|
4501 for fname in s:netrwmarkfilelist_{curbufnr}
|
|
4502 " call Decho("s:NetrwMarkFileCopy: fname<".fname.">")
|
|
4503 " construct suffix pattern
|
|
4504 if fname =~ '\.'
|
|
4505 let sfxpat= "^.*".substitute(fname,'^.*\(\.[^. ]\+\)$','\1','')
|
|
4506 else
|
|
4507 let sfxpat= '^\%(\%(\.\)\@!.\)*$'
|
|
4508 endif
|
|
4509 " determine if its in the hiding list or not
|
|
4510 let inhidelist= 0
|
|
4511 if g:netrw_list_hide != ""
|
|
4512 let itemnum = 0
|
|
4513 let hidelist= split(g:netrw_list_hide,',')
|
|
4514 for hidepat in hidelist
|
|
4515 if sfxpat == hidepat
|
|
4516 let inhidelist= 1
|
|
4517 break
|
|
4518 endif
|
|
4519 let itemnum= itemnum + 1
|
|
4520 endfor
|
|
4521 endif
|
|
4522 " call Decho("fname<".fname."> inhidelist=".inhidelist." sfxpat<".sfxpat.">")
|
|
4523 if inhidelist
|
|
4524 " remove sfxpat from list
|
|
4525 call remove(hidelist,itemnum)
|
|
4526 let g:netrw_list_hide= join(hidelist,",")
|
|
4527 elseif g:netrw_list_hide != ""
|
|
4528 " append sfxpat to non-empty list
|
|
4529 let g:netrw_list_hide= g:netrw_list_hide.",".sfxpat
|
|
4530 else
|
|
4531 " set hiding list to sfxpat
|
|
4532 let g:netrw_list_hide= sfxpat
|
|
4533 endif
|
|
4534 endfor
|
|
4535
|
|
4536 " refresh the listing
|
|
4537 call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
|
|
4538 call netrw#NetrwRestorePosn(svpos)
|
|
4539 else
|
|
4540 call netrw#ErrorMsg(s:ERROR,"no files marked!",59)
|
|
4541 endif
|
|
4542
|
|
4543 " call Dret("s:NetrwMarkHideSfx")
|
|
4544 endfun
|
|
4545
|
|
4546 " ---------------------------------------------------------------------
|
|
4547 " s:NetrwMarkFileGrep: (invoked by mg) This function applies vimgrep to marked files {{{2
|
|
4548 " Uses the global markfilelist
|
|
4549 fun! s:NetrwMarkFileGrep(islocal)
|
|
4550 " call Dfunc("s:NetrwMarkFileGrep(islocal=".a:islocal.")")
|
|
4551 let svpos = netrw#NetrwSavePosn()
|
|
4552 let curbufnr = bufnr("%")
|
|
4553
|
|
4554 if exists("s:netrwmarkfilelist")
|
|
4555 " call Decho("s:netrwmarkfilelist".string(s:netrwmarkfilelist).">")
|
1698
|
4556 let netrwmarkfilelist= join(map(deepcopy(s:netrwmarkfilelist), "fnameescape(v:val)"))
|
1621
|
4557 call s:NetrwUnmarkAll()
|
|
4558
|
|
4559 " ask user for pattern
|
|
4560 call inputsave()
|
|
4561 let pat= input("Enter pattern: ","")
|
|
4562 call inputrestore()
|
|
4563 if pat !~ '^\s'
|
|
4564 if pat !~ '^/'
|
|
4565 let pat= '/'.pat.'/'
|
|
4566 endif
|
|
4567 let pat= " ".pat
|
|
4568 endif
|
|
4569
|
|
4570 " use vimgrep for both local and remote
|
|
4571 " call Decho("exe vimgrep".pat." ".netrwmarkfilelist)
|
2034
|
4572 try
|
|
4573 exe "noautocmd vimgrep".pat." ".netrwmarkfilelist
|
|
4574 catch /^Vim\%((\a\+)\)\=:E480/
|
|
4575 call netrw#ErrorMsg(s:WARNING,"no match with pattern<".pattern.">",76)
|
|
4576 " call Dret("s:NetrwMarkFileGrep : unable to find pattern<".pattern.">")
|
|
4577 return
|
|
4578 endtry
|
1621
|
4579
|
|
4580 2match none
|
|
4581 call netrw#NetrwRestorePosn(svpos)
|
|
4582 endif
|
|
4583
|
|
4584 " call Dret("s:NetrwMarkFileGrep")
|
|
4585 endfun
|
|
4586
|
|
4587 " ---------------------------------------------------------------------
|
|
4588 " s:NetrwMarkFileMove: (invoked by mm) execute arbitrary command on marked files, one at a time {{{2
|
|
4589 " uses the global marked file list
|
|
4590 " s:netrwmfloc= 0: target directory is remote
|
|
4591 " = 1: target directory is local
|
|
4592 fun! s:NetrwMarkFileMove(islocal)
|
|
4593 " call Dfunc("s:NetrwMarkFileMove(islocal=".a:islocal.")")
|
|
4594 let curdir = b:netrw_curdir
|
|
4595 let curbufnr = bufnr("%")
|
|
4596
|
|
4597 " sanity check
|
|
4598 if !exists("s:netrwmarkfilelist_{bufnr('%')}") || empty(s:netrwmarkfilelist_{bufnr('%')})
|
|
4599 call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66)
|
|
4600 " call Dret("s:NetrwMarkFileMove")
|
|
4601 return
|
|
4602 endif
|
|
4603 " call Decho("sanity chk passed: s:netrwmarkfilelist_".bufnr('%')."<".string(s:netrwmarkfilelist_{bufnr('%')}))
|
|
4604 if !exists("s:netrwmftgt")
|
|
4605 call netrw#ErrorMsg(2,"your marked file target is empty! (:help netrw-mt)",67)
|
|
4606 " call Dret("s:NetrwMarkFileCopy 0")
|
|
4607 return 0
|
|
4608 endif
|
|
4609 " call Decho("sanity chk passed: s:netrwmftgt<".s:netrwmftgt.">")
|
|
4610
|
|
4611 if a:islocal && s:netrwmftgt_islocal
|
|
4612 " move: local -> local
|
|
4613 " call Decho("move from local to local")
|
|
4614 " call Decho("(s:NetrwMarkFileMove) local to local move")
|
|
4615 if executable(g:netrw_localmovecmd)
|
|
4616 for fname in s:netrwmarkfilelist_{bufnr("%")}
|
|
4617 " call Decho("system(".g:netrw_localmovecmd." ".shellescape(fname)." ".shellescape(s:netrwmftgt).")")
|
|
4618 let ret= system(g:netrw_localmovecmd." ".shellescape(fname)." ".shellescape(s:netrwmftgt))
|
|
4619 if v:shell_error < 0
|
|
4620 call netrw#ErrorMsg(s:ERROR,"command<".g:netrw_localmovecmd."> failed, aborting",54)
|
|
4621 break
|
|
4622 endif
|
|
4623 endfor
|
|
4624 else
|
|
4625 call netrw#ErrorMsg(s:ERROR,"command<".g:netrw_localmovecmd."> is not executable!",57)
|
|
4626 endif
|
|
4627
|
|
4628 elseif a:islocal && !s:netrwmftgt_islocal
|
|
4629 " move: local -> remote
|
|
4630 " call Decho("move from local to remote")
|
|
4631 " call Decho("copy")
|
|
4632 let mflist= s:netrwmarkfilelist_{bufnr("%")}
|
|
4633 call s:NetrwMarkFileCopy(a:islocal)
|
|
4634 " call Decho("remove")
|
|
4635 for fname in mflist
|
|
4636 let barefname = substitute(fname,'^\(.*/\)\(.\{-}\)$','\2','')
|
|
4637 let ok = s:NetrwLocalRmFile(b:netrw_curdir,barefname,1)
|
|
4638 endfor
|
|
4639 unlet mflist
|
|
4640
|
|
4641 elseif !a:islocal && s:netrwmftgt_islocal
|
|
4642 " move: remote -> local
|
|
4643 " call Decho("move from remote to local")
|
|
4644 " call Decho("copy")
|
|
4645 let mflist= s:netrwmarkfilelist_{bufnr("%")}
|
|
4646 call s:NetrwMarkFileCopy(a:islocal)
|
|
4647 " call Decho("remove")
|
|
4648 for fname in mflist
|
|
4649 let barefname = substitute(fname,'^\(.*/\)\(.\{-}\)$','\2','')
|
|
4650 let ok = s:NetrwRemoteRmFile(b:netrw_curdir,barefname,1)
|
|
4651 endfor
|
|
4652 unlet mflist
|
|
4653
|
|
4654 elseif !a:islocal && !s:netrwmftgt_islocal
|
|
4655 " move: remote -> remote
|
|
4656 " call Decho("move from remote to remote")
|
|
4657 " call Decho("copy")
|
|
4658 let mflist= s:netrwmarkfilelist_{bufnr("%")}
|
|
4659 call s:NetrwMarkFileCopy(a:islocal)
|
|
4660 " call Decho("remove")
|
|
4661 for fname in mflist
|
|
4662 let barefname = substitute(fname,'^\(.*/\)\(.\{-}\)$','\2','')
|
|
4663 let ok = s:NetrwRemoteRmFile(b:netrw_curdir,barefname,1)
|
|
4664 endfor
|
|
4665 unlet mflist
|
|
4666 endif
|
|
4667
|
|
4668 " -------
|
|
4669 " cleanup
|
|
4670 " -------
|
|
4671 " call Decho("cleanup")
|
|
4672
|
|
4673 " remove markings from local buffer
|
|
4674 call s:NetrwUnmarkList(curbufnr,curdir) " remove markings from local buffer
|
|
4675
|
|
4676 " refresh buffers
|
|
4677 if !s:netrwmftgt_islocal
|
|
4678 call s:NetrwRefreshDir(s:netrwmftgt_islocal,s:netrwmftgt)
|
|
4679 endif
|
|
4680 if a:islocal
|
|
4681 call s:NetrwRefreshDir(a:islocal,b:netrw_curdir)
|
|
4682 endif
|
2034
|
4683 if g:netrw_fastbrowse <= 1
|
|
4684 call s:LocalBrowseShellCmdRefresh()
|
|
4685 endif
|
1621
|
4686
|
|
4687 " call Dret("s:NetrwMarkFileMove")
|
|
4688 endfun
|
|
4689
|
|
4690 " ---------------------------------------------------------------------
|
|
4691 " s:NetrwMarkFilePrint: (invoked by mp) This function prints marked files {{{2
|
|
4692 " using the hardcopy command. Local marked-file list only.
|
|
4693 fun! s:NetrwMarkFilePrint(islocal)
|
|
4694 " call Dfunc("s:NetrwMarkFilePrint(islocal=".a:islocal.")")
|
|
4695 let curbufnr= bufnr("%")
|
|
4696 if exists("s:netrwmarkfilelist_{curbufnr}")
|
|
4697 let netrwmarkfilelist = s:netrwmarkfilelist_{curbufnr}
|
|
4698 let curdir = b:netrw_curdir
|
|
4699 call s:NetrwUnmarkList(curbufnr,curdir)
|
|
4700 for fname in netrwmarkfilelist
|
|
4701 if a:islocal
|
|
4702 if g:netrw_keepdir
|
|
4703 let fname= s:ComposePath(curdir,fname)
|
|
4704 endif
|
|
4705 else
|
|
4706 let fname= curdir.fname
|
|
4707 endif
|
|
4708 1split
|
|
4709 " the autocmds will handle both local and remote files
|
|
4710 " call Decho("exe silent e ".escape(fname,' '))
|
1698
|
4711 exe "silent e ".fnameescape(fname)
|
1621
|
4712 " call Decho("hardcopy")
|
|
4713 hardcopy
|
|
4714 q
|
|
4715 endfor
|
|
4716 2match none
|
|
4717 endif
|
|
4718 " call Dret("s:NetrwMarkFilePrint")
|
|
4719 endfun
|
|
4720
|
|
4721 " ---------------------------------------------------------------------
|
|
4722 " s:NetrwMarkFileRegexp: (invoked by mr) This function is used to mark {{{2
|
|
4723 " files when given a regexp (for which a prompt is
|
|
4724 " issued).
|
|
4725 fun! s:NetrwMarkFileRegexp(islocal)
|
|
4726 " call Dfunc("s:NetrwMarkFileRegexp(islocal=".a:islocal.")")
|
|
4727
|
|
4728 " get the regular expression
|
|
4729 call inputsave()
|
|
4730 let regexp= input("Enter regexp: ","","file")
|
|
4731 call inputrestore()
|
|
4732
|
|
4733 if a:islocal
|
|
4734 " get the matching list of files using local glob()
|
|
4735 " call Decho("handle local regexp")
|
|
4736 let dirname = escape(b:netrw_curdir,g:netrw_glob_escape)
|
2034
|
4737 let files = glob(s:ComposePath(dirname,regexp))
|
|
4738 " call Decho("files<".files.">")
|
|
4739 let filelist= split(files,"\n")
|
1621
|
4740
|
|
4741 " mark the list of files
|
2034
|
4742 for fname in filelist
|
|
4743 " call Decho("fname<".fname.">")
|
|
4744 call s:NetrwMarkFile(a:islocal,substitute(fname,'^.*/','',''))
|
|
4745 endfor
|
1621
|
4746
|
|
4747 else
|
|
4748 " call Decho("handle remote regexp")
|
|
4749
|
|
4750 " convert displayed listing into a filelist
|
|
4751 let eikeep = &ei
|
|
4752 let areg = @a
|
|
4753 silent %y a
|
|
4754 set ei=all ma
|
|
4755 " call Decho("set ei=all ma")
|
|
4756 1split
|
2034
|
4757 call s:NetrwEnew()
|
|
4758 call s:NetrwSafeOptions()
|
1621
|
4759 silent norm! "ap
|
|
4760 2
|
|
4761 let bannercnt= search('^" =====','W')
|
|
4762 exe "silent 1,".bannercnt."d"
|
|
4763 set bt=nofile
|
|
4764 if g:netrw_liststyle == s:LONGLIST
|
|
4765 silent %s/\s\{2,}\S.*$//e
|
2034
|
4766 call histdel("/",-1)
|
1621
|
4767 elseif g:netrw_liststyle == s:WIDELIST
|
|
4768 silent %s/\s\{2,}/\r/ge
|
2034
|
4769 call histdel("/",-1)
|
1621
|
4770 elseif g:netrw_liststyle == s:TREELIST
|
|
4771 silent %s/^| //e
|
|
4772 silent! g/^ .*$/d
|
2034
|
4773 call histdel("/",-1)
|
|
4774 call histdel("/",-1)
|
1621
|
4775 endif
|
|
4776 " convert regexp into the more usual glob-style format
|
|
4777 let regexp= substitute(regexp,'\*','.*','g')
|
|
4778 " call Decho("regexp<".regexp.">")
|
|
4779 exe "silent! v/".escape(regexp,'/')."/d"
|
2034
|
4780 call histdel("/",-1)
|
1621
|
4781 let filelist= getline(1,line("$"))
|
|
4782 q!
|
|
4783 for filename in filelist
|
|
4784 call s:NetrwMarkFile(a:islocal,substitute(filename,'^.*/','',''))
|
|
4785 endfor
|
|
4786 unlet filelist
|
|
4787 let @a = areg
|
|
4788 let &ei = eikeep
|
|
4789 endif
|
|
4790
|
|
4791 " call Dret("s:NetrwMarkFileRegexp")
|
|
4792 endfun
|
|
4793
|
|
4794 " ---------------------------------------------------------------------
|
|
4795 " s:NetrwMarkFileSource: (invoked by ms) This function sources marked files {{{2
|
|
4796 " Uses the local marked file list.
|
|
4797 fun! s:NetrwMarkFileSource(islocal)
|
|
4798 " call Dfunc("s:NetrwMarkFileSource(islocal=".a:islocal.")")
|
|
4799 let curbufnr= bufnr("%")
|
|
4800 if exists("s:netrwmarkfilelist_{curbufnr}")
|
|
4801 let netrwmarkfilelist = s:netrwmarkfilelist_{bufnr("%")}
|
|
4802 let curdir = b:netrw_curdir
|
|
4803 call s:NetrwUnmarkList(curbufnr,curdir)
|
|
4804 for fname in netrwmarkfilelist
|
|
4805 if a:islocal
|
|
4806 if g:netrw_keepdir
|
|
4807 let fname= s:ComposePath(curdir,fname)
|
|
4808 endif
|
|
4809 else
|
|
4810 let fname= curdir.fname
|
|
4811 endif
|
|
4812 " the autocmds will handle sourcing both local and remote files
|
1668
|
4813 " call Decho("exe so ".fnameescape(fname))
|
|
4814 exe "so ".fnameescape(fname)
|
1621
|
4815 endfor
|
|
4816 2match none
|
|
4817 endif
|
|
4818 " call Dret("s:NetrwMarkFileSource")
|
|
4819 endfun
|
|
4820
|
|
4821 " ---------------------------------------------------------------------
|
|
4822 " s:NetrwMarkFileTag: (invoked by mT) This function applies g:netrw_ctags to marked files {{{2
|
|
4823 " Uses the global markfilelist
|
|
4824 fun! s:NetrwMarkFileTag(islocal)
|
|
4825 " call Dfunc("s:NetrwMarkFileTag(islocal=".a:islocal.")")
|
|
4826 let svpos = netrw#NetrwSavePosn()
|
|
4827 let curdir = b:netrw_curdir
|
|
4828 let curbufnr = bufnr("%")
|
|
4829
|
|
4830 if exists("s:netrwmarkfilelist")
|
|
4831 " call Decho("s:netrwmarkfilelist".string(s:netrwmarkfilelist).">")
|
1698
|
4832 let netrwmarkfilelist= join(map(deepcopy(s:netrwmarkfilelist), "shellescape(v:val,".!a:islocal.")"))
|
1621
|
4833 call s:NetrwUnmarkAll()
|
|
4834
|
|
4835 if a:islocal
|
|
4836 if executable(g:netrw_ctags)
|
|
4837 " call Decho("call system(".g:netrw_ctags." ".netrwmarkfilelist.")")
|
|
4838 call system(g:netrw_ctags." ".netrwmarkfilelist)
|
|
4839 else
|
|
4840 call netrw#ErrorMsg(s:ERROR,"g:netrw_ctags<".g:netrw_ctags."> is not executable!",51)
|
|
4841 endif
|
|
4842 else
|
1668
|
4843 let cmd = s:RemoteSystem(g:netrw_ctags." ".netrwmarkfilelist)
|
1621
|
4844 call netrw#NetrwObtain(a:islocal,"tags")
|
|
4845 let curdir= b:netrw_curdir
|
|
4846 1split
|
|
4847 e tags
|
|
4848 let path= substitute(curdir,'^\(.*\)/[^/]*$','\1/','')
|
|
4849 " call Decho("curdir<".curdir."> path<".path.">")
|
1698
|
4850 exe '%s/\t\(\S\+\)\t/\t'.escape(path,"/\n\r\\").'\1\t/e'
|
2034
|
4851 call histdel("/",-1)
|
1621
|
4852 wq!
|
|
4853 endif
|
|
4854 2match none
|
|
4855 call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
|
|
4856 call netrw#NetrwRestorePosn(svpos)
|
|
4857 endif
|
|
4858
|
|
4859 " call Dret("s:NetrwMarkFileTag")
|
|
4860 endfun
|
|
4861
|
|
4862 " ---------------------------------------------------------------------
|
|
4863 " s:NetrwMarkFileTgt: (invoked by mt) This function sets up a marked file target {{{2
|
|
4864 " Sets up two variables,
|
|
4865 " s:netrwmftgt : holds the target directory
|
|
4866 " s:netrwmftgt_islocal : 0=target directory is remote
|
|
4867 " 1=target directory is local
|
|
4868 fun! s:NetrwMarkFileTgt(islocal)
|
|
4869 " call Dfunc("s:NetrwMarkFileTgt(islocal=".a:islocal.")")
|
|
4870 let svpos = netrw#NetrwSavePosn()
|
|
4871 let curdir = b:netrw_curdir
|
|
4872 let hadtgt = exists("s:netrwmftgt")
|
|
4873 if !exists("w:netrw_bannercnt")
|
|
4874 let w:netrw_bannercnt= b:netrw_bannercnt
|
|
4875 endif
|
|
4876
|
|
4877 " set up target
|
|
4878 if line(".") < w:netrw_bannercnt
|
|
4879 " if cursor in banner region, use b:netrw_curdir for the target
|
|
4880 let s:netrwmftgt= b:netrw_curdir
|
|
4881 " call Decho("inbanner: s:netrwmftgt<".s:netrwmftgt.">")
|
|
4882
|
|
4883 else
|
|
4884 " get word under cursor.
|
|
4885 " * If directory, use it for the target.
|
|
4886 " * If file, use b:netrw_curdir for the target
|
|
4887 let curword= s:NetrwGetWord()
|
|
4888 let tgtdir = s:ComposePath(curdir,curword)
|
|
4889 if a:islocal && isdirectory(tgtdir)
|
|
4890 let s:netrwmftgt = tgtdir
|
|
4891 " call Decho("local isdir: s:netrwmftgt<".s:netrwmftgt.">")
|
|
4892 elseif !a:islocal && tgtdir =~ '/$'
|
|
4893 let s:netrwmftgt = tgtdir
|
|
4894 " call Decho("remote isdir: s:netrwmftgt<".s:netrwmftgt.">")
|
|
4895 else
|
|
4896 let s:netrwmftgt = curdir
|
|
4897 " call Decho("isfile: s:netrwmftgt<".s:netrwmftgt.">")
|
|
4898 endif
|
|
4899 endif
|
|
4900 if a:islocal
|
|
4901 " simplify the target (eg. /abc/def/../ghi -> /abc/ghi)
|
|
4902 let s:netrwmftgt= simplify(s:netrwmftgt)
|
|
4903 " call Decho("simplify: s:netrwmftgt<".s:netrwmftgt.">")
|
|
4904 endif
|
|
4905 if g:netrw_cygwin
|
|
4906 let s:netrwmftgt= substitute(system("cygpath ".shellescape(s:netrwmftgt)),'\n$','','')
|
|
4907 let s:netrwmftgt= substitute(s:netrwmftgt,'\n$','','')
|
|
4908 endif
|
|
4909 let s:netrwmftgt_islocal= a:islocal
|
|
4910
|
2034
|
4911 if g:netrw_fastbrowse <= 1
|
1621
|
4912 call s:LocalBrowseShellCmdRefresh()
|
|
4913 endif
|
|
4914 call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
|
|
4915 call netrw#NetrwRestorePosn(svpos)
|
|
4916 if !hadtgt
|
|
4917 norm! j
|
|
4918 endif
|
|
4919
|
|
4920 " call Dret("s:NetrwMarkFileTgt : netrwmftgt<".(exists("s:netrwmftgt")? s:netrwmftgt : "").">")
|
|
4921 endfun
|
|
4922
|
|
4923 " ---------------------------------------------------------------------
|
1668
|
4924 " s:NetrwOpenFile: query user for a filename and open it {{{2
|
|
4925 fun! s:NetrwOpenFile(islocal)
|
|
4926 " call Dfunc("s:NetrwOpenFile(islocal=".a:islocal.")")
|
|
4927 call inputsave()
|
|
4928 let fname= input("Enter filename: ")
|
|
4929 call inputrestore()
|
|
4930 if fname !~ '[/\\]'
|
|
4931 if exists("b:netrw_curdir")
|
|
4932 if exists("g:netrw_quiet")
|
|
4933 let netrw_quiet_keep = g:netrw_quiet
|
|
4934 endif
|
|
4935 let g:netrw_quiet = 1
|
|
4936 if b:netrw_curdir =~ '/$'
|
|
4937 exe "e ".fnameescape(b:netrw_curdir.fname)
|
|
4938 else
|
|
4939 exe "e ".fnameescape(b:netrw_curdir."/".fname)
|
|
4940 endif
|
|
4941 if exists("netrw_quiet_keep")
|
|
4942 let g:netrw_quiet= netrw_quiet_keep
|
|
4943 else
|
|
4944 unlet g:netrw_quiet
|
|
4945 endif
|
|
4946 endif
|
|
4947 else
|
|
4948 exe "e ".fnameescape(fname)
|
|
4949 endif
|
|
4950 " call Dret("s:NetrwOpenFile")
|
|
4951 endfun
|
|
4952
|
|
4953 " ---------------------------------------------------------------------
|
1621
|
4954 " s:NetrwUnmarkList: delete local marked file lists and remove their contents from the global marked-file list {{{2
|
|
4955 fun! s:NetrwUnmarkList(curbufnr,curdir)
|
|
4956 " call Dfunc("s:NetrwUnmarkList(curbufnr=".a:curbufnr." curdir<".a:curdir.">)")
|
|
4957
|
|
4958 " remove all files in local marked-file list from global list
|
|
4959 if exists("s:netrwmarkfilelist_{a:curbufnr}")
|
|
4960 for mfile in s:netrwmarkfilelist_{a:curbufnr}
|
|
4961 let dfile = s:ComposePath(a:curdir,mfile) " prepend directory to mfile
|
|
4962 let idx = index(s:netrwmarkfilelist,dfile) " get index in list of dfile
|
|
4963 call remove(s:netrwmarkfilelist,idx) " remove from global list
|
|
4964 endfor
|
|
4965 if s:netrwmarkfilelist == []
|
|
4966 unlet s:netrwmarkfilelist
|
|
4967 endif
|
|
4968
|
|
4969 " getting rid of the local marked-file lists is easy
|
|
4970 unlet s:netrwmarkfilelist_{a:curbufnr}
|
|
4971 endif
|
|
4972 if exists("s:netrwmarkfilemtch_{a:curbufnr}")
|
|
4973 unlet s:netrwmarkfilemtch_{a:curbufnr}
|
|
4974 endif
|
|
4975 2match none
|
|
4976 " call Dret("s:NetrwUnmarkList")
|
|
4977 endfun
|
|
4978
|
|
4979 " ---------------------------------------------------------------------
|
|
4980 " s:NetrwUnmarkAll: remove the global marked file list and all local ones {{{2
|
|
4981 fun! s:NetrwUnmarkAll()
|
|
4982 " call Dfunc("s:NetrwUnmarkAll()")
|
|
4983 if exists("s:netrwmarkfilelist")
|
|
4984 unlet s:netrwmarkfilelist
|
|
4985 endif
|
|
4986 silent call s:NetrwUnmarkAll2()
|
|
4987 2match none
|
|
4988 " call Dret("s:NetrwUnmarkAll")
|
|
4989 endfun
|
|
4990
|
|
4991 " ---------------------------------------------------------------------
|
|
4992 " s:NetrwUnmarkAll2: {{{2
|
|
4993 fun! s:NetrwUnmarkAll2()
|
|
4994 " call Dfunc("s:NetrwUnmarkAll2()")
|
|
4995 redir => netrwmarkfilelist_let
|
|
4996 let
|
|
4997 redir END
|
|
4998 let netrwmarkfilelist_list= split(netrwmarkfilelist_let,'\n') " convert let string into a let list
|
|
4999 call filter(netrwmarkfilelist_list,"v:val =~ '^s:netrwmarkfilelist_'") " retain only those vars that start as s:netrwmarkfilelist_
|
|
5000 call map(netrwmarkfilelist_list,"substitute(v:val,'\\s.*$','','')") " remove what the entries are equal to
|
|
5001 for flist in netrwmarkfilelist_list
|
|
5002 let curbufnr= substitute(flist,'s:netrwmarkfilelist_','','')
|
|
5003 unlet s:netrwmarkfilelist_{curbufnr}
|
|
5004 unlet s:netrwmarkfilemtch_{curbufnr}
|
|
5005 endfor
|
|
5006 " call Dret("s:NetrwUnmarkAll2")
|
|
5007 endfun
|
|
5008
|
|
5009 " ---------------------------------------------------------------------
|
|
5010 " s:NetrwUnMarkFile: {{{2
|
|
5011 fun! s:NetrwUnMarkFile(islocal)
|
|
5012 " call Dfunc("s:NetrwUnMarkFile(islocal=".a:islocal.")")
|
|
5013 let svpos = netrw#NetrwSavePosn()
|
|
5014 let curbufnr = bufnr("%")
|
|
5015
|
|
5016 " unmark marked file list (although I expect s:NetrwUpload()
|
|
5017 " to do it, I'm just making sure)
|
|
5018 if exists("s:netrwmarkfilelist_{bufnr('%')}")
|
|
5019 " call Decho("unlet'ing: s:netrwmarkfile[list|mtch]_".bufnr("%"))
|
|
5020 unlet s:netrwmarkfilelist
|
|
5021 unlet s:netrwmarkfilelist_{curbufnr}
|
|
5022 unlet s:netrwmarkfilemtch_{curbufnr}
|
|
5023 2match none
|
|
5024 endif
|
|
5025
|
|
5026 " call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
|
|
5027 call netrw#NetrwRestorePosn(svpos)
|
|
5028 " call Dret("s:NetrwUnMarkFile")
|
1121
|
5029 endfun
|
|
5030
|
|
5031 " ---------------------------------------------------------------------
|
1621
|
5032 " s:NetrwMenu: generates the menu for gvim and netrw {{{2
|
|
5033 fun! s:NetrwMenu(domenu)
|
|
5034
|
|
5035 if !exists("g:NetrwMenuPriority")
|
|
5036 let g:NetrwMenuPriority= 80
|
|
5037 endif
|
|
5038
|
|
5039 if has("menu") && has("gui_running") && &go =~ 'm' && g:netrw_menu
|
|
5040 " call Dfunc("NetrwMenu(domenu=".a:domenu.")")
|
|
5041
|
|
5042 if !exists("s:netrw_menu_enabled") && a:domenu
|
|
5043 " call Decho("initialize menu")
|
|
5044 let s:netrw_menu_enabled= 1
|
|
5045 exe 'silent! menu '.g:NetrwMenuPriority.'.1 '.g:NetrwTopLvlMenu.'Help<tab><F1> <F1>'
|
|
5046 exe 'silent! menu '.g:NetrwMenuPriority.'.5 '.g:NetrwTopLvlMenu.'-Sep1- :'
|
|
5047 exe 'silent! menu '.g:NetrwMenuPriority.'.6 '.g:NetrwTopLvlMenu.'Go\ Up\ Directory<tab>- -'
|
|
5048 exe 'silent! menu '.g:NetrwMenuPriority.'.7 '.g:NetrwTopLvlMenu.'Apply\ Special\ Viewer<tab>x x'
|
|
5049 exe 'silent! menu '.g:NetrwMenuPriority.'.8.1 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Bookmark\ Current\ Directory<tab>mb mb'
|
|
5050 exe 'silent! menu '.g:NetrwMenuPriority.'.8.4 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Goto\ Prev\ Dir\ (History)<tab>u u'
|
|
5051 exe 'silent! menu '.g:NetrwMenuPriority.'.8.5 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Goto\ Next\ Dir\ (History)<tab>U U'
|
|
5052 exe 'silent! menu '.g:NetrwMenuPriority.'.8.6 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.List<tab>qb qb'
|
2034
|
5053 exe 'silent! menu '.g:NetrwMenuPriority.'.9.1 '.g:NetrwTopLvlMenu.'Browsing\ Control.Edit\ File\ Hiding\ List<tab><ctrl-h>'." \<c-h>'"
|
1621
|
5054 exe 'silent! menu '.g:NetrwMenuPriority.'.9.2 '.g:NetrwTopLvlMenu.'Browsing\ Control.Edit\ Sorting\ Sequence<tab>S S'
|
|
5055 exe 'silent! menu '.g:NetrwMenuPriority.'.9.3 '.g:NetrwTopLvlMenu.'Browsing\ Control.Quick\ Hide/Unhide\ Dot\ Files<tab>'."gh gh"
|
2034
|
5056 exe 'silent! menu '.g:NetrwMenuPriority.'.9.4 '.g:NetrwTopLvlMenu.'Browsing\ Control.Refresh\ Listing<tab>'."<ctrl-l> \<c-l>"
|
1621
|
5057 exe 'silent! menu '.g:NetrwMenuPriority.'.9.5 '.g:NetrwTopLvlMenu.'Browsing\ Control.Settings/Options<tab>:NetrwSettings '.":NetrwSettings\<cr>"
|
|
5058 exe 'silent! menu '.g:NetrwMenuPriority.'.10 '.g:NetrwTopLvlMenu.'Delete\ File/Directory<tab>D D'
|
|
5059 exe 'silent! menu '.g:NetrwMenuPriority.'.11.1 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ Current\ Window<tab><cr> '."\<cr>"
|
|
5060 exe 'silent! menu '.g:NetrwMenuPriority.'.11.2 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.Preview\ File/Directory<tab>p p'
|
|
5061 exe 'silent! menu '.g:NetrwMenuPriority.'.11.3 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ Previous\ Window<tab>P P'
|
|
5062 exe 'silent! menu '.g:NetrwMenuPriority.'.11.4 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ New\ Window<tab>o o'
|
|
5063 exe 'silent! menu '.g:NetrwMenuPriority.'.11.5 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ New\ Vertical\ Window<tab>v v'
|
|
5064 exe 'silent! menu '.g:NetrwMenuPriority.'.12.1 '.g:NetrwTopLvlMenu.'Explore.Directory\ Name :Explore '
|
|
5065 exe 'silent! menu '.g:NetrwMenuPriority.'.12.2 '.g:NetrwTopLvlMenu.'Explore.Filenames\ Matching\ Pattern\ (curdir\ only)<tab>:Explore\ */ :Explore */'
|
|
5066 exe 'silent! menu '.g:NetrwMenuPriority.'.12.2 '.g:NetrwTopLvlMenu.'Explore.Filenames\ Matching\ Pattern\ (+subdirs)<tab>:Explore\ **/ :Explore **/'
|
2034
|
5067 exe 'silent! menu '.g:NetrwMenuPriority.'.12.3 '.g:NetrwTopLvlMenu.'Explore.Files\ Containing\ String\ Pattern\ (curdir\ only)<tab>:Explore\ *// :Explore *//'
|
|
5068 exe 'silent! menu '.g:NetrwMenuPriority.'.12.4 '.g:NetrwTopLvlMenu.'Explore.Files\ Containing\ String\ Pattern\ (+subdirs)<tab>:Explore\ **// :Explore **//'
|
1621
|
5069 exe 'silent! menu '.g:NetrwMenuPriority.'.12.4 '.g:NetrwTopLvlMenu.'Explore.Next\ Match<tab>:Nexplore :Nexplore<cr>'
|
|
5070 exe 'silent! menu '.g:NetrwMenuPriority.'.12.4 '.g:NetrwTopLvlMenu.'Explore.Prev\ Match<tab>:Pexplore :Pexplore<cr>'
|
|
5071 exe 'silent! menu '.g:NetrwMenuPriority.'.13 '.g:NetrwTopLvlMenu.'Make\ Subdirectory<tab>d d'
|
|
5072 exe 'silent! menu '.g:NetrwMenuPriority.'.14.1 '.g:NetrwTopLvlMenu.'Marked\ Files.Mark\ File<tab>mf mf'
|
|
5073 exe 'silent! menu '.g:NetrwMenuPriority.'.14.2 '.g:NetrwTopLvlMenu.'Marked\ Files.Mark\ Files\ by\ Regexp<tab>mr mr'
|
|
5074 exe 'silent! menu '.g:NetrwMenuPriority.'.14.3 '.g:NetrwTopLvlMenu.'Marked\ Files.Hide-Show-List\ Control<tab>a a'
|
|
5075 exe 'silent! menu '.g:NetrwMenuPriority.'.14.4 '.g:NetrwTopLvlMenu.'Marked\ Files.Copy\ To\ Target<tab>mc mc'
|
|
5076 exe 'silent! menu '.g:NetrwMenuPriority.'.14.5 '.g:NetrwTopLvlMenu.'Marked\ Files.Delete<tab>D D'
|
|
5077 exe 'silent! menu '.g:NetrwMenuPriority.'.14.6 '.g:NetrwTopLvlMenu.'Marked\ Files.Diff<tab>md md'
|
|
5078 exe 'silent! menu '.g:NetrwMenuPriority.'.14.7 '.g:NetrwTopLvlMenu.'Marked\ Files.Edit<tab>me me'
|
|
5079 exe 'silent! menu '.g:NetrwMenuPriority.'.14.8 '.g:NetrwTopLvlMenu.'Marked\ Files.Exe\ Cmd<tab>mx mx'
|
|
5080 exe 'silent! menu '.g:NetrwMenuPriority.'.14.9 '.g:NetrwTopLvlMenu.'Marked\ Files.Move\ To\ Target<tab>mm mm'
|
|
5081 exe 'silent! menu '.g:NetrwMenuPriority.'.14.10 '.g:NetrwTopLvlMenu.'Marked\ Files.Obtain<tab>O O'
|
|
5082 exe 'silent! menu '.g:NetrwMenuPriority.'.14.11 '.g:NetrwTopLvlMenu.'Marked\ Files.Print<tab>mp mp'
|
|
5083 exe 'silent! menu '.g:NetrwMenuPriority.'.14.12 '.g:NetrwTopLvlMenu.'Marked\ Files.Replace<tab>R R'
|
|
5084 exe 'silent! menu '.g:NetrwMenuPriority.'.14.13 '.g:NetrwTopLvlMenu.'Marked\ Files.Set\ Target<tab>mt mt'
|
|
5085 exe 'silent! menu '.g:NetrwMenuPriority.'.14.14 '.g:NetrwTopLvlMenu.'Marked\ Files.Tag<tab>mT mT'
|
|
5086 exe 'silent! menu '.g:NetrwMenuPriority.'.14.15 '.g:NetrwTopLvlMenu.'Marked\ Files.Zip/Unzip/Compress/Uncompress<tab>mz mz'
|
|
5087 exe 'silent! menu '.g:NetrwMenuPriority.'.15 '.g:NetrwTopLvlMenu.'Obtain\ File<tab>O O'
|
|
5088 exe 'silent! menu '.g:NetrwMenuPriority.'.16.1 '.g:NetrwTopLvlMenu.'Style.Listing\ Style\ (thin-long-wide-tree)<tab>i i'
|
|
5089 exe 'silent! menu '.g:NetrwMenuPriority.'.16.2 '.g:NetrwTopLvlMenu.'Style.Normal-Hide-Show<tab>a a'
|
|
5090 exe 'silent! menu '.g:NetrwMenuPriority.'.16.3 '.g:NetrwTopLvlMenu.'Style.Reverse\ Sorting\ Order<tab>'."r r"
|
|
5091 exe 'silent! menu '.g:NetrwMenuPriority.'.16.4 '.g:NetrwTopLvlMenu.'Style.Sorting\ Method\ (name-time-size)<tab>s s'
|
|
5092 exe 'silent! menu '.g:NetrwMenuPriority.'.17 '.g:NetrwTopLvlMenu.'Rename\ File/Directory<tab>R R'
|
|
5093 exe 'silent! menu '.g:NetrwMenuPriority.'.18 '.g:NetrwTopLvlMenu.'Set\ Current\ Directory<tab>c c'
|
2034
|
5094 call s:NetrwBookmarkMenu() " provide some history! uses priorities 2,3, reserves 4, 8.2.x
|
1621
|
5095 let s:netrw_menucnt= 28
|
|
5096
|
|
5097 elseif !a:domenu
|
|
5098 let s:netrwcnt = 0
|
|
5099 let curwin = winnr()
|
|
5100 windo if getline(2) =~ "Netrw" | let s:netrwcnt= s:netrwcnt + 1 | endif
|
|
5101 exe curwin."wincmd w"
|
|
5102
|
|
5103 if s:netrwcnt <= 1
|
|
5104 " call Decho("clear menus")
|
|
5105 exe 'silent! unmenu '.g:NetrwTopLvlMenu
|
|
5106 " call Decho('exe silent! unmenu '.g:NetrwTopLvlMenu.'*')
|
|
5107 silent! unlet s:netrw_menu_enabled
|
|
5108 endif
|
|
5109 endif
|
|
5110 " call Dret("NetrwMenu")
|
|
5111 endif
|
|
5112
|
|
5113 endfun
|
|
5114
|
|
5115 " ---------------------------------------------------------------------
|
|
5116 " s:NetrwObtain: obtain file under cursor or from markfile list {{{2
|
|
5117 " Used by the O maps (as <SID>NetrwObtain())
|
|
5118 fun! s:NetrwObtain(islocal)
|
|
5119 " call Dfunc("NetrwObtain(islocal=".a:islocal.")")
|
|
5120
|
|
5121 if exists("s:netrwmarkfilelist_{bufnr('%')}")
|
2034
|
5122 let islocal= s:netrwmarkfilelist_{bufnr('%')}[1] !~ '^\a\+://'
|
|
5123 call netrw#NetrwObtain(islocal,s:netrwmarkfilelist_{bufnr('%')})
|
1621
|
5124 call s:NetrwUnmarkList(bufnr('%'),b:netrw_curdir)
|
|
5125 else
|
|
5126 call netrw#NetrwObtain(a:islocal,expand("<cWORD>"))
|
|
5127 endif
|
|
5128
|
|
5129 " call Dret("NetrwObtain")
|
|
5130 endfun
|
|
5131
|
|
5132 " ---------------------------------------------------------------------
|
|
5133 " netrw#NetrwObtain: {{{2
|
|
5134 " netrw#NetrwObtain(islocal,fname[,tgtdirectory])
|
|
5135 " islocal=0 obtain from remote source
|
|
5136 " =1 obtain from local source
|
|
5137 " fname : a filename or a list of filenames
|
|
5138 " tgtdir : optional place where files are to go (not present, uses getcwd())
|
|
5139 fun! netrw#NetrwObtain(islocal,fname,...)
|
|
5140 " call Dfunc("netrw#NetrwObtain(islocal=".a:islocal." fname<".((type(a:fname) == 1)? a:fname : string(a:fname)).">) a:0=".a:0)
|
|
5141 " NetrwStatusLine support - for obtaining support
|
|
5142
|
|
5143 if type(a:fname) == 1
|
|
5144 let fnamelist= [ a:fname ]
|
|
5145 elseif type(a:fname) == 3
|
|
5146 let fnamelist= a:fname
|
|
5147 else
|
|
5148 call netrw#ErrorMsg(s:ERROR,"attempting to use NetrwObtain on something not a filename or a list",62)
|
|
5149 " call Dret("netrw#NetrwObtain")
|
|
5150 return
|
|
5151 endif
|
|
5152 " call Decho("fnamelist<".string(fnamelist).">")
|
|
5153 if a:0 > 0
|
|
5154 let tgtdir= a:1
|
|
5155 else
|
|
5156 let tgtdir= getcwd()
|
|
5157 endif
|
|
5158 " call Decho("tgtdir<".tgtdir.">")
|
|
5159
|
2034
|
5160 if exists("b:netrw_islocal") && b:netrw_islocal
|
1702
|
5161 " obtain a file from local b:netrw_curdir to (local) tgtdir
|
|
5162 " call Decho("obtain a file from local ".b:netrw_curdir." to ".tgtdir)
|
1621
|
5163 if exists("b:netrw_curdir") && getcwd() != b:netrw_curdir
|
|
5164 let topath= s:ComposePath(tgtdir,"")
|
|
5165 if (has("win32") || has("win95") || has("win64") || has("win16"))
|
|
5166 " transfer files one at time
|
1702
|
5167 " call Decho("transfer files one at a time")
|
1621
|
5168 for fname in fnamelist
|
1668
|
5169 " call Decho("system(".g:netrw_localcopycmd." ".shellescape(fname)." ".shellescape(topath).")")
|
|
5170 call system(g:netrw_localcopycmd." ".shellescape(fname)." ".shellescape(topath))
|
1621
|
5171 endfor
|
|
5172 else
|
|
5173 " transfer files with one command
|
1702
|
5174 " call Decho("transfer files with one command")
|
|
5175 let filelist= join(map(deepcopy(fnamelist),"shellescape(v:val)"))
|
1621
|
5176 " call Decho("system(".g:netrw_localcopycmd." ".filelist." ".shellescape(topath).")")
|
|
5177 call system(g:netrw_localcopycmd." ".filelist." ".shellescape(topath))
|
|
5178 endif
|
|
5179 elseif !exists("b:netrw_curdir")
|
|
5180 call netrw#ErrorMsg(s:ERROR,"local browsing directory doesn't exist!",36)
|
|
5181 else
|
|
5182 call netrw#ErrorMsg(s:WARNING,"local browsing directory and current directory are identical",37)
|
|
5183 endif
|
|
5184
|
|
5185 else
|
1702
|
5186 " obtain files from remote b:netrw_curdir to local tgtdir
|
|
5187 " call Decho("obtain a file from remote ".b:netrw_curdir." to ".tgtdir)
|
1621
|
5188 if type(a:fname) == 1
|
|
5189 call s:SetupNetrwStatusLine('%f %h%m%r%=%9*Obtaining '.a:fname)
|
|
5190 endif
|
|
5191 call s:NetrwMethod(b:netrw_curdir)
|
|
5192
|
|
5193 if b:netrw_method == 4
|
|
5194 " obtain file using scp
|
|
5195 " call Decho("obtain via scp (method#4)")
|
|
5196 if exists("g:netrw_port") && g:netrw_port != ""
|
|
5197 let useport= " ".g:netrw_scpport." ".g:netrw_port
|
|
5198 else
|
|
5199 let useport= ""
|
|
5200 endif
|
|
5201 if b:netrw_fname =~ '/'
|
|
5202 let path= substitute(b:netrw_fname,'^\(.*/\).\{-}$','\1','')
|
|
5203 else
|
|
5204 let path= ""
|
|
5205 endif
|
1698
|
5206 let filelist= join(map(deepcopy(fnamelist),'shellescape(g:netrw_machine.":".path.v:val,1)'))
|
1668
|
5207 " call Decho("exe ".s:netrw_silentxfer."!".g:netrw_scp_cmd.shellescape(useport,1)." ".filelist." ".shellescape(tgtdir,1))
|
|
5208 exe s:netrw_silentxfer."!".g:netrw_scp_cmd.shellescape(useport,1)." ".filelist." ".shellescape(tgtdir,1)
|
1621
|
5209
|
|
5210 elseif b:netrw_method == 2
|
|
5211 " obtain file using ftp + .netrc
|
|
5212 " call Decho("obtain via ftp+.netrc (method #2)")
|
|
5213 call s:SaveBufVars()|silent keepjumps new|call s:RestoreBufVars()
|
|
5214 let tmpbufnr= bufnr("%")
|
|
5215 setlocal ff=unix
|
|
5216 if exists("g:netrw_ftpmode") && g:netrw_ftpmode != ""
|
1698
|
5217 put =g:netrw_ftpmode
|
1621
|
5218 " call Decho("filter input: ".getline('$'))
|
|
5219 endif
|
|
5220
|
|
5221 if exists("b:netrw_fname") && b:netrw_fname != ""
|
|
5222 call setline(line("$")+1,'cd "'.b:netrw_fname.'"')
|
|
5223 " call Decho("filter input: ".getline('$'))
|
|
5224 endif
|
|
5225
|
|
5226 if exists("g:netrw_ftpextracmd")
|
1698
|
5227 put =g:netrw_ftpextracmd
|
1621
|
5228 " call Decho("filter input: ".getline('$'))
|
|
5229 endif
|
|
5230 for fname in fnamelist
|
|
5231 call setline(line("$")+1,'get "'.fname.'"')
|
|
5232 " call Decho("filter input: ".getline('$'))
|
|
5233 endfor
|
|
5234 if exists("g:netrw_port") && g:netrw_port != ""
|
1668
|
5235 " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1))
|
|
5236 exe s:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1)
|
1621
|
5237 else
|
1668
|
5238 " call Decho("executing: %!".g:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1))
|
|
5239 exe s:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)
|
1621
|
5240 endif
|
|
5241 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
|
|
5242 if getline(1) !~ "^$" && !exists("g:netrw_quiet") && getline(1) !~ '^Trying '
|
|
5243 let debugkeep= &debug
|
|
5244 setlocal debug=msg
|
|
5245 call netrw#ErrorMsg(s:ERROR,getline(1),4)
|
|
5246 let &debug= debugkeep
|
|
5247 endif
|
|
5248
|
|
5249 elseif b:netrw_method == 3
|
|
5250 " obtain with ftp + machine, id, passwd, and fname (ie. no .netrc)
|
|
5251 " call Decho("obtain via ftp+mipf (method #3)")
|
|
5252 call s:SaveBufVars()|silent keepjumps new|call s:RestoreBufVars()
|
|
5253 let tmpbufnr= bufnr("%")
|
|
5254 setlocal ff=unix
|
|
5255
|
|
5256 if exists("g:netrw_port") && g:netrw_port != ""
|
|
5257 put ='open '.g:netrw_machine.' '.g:netrw_port
|
|
5258 " call Decho("filter input: ".getline('$'))
|
|
5259 else
|
|
5260 put ='open '.g:netrw_machine
|
|
5261 " call Decho("filter input: ".getline('$'))
|
|
5262 endif
|
|
5263
|
|
5264 if exists("g:netrw_ftp") && g:netrw_ftp == 1
|
|
5265 put =g:netrw_uid
|
|
5266 " call Decho("filter input: ".getline('$'))
|
|
5267 put ='\"'.s:netrw_passwd.'\"'
|
|
5268 " call Decho("filter input: ".getline('$'))
|
|
5269 else
|
|
5270 put ='user \"'.g:netrw_uid.'\" \"'.s:netrw_passwd.'\"'
|
|
5271 " call Decho("filter input: ".getline('$'))
|
|
5272 endif
|
|
5273
|
|
5274 if exists("g:netrw_ftpmode") && g:netrw_ftpmode != ""
|
|
5275 put =g:netrw_ftpmode
|
|
5276 " call Decho("filter input: ".getline('$'))
|
|
5277 endif
|
|
5278
|
|
5279 if exists("b:netrw_fname") && b:netrw_fname != ""
|
|
5280 call setline(line("$")+1,'cd "'.b:netrw_fname.'"')
|
|
5281 " call Decho("filter input: ".getline('$'))
|
|
5282 endif
|
|
5283
|
|
5284 if exists("g:netrw_ftpextracmd")
|
1698
|
5285 put =g:netrw_ftpextracmd
|
1621
|
5286 " call Decho("filter input: ".getline('$'))
|
|
5287 endif
|
|
5288
|
|
5289 if exists("g:netrw_ftpextracmd")
|
1698
|
5290 put =g:netrw_ftpextracmd
|
1621
|
5291 " call Decho("filter input: ".getline('$'))
|
|
5292 endif
|
|
5293 for fname in fnamelist
|
|
5294 call setline(line("$")+1,'get "'.fname.'"')
|
|
5295 endfor
|
|
5296 " call Decho("filter input: ".getline('$'))
|
|
5297
|
|
5298 " perform ftp:
|
|
5299 " -i : turns off interactive prompting from ftp
|
|
5300 " -n unix : DON'T use <.netrc>, even though it exists
|
|
5301 " -n win32: quit being obnoxious about password
|
|
5302 norm! 1Gdd
|
|
5303 " call Decho("executing: %!".g:netrw_ftp_cmd." -i -n")
|
|
5304 exe s:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n"
|
|
5305 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
|
|
5306 if getline(1) !~ "^$"
|
|
5307 " call Decho("error<".getline(1).">")
|
|
5308 if !exists("g:netrw_quiet")
|
|
5309 call netrw#ErrorMsg(s:ERROR,getline(1),5)
|
|
5310 endif
|
|
5311 endif
|
2034
|
5312 elseif !exists("b:netrw_method") || b:netrw_method < 0
|
|
5313 " call Dfunc("netrw#NetrwObtain : unsupported method")
|
|
5314 return
|
|
5315 endif
|
|
5316
|
|
5317 " restore status line
|
|
5318 if type(a:fname) == 1 && exists("s:netrw_users_stl")
|
|
5319 call s:SetupNetrwStatusLine(s:netrw_users_stl)
|
1621
|
5320 endif
|
|
5321
|
|
5322 endif
|
|
5323
|
|
5324 " cleanup
|
|
5325 if exists("tmpbufnr")
|
|
5326 if bufnr("%") != tmpbufnr
|
|
5327 exe tmpbufnr."bw!"
|
|
5328 else
|
|
5329 q!
|
|
5330 endif
|
|
5331 endif
|
|
5332
|
|
5333 " call Dret("netrw#NetrwObtain")
|
|
5334 endfun
|
|
5335
|
|
5336 " ---------------------------------------------------------------------
|
|
5337 " s:NetrwPrevWinOpen: open file/directory in previous window. {{{2
|
|
5338 " If there's only one window, then the window will first be split.
|
|
5339 " Returns:
|
|
5340 " choice = 0 : didn't have to choose
|
|
5341 " choice = 1 : saved modified file in window first
|
|
5342 " choice = 2 : didn't save modified file, opened window
|
|
5343 " choice = 3 : cancel open
|
|
5344 fun! s:NetrwPrevWinOpen(islocal)
|
|
5345 " call Dfunc("NetrwPrevWinOpen(islocal=".a:islocal.")")
|
|
5346
|
|
5347 " grab a copy of the b:netrw_curdir to pass it along to newly split windows
|
|
5348 let curdir = b:netrw_curdir
|
|
5349
|
|
5350 " get last window number and the word currently under the cursor
|
|
5351 let lastwinnr = winnr("$")
|
|
5352 let curword = s:NetrwGetWord()
|
|
5353 let choice = 0
|
|
5354 " call Decho("lastwinnr=".lastwinnr." curword<".curword.">")
|
|
5355
|
|
5356 let didsplit = 0
|
|
5357 if lastwinnr == 1
|
|
5358 " if only one window, open a new one first
|
|
5359 " call Decho("only one window, so open a new one (g:netrw_alto=".g:netrw_alto.")")
|
|
5360 if g:netrw_preview
|
|
5361 " call Decho("exe ".(g:netrw_alto? "top " : "bot ")."vert ".g:netrw_winsize."wincmd s")
|
|
5362 exe (g:netrw_alto? "top " : "bot ")."vert ".g:netrw_winsize."wincmd s"
|
|
5363 else
|
|
5364 " call Decho("exe ".(g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s")
|
|
5365 exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s"
|
|
5366 endif
|
|
5367 let didsplit = 1
|
|
5368
|
|
5369 else
|
|
5370 call s:SaveBufVars()
|
|
5371 " call Decho("wincmd p")
|
|
5372 wincmd p
|
|
5373 call s:RestoreBufVars()
|
|
5374 " if the previous window's buffer has been changed (is modified),
|
|
5375 " and it doesn't appear in any other extant window, then ask the
|
|
5376 " user if s/he wants to abandon modifications therein.
|
|
5377 let bnr = winbufnr(0)
|
|
5378 let bnrcnt = 0
|
|
5379 if &mod
|
|
5380 " call Decho("detected: prev window's buffer has been modified: bnr=".bnr." winnr#".winnr())
|
|
5381 let eikeep= &ei
|
|
5382 set ei=all
|
|
5383 windo if winbufnr(0) == bnr | let bnrcnt=bnrcnt+1 | endif
|
|
5384 exe bnr."wincmd p"
|
|
5385 let &ei= eikeep
|
|
5386 " call Decho("bnr=".bnr." bnrcnt=".bnrcnt." buftype=".&bt." winnr#".winnr())
|
|
5387 if bnrcnt == 1
|
2034
|
5388 let bufname = bufname(winbufnr(winnr()))
|
|
5389 let choice = confirm("Save modified file<".bufname.">?","&Yes\n&No\n&Cancel")
|
1621
|
5390 " call Decho("bufname<".bufname."> choice=".choice." winnr#".winnr())
|
|
5391
|
|
5392 if choice == 1
|
|
5393 " Yes -- write file & then browse
|
|
5394 let v:errmsg= ""
|
|
5395 silent w
|
|
5396 if v:errmsg != ""
|
|
5397 call netrw#ErrorMsg(s:ERROR,"unable to write <".bufname.">!",30)
|
|
5398 if didsplit
|
|
5399 q
|
|
5400 else
|
|
5401 wincmd p
|
|
5402 endif
|
|
5403 " call Dret("NetrwPrevWinOpen ".choice." : unable to write <".bufname.">")
|
|
5404 return choice
|
|
5405 endif
|
|
5406
|
|
5407 elseif choice == 2
|
|
5408 " No -- don't worry about changed file, just browse anyway
|
|
5409 setlocal nomod
|
|
5410 call netrw#ErrorMsg(s:WARNING,bufname." changes to ".bufname." abandoned",31)
|
|
5411 wincmd p
|
|
5412
|
|
5413 else
|
|
5414 " Cancel -- don't do this
|
|
5415 if didsplit
|
|
5416 q
|
|
5417 else
|
|
5418 wincmd p
|
|
5419 endif
|
|
5420 " call Dret("NetrwPrevWinOpen ".choice." : cancelled")
|
|
5421 return choice
|
|
5422 endif
|
|
5423 endif
|
|
5424 endif
|
|
5425 endif
|
|
5426
|
|
5427 " restore b:netrw_curdir (window split/enew may have lost it)
|
|
5428 let b:netrw_curdir= curdir
|
|
5429 if a:islocal < 2
|
|
5430 if a:islocal
|
|
5431 call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(a:islocal,curword))
|
|
5432 else
|
|
5433 call s:NetrwBrowse(a:islocal,s:NetrwBrowseChgDir(a:islocal,curword))
|
|
5434 endif
|
|
5435 endif
|
|
5436 " call Dret("NetrwPrevWinOpen ".choice)
|
|
5437 return choice
|
|
5438 endfun
|
|
5439
|
|
5440 " ---------------------------------------------------------------------
|
|
5441 " s:NetrwUpload: load fname to tgt (used by NetrwMarkFileCopy()) {{{2
|
|
5442 " Always assumed to be local -> remote
|
|
5443 " call s:NetrwUpload(filename, target)
|
|
5444 " call s:NetrwUpload(filename, target, fromdirectory)
|
|
5445 fun! s:NetrwUpload(fname,tgt,...)
|
|
5446 " call Dfunc("s:NetrwUpload(fname<".((type(a:fname) == 1)? a:fname : string(a:fname))."> tgt<".a:tgt.">) a:0=".a:0)
|
|
5447
|
|
5448 if a:tgt =~ '^\a\+://'
|
|
5449 let tgtdir= substitute(a:tgt,'^\a\+://[^/]\+/\(.\{-}\)$','\1','')
|
|
5450 else
|
|
5451 let tgtdir= substitute(a:tgt,'^\(.*\)/[^/]*$','\1','')
|
|
5452 endif
|
|
5453 " call Decho("tgtdir<".tgtdir.">")
|
|
5454
|
|
5455 if a:0 > 0
|
|
5456 let fromdir= a:1
|
|
5457 else
|
|
5458 let fromdir= getcwd()
|
|
5459 endif
|
|
5460 " call Decho("fromdir<".fromdir.">")
|
|
5461
|
|
5462 if type(a:fname) == 1
|
|
5463 " handle uploading a single file using NetWrite
|
|
5464 " call Decho("handle uploading a single file via NetWrite")
|
|
5465 1split
|
1698
|
5466 " call Decho("exe e ".fnameescape(a:fname))
|
|
5467 exe "e ".fnameescape(a:fname)
|
1621
|
5468 " call Decho("now locally editing<".expand("%").">, has ".line("$")." lines")
|
|
5469 if a:tgt =~ '/$'
|
|
5470 let wfname= substitute(a:fname,'^.*/','','')
|
1668
|
5471 " call Decho("exe w! ".fnameescape(wfname))
|
1698
|
5472 exe "w! ".fnameescape(a:tgt.wfname)
|
1621
|
5473 else
|
1668
|
5474 " call Decho("writing local->remote: exe w ".fnameescape(a:tgt))
|
|
5475 exe "w ".fnameescape(a:tgt)
|
1621
|
5476 " call Decho("done writing local->remote")
|
|
5477 endif
|
|
5478 q!
|
|
5479
|
|
5480 elseif type(a:fname) == 3
|
|
5481 " handle uploading a list of files via scp
|
|
5482 " call Decho("handle uploading a list of files via scp")
|
|
5483 let curdir= getcwd()
|
|
5484 if a:tgt =~ '^scp:'
|
|
5485 exe "keepjumps silent lcd ".fnameescape(fromdir)
|
1698
|
5486 let filelist= deepcopy(s:netrwmarkfilelist_{bufnr('%')})
|
|
5487 let args = join(map(filelist,"shellescape(v:val, 1)"))
|
1621
|
5488 if exists("g:netrw_port") && g:netrw_port != ""
|
|
5489 let useport= " ".g:netrw_scpport." ".g:netrw_port
|
|
5490 else
|
|
5491 let useport= ""
|
|
5492 endif
|
|
5493 let machine = substitute(a:tgt,'^scp://\([^/:]\+\).*$','\1','')
|
|
5494 let tgt = substitute(a:tgt,'^scp://[^/]\+/\(.*\)$','\1','')
|
1668
|
5495 " call Decho("exe ".s:netrw_silentxfer."!".g:netrw_scp_cmd.shellescape(useport,1)." ".args." ".shellescape(machine.":".tgt,1))
|
|
5496 exe s:netrw_silentxfer."!".g:netrw_scp_cmd.shellescape(useport,1)." ".args." ".shellescape(machine.":".tgt,1)
|
1621
|
5497 exe "keepjumps silent lcd ".fnameescape(curdir)
|
|
5498
|
|
5499 elseif a:tgt =~ '^ftp:'
|
|
5500 call s:NetrwMethod(a:tgt)
|
|
5501
|
|
5502 if b:netrw_method == 2
|
|
5503 " handle uploading a list of files via ftp+.netrc
|
|
5504 let netrw_fname = b:netrw_fname
|
|
5505 silent keepjumps new
|
|
5506 " call Decho("filter input window#".winnr())
|
|
5507
|
1698
|
5508 put =g:netrw_ftpmode
|
1621
|
5509 " call Decho("filter input: ".getline('$'))
|
|
5510
|
|
5511 if exists("g:netrw_ftpextracmd")
|
1698
|
5512 put =g:netrw_ftpextracmd
|
1621
|
5513 " call Decho("filter input: ".getline('$'))
|
|
5514 endif
|
|
5515
|
|
5516 call setline(line("$")+1,'lcd "'.fromdir.'"')
|
|
5517 " call Decho("filter input: ".getline('$'))
|
|
5518
|
|
5519 call setline(line("$")+1,'cd "'.tgtdir.'"')
|
|
5520 " call Decho("filter input: ".getline('$'))
|
|
5521
|
|
5522 for fname in a:fname
|
|
5523 call setline(line("$")+1,'put "'.fname.'"')
|
|
5524 " call Decho("filter input: ".getline('$'))
|
|
5525 endfor
|
|
5526
|
|
5527 if exists("g:netrw_port") && g:netrw_port != ""
|
1668
|
5528 " call Decho("executing: ".s:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1))
|
|
5529 exe s:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1)
|
1621
|
5530 else
|
|
5531 " call Decho("filter input window#".winnr())
|
1668
|
5532 " call Decho("executing: ".s:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1))
|
|
5533 exe s:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)
|
1621
|
5534 endif
|
|
5535 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
|
|
5536 silent g/Local directory now/d
|
2034
|
5537 call histdel("/",-1)
|
1621
|
5538 if getline(1) !~ "^$" && !exists("g:netrw_quiet") && getline(1) !~ '^Trying '
|
|
5539 call netrw#ErrorMsg(s:ERROR,getline(1),14)
|
|
5540 else
|
|
5541 bw!|q
|
|
5542 endif
|
|
5543
|
|
5544 elseif b:netrw_method == 3
|
|
5545 " upload with ftp + machine, id, passwd, and fname (ie. no .netrc)
|
|
5546 let netrw_fname= b:netrw_fname
|
|
5547 call s:SaveBufVars()|silent keepjumps new|call s:RestoreBufVars()
|
|
5548 let tmpbufnr= bufnr("%")
|
|
5549 setlocal ff=unix
|
|
5550
|
|
5551 if exists("g:netrw_port") && g:netrw_port != ""
|
|
5552 put ='open '.g:netrw_machine.' '.g:netrw_port
|
|
5553 " call Decho("filter input: ".getline('$'))
|
|
5554 else
|
|
5555 put ='open '.g:netrw_machine
|
|
5556 " call Decho("filter input: ".getline('$'))
|
|
5557 endif
|
|
5558
|
|
5559 if exists("g:netrw_ftp") && g:netrw_ftp == 1
|
|
5560 put =g:netrw_uid
|
|
5561 " call Decho("filter input: ".getline('$'))
|
|
5562 call setline(line("$")+1,'"'.s:netrw_passwd.'"')
|
|
5563 " call Decho("filter input: ".getline('$'))
|
|
5564 else
|
|
5565 put ='user \"'.g:netrw_uid.'\" \"'.s:netrw_passwd.'\"'
|
|
5566 " call Decho("filter input: ".getline('$'))
|
|
5567 endif
|
|
5568
|
|
5569 call setline(line("$")+1,'lcd "'.fromdir.'"')
|
|
5570 " call Decho("filter input: ".getline('$'))
|
|
5571
|
|
5572 if exists("b:netrw_fname") && b:netrw_fname != ""
|
|
5573 call setline(line("$")+1,'cd "'.b:netrw_fname.'"')
|
|
5574 " call Decho("filter input: ".getline('$'))
|
|
5575 endif
|
|
5576
|
|
5577 if exists("g:netrw_ftpextracmd")
|
1698
|
5578 put =g:netrw_ftpextracmd
|
1621
|
5579 " call Decho("filter input: ".getline('$'))
|
|
5580 endif
|
|
5581
|
|
5582 for fname in a:fname
|
|
5583 call setline(line("$")+1,'put "'.fname.'"')
|
|
5584 " call Decho("filter input: ".getline('$'))
|
|
5585 endfor
|
|
5586
|
|
5587 " perform ftp:
|
|
5588 " -i : turns off interactive prompting from ftp
|
|
5589 " -n unix : DON'T use <.netrc>, even though it exists
|
|
5590 " -n win32: quit being obnoxious about password
|
|
5591 norm! 1Gdd
|
|
5592 " call Decho("executing: ".s:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n")
|
|
5593 exe s:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n"
|
|
5594 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar)
|
|
5595 silent g/Local directory now/d
|
2034
|
5596 call histdel("/",-1)
|
1621
|
5597 if getline(1) !~ "^$" && !exists("g:netrw_quiet") && getline(1) !~ '^Trying '
|
|
5598 let debugkeep= &debug
|
|
5599 setlocal debug=msg
|
|
5600 call netrw#ErrorMsg(s:ERROR,getline(1),15)
|
|
5601 let &debug = debugkeep
|
|
5602 let mod = 1
|
|
5603 else
|
|
5604 bw!|q
|
|
5605 endif
|
2034
|
5606 elseif !exists("b:netrw_method") || b:netrw_method < 0
|
|
5607 " call Dfunc("netrw#NetrwUpload : unsupported method")
|
|
5608 return
|
1621
|
5609 endif
|
|
5610 else
|
|
5611 call netrw#ErrorMsg(s:ERROR,"can't obtain files with protocol from<".a:tgt.">",63)
|
|
5612 endif
|
|
5613 endif
|
|
5614
|
|
5615 " call Dret("s:NetrwUpload")
|
|
5616 endfun
|
|
5617
|
|
5618 " ---------------------------------------------------------------------
|
|
5619 " s:NetrwPreview: {{{2
|
|
5620 fun! s:NetrwPreview(path) range
|
|
5621 " call Dfunc("NetrwPreview(path<".a:path.">)")
|
|
5622 call s:NetrwOptionSave("s:")
|
|
5623 call s:NetrwSafeOptions()
|
|
5624 if has("quickfix")
|
|
5625 if !isdirectory(a:path)
|
1698
|
5626 exe (g:netrw_preview? "vert " : "")."pedit ".fnameescape(a:path)
|
1621
|
5627 elseif !exists("g:netrw_quiet")
|
|
5628 call netrw#ErrorMsg(s:WARNING,"sorry, cannot preview a directory such as <".a:path.">",38)
|
|
5629 endif
|
|
5630 elseif !exists("g:netrw_quiet")
|
|
5631 call netrw#ErrorMsg(s:WARNING,"sorry, to preview your vim needs the quickfix feature compiled in",39)
|
|
5632 endif
|
|
5633 call s:NetrwOptionRestore("s:")
|
|
5634 " call Dret("NetrwPreview")
|
|
5635 endfun
|
|
5636
|
|
5637 " ---------------------------------------------------------------------
|
|
5638 " s:NetrwRefresh: {{{2
|
|
5639 fun! s:NetrwRefresh(islocal,dirname)
|
|
5640 " call Dfunc("NetrwRefresh(islocal<".a:islocal.">,dirname=".a:dirname.") hide=".g:netrw_hide." sortdir=".g:netrw_sort_direction)
|
|
5641 " at the current time (Mar 19, 2007) all calls to NetrwRefresh() call NetrwBrowseChgDir() first.
|
|
5642 " NetrwBrowseChgDir() may clear the display; hence a NetrwSavePosn() may not work if its placed here.
|
|
5643 " Also, NetrwBrowseChgDir() now does a NetrwSavePosn() itself.
|
|
5644 setlocal ma noro
|
|
5645 " call Decho("setlocal ma noro")
|
|
5646 " call Decho("clear buffer<".expand("%")."> with :%d")
|
|
5647 %d
|
|
5648 if a:islocal
|
|
5649 call netrw#LocalBrowseCheck(a:dirname)
|
|
5650 else
|
|
5651 call s:NetrwBrowse(a:islocal,a:dirname)
|
|
5652 endif
|
|
5653 call netrw#NetrwRestorePosn()
|
|
5654
|
|
5655 " restore file marks
|
|
5656 if exists("s:netrwmarkfilemtch_{bufnr('%')}") && s:netrwmarkfilemtch_{bufnr("%")} != ""
|
|
5657 " call Decho("exe 2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/")
|
|
5658 exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/"
|
|
5659 else
|
|
5660 " call Decho("2match none")
|
|
5661 2match none
|
|
5662 endif
|
|
5663
|
|
5664 " redraw!
|
|
5665 " call Dret("NetrwRefresh")
|
|
5666 endfun
|
|
5667
|
|
5668 " ---------------------------------------------------------------------
|
|
5669 " s:NetrwRefreshDir: refreshes a directory by name {{{2
|
|
5670 " Called by NetrwMarkFileCopy()
|
|
5671 " Interfaces to s:NetrwRefresh() and s:LocalBrowseShellCmdRefresh()
|
|
5672 fun! s:NetrwRefreshDir(islocal,dirname)
|
|
5673 " call Dfunc("s:NetrwRefreshDir(islocal=".a:islocal." dirname<".a:dirname.">) fastbrowse=".g:netrw_fastbrowse)
|
|
5674 if g:netrw_fastbrowse == 0
|
|
5675 " slowest mode (keep buffers refreshed, local or remote)
|
|
5676 " call Decho("slowest mode: keep buffers refreshed, local or remote")
|
|
5677 let tgtwin= bufwinnr(a:dirname)
|
|
5678 " call Decho("tgtwin= bufwinnr(".a:dirname.")=".tgtwin)
|
|
5679
|
|
5680 if tgtwin > 0
|
|
5681 " tgtwin is being displayed, so refresh it
|
|
5682 let curwin= winnr()
|
|
5683 " call Decho("refresh tgtwin#".tgtwin." (curwin#".curwin.")")
|
|
5684 exe tgtwin."wincmd w"
|
|
5685 call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
|
|
5686 exe curwin."wincmd w"
|
|
5687
|
|
5688 elseif bufnr(a:dirname) > 0
|
|
5689 let bn= bufnr(a:dirname)
|
|
5690 " call Decho("bd bufnr(".a:dirname.")=".bn)
|
|
5691 exe "silent bd ".bn
|
|
5692 endif
|
|
5693
|
|
5694 elseif g:netrw_fastbrowse <= 1
|
|
5695 " call Decho("medium-speed mode: refresh local buffers only")
|
|
5696 call s:LocalBrowseShellCmdRefresh()
|
|
5697 endif
|
|
5698 " call Dret("s:NetrwRefreshDir")
|
|
5699 endfun
|
|
5700
|
|
5701 " ---------------------------------------------------------------------
|
|
5702 " s:NetrwSetSort: sets up the sort based on the g:netrw_sort_sequence {{{2
|
|
5703 " What this function does is to compute a priority for the patterns
|
|
5704 " in the g:netrw_sort_sequence. It applies a substitute to any
|
|
5705 " "files" that satisfy each pattern, putting the priority / in
|
|
5706 " front. An "*" pattern handles the default priority.
|
|
5707 fun! s:NetrwSetSort()
|
|
5708 " call Dfunc("SetSort() bannercnt=".w:netrw_bannercnt)
|
|
5709 if w:netrw_liststyle == s:LONGLIST
|
|
5710 let seqlist = substitute(g:netrw_sort_sequence,'\$','\\%(\t\\|\$\\)','ge')
|
|
5711 else
|
|
5712 let seqlist = g:netrw_sort_sequence
|
|
5713 endif
|
|
5714 " sanity check -- insure that * appears somewhere
|
|
5715 if seqlist == ""
|
|
5716 let seqlist= '*'
|
|
5717 elseif seqlist !~ '\*'
|
|
5718 let seqlist= seqlist.',*'
|
|
5719 endif
|
|
5720 let priority = 1
|
|
5721 while seqlist != ""
|
|
5722 if seqlist =~ ','
|
|
5723 let seq = substitute(seqlist,',.*$','','e')
|
|
5724 let seqlist = substitute(seqlist,'^.\{-},\(.*\)$','\1','e')
|
|
5725 else
|
|
5726 let seq = seqlist
|
|
5727 let seqlist = ""
|
|
5728 endif
|
|
5729 if priority < 10
|
2034
|
5730 let spriority= "00".priority.g:netrw_sepchr
|
1621
|
5731 elseif priority < 100
|
2034
|
5732 let spriority= "0".priority.g:netrw_sepchr
|
1621
|
5733 else
|
2034
|
5734 let spriority= priority.g:netrw_sepchr
|
1621
|
5735 endif
|
|
5736 " call Decho("priority=".priority." spriority<".spriority."> seq<".seq."> seqlist<".seqlist.">")
|
|
5737
|
|
5738 " sanity check
|
|
5739 if w:netrw_bannercnt > line("$")
|
|
5740 " apparently no files were left after a Hiding pattern was used
|
|
5741 " call Dret("SetSort : no files left after hiding")
|
|
5742 return
|
|
5743 endif
|
|
5744 if seq == '*'
|
|
5745 let starpriority= spriority
|
|
5746 else
|
|
5747 exe 'silent keepjumps '.w:netrw_bannercnt.',$g/'.seq.'/s/^/'.spriority.'/'
|
2034
|
5748 call histdel("/",-1)
|
1621
|
5749 " sometimes multiple sorting patterns will match the same file or directory.
|
|
5750 " The following substitute is intended to remove the excess matches.
|
2034
|
5751 exe 'silent keepjumps '.w:netrw_bannercnt.',$g/^\d\{3}'.g:netrw_sepchr.'\d\{3}\//s/^\d\{3}'.g:netrw_sepchr.'\(\d\{3}\/\).\@=/\1/e'
|
|
5752 call histdel("/",-1)
|
1621
|
5753 endif
|
|
5754 let priority = priority + 1
|
|
5755 endwhile
|
|
5756 if exists("starpriority")
|
2034
|
5757 exe 'silent keepjumps '.w:netrw_bannercnt.',$v/^\d\{3}'.g:netrw_sepchr.'/s/^/'.starpriority.'/'
|
|
5758 call histdel("/",-1)
|
1621
|
5759 endif
|
|
5760
|
|
5761 " Following line associated with priority -- items that satisfy a priority
|
|
5762 " pattern get prefixed by ###/ which permits easy sorting by priority.
|
|
5763 " Sometimes files can satisfy multiple priority patterns -- only the latest
|
|
5764 " priority pattern needs to be retained. So, at this point, these excess
|
|
5765 " priority prefixes need to be removed, but not directories that happen to
|
|
5766 " be just digits themselves.
|
2034
|
5767 exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\(\d\{3}'.g:netrw_sepchr.'\)\%(\d\{3}'.g:netrw_sepchr.'\)\+\ze./\1/e'
|
|
5768 call histdel("/",-1)
|
1621
|
5769
|
|
5770 " call Dret("SetSort")
|
|
5771 endfun
|
|
5772
|
|
5773 " =====================================================================
|
|
5774 " s:NetrwSortStyle: change sorting style (name - time - size) and refresh display {{{2
|
|
5775 fun! s:NetrwSortStyle(islocal)
|
|
5776 " call Dfunc("s:NetrwSortStyle(islocal=".a:islocal.") netrw_sort_by<".g:netrw_sort_by.">")
|
|
5777 call s:NetrwSaveWordPosn()
|
|
5778 let svpos= netrw#NetrwSavePosn()
|
|
5779
|
|
5780 let g:netrw_sort_by= (g:netrw_sort_by =~ 'n')? 'time' : (g:netrw_sort_by =~ 't')? 'size' : 'name'
|
|
5781 norm! 0
|
|
5782 call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./'))
|
|
5783 call netrw#NetrwRestorePosn(svpos)
|
|
5784
|
|
5785 " call Dret("s:NetrwSortStyle : netrw_sort_by<".g:netrw_sort_by.">")
|
|
5786 endfun
|
|
5787
|
|
5788 " ---------------------------------------------------------------------
|
|
5789 " s:NetrwSplit: mode {{{2
|
|
5790 " =0 : net and o
|
|
5791 " =1 : net and t
|
|
5792 " =2 : net and v
|
|
5793 " =3 : local and o
|
|
5794 " =4 : local and t
|
|
5795 " =5 : local and v
|
|
5796 fun! s:NetrwSplit(mode)
|
|
5797 " call Dfunc("s:NetrwSplit(mode=".a:mode.") alto=".g:netrw_alto." altv=".g:netrw_altv)
|
|
5798
|
|
5799 call s:SaveWinVars()
|
|
5800
|
|
5801 if a:mode == 0
|
|
5802 " remote and o
|
|
5803 " call Decho("exe ".(g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s")
|
|
5804 exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s"
|
|
5805 let s:didsplit= 1
|
|
5806 call s:RestoreWinVars()
|
|
5807 call s:NetrwBrowse(0,s:NetrwBrowseChgDir(0,s:NetrwGetWord()))
|
|
5808 unlet s:didsplit
|
|
5809
|
|
5810 elseif a:mode == 1
|
|
5811 " remote and t
|
2034
|
5812 let newdir = s:NetrwBrowseChgDir(0,s:NetrwGetWord())
|
1621
|
5813 " call Decho("tabnew")
|
|
5814 tabnew
|
|
5815 let s:didsplit= 1
|
|
5816 call s:RestoreWinVars()
|
2034
|
5817 call s:NetrwBrowse(0,newdir)
|
1621
|
5818 unlet s:didsplit
|
|
5819
|
|
5820 elseif a:mode == 2
|
|
5821 " remote and v
|
|
5822 " call Decho("exe ".(g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v")
|
|
5823 exe (g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v"
|
|
5824 let s:didsplit= 1
|
|
5825 call s:RestoreWinVars()
|
|
5826 call s:NetrwBrowse(0,s:NetrwBrowseChgDir(0,s:NetrwGetWord()))
|
|
5827 unlet s:didsplit
|
|
5828
|
|
5829 elseif a:mode == 3
|
|
5830 " local and o
|
|
5831 " call Decho("exe ".(g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s")
|
|
5832 exe (g:netrw_alto? "bel " : "abo ").g:netrw_winsize."wincmd s"
|
|
5833 let s:didsplit= 1
|
|
5834 call s:RestoreWinVars()
|
|
5835 call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,s:NetrwGetWord()))
|
|
5836 unlet s:didsplit
|
|
5837
|
|
5838 elseif a:mode == 4
|
|
5839 " local and t
|
|
5840 let cursorword = s:NetrwGetWord()
|
2034
|
5841 let netrw_curdir= s:NetrwTreeDir()
|
1621
|
5842 " call Decho("tabnew")
|
|
5843 tabnew
|
|
5844 let b:netrw_curdir= netrw_curdir
|
|
5845 let s:didsplit= 1
|
|
5846 call s:RestoreWinVars()
|
|
5847 call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,cursorword))
|
|
5848 unlet s:didsplit
|
|
5849
|
|
5850 elseif a:mode == 5
|
|
5851 " local and v
|
|
5852 " call Decho("exe ".(g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v")
|
|
5853 exe (g:netrw_altv? "rightb " : "lefta ").g:netrw_winsize."wincmd v"
|
|
5854 let s:didsplit= 1
|
|
5855 call s:RestoreWinVars()
|
|
5856 call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,s:NetrwGetWord()))
|
|
5857 unlet s:didsplit
|
|
5858
|
|
5859 else
|
|
5860 call netrw#ErrorMsg(s:ERROR,"(NetrwSplit) unsupported mode=".a:mode,45)
|
|
5861 endif
|
|
5862
|
|
5863 " call Dret("s:NetrwSplit")
|
|
5864 endfun
|
|
5865
|
|
5866 " ---------------------------------------------------------------------
|
|
5867 " NetrwStatusLine: {{{2
|
|
5868 fun! NetrwStatusLine()
|
|
5869
|
|
5870 " vvv NetrwStatusLine() debugging vvv
|
|
5871 " let g:stlmsg=""
|
|
5872 " if !exists("w:netrw_explore_bufnr")
|
|
5873 " let g:stlmsg="!X<explore_bufnr>"
|
|
5874 " elseif w:netrw_explore_bufnr != bufnr("%")
|
|
5875 " let g:stlmsg="explore_bufnr!=".bufnr("%")
|
|
5876 " endif
|
|
5877 " if !exists("w:netrw_explore_line")
|
|
5878 " let g:stlmsg=" !X<explore_line>"
|
|
5879 " elseif w:netrw_explore_line != line(".")
|
|
5880 " let g:stlmsg=" explore_line!={line(.)<".line(".").">"
|
|
5881 " endif
|
|
5882 " if !exists("w:netrw_explore_list")
|
|
5883 " let g:stlmsg=" !X<explore_list>"
|
|
5884 " endif
|
|
5885 " ^^^ NetrwStatusLine() debugging ^^^
|
|
5886
|
|
5887 if !exists("w:netrw_explore_bufnr") || w:netrw_explore_bufnr != bufnr("%") || !exists("w:netrw_explore_line") || w:netrw_explore_line != line(".") || !exists("w:netrw_explore_list")
|
|
5888 " restore user's status line
|
|
5889 let &stl = s:netrw_users_stl
|
|
5890 let &laststatus = s:netrw_users_ls
|
|
5891 if exists("w:netrw_explore_bufnr")|unlet w:netrw_explore_bufnr|endif
|
|
5892 if exists("w:netrw_explore_line") |unlet w:netrw_explore_line |endif
|
|
5893 return ""
|
|
5894 else
|
|
5895 return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen
|
|
5896 endif
|
|
5897 endfun
|
|
5898
|
|
5899 " ---------------------------------------------------------------------
|
|
5900 " s:NetrwTreeDir: determine tree directory given current cursor position {{{2
|
|
5901 " (full path directory with trailing slash returned)
|
|
5902 fun! s:NetrwTreeDir()
|
|
5903 " call Dfunc("NetrwTreeDir() curline#".line(".")."<".getline('.')."> b:netrw_curdir<".b:netrw_curdir."> tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%").">")
|
|
5904
|
|
5905 let treedir= b:netrw_curdir
|
|
5906 " call Decho("set initial treedir<".treedir.">")
|
|
5907 let s:treecurpos= netrw#NetrwSavePosn()
|
|
5908
|
|
5909 if w:netrw_liststyle == s:TREELIST
|
|
5910 " call Decho("w:netrrw_liststyle is TREELIST:")
|
|
5911 " call Decho("line#".line(".")." getline(.)<".getline('.')."> treecurpos<".string(s:treecurpos).">")
|
2034
|
5912
|
|
5913 " extract tree directory if on a line specifying a subdirectory (ie. ends with "/")
|
1621
|
5914 if getline('.') =~ '/$'
|
|
5915 let treedir= substitute(getline('.'),'^\%(| \)*\([^|].\{-}\)$','\1','e')
|
|
5916 else
|
|
5917 let treedir= ""
|
|
5918 endif
|
|
5919 " call Decho("treedir<".treedir.">")
|
|
5920
|
|
5921 " detect user attempting to close treeroot
|
|
5922 if getline('.') !~ '|' && getline('.') != '..'
|
|
5923 " call Decho("user attempted to close treeroot")
|
|
5924 " now force a refresh
|
|
5925 " call Decho("clear buffer<".expand("%")."> with :%d")
|
|
5926 keepjumps %d
|
|
5927 " call Dret("NetrwTreeDir <".treedir."> : (side effect) s:treecurpos<".string(s:treecurpos).">")
|
|
5928 return b:netrw_curdir
|
|
5929 endif
|
|
5930
|
|
5931 " elide all non-depth information
|
|
5932 let depth = substitute(getline('.'),'^\(\%(| \)*\)[^|].\{-}$','\1','e')
|
2034
|
5933 " call Decho("depth<".depth."> 1st subst (non-depth info removed)")
|
1621
|
5934
|
|
5935 " elide first depth
|
|
5936 let depth = substitute(depth,'^| ','','')
|
2034
|
5937 " call Decho("depth<".depth."> 2nd subst (first depth removed)")
|
1621
|
5938
|
|
5939 " construct treedir by searching backwards at correct depth
|
|
5940 " call Decho("constructing treedir<".treedir."> depth<".depth.">")
|
|
5941 while depth != "" && search('^'.depth.'[^|].\{-}/$','bW')
|
|
5942 let dirname= substitute(getline('.'),'^\(| \)*','','e')
|
|
5943 let treedir= dirname.treedir
|
|
5944 let depth = substitute(depth,'^| ','','')
|
|
5945 " call Decho("constructing treedir<".treedir.">: dirname<".dirname."> while depth<".depth.">")
|
|
5946 endwhile
|
|
5947 if w:netrw_treetop =~ '/$'
|
|
5948 let treedir= w:netrw_treetop.treedir
|
|
5949 else
|
|
5950 let treedir= w:netrw_treetop.'/'.treedir
|
|
5951 endif
|
|
5952 " call Decho("bufnr(.)=".bufnr("%")." line($)=".line("$")." line(.)=".line("."))
|
|
5953 endif
|
|
5954 let treedir= substitute(treedir,'//$','/','')
|
|
5955
|
|
5956 " call Dret("NetrwTreeDir <".treedir."> : (side effect) s:treecurpos<".string(s:treecurpos).">")
|
|
5957 return treedir
|
|
5958 endfun
|
|
5959
|
|
5960 " ---------------------------------------------------------------------
|
|
5961 " s:NetrwTreeDisplay: recursive tree display {{{2
|
|
5962 fun! s:NetrwTreeDisplay(dir,depth)
|
|
5963 " call Dfunc("NetrwTreeDisplay(dir<".a:dir."> depth<".a:depth.">)")
|
|
5964
|
|
5965 " insure that there are no folds
|
|
5966 setlocal nofen
|
|
5967
|
|
5968 " install ../ and shortdir
|
|
5969 if a:depth == ""
|
|
5970 call setline(line("$")+1,'../')
|
|
5971 " call Decho("setline#".line("$")." ../ (depth is zero)")
|
|
5972 endif
|
|
5973 if a:dir =~ '^\a\+://'
|
|
5974 if a:dir == w:netrw_treetop
|
|
5975 let shortdir= a:dir
|
|
5976 else
|
|
5977 let shortdir= substitute(a:dir,'^.*/\([^/]\+\)/$','\1/','e')
|
|
5978 endif
|
|
5979 call setline(line("$")+1,a:depth.shortdir)
|
|
5980 else
|
|
5981 let shortdir= substitute(a:dir,'^.*/','','e')
|
|
5982 call setline(line("$")+1,a:depth.shortdir.'/')
|
|
5983 endif
|
|
5984 " call Decho("setline#".line("$")." shortdir<".a:depth.shortdir.">")
|
|
5985
|
|
5986 " append a / to dir if its missing one
|
|
5987 let dir= a:dir
|
|
5988 if dir !~ '/$'
|
|
5989 let dir= dir.'/'
|
|
5990 endif
|
|
5991
|
|
5992 " display subtrees (if any)
|
|
5993 let depth= "| ".a:depth
|
|
5994
|
|
5995 " call Decho("display subtrees with depth<".depth."> and current leaves")
|
|
5996 for entry in w:netrw_treedict[a:dir]
|
|
5997 let direntry= substitute(dir.entry,'/$','','e')
|
|
5998 " call Decho("dir<".dir."> entry<".entry."> direntry<".direntry.">")
|
|
5999 if entry =~ '/$' && has_key(w:netrw_treedict,direntry)
|
|
6000 " call Decho("<".direntry."> is a key in treedict - display subtree for it")
|
|
6001 call s:NetrwTreeDisplay(direntry,depth)
|
|
6002 elseif entry =~ '/$' && has_key(w:netrw_treedict,direntry.'/')
|
|
6003 " call Decho("<".direntry."/> is a key in treedict - display subtree for it")
|
|
6004 call s:NetrwTreeDisplay(direntry.'/',depth)
|
|
6005 else
|
|
6006 " call Decho("<".entry."> is not a key in treedict (no subtree)")
|
|
6007 call setline(line("$")+1,depth.entry)
|
|
6008 endif
|
|
6009 endfor
|
|
6010 " call Dret("NetrwTreeDisplay")
|
|
6011 endfun
|
|
6012
|
|
6013 " ---------------------------------------------------------------------
|
|
6014 " s:NetrwTreeListing: displays tree listing from treetop on down, using NetrwTreeDisplay() {{{2
|
|
6015 fun! s:NetrwTreeListing(dirname)
|
|
6016 if w:netrw_liststyle == s:TREELIST
|
|
6017 " call Dfunc("NetrwTreeListing() bufname<".expand("%").">")
|
|
6018 " call Decho("curdir<".a:dirname.">")
|
|
6019 " call Decho("win#".winnr().": w:netrw_treetop ".(exists("w:netrw_treetop")? "exists" : "doesn't exit")." w:netrw_treedict ".(exists("w:netrw_treedict")? "exists" : "doesn't exit"))
|
|
6020
|
|
6021 " update the treetop
|
|
6022 " call Decho("update the treetop")
|
|
6023 if !exists("w:netrw_treetop")
|
|
6024 let w:netrw_treetop= a:dirname
|
|
6025 " call Decho("w:netrw_treetop<".w:netrw_treetop."> (reusing)")
|
|
6026 elseif (w:netrw_treetop =~ ('^'.a:dirname) && s:Strlen(a:dirname) < s:Strlen(w:netrw_treetop)) || a:dirname !~ ('^'.w:netrw_treetop)
|
|
6027 let w:netrw_treetop= a:dirname
|
|
6028 " call Decho("w:netrw_treetop<".w:netrw_treetop."> (went up)")
|
|
6029 endif
|
|
6030
|
|
6031 " insure that we have at least an empty treedict
|
|
6032 if !exists("w:netrw_treedict")
|
|
6033 let w:netrw_treedict= {}
|
|
6034 endif
|
|
6035
|
|
6036 " update the directory listing for the current directory
|
|
6037 " call Decho("updating dictionary with ".a:dirname.":[..directory listing..]")
|
|
6038 " call Decho("bannercnt=".w:netrw_bannercnt." line($)=".line("$"))
|
|
6039 exe "silent! keepjumps ".w:netrw_bannercnt.',$g@^\.\.\=/$@d'
|
|
6040 let w:netrw_treedict[a:dirname]= getline(w:netrw_bannercnt,line("$"))
|
|
6041 " call Decho("w:treedict[".a:dirname."]= ".w:netrw_treedict[a:dirname])
|
|
6042 exe "silent! keepjumps ".w:netrw_bannercnt.",$d"
|
|
6043
|
|
6044 " if past banner, record word
|
|
6045 if exists("w:netrw_bannercnt") && line(".") > w:netrw_bannercnt
|
|
6046 let fname= expand("<cword>")
|
|
6047 else
|
|
6048 let fname= ""
|
|
6049 endif
|
|
6050 " call Decho("fname<".fname.">")
|
|
6051
|
|
6052 " display from treetop on down
|
|
6053 call s:NetrwTreeDisplay(w:netrw_treetop,"")
|
|
6054
|
|
6055 " call Dret("NetrwTreeListing : bufname<".expand("%").">")
|
|
6056 endif
|
|
6057 endfun
|
|
6058
|
|
6059 " ---------------------------------------------------------------------
|
|
6060 " s:NetrwWideListing: {{{2
|
|
6061 fun! s:NetrwWideListing()
|
|
6062
|
|
6063 if w:netrw_liststyle == s:WIDELIST
|
|
6064 " call Dfunc("NetrwWideListing() w:netrw_liststyle=".w:netrw_liststyle.' fo='.&fo.' l:fo='.&l:fo)
|
|
6065 " look for longest filename (cpf=characters per filename)
|
2034
|
6066 " cpf: characters per filename
|
|
6067 " fpl: filenames per line
|
|
6068 " fpc: filenames per column
|
1621
|
6069 setlocal ma noro
|
|
6070 " call Decho("setlocal ma noro")
|
|
6071 let b:netrw_cpf= 0
|
|
6072 if line("$") >= w:netrw_bannercnt
|
|
6073 exe 'silent keepjumps '.w:netrw_bannercnt.',$g/^./if virtcol("$") > b:netrw_cpf|let b:netrw_cpf= virtcol("$")|endif'
|
2034
|
6074 call histdel("/",-1)
|
1621
|
6075 else
|
|
6076 " call Dret("NetrwWideListing")
|
|
6077 return
|
|
6078 endif
|
2034
|
6079 let b:netrw_cpf= b:netrw_cpf + 2
|
|
6080 " call Decho("b:netrw_cpf=max_filename_length+2=".b:netrw_cpf)
|
1621
|
6081
|
|
6082 " determine qty files per line (fpl)
|
|
6083 let w:netrw_fpl= winwidth(0)/b:netrw_cpf
|
|
6084 if w:netrw_fpl <= 0
|
|
6085 let w:netrw_fpl= 1
|
|
6086 endif
|
2034
|
6087 " call Decho("fpl= [winwidth=".winwidth(0)."]/[b:netrw_cpf=".b:netrw_cpf.']='.w:netrw_fpl)
|
1621
|
6088
|
|
6089 " make wide display
|
|
6090 exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^.*$/\=escape(printf("%-'.b:netrw_cpf.'s",submatch(0)),"\\")/'
|
2034
|
6091 call histdel("/",-1)
|
1621
|
6092 let fpc = (line("$") - w:netrw_bannercnt + w:netrw_fpl)/w:netrw_fpl
|
|
6093 let newcolstart = w:netrw_bannercnt + fpc
|
|
6094 let newcolend = newcolstart + fpc - 1
|
|
6095 " call Decho("bannercnt=".w:netrw_bannercnt." fpl=".w:netrw_fpl." fpc=".fpc." newcol[".newcolstart.",".newcolend."]")
|
|
6096 silent! let keepregstar = @*
|
|
6097 while line("$") >= newcolstart
|
|
6098 if newcolend > line("$") | let newcolend= line("$") | endif
|
|
6099 let newcolqty= newcolend - newcolstart
|
|
6100 exe newcolstart
|
|
6101 if newcolqty == 0
|
|
6102 exe "silent keepjumps norm! 0\<c-v>$hx".w:netrw_bannercnt."G$p"
|
|
6103 else
|
|
6104 exe "silent keepjumps norm! 0\<c-v>".newcolqty.'j$hx'.w:netrw_bannercnt.'G$p'
|
|
6105 endif
|
|
6106 exe "silent keepjumps ".newcolstart.','.newcolend.'d'
|
|
6107 exe 'silent keepjumps '.w:netrw_bannercnt
|
|
6108 endwhile
|
|
6109 silent! let @*= keepregstar
|
|
6110 exe "silent keepjumps ".w:netrw_bannercnt.',$s/\s\+$//e'
|
2034
|
6111 call histdel("/",-1)
|
1621
|
6112 setlocal noma nomod ro
|
|
6113 " call Dret("NetrwWideListing")
|
|
6114 endif
|
|
6115
|
|
6116 endfun
|
|
6117
|
|
6118 " ---------------------------------------------------------------------
|
|
6119 " s:PerformListing: {{{2
|
|
6120 fun! s:PerformListing(islocal)
|
|
6121 " call Dfunc("s:PerformListing(islocal=".a:islocal.") buf(%)=".bufnr("%")."<".bufname("%").">")
|
|
6122
|
|
6123 call s:NetrwSafeOptions()
|
|
6124 setlocal noro ma
|
|
6125 " call Decho("setlocal noro ma")
|
|
6126
|
|
6127 " if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1 " Decho
|
|
6128 " call Decho("(netrw) Processing your browsing request...")
|
|
6129 " endif " Decho
|
|
6130
|
|
6131 " call Decho('w:netrw_liststyle='.(exists("w:netrw_liststyle")? w:netrw_liststyle : 'n/a'))
|
|
6132 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict")
|
|
6133 " force a refresh for tree listings
|
|
6134 " call Decho("force refresh for treelisting: clear buffer<".expand("%")."> with :%d")
|
|
6135 keepjumps %d
|
|
6136 endif
|
|
6137
|
|
6138 " save current directory on directory history list
|
2034
|
6139 call s:NetrwBookHistHandler(3,b:netrw_curdir)
|
1621
|
6140
|
|
6141 " Set up the banner {{{3
|
2034
|
6142 if g:netrw_banner
|
|
6143 " call Decho("set up banner")
|
|
6144 keepjumps put ='\" ============================================================================'
|
|
6145 keepjumps put ='\" Netrw Directory Listing (netrw '.g:loaded_netrw.')'
|
|
6146 keepjumps put ='\" '.b:netrw_curdir
|
|
6147 keepjumps 1d
|
|
6148 let w:netrw_bannercnt= 3
|
|
6149 exe "keepjumps ".w:netrw_bannercnt
|
|
6150 else
|
|
6151 keepjumps 1
|
|
6152 let w:netrw_bannercnt= 1
|
|
6153 endif
|
1621
|
6154
|
|
6155 let sortby= g:netrw_sort_by
|
|
6156 if g:netrw_sort_direction =~ "^r"
|
|
6157 let sortby= sortby." reversed"
|
|
6158 endif
|
|
6159
|
|
6160 " Sorted by... {{{3
|
2034
|
6161 if g:netrw_banner
|
|
6162 " call Decho("handle specified sorting: g:netrw_sort_by<".g:netrw_sort_by.">")
|
|
6163 if g:netrw_sort_by =~ "^n"
|
1621
|
6164 " call Decho("directories will be sorted by name")
|
2034
|
6165 " sorted by name
|
|
6166 keepjumps put ='\" Sorted by '.sortby
|
|
6167 keepjumps put ='\" Sort sequence: '.g:netrw_sort_sequence
|
|
6168 let w:netrw_bannercnt= w:netrw_bannercnt + 2
|
|
6169 else
|
1621
|
6170 " call Decho("directories will be sorted by size or time")
|
2034
|
6171 " sorted by size or date
|
|
6172 keepjumps put ='\" Sorted by '.sortby
|
|
6173 let w:netrw_bannercnt= w:netrw_bannercnt + 1
|
|
6174 endif
|
|
6175 exe "keepjumps ".w:netrw_bannercnt
|
|
6176 endif
|
1621
|
6177
|
|
6178 " show copy/move target, if any
|
2034
|
6179 if g:netrw_banner
|
|
6180 if exists("s:netrwmftgt") && exists("s:netrwmftgt_islocal")
|
|
6181 " call Decho("show copy/move target<".s:netrwmftgt.">")
|
|
6182 keepjumps put =''
|
|
6183 if s:netrwmftgt_islocal
|
|
6184 call setline(line("."),'" Copy/Move Tgt: '.s:netrwmftgt.' (local)')
|
|
6185 else
|
|
6186 call setline(line("."),'" Copy/Move Tgt: '.s:netrwmftgt.' (remote)')
|
|
6187 endif
|
|
6188 let w:netrw_bannercnt= w:netrw_bannercnt + 1
|
1621
|
6189 else
|
2034
|
6190 " call Decho("s:netrwmftgt does not exist, don't make Copy/Move Tgt")
|
|
6191 endif
|
|
6192 exe "keepjumps ".w:netrw_bannercnt
|
|
6193 endif
|
1621
|
6194
|
|
6195 " Hiding... -or- Showing... {{{3
|
2034
|
6196 if g:netrw_banner
|
|
6197 " call Decho("handle hiding/showing (g:netrw_hide=".g:netrw_list_hide." g:netrw_list_hide<".g:netrw_list_hide.">)")
|
|
6198 if g:netrw_list_hide != "" && g:netrw_hide
|
|
6199 if g:netrw_hide == 1
|
|
6200 keepjumps put ='\" Hiding: '.g:netrw_list_hide
|
|
6201 else
|
|
6202 keepjumps put ='\" Showing: '.g:netrw_list_hide
|
|
6203 endif
|
|
6204 let w:netrw_bannercnt= w:netrw_bannercnt + 1
|
|
6205 endif
|
|
6206 exe "keepjumps ".w:netrw_bannercnt
|
|
6207 keepjumps put ='\" Quick Help: <F1>:help -:go up dir D:delete R:rename s:sort-by x:exec'
|
|
6208 keepjumps put ='\" ============================================================================'
|
|
6209 let w:netrw_bannercnt= w:netrw_bannercnt + 2
|
|
6210 endif
|
1621
|
6211
|
|
6212 " bannercnt should index the line just after the banner
|
2034
|
6213 if g:netrw_banner
|
|
6214 let w:netrw_bannercnt= w:netrw_bannercnt + 1
|
|
6215 exe "keepjumps ".w:netrw_bannercnt
|
|
6216 " call Decho("bannercnt=".w:netrw_bannercnt." (should index line just after banner) line($)=".line("$"))
|
|
6217 endif
|
1621
|
6218
|
|
6219 " set up syntax highlighting {{{3
|
|
6220 " call Decho("set up syntax highlighting")
|
|
6221 if has("syntax")
|
|
6222 setlocal ft=netrw
|
|
6223 if !exists("g:syntax_on") || !g:syntax_on
|
|
6224 setlocal ft=
|
|
6225 endif
|
|
6226 endif
|
|
6227
|
|
6228 " get list of files
|
|
6229 " call Decho("Get list of files - islocal=".a:islocal)
|
|
6230 if a:islocal
|
|
6231 call s:LocalListing()
|
|
6232 else " remote
|
|
6233 call s:NetrwRemoteListing()
|
|
6234 endif
|
2034
|
6235 " call Decho("g:netrw_banner=".g:netrw_banner." w:netrw_bannercnt=".w:netrw_bannercnt." (banner complete)")
|
1621
|
6236
|
|
6237 " manipulate the directory listing (hide, sort) {{{3
|
2034
|
6238 if !g:netrw_banner || line("$") >= w:netrw_bannercnt
|
1621
|
6239 " call Decho("manipulate directory listing (hide)")
|
|
6240 " call Decho("g:netrw_hide=".g:netrw_hide." g:netrw_list_hide<".g:netrw_list_hide.">")
|
|
6241 if g:netrw_hide && g:netrw_list_hide != ""
|
|
6242 call s:NetrwListHide()
|
|
6243 endif
|
2034
|
6244 if !g:netrw_banner || line("$") >= w:netrw_bannercnt
|
1621
|
6245 " call Decho("manipulate directory listing (sort) : g:netrw_sort_by<".g:netrw_sort_by.">")
|
|
6246
|
|
6247 if g:netrw_sort_by =~ "^n"
|
|
6248 " sort by name
|
|
6249 call s:NetrwSetSort()
|
|
6250
|
2034
|
6251 if !g:netrw_banner || w:netrw_bannercnt < line("$")
|
1621
|
6252 " call Decho("g:netrw_sort_direction=".g:netrw_sort_direction." (bannercnt=".w:netrw_bannercnt.")")
|
|
6253 if g:netrw_sort_direction =~ 'n'
|
|
6254 " normal direction sorting
|
1668
|
6255 exe 'silent keepjumps '.w:netrw_bannercnt.',$sort'.' '.g:netrw_sort_options
|
1621
|
6256 else
|
|
6257 " reverse direction sorting
|
1668
|
6258 exe 'silent keepjumps '.w:netrw_bannercnt.',$sort!'.' '.g:netrw_sort_options
|
1621
|
6259 endif
|
|
6260 endif
|
|
6261 " remove priority pattern prefix
|
|
6262 " call Decho("remove priority pattern prefix")
|
2034
|
6263 exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\d\{3}'.g:netrw_sepchr.'//e'
|
|
6264 call histdel("/",-1)
|
1621
|
6265
|
|
6266 elseif a:islocal
|
2034
|
6267 if !g:netrw_banner || w:netrw_bannercnt < line("$")
|
1621
|
6268 " call Decho("g:netrw_sort_direction=".g:netrw_sort_direction)
|
|
6269 if g:netrw_sort_direction =~ 'n'
|
|
6270 " call Decho('exe silent keepjumps '.w:netrw_bannercnt.',$sort')
|
1668
|
6271 exe 'silent keepjumps '.w:netrw_bannercnt.',$sort'.' '.g:netrw_sort_options
|
1621
|
6272 else
|
|
6273 " call Decho('exe silent keepjumps '.w:netrw_bannercnt.',$sort!')
|
1668
|
6274 exe 'silent keepjumps '.w:netrw_bannercnt.',$sort!'.' '.g:netrw_sort_options
|
1621
|
6275 endif
|
2034
|
6276 exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\d\{-}\///e'
|
|
6277 call histdel("/",-1)
|
1621
|
6278 endif
|
|
6279 endif
|
|
6280
|
|
6281 elseif g:netrw_sort_direction =~ 'r'
|
|
6282 " call Decho('reverse the sorted listing')
|
2034
|
6283 if !g:netrw_banner || w:netrw_bannercnt < line('$')
|
|
6284 exe 'silent keepjumps '.w:netrw_bannercnt.',$g/^/m '.w:netrw_bannercnt
|
|
6285 call histdel("/",-1)
|
|
6286 endif
|
1621
|
6287 endif
|
|
6288 endif
|
|
6289
|
|
6290 " convert to wide/tree listing {{{3
|
|
6291 " call Decho("modify display if wide/tree listing style")
|
|
6292 call s:NetrwWideListing()
|
|
6293 call s:NetrwTreeListing(b:netrw_curdir)
|
|
6294
|
2034
|
6295 if exists("w:netrw_bannercnt") && (line("$") > w:netrw_bannercnt || !g:netrw_banner)
|
1621
|
6296 " place cursor on the top-left corner of the file listing
|
|
6297 " call Decho("place cursor on top-left corner of file listing")
|
|
6298 exe 'silent keepjumps '.w:netrw_bannercnt
|
|
6299 norm! 0
|
|
6300 endif
|
|
6301
|
|
6302 " record previous current directory
|
|
6303 let w:netrw_prvdir= b:netrw_curdir
|
|
6304 " call Decho("record netrw_prvdir<".w:netrw_prvdir.">")
|
|
6305
|
|
6306 " save certain window-oriented variables into buffer-oriented variables {{{3
|
|
6307 call s:SetBufWinVars()
|
|
6308 call s:NetrwOptionRestore("w:")
|
|
6309
|
|
6310 " set display to netrw display settings
|
|
6311 " call Decho("set display to netrw display settings (noma nomod etc)")
|
|
6312 setlocal noma nomod nonu nobl nowrap ro
|
|
6313 if exists("s:treecurpos")
|
|
6314
|
|
6315 call netrw#NetrwRestorePosn(s:treecurpos)
|
|
6316 unlet s:treecurpos
|
|
6317 endif
|
|
6318
|
|
6319 " call Dret("s:PerformListing : curpos<".string(getpos(".")).">")
|
|
6320 endfun
|
|
6321
|
|
6322 " ---------------------------------------------------------------------
|
|
6323 " s:SetupNetrwStatusLine: {{{2
|
1121
|
6324 fun! s:SetupNetrwStatusLine(statline)
|
|
6325 " call Dfunc("SetupNetrwStatusLine(statline<".a:statline.">)")
|
|
6326
|
|
6327 if !exists("s:netrw_setup_statline")
|
|
6328 let s:netrw_setup_statline= 1
|
|
6329 " call Decho("do first-time status line setup")
|
|
6330
|
|
6331 if !exists("s:netrw_users_stl")
|
|
6332 let s:netrw_users_stl= &stl
|
|
6333 endif
|
|
6334 if !exists("s:netrw_users_ls")
|
|
6335 let s:netrw_users_ls= &laststatus
|
|
6336 endif
|
|
6337
|
|
6338 " set up User9 highlighting as needed
|
|
6339 let keepa= @a
|
|
6340 redir @a
|
|
6341 try
|
|
6342 hi User9
|
|
6343 catch /^Vim\%((\a\+)\)\=:E411/
|
|
6344 if &bg == "dark"
|
|
6345 hi User9 ctermfg=yellow ctermbg=blue guifg=yellow guibg=blue
|
|
6346 else
|
|
6347 hi User9 ctermbg=yellow ctermfg=blue guibg=yellow guifg=blue
|
|
6348 endif
|
|
6349 endtry
|
|
6350 redir END
|
|
6351 let @a= keepa
|
|
6352 endif
|
|
6353
|
|
6354 " set up status line (may use User9 highlighting)
|
|
6355 " insure that windows have a statusline
|
|
6356 " make sure statusline is displayed
|
|
6357 let &stl=a:statline
|
|
6358 setlocal laststatus=2
|
|
6359 " call Decho("stl=".&stl)
|
1621
|
6360 redraw
|
1121
|
6361
|
|
6362 " call Dret("SetupNetrwStatusLine : stl=".&stl)
|
|
6363 endfun
|
|
6364
|
|
6365 " ---------------------------------------------------------------------
|
1621
|
6366 " Remote Directory Browsing Support: {{{1
|
|
6367 " ===========================================
|
|
6368
|
|
6369 " ---------------------------------------------------------------------
|
|
6370 " s:NetrwRemoteListing: {{{2
|
|
6371 fun! s:NetrwRemoteListing()
|
|
6372 " call Dfunc("s:NetrwRemoteListing() b:netrw_curdir<".b:netrw_curdir.">)")
|
|
6373
|
|
6374 call s:RemotePathAnalysis(b:netrw_curdir)
|
|
6375
|
|
6376 " sanity check:
|
|
6377 if exists("b:netrw_method") && b:netrw_method =~ '[235]'
|
|
6378 " call Decho("b:netrw_method=".b:netrw_method)
|
|
6379 if !executable("ftp")
|
|
6380 if !exists("g:netrw_quiet")
|
|
6381 call netrw#ErrorMsg(s:ERROR,"this system doesn't support remote directory listing via ftp",18)
|
|
6382 endif
|
|
6383 call s:NetrwOptionRestore("w:")
|
|
6384 " call Dret("s:NetrwRemoteListing")
|
|
6385 return
|
|
6386 endif
|
|
6387
|
|
6388 elseif !exists("g:netrw_list_cmd") || g:netrw_list_cmd == ''
|
|
6389 if !exists("g:netrw_quiet")
|
|
6390 if g:netrw_list_cmd == ""
|
|
6391 call netrw#ErrorMsg(s:ERROR,g:netrw_ssh_cmd." is not executable on your system",47)
|
|
6392 else
|
|
6393 call netrw#ErrorMsg(s:ERROR,"this system doesn't support remote directory listing via ".g:netrw_list_cmd,19)
|
|
6394 endif
|
|
6395 endif
|
|
6396
|
|
6397 call s:NetrwOptionRestore("w:")
|
|
6398 " call Dret("s:NetrwRemoteListing")
|
|
6399 return
|
|
6400 endif " (remote handling sanity check)
|
|
6401
|
|
6402 if exists("b:netrw_method")
|
|
6403 " call Decho("setting w:netrw_method<".b:netrw_method.">")
|
|
6404 let w:netrw_method= b:netrw_method
|
|
6405 endif
|
|
6406
|
|
6407 if s:method == "ftp"
|
|
6408 " use ftp to get remote file listing
|
|
6409 " call Decho("use ftp to get remote file listing")
|
|
6410 let s:method = "ftp"
|
|
6411 let listcmd = g:netrw_ftp_list_cmd
|
|
6412 if g:netrw_sort_by =~ '^t'
|
|
6413 let listcmd= g:netrw_ftp_timelist_cmd
|
|
6414 elseif g:netrw_sort_by =~ '^s'
|
|
6415 let listcmd= g:netrw_ftp_sizelist_cmd
|
|
6416 endif
|
|
6417 " call Decho("listcmd<".listcmd."> (using g:netrw_ftp_list_cmd)")
|
|
6418 call s:NetrwRemoteFtpCmd(s:path,listcmd)
|
|
6419 " exe "keepjumps ".w:netrw_bannercnt.',$g/^./call Decho("raw listing: ".getline("."))'
|
|
6420
|
|
6421 if w:netrw_liststyle == s:THINLIST || w:netrw_liststyle == s:WIDELIST || w:netrw_liststyle == s:TREELIST
|
|
6422 " shorten the listing
|
|
6423 " call Decho("generate short listing")
|
|
6424 exe "keepjumps ".w:netrw_bannercnt
|
|
6425
|
|
6426 " cleanup
|
|
6427 if g:netrw_ftp_browse_reject != ""
|
|
6428 exe "silent! g/".g:netrw_ftp_browse_reject."/keepjumps d"
|
2034
|
6429 call histdel("/",-1)
|
1621
|
6430 endif
|
|
6431 silent! keepjumps %s/\r$//e
|
2034
|
6432 call histdel("/",-1)
|
1621
|
6433
|
|
6434 " if there's no ../ listed, then put ./ and ../ in
|
|
6435 let line1= line(".")
|
|
6436 exe "keepjumps ".w:netrw_bannercnt
|
|
6437 let line2= search('^\.\.\/\%(\s\|$\)','cnW')
|
|
6438 if line2 == 0
|
|
6439 " call Decho("netrw is putting ./ and ../ into listing")
|
|
6440 keepjumps put='../'
|
|
6441 keepjumps put='./'
|
|
6442 endif
|
|
6443 exe "keepjumps ".line1
|
|
6444 keepjumps norm! 0
|
|
6445
|
|
6446 " call Decho("line1=".line1." line2=".line2." line(.)=".line("."))
|
|
6447 if search('^\d\{2}-\d\{2}-\d\{2}\s','n') " M$ ftp site cleanup
|
|
6448 " call Decho("M$ ftp cleanup")
|
|
6449 exe 'silent! keepjumps '.w:netrw_bannercnt.',$s/^\d\{2}-\d\{2}-\d\{2}\s\+\d\+:\d\+[AaPp][Mm]\s\+\%(<DIR>\|\d\+\)\s\+//'
|
2034
|
6450 call histdel("/",-1)
|
1621
|
6451 else " normal ftp cleanup
|
|
6452 " call Decho("normal ftp cleanup")
|
|
6453 exe 'silent! keepjumps '.w:netrw_bannercnt.',$s/^\(\%(\S\+\s\+\)\{7}\S\+\)\s\+\(\S.*\)$/\2/e'
|
|
6454 exe "silent! keepjumps ".w:netrw_bannercnt.',$g/ -> /s# -> .*/$#/#e'
|
|
6455 exe "silent! keepjumps ".w:netrw_bannercnt.',$g/ -> /s# -> .*$#/#e'
|
2034
|
6456 call histdel("/",-1)
|
|
6457 call histdel("/",-1)
|
|
6458 call histdel("/",-1)
|
1621
|
6459 endif
|
|
6460 endif
|
|
6461
|
1121
|
6462 else
|
1621
|
6463 " use ssh to get remote file listing {{{3
|
|
6464 " call Decho("use ssh to get remote file listing: s:path<".s:path.">")
|
|
6465 let listcmd= s:MakeSshCmd(g:netrw_list_cmd)
|
|
6466 " call Decho("listcmd<".listcmd."> (using g:netrw_list_cmd)")
|
|
6467 if g:netrw_scp_cmd =~ '^pscp'
|
1698
|
6468 " call Decho("1: exe silent r! ".shellescape(listcmd.s:path, 1))
|
|
6469 exe "silent r! ".listcmd.shellescape(s:path, 1)
|
1621
|
6470 " remove rubbish and adjust listing format of 'pscp' to 'ssh ls -FLa' like
|
|
6471 g/^Listing directory/d
|
|
6472 g/^d[-rwx][-rwx][-rwx]/s+$+/+e
|
|
6473 silent g/^l[-rwx][-rwx][-rwx]/s+$+@+e
|
2034
|
6474 call histdel("/",-1)
|
|
6475 call histdel("/",-1)
|
|
6476 call histdel("/",-1)
|
1621
|
6477 if g:netrw_liststyle != s:LONGLIST
|
|
6478 g/^[dlsp-][-rwx][-rwx][-rwx]/s/^.*\s\(\S\+\)$/\1/e
|
2034
|
6479 call histdel("/",-1)
|
1621
|
6480 endif
|
|
6481 else
|
|
6482 if s:path == ""
|
|
6483 " call Decho("2: exe silent r! ".listcmd)
|
|
6484 exe "silent r! ".listcmd
|
|
6485 else
|
1668
|
6486 " call Decho("3: exe silent r! ".listcmd.' '.shellescape(s:path,1))
|
|
6487 exe "silent r! ".listcmd.' '.shellescape(s:path,1)
|
1621
|
6488 " call Decho("listcmd<".listcmd."> path<".s:path.">")
|
|
6489 endif
|
|
6490 endif
|
|
6491
|
|
6492 " cleanup
|
|
6493 if g:netrw_ftp_browse_reject != ""
|
|
6494 " call Decho("(cleanup) exe silent! g/".g:netrw_ssh_browse_reject."/keepjumps d")
|
|
6495 exe "silent! g/".g:netrw_ssh_browse_reject."/keepjumps d"
|
2034
|
6496 call histdel("/",-1)
|
1621
|
6497 endif
|
|
6498 endif
|
|
6499
|
|
6500 if w:netrw_liststyle == s:LONGLIST
|
|
6501 " do a long listing; these substitutions need to be done prior to sorting {{{3
|
|
6502 " call Decho("fix long listing:")
|
|
6503
|
|
6504 if s:method == "ftp"
|
|
6505 " cleanup
|
|
6506 exe "keepjumps ".w:netrw_bannercnt
|
|
6507 while getline('.') =~ g:netrw_ftp_browse_reject
|
|
6508 keepjumps d
|
|
6509 endwhile
|
|
6510 " if there's no ../ listed, then put ./ and ../ in
|
|
6511 let line1= line(".")
|
|
6512 keepjumps 1
|
|
6513 silent keepjumps call search('^\.\.\/\%(\s\|$\)','W')
|
|
6514 let line2= line(".")
|
|
6515 if line2 == 0
|
|
6516 exe 'keepjumps '.w:netrw_bannercnt."put='./'"
|
|
6517 if b:netrw_curdir != '/'
|
|
6518 exe 'keepjumps '.w:netrw_bannercnt."put='../'"
|
|
6519 endif
|
|
6520 endif
|
|
6521 exe "keepjumps ".line1
|
|
6522 keepjumps norm! 0
|
|
6523 endif
|
|
6524
|
|
6525 if search('^\d\{2}-\d\{2}-\d\{2}\s','n') " M$ ftp site cleanup
|
|
6526 " call Decho("M$ ftp site listing cleanup")
|
|
6527 exe 'silent! keepjumps '.w:netrw_bannercnt.',$s/^\(\d\{2}-\d\{2}-\d\{2}\s\+\d\+:\d\+[AaPp][Mm]\s\+\%(<DIR>\|\d\+\)\s\+\)\(\w.*\)$/\2\t\1/'
|
|
6528 elseif exists("w:netrw_bannercnt") && w:netrw_bannercnt <= line("$")
|
|
6529 " call Decho("normal ftp site listing cleanup: bannercnt=".w:netrw_bannercnt." line($)=".line("$"))
|
|
6530 exe 'silent keepjumps '.w:netrw_bannercnt.',$s/ -> .*$//e'
|
|
6531 exe 'silent keepjumps '.w:netrw_bannercnt.',$s/^\(\%(\S\+\s\+\)\{7}\S\+\)\s\+\(\S.*\)$/\2\t\1/e'
|
|
6532 exe 'silent keepjumps '.w:netrw_bannercnt
|
2034
|
6533 call histdel("/",-1)
|
|
6534 call histdel("/",-1)
|
|
6535 call histdel("/",-1)
|
1621
|
6536 endif
|
|
6537 endif
|
|
6538
|
|
6539 " if exists("w:netrw_bannercnt") && w:netrw_bannercnt <= line("$") " Decho
|
|
6540 " exe "keepjumps ".w:netrw_bannercnt.',$g/^./call Decho("listing: ".getline("."))'
|
|
6541 " endif " Decho
|
|
6542 " call Dret("s:NetrwRemoteListing")
|
|
6543 endfun
|
|
6544
|
|
6545 " ---------------------------------------------------------------------
|
|
6546 " s:NetrwRemoteRm: remove/delete a remote file or directory {{{2
|
|
6547 fun! s:NetrwRemoteRm(usrhost,path) range
|
|
6548 " call Dfunc("s:NetrwRemoteRm(usrhost<".a:usrhost."> path<".a:path.">) virtcol=".virtcol("."))
|
|
6549 " call Decho("firstline=".a:firstline." lastline=".a:lastline)
|
|
6550 let svpos= netrw#NetrwSavePosn()
|
|
6551
|
|
6552 let all= 0
|
|
6553 if exists("s:netrwmarkfilelist_{bufnr('%')}")
|
|
6554 " remove all marked files
|
2034
|
6555 " call Decho("remove all marked files with bufnr#".bufnr("%"))
|
1621
|
6556 for fname in s:netrwmarkfilelist_{bufnr("%")}
|
|
6557 let ok= s:NetrwRemoteRmFile(a:path,fname,all)
|
|
6558 if ok =~ 'q\%[uit]'
|
|
6559 break
|
|
6560 elseif ok =~ 'a\%[ll]'
|
|
6561 let all= 1
|
|
6562 endif
|
|
6563 endfor
|
2034
|
6564 call s:NetrwUnmarkList(bufnr("%"),b:netrw_curdir)
|
1621
|
6565
|
|
6566 else
|
|
6567 " remove files specified by range
|
2034
|
6568 " call Decho("remove files specified by range")
|
1621
|
6569
|
|
6570 " preparation for removing multiple files/directories
|
|
6571 let ctr= a:firstline
|
|
6572
|
|
6573 " remove multiple files and directories
|
|
6574 while ctr <= a:lastline
|
|
6575 exe ctr
|
|
6576 let ok= s:NetrwRemoteRmFile(a:path,s:NetrwGetWord(),all)
|
|
6577 if ok =~ 'q\%[uit]'
|
|
6578 break
|
|
6579 elseif ok =~ 'a\%[ll]'
|
|
6580 let all= 1
|
|
6581 endif
|
|
6582 let ctr= ctr + 1
|
|
6583 endwhile
|
|
6584 endif
|
|
6585
|
|
6586 " refresh the (remote) directory listing
|
|
6587 " call Decho("refresh remote directory listing")
|
|
6588 call s:NetrwRefresh(0,s:NetrwBrowseChgDir(0,'./'))
|
|
6589 call netrw#NetrwRestorePosn(svpos)
|
|
6590
|
|
6591 " call Dret("s:NetrwRemoteRm")
|
1121
|
6592 endfun
|
|
6593
|
|
6594 " ---------------------------------------------------------------------
|
1621
|
6595 " s:NetrwRemoteRmFile: {{{2
|
|
6596 fun! s:NetrwRemoteRmFile(path,rmfile,all)
|
|
6597 " call Dfunc("s:NetrwRemoteRmFile(path<".a:path."> rmfile<".a:rmfile.">) all=".a:all)
|
|
6598
|
|
6599 let all= a:all
|
|
6600 let ok = ""
|
|
6601
|
|
6602 if a:rmfile !~ '^"' && (a:rmfile =~ '@$' || a:rmfile !~ '[\/]$')
|
|
6603 " attempt to remove file
|
|
6604 " call Decho("attempt to remove file (all=".all.")")
|
|
6605 if !all
|
|
6606 echohl Statement
|
|
6607 " call Decho("case all=0:")
|
|
6608 call inputsave()
|
|
6609 let ok= input("Confirm deletion of file<".a:rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ")
|
|
6610 call inputrestore()
|
|
6611 echohl NONE
|
|
6612 if ok == ""
|
|
6613 let ok="no"
|
|
6614 endif
|
|
6615 let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e')
|
|
6616 if ok =~ 'a\%[ll]'
|
|
6617 let all= 1
|
|
6618 endif
|
|
6619 endif
|
|
6620
|
|
6621 if all || ok =~ 'y\%[es]' || ok == ""
|
|
6622 " call Decho("case all=".all." or ok<".ok.">".(exists("w:netrw_method")? ': netrw_method='.w:netrw_method : ""))
|
|
6623 if exists("w:netrw_method") && (w:netrw_method == 2 || w:netrw_method == 3)
|
|
6624 " call Decho("case ftp:")
|
|
6625 let path= a:path
|
|
6626 if path =~ '^\a\+://'
|
|
6627 let path= substitute(path,'^\a\+://[^/]\+/','','')
|
|
6628 endif
|
|
6629 silent! keepjumps .,$d
|
|
6630 call s:NetrwRemoteFtpCmd(path,"delete ".'"'.a:rmfile.'"')
|
|
6631 else
|
|
6632 " call Decho("case ssh: g:netrw_rm_cmd<".g:netrw_rm_cmd.">")
|
|
6633 let netrw_rm_cmd= s:MakeSshCmd(g:netrw_rm_cmd)
|
|
6634 " call Decho("netrw_rm_cmd<".netrw_rm_cmd.">")
|
|
6635 if !exists("b:netrw_curdir")
|
|
6636 call netrw#ErrorMsg(s:ERROR,"for some reason b:netrw_curdir doesn't exist!",53)
|
|
6637 let ok="q"
|
|
6638 else
|
|
6639 let remotedir= substitute(b:netrw_curdir,'^.*//[^/]\+/\(.*\)$','\1','')
|
|
6640 " call Decho("netrw_rm_cmd<".netrw_rm_cmd.">")
|
|
6641 " call Decho("remotedir<".remotedir.">")
|
|
6642 " call Decho("rmfile<".a:rmfile.">")
|
|
6643 if remotedir != ""
|
|
6644 let netrw_rm_cmd= netrw_rm_cmd." ".shellescape(fnameescape(remotedir.a:rmfile))
|
|
6645 else
|
|
6646 let netrw_rm_cmd= netrw_rm_cmd." ".shellescape(fnameescape(a:rmfile))
|
|
6647 endif
|
|
6648 " call Decho("call system(".netrw_rm_cmd.")")
|
|
6649 let ret= system(netrw_rm_cmd)
|
|
6650 if ret != 0
|
|
6651 call netrw#ErrorMsg(s:WARNING,"cmd<".netrw_rm_cmd."> failed",60)
|
|
6652 endif
|
|
6653 " call Decho("returned=".ret." errcode=".v:shell_error)
|
|
6654 endif
|
|
6655 endif
|
|
6656 elseif ok =~ 'q\%[uit]'
|
|
6657 " call Decho("ok==".ok)
|
|
6658 break
|
|
6659 endif
|
|
6660
|
|
6661 else
|
|
6662 " attempt to remove directory
|
|
6663 " call Decho("attempt to remove directory")
|
|
6664 if !all
|
|
6665 call inputsave()
|
|
6666 let ok= input("Confirm deletion of directory<".a:rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ")
|
|
6667 call inputrestore()
|
|
6668 if ok == ""
|
|
6669 let ok="no"
|
|
6670 endif
|
|
6671 let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e')
|
|
6672 if ok =~ 'a\%[ll]'
|
|
6673 let all= 1
|
|
6674 endif
|
|
6675 endif
|
|
6676
|
|
6677 if all || ok =~ 'y\%[es]' || ok == ""
|
|
6678 if exists("w:netrw_method") && (w:netrw_method == 2 || w:netrw_method == 3)
|
|
6679 call s:NetrwRemoteFtpCmd(a:path,"rmdir ".a:rmfile)
|
|
6680 else
|
|
6681 let rmfile = substitute(a:path.a:rmfile,'/$','','')
|
2034
|
6682 let netrw_rmdir_cmd = s:MakeSshCmd(netrw#WinPath(g:netrw_rmdir_cmd)).' '.shellescape(netrw#WinPath(rmfile))
|
1621
|
6683 " call Decho("attempt to remove dir: system(".netrw_rmdir_cmd.")")
|
1668
|
6684 let ret= system(netrw_rmdir_cmd)
|
1621
|
6685 " call Decho("returned=".ret." errcode=".v:shell_error)
|
|
6686
|
|
6687 if v:shell_error != 0
|
1668
|
6688 " call Decho("v:shell_error not 0")
|
2034
|
6689 let netrw_rmf_cmd= s:MakeSshCmd(netrw#WinPath(g:netrw_rmf_cmd)).' '.shellescape(netrw#WinPath(substitute(rmfile,'[\/]$','','e')))
|
1668
|
6690 " call Decho("2nd attempt to remove dir: system(".netrw_rmf_cmd.")")
|
|
6691 let ret= system(netrw_rmf_cmd)
|
|
6692 " call Decho("returned=".ret." errcode=".v:shell_error)
|
1621
|
6693
|
|
6694 if v:shell_error != 0 && !exists("g:netrw_quiet")
|
|
6695 call netrw#ErrorMsg(s:ERROR,"unable to remove directory<".rmfile."> -- is it empty?",22)
|
|
6696 endif
|
|
6697 endif
|
|
6698 endif
|
|
6699
|
|
6700 elseif ok =~ 'q\%[uit]'
|
|
6701 break
|
|
6702 endif
|
|
6703 endif
|
|
6704
|
|
6705 " call Dret("s:NetrwRemoteRmFile ".ok)
|
|
6706 return ok
|
|
6707 endfun
|
|
6708
|
|
6709 " ---------------------------------------------------------------------
|
|
6710 " s:NetrwRemoteFtpCmd: unfortunately, not all ftp servers honor options for ls {{{2
|
|
6711 " This function assumes that a long listing will be received. Size, time,
|
|
6712 " and reverse sorts will be requested of the server but not otherwise
|
|
6713 " enforced here.
|
|
6714 fun! s:NetrwRemoteFtpCmd(path,listcmd)
|
|
6715 " call Dfunc("NetrwRemoteFtpCmd(path<".a:path."> listcmd<".a:listcmd.">) netrw_method=".w:netrw_method)
|
|
6716 " call Decho("line($)=".line("$")." bannercnt=".w:netrw_bannercnt)
|
|
6717
|
|
6718 " because WinXX ftp uses unix style input
|
|
6719 let ffkeep= &ff
|
|
6720 setlocal ma ff=unix noro
|
|
6721 " call Decho("setlocal ma ff=unix noro")
|
|
6722
|
|
6723 " clear off any older non-banner lines
|
|
6724 " note that w:netrw_bannercnt indexes the line after the banner
|
|
6725 " call Decho('exe silent! keepjumps '.w:netrw_bannercnt.",$d (clear off old non-banner lines)")
|
|
6726 exe "silent! keepjumps ".w:netrw_bannercnt.",$d"
|
|
6727
|
|
6728 ".........................................
|
|
6729 if w:netrw_method == 2 || w:netrw_method == 5
|
|
6730 " ftp + <.netrc>: Method #2
|
|
6731 if a:path != ""
|
|
6732 put ='cd \"'.a:path.'\"'
|
|
6733 endif
|
|
6734 if exists("g:netrw_ftpextracmd")
|
1698
|
6735 put =g:netrw_ftpextracmd
|
1621
|
6736 " call Decho("filter input: ".getline('.'))
|
|
6737 endif
|
|
6738 call setline(line("$")+1,a:listcmd)
|
|
6739 " exe "keepjumps ".w:netrw_bannercnt.',$g/^./call Decho("ftp#".line(".").": ".getline("."))'
|
|
6740 if exists("g:netrw_port") && g:netrw_port != ""
|
1668
|
6741 " call Decho("exe ".s:netrw_silentxfer.w:netrw_bannercnt.",$!".g:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1))
|
|
6742 exe s:netrw_silentxfer." keepjumps ".w:netrw_bannercnt.",$!".g:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)." ".shellescape(g:netrw_port,1)
|
1621
|
6743 else
|
1668
|
6744 " call Decho("exe ".s:netrw_silentxfer.w:netrw_bannercnt.",$!".g:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1))
|
|
6745 exe s:netrw_silentxfer." keepjumps ".w:netrw_bannercnt.",$!".g:netrw_ftp_cmd." -i ".shellescape(g:netrw_machine,1)
|
1621
|
6746 endif
|
|
6747
|
|
6748 ".........................................
|
|
6749 elseif w:netrw_method == 3
|
|
6750 " ftp + machine,id,passwd,filename: Method #3
|
|
6751 setlocal ff=unix
|
|
6752 if exists("g:netrw_port") && g:netrw_port != ""
|
|
6753 put ='open '.g:netrw_machine.' '.g:netrw_port
|
|
6754 else
|
|
6755 put ='open '.g:netrw_machine
|
|
6756 endif
|
|
6757
|
|
6758 if exists("g:netrw_ftp") && g:netrw_ftp == 1
|
|
6759 put =g:netrw_uid
|
|
6760 put ='\"'.s:netrw_passwd.'\"'
|
|
6761 else
|
|
6762 put ='user \"'.g:netrw_uid.'\" \"'.s:netrw_passwd.'\"'
|
|
6763 endif
|
|
6764
|
|
6765 if a:path != ""
|
|
6766 put ='cd \"'.a:path.'\"'
|
|
6767 endif
|
|
6768 if exists("g:netrw_ftpextracmd")
|
1698
|
6769 put =g:netrw_ftpextracmd
|
1621
|
6770 " call Decho("filter input: ".getline('.'))
|
|
6771 endif
|
|
6772 call setline(line("$")+1,a:listcmd)
|
|
6773
|
|
6774 " perform ftp:
|
|
6775 " -i : turns off interactive prompting from ftp
|
|
6776 " -n unix : DON'T use <.netrc>, even though it exists
|
|
6777 " -n win32: quit being obnoxious about password
|
|
6778 " exe w:netrw_bannercnt.',$g/^./call Decho("ftp#".line(".").": ".getline("."))'
|
|
6779 " call Decho("exe ".s:netrw_silentxfer.w:netrw_bannercnt.",$!".g:netrw_ftp_cmd." -i -n")
|
|
6780 exe s:netrw_silentxfer.w:netrw_bannercnt.",$!".g:netrw_ftp_cmd." -i -n"
|
|
6781
|
|
6782 ".........................................
|
|
6783 else
|
|
6784 call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . choice . ">",23)
|
|
6785 endif
|
|
6786
|
|
6787 " cleanup for Windows
|
|
6788 if has("win32") || has("win95") || has("win64") || has("win16")
|
|
6789 silent! keepjumps %s/\r$//e
|
2034
|
6790 call histdel("/",-1)
|
1621
|
6791 endif
|
|
6792 if a:listcmd == "dir"
|
|
6793 " infer directory/link based on the file permission string
|
|
6794 silent! keepjumps g/d\%([-r][-w][-x]\)\{3}/s@$@/@
|
|
6795 silent! keepjumps g/l\%([-r][-w][-x]\)\{3}/s/$/@/
|
2034
|
6796 call histdel("/",-1)
|
|
6797 call histdel("/",-1)
|
1621
|
6798 if w:netrw_liststyle == s:THINLIST || w:netrw_liststyle == s:WIDELIST || w:netrw_liststyle == s:TREELIST
|
|
6799 exe "silent! keepjumps ".w:netrw_bannercnt.',$s/^\%(\S\+\s\+\)\{8}//e'
|
2034
|
6800 call histdel("/",-1)
|
1621
|
6801 endif
|
|
6802 endif
|
|
6803
|
|
6804 " ftp's listing doesn't seem to include ./ or ../
|
|
6805 if !search('^\.\/$\|\s\.\/$','wn')
|
|
6806 exe 'keepjumps '.w:netrw_bannercnt
|
|
6807 put ='./'
|
|
6808 endif
|
|
6809 if !search('^\.\.\/$\|\s\.\.\/$','wn')
|
|
6810 exe 'keepjumps '.w:netrw_bannercnt
|
|
6811 put ='../'
|
|
6812 endif
|
|
6813
|
|
6814 " restore settings
|
|
6815 let &ff= ffkeep
|
|
6816 " call Dret("NetrwRemoteFtpCmd")
|
|
6817 endfun
|
|
6818
|
|
6819 " ---------------------------------------------------------------------
|
|
6820 " s:NetrwRemoteRename: rename a remote file or directory {{{2
|
|
6821 fun! s:NetrwRemoteRename(usrhost,path) range
|
|
6822 " call Dfunc("NetrwRemoteRename(usrhost<".a:usrhost."> path<".a:path.">)")
|
|
6823
|
|
6824 " preparation for removing multiple files/directories
|
|
6825 let svpos = netrw#NetrwSavePosn()
|
|
6826 let ctr = a:firstline
|
|
6827 let rename_cmd = s:MakeSshCmd(g:netrw_rename_cmd)
|
|
6828
|
|
6829 " rename files given by the markfilelist
|
|
6830 if exists("s:netrwmarkfilelist_{bufnr('%')}")
|
|
6831 for oldname in s:netrwmarkfilelist_{bufnr("%")}
|
|
6832 " call Decho("oldname<".oldname.">")
|
|
6833 if exists("subfrom")
|
|
6834 let newname= substitute(oldname,subfrom,subto,'')
|
|
6835 " call Decho("subfrom<".subfrom."> subto<".subto."> newname<".newname.">")
|
|
6836 else
|
|
6837 call inputsave()
|
|
6838 let newname= input("Moving ".oldname." to : ",oldname)
|
|
6839 call inputrestore()
|
|
6840 if newname =~ '^s/'
|
|
6841 let subfrom = substitute(newname,'^s/\([^/]*\)/.*/$','\1','')
|
|
6842 let subto = substitute(newname,'^s/[^/]*/\(.*\)/$','\1','')
|
|
6843 let newname = substitute(oldname,subfrom,subto,'')
|
|
6844 " call Decho("subfrom<".subfrom."> subto<".subto."> newname<".newname.">")
|
|
6845 endif
|
|
6846 endif
|
|
6847
|
|
6848 if exists("w:netrw_method") && (w:netrw_method == 2 || w:netrw_method == 3)
|
|
6849 call s:NetrwRemoteFtpCmd(a:path,"rename ".oldname." ".newname)
|
|
6850 else
|
1668
|
6851 let oldname= shellescape(a:path.oldname)
|
|
6852 let newname= shellescape(a:path.newname)
|
2034
|
6853 " call Decho("system(netrw#WinPath(".rename_cmd.") ".oldname.' '.newname.")")
|
|
6854 let ret = system(netrw#WinPath(rename_cmd).' '.oldname.' '.newname)
|
1621
|
6855 endif
|
|
6856
|
|
6857 endfor
|
|
6858 call s:NetrwUnMarkFile(1)
|
|
6859
|
|
6860 else
|
|
6861
|
|
6862 " attempt to rename files/directories
|
|
6863 while ctr <= a:lastline
|
|
6864 exe "keepjumps ".ctr
|
|
6865
|
|
6866 let oldname= s:NetrwGetWord()
|
|
6867 " call Decho("oldname<".oldname.">")
|
|
6868
|
|
6869 call inputsave()
|
|
6870 let newname= input("Moving ".oldname." to : ",oldname)
|
|
6871 call inputrestore()
|
|
6872
|
|
6873 if exists("w:netrw_method") && (w:netrw_method == 2 || w:netrw_method == 3)
|
|
6874 call s:NetrwRemoteFtpCmd(a:path,"rename ".oldname." ".newname)
|
|
6875 else
|
1668
|
6876 let oldname= shellescape(a:path.oldname)
|
|
6877 let newname= shellescape(a:path.newname)
|
2034
|
6878 " call Decho("system(netrw#WinPath(".rename_cmd.") ".oldname.' '.newname.")")
|
|
6879 let ret = system(netrw#WinPath(rename_cmd).' '.oldname.' '.newname)
|
1621
|
6880 endif
|
|
6881
|
|
6882 let ctr= ctr + 1
|
|
6883 endwhile
|
|
6884 endif
|
|
6885
|
|
6886 " refresh the directory
|
|
6887 call s:NetrwRefresh(0,s:NetrwBrowseChgDir(0,'./'))
|
|
6888 call netrw#NetrwRestorePosn(svpos)
|
|
6889
|
|
6890 " call Dret("NetrwRemoteRename")
|
|
6891 endfun
|
|
6892
|
|
6893 " ---------------------------------------------------------------------
|
|
6894 " Local Directory Browsing Support: {{{1
|
|
6895 " ==========================================
|
|
6896
|
|
6897 " ---------------------------------------------------------------------
|
|
6898 " netrw#LocalBrowseCheck: {{{2
|
|
6899 fun! netrw#LocalBrowseCheck(dirname)
|
|
6900 " unfortunate interaction -- split window debugging can't be
|
|
6901 " used here, must use D-echoRemOn or D-echoTabOn -- the BufEnter
|
|
6902 " event triggers another call to LocalBrowseCheck() when attempts
|
|
6903 " to write to the DBG buffer are made.
|
|
6904 " The &ft == "netrw" test was installed because the BufEnter event
|
|
6905 " would hit when re-entering netrw windows, creating unexpected
|
|
6906 " refreshes (and would do so in the middle of NetrwSaveOptions(), too)
|
2034
|
6907 " call Decho("netrw#LocalBrowseCheck: isdir<".a:dirname.">=".isdirectory(a:dirname).((exists("s:treeforceredraw")? " treeforceredraw" : "")))
|
1621
|
6908 if isdirectory(a:dirname)
|
|
6909 " call Decho(" ft<".&ft."> b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : " doesn't exist")."> dirname<".a:dirname.">"." line($)=".line("$"))
|
|
6910 if &ft != "netrw" || (exists("b:netrw_curdir") && b:netrw_curdir != a:dirname)
|
|
6911 silent! call s:NetrwBrowse(1,a:dirname)
|
|
6912 elseif &ft == "netrw" && line("$") == 1
|
|
6913 silent! call s:NetrwBrowse(1,a:dirname)
|
2034
|
6914 elseif exists("s:treeforceredraw")
|
|
6915 unlet s:treeforceredraw
|
|
6916 silent! call s:NetrwBrowse(1,a:dirname)
|
1621
|
6917 endif
|
|
6918 endif
|
|
6919 " not a directory, ignore it
|
1121
|
6920 endfun
|
482
|
6921
|
|
6922 " ---------------------------------------------------------------------
|
1621
|
6923 " s:LocalListing: does the job of "ls" for local directories {{{2
|
|
6924 fun! s:LocalListing()
|
|
6925 " call Dfunc("s:LocalListing()")
|
|
6926 " call Decho("&ma=".&ma)
|
|
6927 " call Decho("&mod=".&mod)
|
|
6928 " call Decho("&ro=".&ro)
|
|
6929 " call Decho("bufname(%)<".bufname("%").">")
|
|
6930
|
|
6931 " if exists("b:netrw_curdir") |call Decho('b:netrw_curdir<'.b:netrw_curdir.">") |else|call Decho("b:netrw_curdir doesn't exist") |endif
|
|
6932 " if exists("g:netrw_sort_by")|call Decho('g:netrw_sort_by<'.g:netrw_sort_by.">")|else|call Decho("g:netrw_sort_by doesn't exist")|endif
|
|
6933
|
|
6934 " get the list of files contained in the current directory
|
|
6935 let dirname = escape(b:netrw_curdir,g:netrw_glob_escape)
|
2034
|
6936 let dirnamelen = s:Strlen(b:netrw_curdir)
|
1621
|
6937 let filelist = glob(s:ComposePath(dirname,"*"))
|
|
6938 " call Decho("glob(dirname<".dirname."/*>)=".filelist)
|
|
6939 if filelist != ""
|
|
6940 let filelist= filelist."\n"
|
|
6941 endif
|
|
6942 let filelist= filelist.glob(s:ComposePath(dirname,".*"))
|
|
6943 " call Decho("glob(dirname<".dirname."/.*>)=".filelist)
|
|
6944
|
|
6945 " Coding choice: either elide ./ if present
|
|
6946 " or include ./ if not present
|
|
6947 if filelist =~ '[\\/]\.[\\/]\=\(\n\|$\)'
|
|
6948 " elide /path/. from glob() entries if present
|
|
6949 " call Decho("elide /path/. from glob entries if present")
|
|
6950 let filelist = substitute(filelist,'\n','\t','g')
|
|
6951 let filelist = substitute(filelist,'^[^\t]\+[/\\]\.\t','','')
|
|
6952 let filelist = substitute(filelist,'[^\t]\+[/\\]\.$','','')
|
|
6953 let filelist = substitute(filelist,'\t\zs[^\t]\+[/\\]\.\t','','')
|
|
6954 let filelist = substitute(filelist,'\t','\n','g')
|
|
6955 endif
|
|
6956 " call Decho("filelist<".filelist.">")
|
|
6957 if filelist !~ '[\\/]\.\.[\\/]\=\(\n\|$\)'
|
|
6958 " include ../ in the glob() entry if its missing
|
|
6959 " call Decho("forcibly tacking on ..")
|
|
6960 let filelist= filelist."\n".s:ComposePath(b:netrw_curdir,"../")
|
|
6961 " call Decho("filelist<".filelist.">")
|
|
6962 endif
|
|
6963 if b:netrw_curdir == '/'
|
|
6964 " remove .. from filelist when current directory is root directory
|
|
6965 " call Decho("remove .. from filelist")
|
|
6966 let filelist= substitute(filelist,'/\.\.\n','','')
|
|
6967 endif
|
|
6968 " remove multiple contiguous newlines
|
|
6969 let filelist= substitute(filelist,'\n\{2,}','\n','ge')
|
|
6970 if !g:netrw_cygwin && (has("win32") || has("win95") || has("win64") || has("win16"))
|
|
6971 " change all \s to /s
|
|
6972 " call Decho('change all \s to /s')
|
|
6973 let filelist= substitute(filelist,'\','/','g')
|
482
|
6974 else
|
1621
|
6975 " escape all \s to \\
|
|
6976 " call Decho('escape all \s to \\')
|
|
6977 let filelist= substitute(filelist,'\','\\','g')
|
|
6978 endif
|
|
6979
|
|
6980 " call Decho("(before while) dirname<".dirname.">")
|
|
6981 " call Decho("(before while) dirnamelen<".dirnamelen.">")
|
|
6982 " call Decho("(before while) filelist<".filelist.">")
|
|
6983
|
|
6984 while filelist != ""
|
|
6985 if filelist =~ '\n'
|
|
6986 let filename = substitute(filelist,'\n.*$','','e')
|
|
6987 let filelist = substitute(filelist,'^.\{-}\n\(.*\)$','\1','e')
|
|
6988 else
|
|
6989 let filename = filelist
|
|
6990 let filelist = ""
|
|
6991 endif
|
|
6992 " call Decho(" ")
|
|
6993 " call Decho("(while) filelist<".filelist.">")
|
|
6994 " call Decho("(while) filename<".filename.">")
|
|
6995
|
|
6996 if getftype(filename) == "link"
|
|
6997 " indicate a symbolic link
|
|
6998 " call Decho("indicate <".filename."> is a symbolic link with trailing @")
|
|
6999 let pfile= filename."@"
|
|
7000
|
|
7001 elseif getftype(filename) == "socket"
|
|
7002 " indicate a socket
|
|
7003 " call Decho("indicate <".filename."> is a socket with trailing =")
|
|
7004 let pfile= filename."="
|
|
7005
|
|
7006 elseif getftype(filename) == "fifo"
|
|
7007 " indicate a fifo
|
|
7008 " call Decho("indicate <".filename."> is a fifo with trailing |")
|
|
7009 let pfile= filename."|"
|
|
7010
|
|
7011 elseif isdirectory(filename)
|
|
7012 " indicate a directory
|
|
7013 " call Decho("indicate <".filename."> is a directory with trailing /")
|
|
7014 let pfile= filename."/"
|
|
7015
|
|
7016 elseif exists("b:netrw_curdir") && b:netrw_curdir !~ '^.*://' && !isdirectory(filename)
|
|
7017 if (has("win32") || has("win95") || has("win64") || has("win16"))
|
|
7018 if filename =~ '\.[eE][xX][eE]$' || filename =~ '\.[cC][oO][mM]$' || filename =~ '\.[bB][aA][tT]$'
|
|
7019 " indicate an executable
|
|
7020 " call Decho("indicate <".filename."> is executable with trailing *")
|
|
7021 let pfile= filename."*"
|
|
7022 else
|
|
7023 " normal file
|
|
7024 let pfile= filename
|
|
7025 endif
|
|
7026 elseif executable(filename)
|
|
7027 " indicate an executable
|
|
7028 " call Decho("indicate <".filename."> is executable with trailing *")
|
|
7029 let pfile= filename."*"
|
|
7030 else
|
|
7031 " normal file
|
|
7032 let pfile= filename
|
|
7033 endif
|
|
7034
|
|
7035 else
|
|
7036 " normal file
|
|
7037 let pfile= filename
|
|
7038 endif
|
|
7039 " call Decho("pfile<".pfile."> (after *@/ appending)")
|
|
7040
|
|
7041 if pfile =~ '//$'
|
|
7042 let pfile= substitute(pfile,'//$','/','e')
|
|
7043 " call Decho("change // to /: pfile<".pfile.">")
|
|
7044 endif
|
|
7045 let pfile= strpart(pfile,dirnamelen)
|
|
7046 let pfile= substitute(pfile,'^[/\\]','','e')
|
|
7047 " call Decho("filename<".filename.">")
|
|
7048 " call Decho("pfile <".pfile.">")
|
|
7049
|
|
7050 if w:netrw_liststyle == s:LONGLIST
|
|
7051 let sz = getfsize(filename)
|
2034
|
7052 let fsz = strpart(" ",1,15-strlen(sz)).sz
|
1621
|
7053 let pfile= pfile."\t".fsz." ".strftime(g:netrw_timefmt,getftime(filename))
|
|
7054 " call Decho("sz=".sz." fsz=".fsz)
|
|
7055 endif
|
|
7056
|
|
7057 if g:netrw_sort_by =~ "^t"
|
|
7058 " sort by time (handles time up to 1 quintillion seconds, US)
|
|
7059 " call Decho("getftime(".filename.")=".getftime(filename))
|
|
7060 let t = getftime(filename)
|
2034
|
7061 let ft = strpart("000000000000000000",1,18-strlen(t)).t
|
1621
|
7062 " call Decho("exe keepjumps put ='".ft.'/'.filename."'")
|
|
7063 let ftpfile= ft.'/'.pfile
|
|
7064 keepjumps silent! put=ftpfile
|
|
7065
|
|
7066 elseif g:netrw_sort_by =~ "^s"
|
|
7067 " sort by size (handles file sizes up to 1 quintillion bytes, US)
|
|
7068 " call Decho("getfsize(".filename.")=".getfsize(filename))
|
|
7069 let sz = getfsize(filename)
|
2034
|
7070 let fsz = strpart("000000000000000000",1,18-strlen(sz)).sz
|
1621
|
7071 " call Decho("exe keepjumps put ='".fsz.'/'.filename."'")
|
|
7072 let fszpfile= fsz.'/'.pfile
|
|
7073 keepjumps silent! put =fszpfile
|
|
7074
|
482
|
7075 else
|
1621
|
7076 " sort by name
|
|
7077 " call Decho("exe keepjumps put ='".pfile."'")
|
|
7078 keepjumps silent! put=pfile
|
|
7079 endif
|
|
7080 endwhile
|
|
7081
|
|
7082 " cleanup any windows mess at end-of-line
|
2034
|
7083 silent! keepjumps g/^$/d
|
1621
|
7084 silent! keepjumps %s/\r$//e
|
2034
|
7085 call histdel("/",-1)
|
1621
|
7086 exe "setlocal ts=".g:netrw_maxfilenamelen
|
|
7087 " call Decho("setlocal ts=".g:netrw_maxfilenamelen)
|
|
7088
|
|
7089 " call Dret("s:LocalListing")
|
|
7090 endfun
|
|
7091
|
|
7092 " ---------------------------------------------------------------------
|
|
7093 " s:LocalBrowseShellCmdRefresh: this function is called after a user has {{{2
|
|
7094 " performed any shell command. The idea is to cause all local-browsing
|
|
7095 " buffers to be refreshed after a user has executed some shell command,
|
|
7096 " on the chance that s/he removed/created a file/directory with it.
|
|
7097 fun! s:LocalBrowseShellCmdRefresh()
|
|
7098 " call Dfunc("LocalBrowseShellCmdRefresh() browselist=".(exists("s:netrw_browselist")? string(s:netrw_browselist) : "empty")." ".tabpagenr("$")." tabs")
|
|
7099 " determine which buffers currently reside in a tab
|
|
7100 if !exists("s:netrw_browselist")
|
|
7101 " call Dret("LocalBrowseShellCmdRefresh : browselist is empty")
|
|
7102 return
|
|
7103 endif
|
|
7104 if !exists("w:netrw_bannercnt")
|
2034
|
7105 " call Dret("LocalBrowseShellCmdRefresh : don't refresh when focus not on netrw window")
|
1621
|
7106 return
|
|
7107 endif
|
2034
|
7108 if exists("s:locbrowseshellcmd")
|
|
7109 if s:locbrowseshellcmd
|
|
7110 let s:locbrowseshellcmd= 0
|
|
7111 " call Dret("LocalBrowseShellCmdRefresh : NetrwBrowse itself caused the refresh")
|
|
7112 return
|
|
7113 endif
|
|
7114 let s:locbrowseshellcmd= 0
|
|
7115 endif
|
1621
|
7116 let itab = 1
|
|
7117 let buftablist = []
|
|
7118 while itab <= tabpagenr("$")
|
|
7119 let buftablist = buftablist + tabpagebuflist()
|
|
7120 let itab = itab + 1
|
|
7121 tabn
|
482
|
7122 endwhile
|
1621
|
7123 " call Decho("buftablist".string(buftablist))
|
|
7124 " call Decho("s:netrw_browselist<".(exists("s:netrw_browselist")? string(s:netrw_browselist) : "").">")
|
|
7125 " GO through all buffers on netrw_browselist (ie. just local-netrw buffers):
|
|
7126 " | refresh any netrw window
|
|
7127 " | wipe out any non-displaying netrw buffer
|
|
7128 let curwin = winnr()
|
|
7129 let ibl = 0
|
|
7130 for ibuf in s:netrw_browselist
|
|
7131 " call Decho("bufwinnr(".ibuf.") index(buftablist,".ibuf.")=".index(buftablist,ibuf))
|
|
7132 if bufwinnr(ibuf) == -1 && index(buftablist,ibuf) == -1
|
|
7133 " wipe out any non-displaying netrw buffer
|
|
7134 " call Decho("wiping buf#".ibuf,"<".bufname(ibuf).">")
|
1698
|
7135 exe "silent! bd ".fnameescape(ibuf)
|
1621
|
7136 call remove(s:netrw_browselist,ibl)
|
|
7137 " call Decho("browselist=".string(s:netrw_browselist))
|
|
7138 continue
|
|
7139 elseif index(tabpagebuflist(),ibuf) != -1
|
|
7140 " refresh any netrw buffer
|
|
7141 " call Decho("refresh buf#".ibuf.'-> win#'.bufwinnr(ibuf))
|
|
7142 exe bufwinnr(ibuf)."wincmd w"
|
|
7143 call s:NetrwRefresh(1,s:NetrwBrowseChgDir(1,'./'))
|
|
7144 endif
|
|
7145 let ibl= ibl + 1
|
|
7146 endfor
|
|
7147 exe curwin."wincmd w"
|
|
7148
|
|
7149 " call Dret("LocalBrowseShellCmdRefresh")
|
|
7150 endfun
|
|
7151
|
|
7152 " ---------------------------------------------------------------------
|
|
7153 " s:NetrwLocalRm: {{{2
|
|
7154 fun! s:NetrwLocalRm(path) range
|
|
7155 " call Dfunc("s:NetrwLocalRm(path<".a:path.">)")
|
|
7156 " call Decho("firstline=".a:firstline." lastline=".a:lastline)
|
|
7157
|
|
7158 " preparation for removing multiple files/directories
|
|
7159 let ret = 0
|
|
7160 let all = 0
|
|
7161 let svpos = netrw#NetrwSavePosn()
|
|
7162
|
|
7163 if exists("s:netrwmarkfilelist_{bufnr('%')}")
|
|
7164 " remove all marked files
|
|
7165 " call Decho("remove all marked files")
|
|
7166 for fname in s:netrwmarkfilelist_{bufnr("%")}
|
|
7167 let ok= s:NetrwLocalRmFile(a:path,fname,all)
|
|
7168 if ok =~ 'q\%[uit]' || ok == "no"
|
|
7169 break
|
|
7170 elseif ok =~ 'a\%[ll]'
|
|
7171 let all= 1
|
|
7172 endif
|
|
7173 endfor
|
|
7174 call s:NetrwUnMarkFile(1)
|
|
7175
|
|
7176 else
|
|
7177 " remove (multiple) files and directories
|
|
7178 " call Decho("remove files in range [".a:firstline.",".a:lastline."]")
|
|
7179
|
|
7180 let ctr = a:firstline
|
|
7181 while ctr <= a:lastline
|
|
7182 exe "keepjumps ".ctr
|
|
7183
|
|
7184 " sanity checks
|
|
7185 if line(".") < w:netrw_bannercnt
|
|
7186 let ctr= ctr + 1
|
|
7187 continue
|
|
7188 endif
|
|
7189 let curword= s:NetrwGetWord()
|
|
7190 if curword == "./" || curword == "../"
|
|
7191 let ctr= ctr + 1
|
|
7192 continue
|
|
7193 endif
|
|
7194 let ok= s:NetrwLocalRmFile(a:path,curword,all)
|
|
7195 if ok =~ 'q\%[uit]' || ok == "no"
|
|
7196 break
|
|
7197 elseif ok =~ 'a\%[ll]'
|
|
7198 let all= 1
|
|
7199 endif
|
|
7200 let ctr= ctr + 1
|
|
7201 endwhile
|
|
7202 endif
|
|
7203
|
|
7204 " refresh the directory
|
|
7205 " call Decho("bufname<".bufname("%").">")
|
|
7206 if bufname("%") != "NetrwMessage"
|
|
7207 call s:NetrwRefresh(1,s:NetrwBrowseChgDir(1,'./'))
|
|
7208 call netrw#NetrwRestorePosn(svpos)
|
|
7209 endif
|
|
7210
|
|
7211 " call Dret("s:NetrwLocalRm")
|
482
|
7212 endfun
|
|
7213
|
1621
|
7214 " ---------------------------------------------------------------------
|
|
7215 " s:NetrwLocalRmFile: remove file fname given the path {{{2
|
|
7216 " Give confirmation prompt unless all==1
|
|
7217 fun! s:NetrwLocalRmFile(path,fname,all)
|
|
7218 " call Dfunc("s:NetrwLocalRmFile(path<".a:path."> fname<".a:fname."> all=".a:all)
|
|
7219
|
|
7220 let all= a:all
|
|
7221 let ok = ""
|
|
7222 norm! 0
|
|
7223 let rmfile= s:ComposePath(a:path,a:fname)
|
|
7224 " call Decho("rmfile<".rmfile.">")
|
|
7225
|
|
7226 if rmfile !~ '^"' && (rmfile =~ '@$' || rmfile !~ '[\/]$')
|
|
7227 " attempt to remove file
|
|
7228 " call Decho("attempt to remove file<".rmfile.">")
|
|
7229 if !all
|
|
7230 echohl Statement
|
|
7231 call inputsave()
|
|
7232 let ok= input("Confirm deletion of file<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ")
|
|
7233 call inputrestore()
|
|
7234 echohl NONE
|
|
7235 if ok == ""
|
|
7236 let ok="no"
|
|
7237 endif
|
|
7238 " call Decho("response: ok<".ok.">")
|
|
7239 let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e')
|
|
7240 " call Decho("response: ok<".ok."> (after sub)")
|
|
7241 if ok =~ 'a\%[ll]'
|
|
7242 let all= 1
|
|
7243 endif
|
|
7244 endif
|
|
7245
|
|
7246 if all || ok =~ 'y\%[es]' || ok == ""
|
1668
|
7247 let ret= s:NetrwDelete(rmfile)
|
1621
|
7248 " call Decho("errcode=".v:shell_error." ret=".ret)
|
|
7249 endif
|
|
7250
|
|
7251 else
|
|
7252 " attempt to remove directory
|
|
7253 if !all
|
|
7254 echohl Statement
|
|
7255 call inputsave()
|
|
7256 let ok= input("Confirm deletion of directory<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ")
|
|
7257 call inputrestore()
|
|
7258 let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e')
|
|
7259 if ok == ""
|
|
7260 let ok="no"
|
|
7261 endif
|
|
7262 if ok =~ 'a\%[ll]'
|
|
7263 let all= 1
|
|
7264 endif
|
|
7265 endif
|
|
7266 let rmfile= substitute(rmfile,'[\/]$','','e')
|
|
7267
|
|
7268 if all || ok =~ 'y\%[es]' || ok == ""
|
2034
|
7269 " call Decho("1st attempt: system(netrw#WinPath(".g:netrw_local_rmdir.') '.shellescape(rmfile).')')
|
|
7270 call system(netrw#WinPath(g:netrw_local_rmdir).' '.shellescape(rmfile))
|
1621
|
7271 " call Decho("v:shell_error=".v:shell_error)
|
|
7272
|
|
7273 if v:shell_error != 0
|
|
7274 " call Decho("2nd attempt to remove directory<".rmfile.">")
|
1668
|
7275 let errcode= s:NetrwDelete(rmfile)
|
1621
|
7276 " call Decho("errcode=".errcode)
|
|
7277
|
|
7278 if errcode != 0
|
|
7279 if has("unix")
|
|
7280 " call Decho("3rd attempt to remove directory<".rmfile.">")
|
1668
|
7281 call system("rm ".shellescape(rmfile))
|
1621
|
7282 if v:shell_error != 0 && !exists("g:netrw_quiet")
|
|
7283 call netrw#ErrorMsg(s:ERROR,"unable to remove directory<".rmfile."> -- is it empty?",34)
|
|
7284 let ok="no"
|
|
7285 endif
|
|
7286 elseif !exists("g:netrw_quiet")
|
|
7287 call netrw#ErrorMsg(s:ERROR,"unable to remove directory<".rmfile."> -- is it empty?",35)
|
|
7288 let ok="no"
|
|
7289 endif
|
|
7290 endif
|
|
7291 endif
|
|
7292 endif
|
|
7293 endif
|
|
7294
|
|
7295 " call Dret("s:NetrwLocalRmFile ".ok)
|
|
7296 return ok
|
|
7297 endfun
|
|
7298
|
|
7299 " ---------------------------------------------------------------------
|
|
7300 " s:NetrwLocalRename: rename a remote file or directory {{{2
|
|
7301 fun! s:NetrwLocalRename(path) range
|
|
7302 " call Dfunc("NetrwLocalRename(path<".a:path.">)")
|
|
7303
|
|
7304 " preparation for removing multiple files/directories
|
|
7305 let ctr = a:firstline
|
|
7306 let svpos= netrw#NetrwSavePosn()
|
|
7307
|
|
7308 " rename files given by the markfilelist
|
|
7309 if exists("s:netrwmarkfilelist_{bufnr('%')}")
|
|
7310 for oldname in s:netrwmarkfilelist_{bufnr("%")}
|
|
7311 " call Decho("oldname<".oldname.">")
|
|
7312 if exists("subfrom")
|
|
7313 let newname= substitute(oldname,subfrom,subto,'')
|
|
7314 " call Decho("subfrom<".subfrom."> subto<".subto."> newname<".newname.">")
|
|
7315 else
|
|
7316 call inputsave()
|
|
7317 let newname= input("Moving ".oldname." to : ",oldname)
|
|
7318 call inputrestore()
|
|
7319 if newname =~ '^s/'
|
|
7320 let subfrom = substitute(newname,'^s/\([^/]*\)/.*/$','\1','')
|
|
7321 let subto = substitute(newname,'^s/[^/]*/\(.*\)/$','\1','')
|
|
7322 " call Decho("subfrom<".subfrom."> subto<".subto."> newname<".newname.">")
|
|
7323 let newname = substitute(oldname,subfrom,subto,'')
|
|
7324 endif
|
|
7325 endif
|
1698
|
7326 call rename(oldname,newname)
|
1621
|
7327 endfor
|
2034
|
7328 call s:NetrwUnmarkList(bufnr("%"),b:netrw_curdir)
|
1621
|
7329
|
|
7330 else
|
|
7331
|
|
7332 " attempt to rename files/directories
|
|
7333 while ctr <= a:lastline
|
|
7334 exe "keepjumps ".ctr
|
|
7335
|
|
7336 " sanity checks
|
|
7337 if line(".") < w:netrw_bannercnt
|
|
7338 let ctr= ctr + 1
|
|
7339 continue
|
|
7340 endif
|
|
7341 let curword= s:NetrwGetWord()
|
|
7342 if curword == "./" || curword == "../"
|
|
7343 let ctr= ctr + 1
|
|
7344 continue
|
|
7345 endif
|
|
7346
|
|
7347 norm! 0
|
|
7348 let oldname= s:ComposePath(a:path,curword)
|
|
7349 " call Decho("oldname<".oldname.">")
|
|
7350
|
|
7351 call inputsave()
|
|
7352 let newname= input("Moving ".oldname." to : ",substitute(oldname,'/*$','','e'))
|
|
7353 call inputrestore()
|
|
7354
|
1698
|
7355 call rename(oldname,newname)
|
1621
|
7356 " call Decho("renaming <".oldname."> to <".newname.">")
|
|
7357
|
|
7358 let ctr= ctr + 1
|
|
7359 endwhile
|
|
7360 endif
|
|
7361
|
|
7362 " refresh the directory
|
|
7363 " call Decho("refresh the directory listing")
|
|
7364 call s:NetrwRefresh(1,s:NetrwBrowseChgDir(1,'./'))
|
|
7365 call netrw#NetrwRestorePosn(svpos)
|
|
7366
|
|
7367 " call Dret("NetrwLocalRename")
|
|
7368 endfun
|
|
7369
|
|
7370 " ---------------------------------------------------------------------
|
|
7371 " s:LocalFastBrowser: handles setting up/taking down fast browsing for the local browser {{{2
|
|
7372 "
|
|
7373 " g:netrw_ Directory Is
|
|
7374 " fastbrowse Local Remote
|
|
7375 " slow 0 D D D=Deleting a buffer implies it will not be re-used (slow)
|
|
7376 " med 1 D H H=Hiding a buffer implies it may be re-used (fast)
|
|
7377 " fast 2 H H
|
|
7378 "
|
|
7379 " Deleting a buffer means that it will be re-loaded when examined, hence "slow".
|
|
7380 " Hiding a buffer means that it will be re-used when examined, hence "fast".
|
|
7381 " (re-using a buffer may not be as accurate)
|
|
7382 fun! s:LocalFastBrowser()
|
|
7383 " call Dfunc("LocalFastBrowser() g:netrw_fastbrowse=".g:netrw_fastbrowse)
|
|
7384
|
|
7385 " initialize browselist, a list of buffer numbers that the local browser has used
|
|
7386 if !exists("s:netrw_browselist")
|
|
7387 " call Decho("initialize s:netrw_browselist")
|
|
7388 let s:netrw_browselist= []
|
|
7389 endif
|
|
7390
|
|
7391 " append current buffer to fastbrowse list
|
|
7392 if empty(s:netrw_browselist) || bufnr("%") > s:netrw_browselist[-1]
|
|
7393 " call Decho("appendng current buffer to browselist")
|
|
7394 call add(s:netrw_browselist,bufnr("%"))
|
|
7395 " call Decho("browselist=".string(s:netrw_browselist))
|
|
7396 endif
|
|
7397
|
|
7398 " enable autocmd events to handle refreshing/removing local browser buffers
|
|
7399 " If local browse buffer is currently showing: refresh it
|
|
7400 " If local browse buffer is currently hidden : wipe it
|
|
7401 if !exists("s:netrw_browser_shellcmd") && g:netrw_fastbrowse <= 1
|
|
7402 " call Decho("setting up local-browser shell command refresh")
|
|
7403 let s:netrw_browser_shellcmd= 1
|
|
7404 augroup AuNetrwShellCmd
|
|
7405 au!
|
|
7406 if (has("win32") || has("win95") || has("win64") || has("win16"))
|
2034
|
7407 " call Decho("autocmd: ShellCmdPost * call s:LocalBrowseShellCmdRefresh()")
|
1621
|
7408 au ShellCmdPost * call s:LocalBrowseShellCmdRefresh()
|
|
7409 else
|
|
7410 au ShellCmdPost,FocusGained * call s:LocalBrowseShellCmdRefresh()
|
2034
|
7411 " call Decho("autocmd: ShellCmdPost,FocusGained * call s:LocalBrowseShellCmdRefresh()")
|
1621
|
7412 endif
|
|
7413 augroup END
|
|
7414 endif
|
|
7415
|
|
7416 " user must have changed fastbrowse to its fast setting, so remove
|
|
7417 " the associated autocmd events
|
|
7418 if g:netrw_fastbrowse > 1 && exists("s:netrw_browser_shellcmd")
|
|
7419 " call Decho("remove AuNetrwShellCmd autcmd group")
|
|
7420 unlet s:netrw_browser_shellcmd
|
|
7421 augroup AuNetrwShellCmd
|
|
7422 au!
|
|
7423 augroup END
|
|
7424 augroup! AuNetrwShellCmd
|
|
7425 endif
|
|
7426
|
|
7427 " call Dret("LocalFastBrowser : browselist<".string(s:netrw_browselist).">")
|
|
7428 endfun
|
|
7429
|
|
7430 " ---------------------------------------------------------------------
|
1121
|
7431 " Support Functions: {{{1
|
|
7432
|
482
|
7433 " ---------------------------------------------------------------------
|
1121
|
7434 " netrw#ErrorMsg: {{{2
|
|
7435 " 0=note = s:NOTE
|
|
7436 " 1=warning = s:WARNING
|
|
7437 " 2=error = s:ERROR
|
2034
|
7438 " Dec 03, 2009 : max errnum currently is 76
|
1121
|
7439 fun! netrw#ErrorMsg(level,msg,errnum)
|
1209
|
7440 " call Dfunc("netrw#ErrorMsg(level=".a:level." msg<".a:msg."> errnum=".a:errnum.") g:netrw_use_errorwindow=".g:netrw_use_errorwindow)
|
|
7441
|
|
7442 if a:level == 1
|
|
7443 let level= "**warning** (netrw) "
|
|
7444 elseif a:level == 2
|
|
7445 let level= "**error** (netrw) "
|
|
7446 else
|
|
7447 let level= "**note** (netrw) "
|
|
7448 endif
|
1621
|
7449 " call Decho("level=".level)
|
1209
|
7450
|
|
7451 if g:netrw_use_errorwindow
|
|
7452 " (default) netrw creates a one-line window to show error/warning
|
|
7453 " messages (reliably displayed)
|
|
7454
|
1621
|
7455 " record current window number for NetrwRestorePosn()'s benefit
|
1209
|
7456 let s:winBeforeErr= winnr()
|
1621
|
7457 " call Decho("s:winBeforeErr=".s:winBeforeErr)
|
|
7458
|
1209
|
7459 " getting messages out reliably is just plain difficult!
|
|
7460 " This attempt splits the current window, creating a one line window.
|
|
7461 if bufexists("NetrwMessage") && bufwinnr("NetrwMessage") > 0
|
1621
|
7462 " call Decho("write to NetrwMessage buffer")
|
1209
|
7463 exe bufwinnr("NetrwMessage")."wincmd w"
|
1621
|
7464 " call Decho("setlocal ma noro")
|
|
7465 setlocal ma noro
|
1209
|
7466 call setline(line("$")+1,level.a:msg)
|
|
7467 $
|
|
7468 else
|
1621
|
7469 " call Decho("create a NetrwMessage buffer window")
|
1209
|
7470 bo 1split
|
2034
|
7471 call s:NetrwEnew()
|
|
7472 call s:NetrwSafeOptions()
|
1209
|
7473 setlocal bt=nofile
|
|
7474 file NetrwMessage
|
1621
|
7475 " call Decho("setlocal ma noro")
|
|
7476 setlocal ma noro
|
1209
|
7477 call setline(line("$"),level.a:msg)
|
|
7478 endif
|
1621
|
7479 " call Decho("wrote msg<".level.a:msg."> to NetrwMessage win#".winnr())
|
1209
|
7480 if &fo !~ '[ta]'
|
|
7481 syn clear
|
|
7482 syn match netrwMesgNote "^\*\*note\*\*"
|
|
7483 syn match netrwMesgWarning "^\*\*warning\*\*"
|
|
7484 syn match netrwMesgError "^\*\*error\*\*"
|
|
7485 hi link netrwMesgWarning WarningMsg
|
|
7486 hi link netrwMesgError Error
|
|
7487 endif
|
|
7488 setlocal noma ro bh=wipe
|
|
7489
|
|
7490 else
|
|
7491 " (optional) netrw will show messages using echomsg. Even if the
|
|
7492 " message doesn't appear, at least it'll be recallable via :messages
|
1621
|
7493 " redraw!
|
1121
|
7494 if a:level == s:WARNING
|
1209
|
7495 echohl WarningMsg
|
1121
|
7496 elseif a:level == s:ERROR
|
1209
|
7497 echohl Error
|
1121
|
7498 endif
|
1209
|
7499 echomsg level.a:msg
|
|
7500 " call Decho("echomsg ***netrw*** ".a:msg)
|
|
7501 echohl None
|
1121
|
7502 endif
|
|
7503
|
|
7504 " call Dret("netrw#ErrorMsg")
|
|
7505 endfun
|
|
7506
|
|
7507 " ---------------------------------------------------------------------
|
1668
|
7508 " netrw#NetrwRestorePosn: restores the cursor and file position as saved by NetrwSavePosn() {{{2
|
|
7509 fun! netrw#NetrwRestorePosn(...)
|
|
7510 " call Dfunc("netrw#NetrwRestorePosn() a:0=".a:0." winnr=".(exists("w:netrw_winnr")? w:netrw_winnr : -1)." line=".(exists("w:netrw_line")? w:netrw_line : -1)." col=".(exists("w:netrw_col")? w:netrw_col : -1)." hline=".(exists("w:netrw_hline")? w:netrw_hline : -1))
|
|
7511 let eikeep= &ei
|
|
7512 set ei=all
|
|
7513 if expand("%") == "NetrwMessage"
|
|
7514 exe s:winBeforeErr."wincmd w"
|
|
7515 endif
|
|
7516
|
|
7517 if a:0 > 0
|
|
7518 exe a:1
|
|
7519 endif
|
|
7520
|
|
7521 " restore window
|
|
7522 if exists("w:netrw_winnr")
|
|
7523 " call Decho("restore window: exe silent! ".w:netrw_winnr."wincmd w")
|
|
7524 exe "silent! ".w:netrw_winnr."wincmd w"
|
|
7525 endif
|
|
7526 if v:shell_error == 0
|
|
7527 " as suggested by Bram M: redraw on no error
|
|
7528 " allows protocol error messages to remain visible
|
|
7529 " redraw!
|
|
7530 endif
|
|
7531
|
|
7532 " restore top-of-screen line
|
|
7533 if exists("w:netrw_hline")
|
|
7534 " call Decho("restore topofscreen: exe norm! ".w:netrw_hline."G0z")
|
|
7535 exe "norm! ".w:netrw_hline."G0z\<CR>"
|
|
7536 endif
|
|
7537
|
|
7538 " restore position
|
|
7539 if exists("w:netrw_line") && exists("w:netrw_col")
|
|
7540 " call Decho("restore posn: exe norm! ".w:netrw_line."G0".w:netrw_col."|")
|
|
7541 exe "norm! ".w:netrw_line."G0".w:netrw_col."\<bar>"
|
|
7542 endif
|
|
7543
|
|
7544 let &ei= eikeep
|
|
7545 " call Dret("netrw#NetrwRestorePosn")
|
|
7546 endfun
|
|
7547
|
|
7548 " ---------------------------------------------------------------------
|
|
7549 " netrw#NetrwSavePosn: saves position of cursor on screen {{{2
|
|
7550 fun! netrw#NetrwSavePosn()
|
|
7551 " call Dfunc("netrw#NetrwSavePosn()")
|
|
7552 " Save current line and column
|
|
7553 let w:netrw_winnr= winnr()
|
|
7554 let w:netrw_line = line(".")
|
|
7555 let w:netrw_col = virtcol(".")
|
2034
|
7556 " call Decho("currently, win#".w:netrw_winnr." line#".w:netrw_line." col#".w:netrw_col)
|
1668
|
7557
|
|
7558 " Save top-of-screen line
|
|
7559 norm! H0
|
|
7560 let w:netrw_hline= line(".")
|
|
7561
|
|
7562 " set up string holding position parameters
|
|
7563 let ret = "let w:netrw_winnr=".w:netrw_winnr."|let w:netrw_line=".w:netrw_line."|let w:netrw_col=".w:netrw_col."|let w:netrw_hline=".w:netrw_hline
|
|
7564
|
|
7565 call netrw#NetrwRestorePosn()
|
|
7566 " call Dret("netrw#NetrwSavePosn : winnr=".w:netrw_winnr." line=".w:netrw_line." col=".w:netrw_col." hline=".w:netrw_hline)
|
|
7567 return ret
|
|
7568 endfun
|
|
7569
|
|
7570 " ------------------------------------------------------------------------
|
1121
|
7571 " netrw#RFC2396: converts %xx into characters {{{2
|
|
7572 fun! netrw#RFC2396(fname)
|
|
7573 " call Dfunc("netrw#RFC2396(fname<".a:fname.">)")
|
|
7574 let fname = escape(substitute(a:fname,'%\(\x\x\)','\=nr2char("0x".submatch(1))','ge')," \t")
|
|
7575 " call Dret("netrw#RFC2396 ".fname)
|
|
7576 return fname
|
|
7577 endfun
|
|
7578
|
|
7579 " ---------------------------------------------------------------------
|
1668
|
7580 " s:ComposePath: Appends a new part to a path taking different systems into consideration {{{2
|
|
7581 fun! s:ComposePath(base,subdir)
|
|
7582 " call Dfunc("s:ComposePath(base<".a:base."> subdir<".a:subdir.">)")
|
|
7583
|
|
7584 if(has("amiga"))
|
|
7585 " call Decho("amiga")
|
2034
|
7586 let ec = a:base[s:Strlen(a:base)-1]
|
1668
|
7587 if ec != '/' && ec != ':'
|
|
7588 let ret = a:base . "/" . a:subdir
|
|
7589 else
|
|
7590 let ret = a:base . a:subdir
|
|
7591 endif
|
|
7592
|
|
7593 elseif a:subdir =~ '^\a:[/\\][^/\\]' && (has("win32") || has("win95") || has("win64") || has("win16"))
|
|
7594 " call Decho("windows")
|
|
7595 let ret= a:subdir
|
|
7596
|
2034
|
7597 elseif a:base =~ '^\a:[/\\][^/\\]' && (has("win32") || has("win95") || has("win64") || has("win16"))
|
|
7598 " call Decho("windows")
|
|
7599 if a:base =~ '[/\\]$'
|
|
7600 let ret= a:base.a:subdir
|
|
7601 else
|
|
7602 let ret= a:base."/".a:subdir
|
|
7603 endif
|
|
7604
|
1668
|
7605 elseif a:base =~ '^\a\+://'
|
|
7606 " call Decho("remote linux/macos")
|
|
7607 let urlbase = substitute(a:base,'^\(\a\+://.\{-}/\)\(.*\)$','\1','')
|
|
7608 let curpath = substitute(a:base,'^\(\a\+://.\{-}/\)\(.*\)$','\2','')
|
|
7609 if a:subdir == '../'
|
|
7610 if curpath =~ '[^/]/[^/]\+/$'
|
|
7611 let curpath= substitute(curpath,'[^/]\+/$','','')
|
|
7612 else
|
|
7613 let curpath=""
|
|
7614 endif
|
|
7615 let ret= urlbase.curpath
|
|
7616 else
|
|
7617 let ret= urlbase.curpath.a:subdir
|
|
7618 endif
|
|
7619 " call Decho("urlbase<".urlbase.">")
|
|
7620 " call Decho("curpath<".curpath.">")
|
|
7621 " call Decho("ret<".ret.">")
|
|
7622
|
|
7623 else
|
|
7624 " call Decho("local linux/macos")
|
|
7625 let ret = substitute(a:base."/".a:subdir,"//","/","g")
|
|
7626 if a:base =~ '^//'
|
|
7627 " keeping initial '//' for the benefit of network share listing support
|
|
7628 let ret= '/'.ret
|
|
7629 endif
|
|
7630 let ret= simplify(ret)
|
|
7631 endif
|
|
7632
|
|
7633 " call Dret("s:ComposePath ".ret)
|
|
7634 return ret
|
|
7635 endfun
|
|
7636
|
|
7637 " ---------------------------------------------------------------------
|
1121
|
7638 " s:FileReadable: o/s independent filereadable {{{2
|
|
7639 fun! s:FileReadable(fname)
|
|
7640 " call Dfunc("s:FileReadable(fname<".a:fname.">)")
|
|
7641
|
|
7642 if g:netrw_cygwin
|
|
7643 let ret= filereadable(substitute(a:fname,'/cygdrive/\(.\)','\1:/',''))
|
|
7644 else
|
|
7645 let ret= filereadable(a:fname)
|
|
7646 endif
|
|
7647
|
|
7648 " call Dret("s:FileReadable ".ret)
|
|
7649 return ret
|
482
|
7650 endfun
|
|
7651
|
|
7652 " ---------------------------------------------------------------------
|
1121
|
7653 " s:GetTempfile: gets a tempname that'll work for various o/s's {{{2
|
|
7654 " Places correct suffix on end of temporary filename,
|
|
7655 " using the suffix provided with fname
|
|
7656 fun! s:GetTempfile(fname)
|
|
7657 " call Dfunc("s:GetTempfile(fname<".a:fname.">)")
|
|
7658
|
|
7659 if !exists("b:netrw_tmpfile")
|
|
7660 " get a brand new temporary filename
|
|
7661 let tmpfile= tempname()
|
|
7662 " call Decho("tmpfile<".tmpfile."> : from tempname()")
|
1621
|
7663
|
1668
|
7664 let tmpfile= substitute(tmpfile,'\','/','ge')
|
1121
|
7665 " call Decho("tmpfile<".tmpfile."> : chgd any \\ -> /")
|
1621
|
7666
|
1121
|
7667 " sanity check -- does the temporary file's directory exist?
|
|
7668 if !isdirectory(substitute(tmpfile,'[^/]\+$','','e'))
|
1668
|
7669 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap)
|
1121
|
7670 call netrw#ErrorMsg(s:ERROR,"your <".substitute(tmpfile,'[^/]\+$','','e')."> directory is missing!",2)
|
|
7671 " call Dret("s:GetTempfile getcwd<".getcwd().">")
|
|
7672 return ""
|
|
7673 endif
|
1621
|
7674
|
1121
|
7675 " let netrw#NetSource() know about the tmpfile
|
2034
|
7676 let s:netrw_tmpfile= tmpfile " used by netrw#NetSource() and netrw#NetrwBrowseX()
|
1121
|
7677 " call Decho("tmpfile<".tmpfile."> s:netrw_tmpfile<".s:netrw_tmpfile.">")
|
1621
|
7678
|
1121
|
7679 " o/s dependencies
|
1621
|
7680 if g:netrw_cygwin != 0
|
1121
|
7681 let tmpfile = substitute(tmpfile,'^\(\a\):','/cygdrive/\1','e')
|
|
7682 elseif has("win32") || has("win95") || has("win64") || has("win16")
|
1621
|
7683 if !exists("+shellslash") || !&ssl
|
|
7684 let tmpfile = substitute(tmpfile,'/','\','g')
|
|
7685 endif
|
1121
|
7686 else
|
1621
|
7687 let tmpfile = tmpfile
|
1121
|
7688 endif
|
|
7689 let b:netrw_tmpfile= tmpfile
|
|
7690 " call Decho("o/s dependent fixed tempname<".tmpfile.">")
|
|
7691 else
|
|
7692 " re-use temporary filename
|
|
7693 let tmpfile= b:netrw_tmpfile
|
|
7694 " call Decho("tmpfile<".tmpfile."> re-using")
|
|
7695 endif
|
|
7696
|
|
7697 " use fname's suffix for the temporary file
|
|
7698 if a:fname != ""
|
|
7699 if a:fname =~ '\.[^./]\+$'
|
|
7700 " call Decho("using fname<".a:fname.">'s suffix")
|
|
7701 if a:fname =~ '.tar.gz' || a:fname =~ '.tar.bz2'
|
|
7702 let suffix = ".tar".substitute(a:fname,'^.*\(\.[^./]\+\)$','\1','e')
|
|
7703 else
|
|
7704 let suffix = substitute(a:fname,'^.*\(\.[^./]\+\)$','\1','e')
|
|
7705 endif
|
|
7706 " call Decho("suffix<".suffix.">")
|
|
7707 let tmpfile= substitute(tmpfile,'\.tmp$','','e')
|
|
7708 " call Decho("chgd tmpfile<".tmpfile."> (removed any .tmp suffix)")
|
|
7709 let tmpfile .= suffix
|
|
7710 " call Decho("chgd tmpfile<".tmpfile."> (added ".suffix." suffix) netrw_fname<".b:netrw_fname.">")
|
|
7711 let s:netrw_tmpfile= tmpfile " supports netrw#NetSource()
|
|
7712 endif
|
|
7713 endif
|
|
7714
|
1668
|
7715 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap)
|
1121
|
7716 " call Dret("s:GetTempfile <".tmpfile.">")
|
|
7717 return tmpfile
|
1621
|
7718 endfun
|
1121
|
7719
|
|
7720 " ---------------------------------------------------------------------
|
|
7721 " s:MakeSshCmd: transforms input command using USEPORT HOSTNAME into {{{2
|
1668
|
7722 " a correct command for use with a system() call
|
1121
|
7723 fun! s:MakeSshCmd(sshcmd)
|
1621
|
7724 " call Dfunc("s:MakeSshCmd(sshcmd<".a:sshcmd.">) user<".s:user."> machine<".s:machine.">")
|
1121
|
7725 let sshcmd = substitute(a:sshcmd,'\<HOSTNAME\>',s:user.s:machine,'')
|
|
7726 if exists("g:netrw_port") && g:netrw_port != ""
|
1209
|
7727 let sshcmd= substitute(sshcmd,"USEPORT",g:netrw_sshport.' '.g:netrw_port,'')
|
1121
|
7728 elseif exists("s:port") && s:port != ""
|
1209
|
7729 let sshcmd= substitute(sshcmd,"USEPORT",g:netrw_sshport.' '.s:port,'')
|
1121
|
7730 else
|
|
7731 let sshcmd= substitute(sshcmd,"USEPORT ",'','')
|
|
7732 endif
|
|
7733 " call Dret("s:MakeSshCmd <".sshcmd.">")
|
|
7734 return sshcmd
|
482
|
7735 endfun
|
|
7736
|
|
7737 " ---------------------------------------------------------------------
|
1668
|
7738 " s:NetrwBMShow: {{{2
|
|
7739 fun! s:NetrwBMShow()
|
|
7740 " call Dfunc("s:NetrwBMShow()")
|
|
7741 redir => bmshowraw
|
|
7742 menu
|
|
7743 redir END
|
|
7744 let bmshowlist = split(bmshowraw,'\n')
|
|
7745 if bmshowlist != []
|
|
7746 let bmshowfuncs= filter(bmshowlist,'v:val =~ "<SNR>\\d\\+_BMShow()"')
|
|
7747 if bmshowfuncs != []
|
|
7748 let bmshowfunc = substitute(bmshowfuncs[0],'^.*:\(call.*BMShow()\).*$','\1','')
|
|
7749 if bmshowfunc =~ '^call.*BMShow()'
|
|
7750 exe "silent! ".bmshowfunc
|
|
7751 endif
|
|
7752 endif
|
|
7753 endif
|
|
7754 " call Dret("s:NetrwBMShow : bmshowfunc<".(exists("bmshowfunc")? bmshowfunc : 'n/a').">")
|
|
7755 endfun
|
|
7756
|
|
7757 " ---------------------------------------------------------------------
|
|
7758 " s:NetrwDelete: Deletes a file. {{{2
|
|
7759 " Uses Steve Hall's idea to insure that Windows paths stay
|
|
7760 " acceptable. No effect on Unix paths.
|
|
7761 " Examples of use: let result= s:NetrwDelete(path)
|
|
7762 fun! s:NetrwDelete(path)
|
|
7763 " call Dfunc("s:NetrwDelete(path<".a:path.">)")
|
|
7764
|
2034
|
7765 let path = netrw#WinPath(a:path)
|
1668
|
7766 if !g:netrw_cygwin && (has("win32") || has("win95") || has("win64") || has("win16"))
|
|
7767 if exists("+shellslash")
|
|
7768 let sskeep= &shellslash
|
|
7769 setlocal noshellslash
|
|
7770 let result = delete(path)
|
|
7771 let &shellslash = sskeep
|
|
7772 else
|
|
7773 " call Decho("exe let result= ".a:cmd."('".path."')")
|
|
7774 let result= delete(path)
|
|
7775 endif
|
1621
|
7776 else
|
1668
|
7777 " call Decho("let result= delete(".path.")")
|
|
7778 let result= delete(path)
|
|
7779 endif
|
|
7780 if result < 0
|
2034
|
7781 call netrw#ErrorMsg(s:WARNING,"delete(".path.") failed!",71)
|
1668
|
7782 endif
|
|
7783
|
|
7784 " call Dret("s:NetrwDelete ".result)
|
|
7785 return result
|
1621
|
7786 endfun
|
|
7787
|
|
7788 " ---------------------------------------------------------------------
|
1121
|
7789 " s:NetrwEnew: opens a new buffer, passes netrw buffer variables through {{{2
|
2034
|
7790 fun! s:NetrwEnew(...)
|
|
7791 " call Dfunc("s:NetrwEnew() a:0=".a:0)
|
|
7792 " call Decho("curdir<".((a:0>0)? a:1 : "")."> buf#".bufnr("%")."<".bufname("%").">")
|
1121
|
7793
|
1621
|
7794 " grab a function-local-variable copy of buffer variables
|
1121
|
7795 if exists("b:netrw_bannercnt") |let netrw_bannercnt = b:netrw_bannercnt |endif
|
|
7796 if exists("b:netrw_browser_active") |let netrw_browser_active = b:netrw_browser_active |endif
|
|
7797 if exists("b:netrw_cpf") |let netrw_cpf = b:netrw_cpf |endif
|
|
7798 if exists("b:netrw_curdir") |let netrw_curdir = b:netrw_curdir |endif
|
|
7799 if exists("b:netrw_explore_bufnr") |let netrw_explore_bufnr = b:netrw_explore_bufnr |endif
|
|
7800 if exists("b:netrw_explore_indx") |let netrw_explore_indx = b:netrw_explore_indx |endif
|
|
7801 if exists("b:netrw_explore_line") |let netrw_explore_line = b:netrw_explore_line |endif
|
|
7802 if exists("b:netrw_explore_list") |let netrw_explore_list = b:netrw_explore_list |endif
|
|
7803 if exists("b:netrw_explore_listlen")|let netrw_explore_listlen = b:netrw_explore_listlen|endif
|
|
7804 if exists("b:netrw_explore_mtchcnt")|let netrw_explore_mtchcnt = b:netrw_explore_mtchcnt|endif
|
|
7805 if exists("b:netrw_fname") |let netrw_fname = b:netrw_fname |endif
|
|
7806 if exists("b:netrw_lastfile") |let netrw_lastfile = b:netrw_lastfile |endif
|
|
7807 if exists("b:netrw_liststyle") |let netrw_liststyle = b:netrw_liststyle |endif
|
|
7808 if exists("b:netrw_method") |let netrw_method = b:netrw_method |endif
|
|
7809 if exists("b:netrw_option") |let netrw_option = b:netrw_option |endif
|
|
7810 if exists("b:netrw_prvdir") |let netrw_prvdir = b:netrw_prvdir |endif
|
|
7811
|
1621
|
7812 call s:NetrwOptionRestore("w:")
|
|
7813 " call Decho("generate a buffer with keepjumps keepalt enew!")
|
|
7814 keepjumps keepalt enew!
|
|
7815 call s:NetrwOptionSave("w:")
|
|
7816
|
|
7817 " copy function-local-variables to buffer variable equivalents
|
1121
|
7818 if exists("netrw_bannercnt") |let b:netrw_bannercnt = netrw_bannercnt |endif
|
|
7819 if exists("netrw_browser_active") |let b:netrw_browser_active = netrw_browser_active |endif
|
|
7820 if exists("netrw_cpf") |let b:netrw_cpf = netrw_cpf |endif
|
|
7821 if exists("netrw_curdir") |let b:netrw_curdir = netrw_curdir |endif
|
|
7822 if exists("netrw_explore_bufnr") |let b:netrw_explore_bufnr = netrw_explore_bufnr |endif
|
|
7823 if exists("netrw_explore_indx") |let b:netrw_explore_indx = netrw_explore_indx |endif
|
|
7824 if exists("netrw_explore_line") |let b:netrw_explore_line = netrw_explore_line |endif
|
|
7825 if exists("netrw_explore_list") |let b:netrw_explore_list = netrw_explore_list |endif
|
|
7826 if exists("netrw_explore_listlen")|let b:netrw_explore_listlen = netrw_explore_listlen|endif
|
|
7827 if exists("netrw_explore_mtchcnt")|let b:netrw_explore_mtchcnt = netrw_explore_mtchcnt|endif
|
|
7828 if exists("netrw_fname") |let b:netrw_fname = netrw_fname |endif
|
|
7829 if exists("netrw_lastfile") |let b:netrw_lastfile = netrw_lastfile |endif
|
|
7830 if exists("netrw_liststyle") |let b:netrw_liststyle = netrw_liststyle |endif
|
|
7831 if exists("netrw_method") |let b:netrw_method = netrw_method |endif
|
|
7832 if exists("netrw_option") |let b:netrw_option = netrw_option |endif
|
|
7833 if exists("netrw_prvdir") |let b:netrw_prvdir = netrw_prvdir |endif
|
|
7834
|
2034
|
7835 if a:0 > 0
|
|
7836 let b:netrw_curdir= a:1
|
|
7837 if b:netrw_curdir =~ '/$'
|
|
7838 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST
|
|
7839 file NetrwTreeListing
|
|
7840 nno <silent> <buffer> [ :silent call <SID>TreeListMove('[')<cr>
|
|
7841 nno <silent> <buffer> ] :silent call <SID>TreeListMove(']')<cr>
|
|
7842 else
|
|
7843 exe "silent! keepalt file ".fnameescape(b:netrw_curdir)
|
|
7844 endif
|
1621
|
7845 endif
|
|
7846 endif
|
|
7847
|
|
7848 " call Dret("s:NetrwEnew : buf#".bufnr("%")."<".bufname("%")."> expand(%)<".expand("%")."> expand(#)<".expand("#").">")
|
|
7849 endfun
|
|
7850
|
|
7851 " ------------------------------------------------------------------------
|
|
7852 " s:NetrwSaveWordPosn: used to keep cursor on same word after refresh, {{{2
|
|
7853 " changed sorting, etc. Also see s:NetrwRestoreWordPosn().
|
|
7854 fun! s:NetrwSaveWordPosn()
|
|
7855 " call Dfunc("NetrwSaveWordPosn()")
|
|
7856 let s:netrw_saveword= '^'.fnameescape(getline('.')).'$'
|
|
7857 " call Dret("NetrwSaveWordPosn : saveword<".s:netrw_saveword.">")
|
|
7858 endfun
|
|
7859
|
|
7860 " ---------------------------------------------------------------------
|
|
7861 " s:NetrwRestoreWordPosn: used to keep cursor on same word after refresh, {{{2
|
|
7862 " changed sorting, etc. Also see s:NetrwSaveWordPosn().
|
|
7863 fun! s:NetrwRestoreWordPosn()
|
|
7864 " call Dfunc("NetrwRestoreWordPosn()")
|
|
7865 silent! call search(s:netrw_saveword,'w')
|
|
7866 " call Dret("NetrwRestoreWordPosn")
|
|
7867 endfun
|
|
7868
|
|
7869 " ---------------------------------------------------------------------
|
1668
|
7870 " s:RestoreBufVars: {{{2
|
|
7871 fun! s:RestoreBufVars()
|
|
7872 " call Dfunc("s:RestoreBufVars()")
|
|
7873
|
|
7874 if exists("s:netrw_curdir") |let b:netrw_curdir = s:netrw_curdir |endif
|
|
7875 if exists("s:netrw_lastfile") |let b:netrw_lastfile = s:netrw_lastfile |endif
|
|
7876 if exists("s:netrw_method") |let b:netrw_method = s:netrw_method |endif
|
|
7877 if exists("s:netrw_fname") |let b:netrw_fname = s:netrw_fname |endif
|
|
7878 if exists("s:netrw_machine") |let b:netrw_machine = s:netrw_machine |endif
|
|
7879 if exists("s:netrw_browser_active")|let b:netrw_browser_active = s:netrw_browser_active|endif
|
|
7880
|
|
7881 " call Dret("s:RestoreBufVars")
|
|
7882 endfun
|
|
7883
|
|
7884 " ---------------------------------------------------------------------
|
1121
|
7885 " s:RemotePathAnalysis: {{{2
|
|
7886 fun! s:RemotePathAnalysis(dirname)
|
|
7887 " call Dfunc("s:RemotePathAnalysis()")
|
|
7888
|
|
7889 let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/:#]\+\)\%([:#]\(\d\+\)\)\=/\(.*\)$'
|
|
7890 let s:method = substitute(a:dirname,dirpat,'\1','')
|
|
7891 let s:user = substitute(a:dirname,dirpat,'\2','')
|
|
7892 let s:machine = substitute(a:dirname,dirpat,'\3','')
|
|
7893 let s:port = substitute(a:dirname,dirpat,'\4','')
|
|
7894 let s:path = substitute(a:dirname,dirpat,'\5','')
|
|
7895 let s:fname = substitute(a:dirname,'^.*/\ze.','','')
|
|
7896
|
|
7897 " call Decho("set up s:method <".s:method .">")
|
|
7898 " call Decho("set up s:user <".s:user .">")
|
|
7899 " call Decho("set up s:machine<".s:machine.">")
|
|
7900 " call Decho("set up s:port <".s:port.">")
|
|
7901 " call Decho("set up s:path <".s:path .">")
|
|
7902 " call Decho("set up s:fname <".s:fname .">")
|
|
7903
|
|
7904 " call Dret("s:RemotePathAnalysis")
|
|
7905 endfun
|
|
7906
|
|
7907 " ---------------------------------------------------------------------
|
1668
|
7908 " s:RemoteSystem: runs a command on a remote host using ssh {{{2
|
|
7909 " Returns status
|
|
7910 " Runs system() on
|
|
7911 " [cd REMOTEDIRPATH;] a:cmd
|
|
7912 " Note that it doesn't do shellescape(a:cmd)!
|
|
7913 fun! s:RemoteSystem(cmd)
|
|
7914 " call Dfunc("s:RemoteSystem(cmd<".a:cmd.">)")
|
|
7915 if !executable(g:netrw_ssh_cmd)
|
|
7916 call netrw#ErrorMsg(s:ERROR,"g:netrw_ssh_cmd<".g:netrw_ssh_cmd."> is not executable!",52)
|
|
7917 elseif !exists("b:netrw_curdir")
|
|
7918 call netrw#ErrorMsg(s:ERROR,"for some reason b:netrw_curdir doesn't exist!",53)
|
|
7919 else
|
|
7920 let cmd = s:MakeSshCmd(g:netrw_ssh_cmd." USEPORT HOSTNAME")
|
|
7921 let remotedir= substitute(b:netrw_curdir,'^.*//[^/]\+/\(.*\)$','\1','')
|
|
7922 if remotedir != ""
|
|
7923 let cmd= cmd.' cd '.shellescape(remotedir).";"
|
|
7924 else
|
|
7925 let cmd= cmd.' '
|
|
7926 endif
|
|
7927 let cmd= cmd.a:cmd
|
|
7928 " call Decho("call system(".cmd.")")
|
|
7929 let ret= system(cmd)
|
|
7930 endif
|
|
7931 " call Dret("s:RemoteSystem ".ret)
|
|
7932 return ret
|
1121
|
7933 endfun
|
|
7934
|
|
7935 " ---------------------------------------------------------------------
|
1621
|
7936 " s:RestoreWinVars: (used by Explore() and NetrwSplit()) {{{2
|
1121
|
7937 fun! s:RestoreWinVars()
|
|
7938 " call Dfunc("s:RestoreWinVars()")
|
|
7939 if exists("s:bannercnt") |let w:netrw_bannercnt = s:bannercnt |unlet s:bannercnt |endif
|
|
7940 if exists("s:col") |let w:netrw_col = s:col |unlet s:col |endif
|
|
7941 if exists("s:curdir") |let w:netrw_curdir = s:curdir |unlet s:curdir |endif
|
|
7942 if exists("s:explore_bufnr") |let w:netrw_explore_bufnr = s:explore_bufnr |unlet s:explore_bufnr |endif
|
|
7943 if exists("s:explore_indx") |let w:netrw_explore_indx = s:explore_indx |unlet s:explore_indx |endif
|
|
7944 if exists("s:explore_line") |let w:netrw_explore_line = s:explore_line |unlet s:explore_line |endif
|
|
7945 if exists("s:explore_listlen")|let w:netrw_explore_listlen = s:explore_listlen|unlet s:explore_listlen|endif
|
|
7946 if exists("s:explore_list") |let w:netrw_explore_list = s:explore_list |unlet s:explore_list |endif
|
|
7947 if exists("s:explore_mtchcnt")|let w:netrw_explore_mtchcnt = s:explore_mtchcnt|unlet s:explore_mtchcnt|endif
|
|
7948 if exists("s:fpl") |let w:netrw_fpl = s:fpl |unlet s:fpl |endif
|
|
7949 if exists("s:hline") |let w:netrw_hline = s:hline |unlet s:hline |endif
|
|
7950 if exists("s:line") |let w:netrw_line = s:line |unlet s:line |endif
|
|
7951 if exists("s:liststyle") |let w:netrw_liststyle = s:liststyle |unlet s:liststyle |endif
|
|
7952 if exists("s:method") |let w:netrw_method = s:method |unlet s:method |endif
|
|
7953 if exists("s:prvdir") |let w:netrw_prvdir = s:prvdir |unlet s:prvdir |endif
|
|
7954 if exists("s:treedict") |let w:netrw_treedict = s:treedict |unlet s:treedict |endif
|
|
7955 if exists("s:treetop") |let w:netrw_treetop = s:treetop |unlet s:treetop |endif
|
|
7956 if exists("s:winnr") |let w:netrw_winnr = s:winnr |unlet s:winnr |endif
|
|
7957 " call Dret("s:RestoreWinVars")
|
|
7958 endfun
|
|
7959
|
|
7960 " ---------------------------------------------------------------------
|
1621
|
7961 " s:Rexplore: implements returning from a buffer to a netrw directory {{{2
|
|
7962 "
|
|
7963 " s:SetRexDir() sets up <2-leftmouse> maps (if g:netrw_retmap
|
|
7964 " is true) and a command, :Rexplore, which call this function.
|
|
7965 "
|
|
7966 " s:nbcd_curpos_{bufnr('%')} is set up by s:NetrwBrowseChgDir()
|
|
7967 fun! s:NetrwRexplore(islocal,dirname)
|
|
7968 " call Dfunc("s:NetrwRexplore(islocal=".a:islocal." dirname<".a:dirname.">)")
|
|
7969 if a:islocal
|
|
7970 call netrw#LocalBrowseCheck(a:dirname)
|
|
7971 else
|
|
7972 call s:NetrwBrowse(0,a:dirname)
|
|
7973 endif
|
|
7974 if exists("s:nbcd_curpos_{bufnr('%')}")
|
|
7975 call netrw#NetrwRestorePosn(s:nbcd_curpos_{bufnr('%')})
|
|
7976 unlet s:nbcd_curpos_{bufnr('%')}
|
|
7977 endif
|
2034
|
7978 if exists("s:explore_match")
|
|
7979 exe "2match netrwMarkFile /".s:explore_match."/"
|
|
7980 endif
|
1621
|
7981 " call Dret("s:NetrwRexplore")
|
|
7982 endfun
|
|
7983
|
|
7984 " ---------------------------------------------------------------------
|
1121
|
7985 " s:SaveBufVars: {{{2
|
|
7986 fun! s:SaveBufVars()
|
2034
|
7987 " call Dfunc("s:SaveBufVars() buf#".bufnr("%"))
|
1121
|
7988
|
|
7989 if exists("b:netrw_curdir") |let s:netrw_curdir = b:netrw_curdir |endif
|
|
7990 if exists("b:netrw_lastfile") |let s:netrw_lastfile = b:netrw_lastfile |endif
|
|
7991 if exists("b:netrw_method") |let s:netrw_method = b:netrw_method |endif
|
|
7992 if exists("b:netrw_fname") |let s:netrw_fname = b:netrw_fname |endif
|
|
7993 if exists("b:netrw_machine") |let s:netrw_machine = b:netrw_machine |endif
|
|
7994 if exists("b:netrw_browser_active")|let s:netrw_browser_active = b:netrw_browser_active|endif
|
|
7995
|
|
7996 " call Dret("s:SaveBufVars")
|
|
7997 endfun
|
|
7998
|
|
7999 " ---------------------------------------------------------------------
|
1621
|
8000 " s:SaveWinVars: (used by Explore() and NetrwSplit()) {{{2
|
1121
|
8001 fun! s:SaveWinVars()
|
2034
|
8002 " call Dfunc("s:SaveWinVars() win#".winnr())
|
1121
|
8003 if exists("w:netrw_bannercnt") |let s:bannercnt = w:netrw_bannercnt |endif
|
|
8004 if exists("w:netrw_col") |let s:col = w:netrw_col |endif
|
|
8005 if exists("w:netrw_curdir") |let s:curdir = w:netrw_curdir |endif
|
|
8006 if exists("w:netrw_explore_bufnr") |let s:explore_bufnr = w:netrw_explore_bufnr |endif
|
|
8007 if exists("w:netrw_explore_indx") |let s:explore_indx = w:netrw_explore_indx |endif
|
|
8008 if exists("w:netrw_explore_line") |let s:explore_line = w:netrw_explore_line |endif
|
|
8009 if exists("w:netrw_explore_listlen")|let s:explore_listlen = w:netrw_explore_listlen|endif
|
|
8010 if exists("w:netrw_explore_list") |let s:explore_list = w:netrw_explore_list |endif
|
|
8011 if exists("w:netrw_explore_mtchcnt")|let s:explore_mtchcnt = w:netrw_explore_mtchcnt|endif
|
|
8012 if exists("w:netrw_fpl") |let s:fpl = w:netrw_fpl |endif
|
|
8013 if exists("w:netrw_hline") |let s:hline = w:netrw_hline |endif
|
|
8014 if exists("w:netrw_line") |let s:line = w:netrw_line |endif
|
|
8015 if exists("w:netrw_liststyle") |let s:liststyle = w:netrw_liststyle |endif
|
|
8016 if exists("w:netrw_method") |let s:method = w:netrw_method |endif
|
|
8017 if exists("w:netrw_prvdir") |let s:prvdir = w:netrw_prvdir |endif
|
|
8018 if exists("w:netrw_treedict") |let s:treedict = w:netrw_treedict |endif
|
|
8019 if exists("w:netrw_treetop") |let s:treetop = w:netrw_treetop |endif
|
|
8020 if exists("w:netrw_winnr") |let s:winnr = w:netrw_winnr |endif
|
|
8021 " call Dret("s:SaveWinVars")
|
|
8022 endfun
|
|
8023
|
|
8024 " ---------------------------------------------------------------------
|
1621
|
8025 " s:SetBufWinVars: (used by NetrwBrowse() and LocalBrowseCheck()) {{{2
|
482
|
8026 " To allow separate windows to have their own activities, such as
|
|
8027 " Explore **/pattern, several variables have been made window-oriented.
|
|
8028 " However, when the user splits a browser window (ex: ctrl-w s), these
|
559
|
8029 " variables are not inherited by the new window. SetBufWinVars() and
|
482
|
8030 " UseBufWinVars() get around that.
|
559
|
8031 fun! s:SetBufWinVars()
|
2034
|
8032 " call Dfunc("s:SetBufWinVars() win#".winnr())
|
1121
|
8033 if exists("w:netrw_liststyle") |let b:netrw_liststyle = w:netrw_liststyle |endif
|
|
8034 if exists("w:netrw_bannercnt") |let b:netrw_bannercnt = w:netrw_bannercnt |endif
|
|
8035 if exists("w:netrw_method") |let b:netrw_method = w:netrw_method |endif
|
|
8036 if exists("w:netrw_prvdir") |let b:netrw_prvdir = w:netrw_prvdir |endif
|
|
8037 if exists("w:netrw_explore_indx") |let b:netrw_explore_indx = w:netrw_explore_indx |endif
|
|
8038 if exists("w:netrw_explore_listlen")|let b:netrw_explore_listlen= w:netrw_explore_listlen|endif
|
|
8039 if exists("w:netrw_explore_mtchcnt")|let b:netrw_explore_mtchcnt= w:netrw_explore_mtchcnt|endif
|
|
8040 if exists("w:netrw_explore_bufnr") |let b:netrw_explore_bufnr = w:netrw_explore_bufnr |endif
|
|
8041 if exists("w:netrw_explore_line") |let b:netrw_explore_line = w:netrw_explore_line |endif
|
|
8042 if exists("w:netrw_explore_list") |let b:netrw_explore_list = w:netrw_explore_list |endif
|
|
8043 " call Dret("s:SetBufWinVars")
|
482
|
8044 endfun
|
|
8045
|
|
8046 " ---------------------------------------------------------------------
|
1621
|
8047 " s:SetRexDir: set directory for :Rexplore {{{2
|
|
8048 fun! s:SetRexDir(islocal,dirname)
|
|
8049 " call Dfunc("s:SetRexDir(islocal=".a:islocal." dirname<".a:dirname.">)")
|
|
8050 " set up Rex and leftmouse-double-click
|
|
8051 if a:islocal
|
1698
|
8052 exe 'com! Rexplore call s:NetrwRexplore(1,"'.escape(a:dirname,'"\').'")'
|
1621
|
8053 if g:netrw_retmap
|
2034
|
8054 if !hasmapto("<Plug>NetrwReturn") && maparg("<2-leftmouse>","n") == ""
|
1621
|
8055 nmap <unique> <silent> <2-leftmouse> <Plug>NetrwReturn
|
|
8056 endif
|
1698
|
8057 let dir = escape(a:dirname, s:netrw_map_escape)
|
|
8058 exe 'nnoremap <silent> <Plug>NetrwReturn :call <SID>NetrwRexplore(1,"'.dir.'")<cr>'
|
1621
|
8059 endif
|
|
8060 else
|
1698
|
8061 exe 'com! Rexplore call s:NetrwRexplore(0,"'.escape(a:dirname,'"\').'")'
|
1621
|
8062 if g:netrw_retmap
|
2034
|
8063 if !hasmapto("<Plug>NetrwReturn") && maparg("<2-leftmouse>","n") == ""
|
1621
|
8064 nmap <unique> <silent> <2-leftmouse> <Plug>NetrwReturn
|
|
8065 endif
|
1698
|
8066 let dir = escape(a:dirname, s:netrw_map_escape)
|
|
8067 exe 'nnoremap <silent> <Plug>NetrwReturn :call <SID>NetrwRexplore(0,"'.dir.'")<cr>'
|
1621
|
8068 endif
|
|
8069 endif
|
|
8070 " call Dret("s:SetRexDir")
|
|
8071 endfun
|
|
8072
|
|
8073 " ---------------------------------------------------------------------
|
|
8074 " s:Strlen: this function returns the length of a string, even if its {{{2
|
|
8075 " using two-byte etc characters.
|
2034
|
8076 " Solution from Nicolai Weibull, vim docs (:help strlen()), Tony Mechelynck,
|
|
8077 " and a bit from me.
|
|
8078 " if g:netrw_xstrlen is zero (default), then the builtin strlen() function is used.
|
1621
|
8079 fun! s:Strlen(x)
|
|
8080 " call Dfunc("s:Strlen(x<".a:x.">")
|
|
8081 if g:netrw_xstrlen == 1
|
|
8082 " number of codepoints (Latin a + combining circumflex is two codepoints)
|
|
8083 " (comment from TM, solution from NW)
|
|
8084 let ret= strlen(substitute(a:x,'.','c','g'))
|
|
8085
|
|
8086 elseif g:netrw_xstrlen == 2
|
|
8087 " number of spacing codepoints (Latin a + combining circumflex is one spacing
|
|
8088 " codepoint; a hard tab is one; wide and narrow CJK are one each; etc.)
|
|
8089 " (comment from TM, solution from TM)
|
|
8090 let ret=strlen(substitute(a:x, '.\Z', 'x', 'g'))
|
|
8091
|
|
8092 elseif g:netrw_xstrlen == 3
|
|
8093 " virtual length (counting, for instance, tabs as anything between 1 and
|
|
8094 " 'tabstop', wide CJK as 2 rather than 1, Arabic alif as zero when immediately
|
|
8095 " preceded by lam, one otherwise, etc.)
|
|
8096 " (comment from TM, solution from me)
|
|
8097 let modkeep= &mod
|
|
8098 exe "norm! o\<esc>"
|
|
8099 call setline(line("."),a:x)
|
|
8100 let ret= virtcol("$") - 1
|
|
8101 d
|
|
8102 let &mod= modkeep
|
|
8103
|
|
8104 else
|
|
8105 " at least give a decent default
|
2034
|
8106 let ret= strlen(a:x)
|
1621
|
8107 endif
|
|
8108 " call Dret("s:Strlen ".ret)
|
|
8109 return ret
|
|
8110 endfun
|
|
8111
|
|
8112 " ---------------------------------------------------------------------
|
|
8113 " s:TreeListMove: {{{2
|
|
8114 fun! s:TreeListMove(dir)
|
|
8115 " call Dfunc("s:TreeListMove(dir<".a:dir.">)")
|
|
8116 let curline = getline('.')
|
|
8117 let prvline = (line(".") > 1)? getline(line(".")-1) : ''
|
|
8118 let nxtline = (line(".") < line("$"))? getline(line(".")+1) : ''
|
|
8119 let curindent= substitute(curline,'^\([| ]*\).\{-}$','\1','')
|
|
8120 let indentm1 = substitute(curindent,'^| ','','')
|
|
8121 " call Decho("prvline <".prvline."> #".line(".")-1)
|
|
8122 " call Decho("curline <".curline."> #".line("."))
|
|
8123 " call Decho("nxtline <".nxtline."> #".line(".")+1)
|
|
8124 " call Decho("curindent<".curindent.">")
|
|
8125 " call Decho("indentm1 <".indentm1.">")
|
|
8126
|
|
8127 if curline !~ '/$'
|
|
8128 " call Decho('regfile')
|
|
8129 if a:dir == '[' && prvline != ''
|
|
8130 norm! 0
|
|
8131 let nl = search('^'.indentm1.'[^|]','bWe') " search backwards from regular file
|
|
8132 " call Decho("regfile srch back: ".nl)
|
|
8133 elseif a:dir == ']' && nxtline != ''
|
|
8134 norm! $
|
|
8135 let nl = search('^'.indentm1.'[^|]','We') " search forwards from regular file
|
|
8136 " call Decho("regfile srch fwd: ".nl)
|
|
8137 endif
|
|
8138
|
|
8139 elseif a:dir == '[' && prvline != ''
|
|
8140 norm! 0
|
|
8141 let curline= line(".")
|
|
8142 let nl = search('^'.curindent.'[^|]','bWe') " search backwards From directory, same indentation
|
|
8143 " call Decho("dir srch back ind: ".nl)
|
|
8144 if nl != 0
|
|
8145 if line(".") == curline-1
|
|
8146 let nl= search('^'.indentm1.'[^|]','bWe') " search backwards from directory, indentation - 1
|
|
8147 " call Decho("dir srch back ind-1: ".nl)
|
|
8148 endif
|
|
8149 endif
|
|
8150
|
|
8151 elseif a:dir == ']' && nxtline != ''
|
|
8152 norm! $
|
|
8153 let curline = line(".")
|
|
8154 let nl = search('^'.curindent.'[^|]','We') " search forwards from directory, same indentation
|
|
8155 " call Decho("dir srch fwd ind: ".nl)
|
|
8156 if nl != 0
|
|
8157 if line(".") == curline+1
|
|
8158 let nl= search('^'.indentm1.'[^|]','We') " search forwards from directory, indentation - 1
|
|
8159 " call Decho("dir srch fwd ind-1: ".nl)
|
|
8160 endif
|
|
8161 endif
|
|
8162
|
|
8163 endif
|
|
8164
|
|
8165 " call Dret("s:TreeListMove")
|
|
8166 endfun
|
|
8167
|
|
8168 " ---------------------------------------------------------------------
|
1668
|
8169 " s:UpdateBuffersMenu: does emenu Buffers.Refresh (but due to locale, the menu item may not be called that) {{{2
|
|
8170 " The Buffers.Refresh menu calls s:BMShow(); unfortunately, that means that that function
|
|
8171 " can't be called except via emenu. But due to locale, that menu line may not be called
|
|
8172 " Buffers.Refresh; hence, s:NetrwBMShow() utilizes a "cheat" to call that function anyway.
|
|
8173 fun! s:UpdateBuffersMenu()
|
|
8174 " call Dfunc("s:UpdateBuffersMenu()")
|
2034
|
8175 if has("gui") && has("menu") && has("gui_running") && &go =~ 'm' && g:netrw_menu
|
1668
|
8176 try
|
|
8177 silent emenu Buffers.Refresh\ menu
|
|
8178 catch /^Vim\%((\a\+)\)\=:E/
|
|
8179 let v:errmsg= ""
|
|
8180 silent call s:NetrwBMShow()
|
|
8181 endtry
|
|
8182 endif
|
|
8183 " call Dret("s:UpdateBuffersMenu")
|
|
8184 endfun
|
|
8185
|
|
8186 " ---------------------------------------------------------------------
|
1621
|
8187 " s:UseBufWinVars: (used by NetrwBrowse() and LocalBrowseCheck() {{{2
|
482
|
8188 " Matching function to BufferWinVars()
|
|
8189 fun! s:UseBufWinVars()
|
1121
|
8190 " call Dfunc("s:UseBufWinVars()")
|
|
8191 if exists("b:netrw_liststyle") && !exists("w:netrw_liststyle") |let w:netrw_liststyle = b:netrw_liststyle |endif
|
482
|
8192 if exists("b:netrw_bannercnt") && !exists("w:netrw_bannercnt") |let w:netrw_bannercnt = b:netrw_bannercnt |endif
|
|
8193 if exists("b:netrw_method") && !exists("w:netrw_method") |let w:netrw_method = b:netrw_method |endif
|
|
8194 if exists("b:netrw_prvdir") && !exists("w:netrw_prvdir") |let w:netrw_prvdir = b:netrw_prvdir |endif
|
|
8195 if exists("b:netrw_explore_indx") && !exists("w:netrw_explore_indx") |let w:netrw_explore_indx = b:netrw_explore_indx |endif
|
|
8196 if exists("b:netrw_explore_listlen") && !exists("w:netrw_explore_listlen")|let w:netrw_explore_listlen = b:netrw_explore_listlen|endif
|
|
8197 if exists("b:netrw_explore_mtchcnt") && !exists("w:netrw_explore_mtchcnt")|let w:netrw_explore_mtchcnt = b:netrw_explore_mtchcnt|endif
|
|
8198 if exists("b:netrw_explore_bufnr") && !exists("w:netrw_explore_bufnr") |let w:netrw_explore_bufnr = b:netrw_explore_bufnr |endif
|
|
8199 if exists("b:netrw_explore_line") && !exists("w:netrw_explore_line") |let w:netrw_explore_line = b:netrw_explore_line |endif
|
|
8200 if exists("b:netrw_explore_list") && !exists("w:netrw_explore_list") |let w:netrw_explore_list = b:netrw_explore_list |endif
|
1121
|
8201 " call Dret("s:UseBufWinVars")
|
482
|
8202 endfun
|
|
8203
|
559
|
8204 " ---------------------------------------------------------------------
|
2034
|
8205 " netrw#WinPath: tries to insure that the path is windows-acceptable, whether cygwin is used or not {{{2
|
|
8206 fun! netrw#WinPath(path)
|
|
8207 " call Dfunc("netrw#WinPath(path<".a:path.">)")
|
|
8208 if (!g:netrw_cygwin || &shell !~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$') && (has("win32") || has("win95") || has("win64") || has("win16"))
|
|
8209 " remove cygdrive prefix, if present
|
|
8210 let path = substitute(a:path,'/cygdrive/\(.\)','\1:','')
|
1668
|
8211 " remove trailing slash (Win95)
|
2034
|
8212 let path = substitute(path, '\(\\\|/\)$', '', 'g')
|
1668
|
8213 " remove escaped spaces
|
|
8214 let path = substitute(path, '\ ', ' ', 'g')
|
|
8215 " convert slashes to backslashes
|
|
8216 let path = substitute(path, '/', '\', 'g')
|
|
8217 else
|
|
8218 let path= a:path
|
|
8219 endif
|
2034
|
8220 " call Dret("netrw#WinPath <".path.">")
|
1668
|
8221 return path
|
|
8222 endfun
|
|
8223
|
|
8224 " ---------------------------------------------------------------------
|
650
|
8225 " Settings Restoration: {{{2
|
482
|
8226 let &cpo= s:keepcpo
|
|
8227 unlet s:keepcpo
|
|
8228
|
|
8229 " ------------------------------------------------------------------------
|
|
8230 " Modelines: {{{1
|
|
8231 " vim:ts=8 fdm=marker
|