Mercurial > vim
annotate runtime/autoload/netrw.vim @ 18527:edccc0b13ac3
Added tag v8.1.2257 for changeset 334b1f897f3a1769683ab72080f63f1f53855b95
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 05 Nov 2019 21:15:05 +0100 |
parents | ca8e754bdd53 |
children | e9a47bcf7b94 |
rev | line source |
---|---|
1121 | 1 " netrw.vim: Handles file transfer and remote directory listing across |
2 " AUTOLOAD SECTION | |
17433 | 3 " Date: Jul 16, 2019 |
4 " Version: 165 | |
4339 | 5 " Maintainer: Charles E Campbell <NdrOchip@ScampbellPfamily.AbizM-NOSPAM> |
482 | 6 " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7 " Copyright: Copyright (C) 2016 Charles E. Campbell {{{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. | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
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 | |
17433 | 25 |
26 " Check that vim has patches that netrw requires. | |
27 " Patches needed for v7.4: 1557, and 213. | |
28 " (netrw will benefit from vim's having patch#656, too) | |
29 let s:needspatches=[1557,213] | |
30 if exists("s:needspatches") | |
31 for ptch in s:needspatches | |
32 if v:version < 704 || (v:version == 704 && !has("patch".ptch)) | |
33 if !exists("s:needpatch{ptch}") | |
34 unsilent echomsg "***sorry*** this version of netrw requires vim v7.4 with patch#".ptch | |
35 endif | |
36 let s:needpatch{ptch}= 1 | |
37 finish | |
38 endif | |
39 endfor | |
5929 | 40 endif |
17433 | 41 |
42 let g:loaded_netrw = "v165" | |
1121 | 43 if !exists("s:NOTE") |
44 let s:NOTE = 0 | |
45 let s:WARNING = 1 | |
46 let s:ERROR = 2 | |
47 endif | |
1621 | 48 |
559 | 49 let s:keepcpo= &cpo |
5734 | 50 setl cpo&vim |
17433 | 51 "DechoFuncName 1 |
5618 | 52 "DechoRemOn |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
53 "call Decho("doing autoload/netrw.vim version ".g:loaded_netrw,'~'.expand("<slnum>")) |
482 | 54 |
650 | 55 " ====================== |
56 " Netrw Variables: {{{1 | |
57 " ====================== | |
58 | |
482 | 59 " --------------------------------------------------------------------- |
3456 | 60 " netrw#ErrorMsg: {{{2 |
61 " 0=note = s:NOTE | |
62 " 1=warning = s:WARNING | |
63 " 2=error = s:ERROR | |
6476 | 64 " Usage: netrw#ErrorMsg(s:NOTE | s:WARNING | s:ERROR,"some message",error-number) |
65 " netrw#ErrorMsg(s:NOTE | s:WARNING | s:ERROR,["message1","message2",...],error-number) | |
66 " (this function can optionally take a list of messages) | |
17433 | 67 " Mar 21, 2017 : max errnum currently is 105 |
3456 | 68 fun! netrw#ErrorMsg(level,msg,errnum) |
69 " call Dfunc("netrw#ErrorMsg(level=".a:level." msg<".a:msg."> errnum=".a:errnum.") g:netrw_use_errorwindow=".g:netrw_use_errorwindow) | |
70 | |
71 if a:level < g:netrw_errorlvl | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
72 " call Dret("netrw#ErrorMsg : suppressing level=".a:level." since g:netrw_errorlvl=".g:netrw_errorlvl) |
3456 | 73 return |
74 endif | |
75 | |
76 if a:level == 1 | |
77 let level= "**warning** (netrw) " | |
78 elseif a:level == 2 | |
79 let level= "**error** (netrw) " | |
80 else | |
81 let level= "**note** (netrw) " | |
82 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
83 " call Decho("level=".level,'~'.expand("<slnum>")) |
3456 | 84 |
85 if g:netrw_use_errorwindow | |
86 " (default) netrw creates a one-line window to show error/warning | |
87 " messages (reliably displayed) | |
88 | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
89 " record current window number |
3456 | 90 let s:winBeforeErr= winnr() |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
91 " call Decho("s:winBeforeErr=".s:winBeforeErr,'~'.expand("<slnum>")) |
3456 | 92 |
93 " getting messages out reliably is just plain difficult! | |
94 " This attempt splits the current window, creating a one line window. | |
95 if bufexists("NetrwMessage") && bufwinnr("NetrwMessage") > 0 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
96 " call Decho("write to NetrwMessage buffer",'~'.expand("<slnum>")) |
3456 | 97 exe bufwinnr("NetrwMessage")."wincmd w" |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
98 " call Decho("setl ma noro",'~'.expand("<slnum>")) |
3456 | 99 setl ma noro |
6476 | 100 if type(a:msg) == 3 |
101 for msg in a:msg | |
102 NetrwKeepj call setline(line("$")+1,level.msg) | |
103 endfor | |
104 else | |
105 NetrwKeepj call setline(line("$")+1,level.a:msg) | |
106 endif | |
107 NetrwKeepj $ | |
3456 | 108 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
109 " call Decho("create a NetrwMessage buffer window",'~'.expand("<slnum>")) |
3456 | 110 bo 1split |
111 sil! call s:NetrwEnew() | |
17433 | 112 sil! NetrwKeepj call s:NetrwOptionsSafe(1) |
3456 | 113 setl bt=nofile |
6476 | 114 NetrwKeepj file NetrwMessage |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
115 " call Decho("setl ma noro",'~'.expand("<slnum>")) |
3456 | 116 setl ma noro |
6476 | 117 if type(a:msg) == 3 |
118 for msg in a:msg | |
119 NetrwKeepj call setline(line("$")+1,level.msg) | |
120 endfor | |
121 else | |
122 NetrwKeepj call setline(line("$"),level.a:msg) | |
123 endif | |
124 NetrwKeepj $ | |
3456 | 125 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
126 " call Decho("wrote msg<".level.a:msg."> to NetrwMessage win#".winnr(),'~'.expand("<slnum>")) |
3456 | 127 if &fo !~ '[ta]' |
128 syn clear | |
129 syn match netrwMesgNote "^\*\*note\*\*" | |
130 syn match netrwMesgWarning "^\*\*warning\*\*" | |
131 syn match netrwMesgError "^\*\*error\*\*" | |
132 hi link netrwMesgWarning WarningMsg | |
133 hi link netrwMesgError Error | |
134 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
135 " call Decho("setl noma ro bh=wipe",'~'.expand("<slnum>")) |
5929 | 136 setl ro nomod noma bh=wipe |
3456 | 137 |
138 else | |
139 " (optional) netrw will show messages using echomsg. Even if the | |
140 " message doesn't appear, at least it'll be recallable via :messages | |
141 " redraw! | |
142 if a:level == s:WARNING | |
143 echohl WarningMsg | |
144 elseif a:level == s:ERROR | |
145 echohl Error | |
146 endif | |
6476 | 147 |
148 if type(a:msg) == 3 | |
149 for msg in a:msg | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
150 unsilent echomsg level.msg |
6476 | 151 endfor |
152 else | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
153 unsilent echomsg level.a:msg |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
154 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
155 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
156 " call Decho("echomsg ***netrw*** ".a:msg,'~'.expand("<slnum>")) |
3456 | 157 echohl None |
158 endif | |
159 | |
160 " call Dret("netrw#ErrorMsg") | |
161 endfun | |
162 | |
163 " --------------------------------------------------------------------- | |
6476 | 164 " s:NetrwInit: initializes variables if they haven't been defined {{{2 |
2034 | 165 " Loosely, varname = value. |
166 fun s:NetrwInit(varname,value) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
167 " call Decho("varname<".a:varname."> value=".a:value,'~'.expand("<slnum>")) |
2034 | 168 if !exists(a:varname) |
169 if type(a:value) == 0 | |
170 exe "let ".a:varname."=".a:value | |
4339 | 171 elseif type(a:value) == 1 && a:value =~ '^[{[]' |
172 exe "let ".a:varname."=".a:value | |
2034 | 173 elseif type(a:value) == 1 |
174 exe "let ".a:varname."="."'".a:value."'" | |
175 else | |
176 exe "let ".a:varname."=".a:value | |
177 endif | |
178 endif | |
179 endfun | |
180 | |
181 " --------------------------------------------------------------------- | |
1121 | 182 " Netrw Constants: {{{2 |
17433 | 183 call s:NetrwInit("g:netrw_dirhistcnt",0) |
1121 | 184 if !exists("s:LONGLIST") |
2034 | 185 call s:NetrwInit("s:THINLIST",0) |
186 call s:NetrwInit("s:LONGLIST",1) | |
187 call s:NetrwInit("s:WIDELIST",2) | |
188 call s:NetrwInit("s:TREELIST",3) | |
189 call s:NetrwInit("s:MAXLIST" ,4) | |
1121 | 190 endif |
191 | |
192 " --------------------------------------------------------------------- | |
17433 | 193 " Default option values: {{{2 |
194 let g:netrw_localcopycmdopt = "" | |
195 let g:netrw_localcopydircmdopt = "" | |
196 let g:netrw_localmkdiropt = "" | |
197 let g:netrw_localmovecmdopt = "" | |
198 let g:netrw_localrmdiropt = "" | |
199 | |
200 " --------------------------------------------------------------------- | |
650 | 201 " Default values for netrw's global protocol variables {{{2 |
2751 | 202 call s:NetrwInit("g:netrw_use_errorwindow",1) |
203 | |
559 | 204 if !exists("g:netrw_dav_cmd") |
2034 | 205 if executable("cadaver") |
559 | 206 let g:netrw_dav_cmd = "cadaver" |
2034 | 207 elseif executable("curl") |
208 let g:netrw_dav_cmd = "curl" | |
209 else | |
210 let g:netrw_dav_cmd = "" | |
211 endif | |
559 | 212 endif |
213 if !exists("g:netrw_fetch_cmd") | |
214 if executable("fetch") | |
215 let g:netrw_fetch_cmd = "fetch -o" | |
216 else | |
217 let g:netrw_fetch_cmd = "" | |
218 endif | |
219 endif | |
6476 | 220 if !exists("g:netrw_file_cmd") |
221 if executable("elinks") | |
222 call s:NetrwInit("g:netrw_file_cmd","elinks") | |
223 elseif executable("links") | |
224 call s:NetrwInit("g:netrw_file_cmd","links") | |
225 endif | |
226 endif | |
559 | 227 if !exists("g:netrw_ftp_cmd") |
228 let g:netrw_ftp_cmd = "ftp" | |
229 endif | |
2751 | 230 let s:netrw_ftp_cmd= g:netrw_ftp_cmd |
3456 | 231 if !exists("g:netrw_ftp_options") |
232 let g:netrw_ftp_options= "-i -n" | |
233 endif | |
559 | 234 if !exists("g:netrw_http_cmd") |
17433 | 235 if executable("curl") |
2034 | 236 let g:netrw_http_cmd = "curl" |
17433 | 237 call s:NetrwInit("g:netrw_http_xcmd","-L -o") |
1121 | 238 elseif executable("wget") |
2034 | 239 let g:netrw_http_cmd = "wget" |
240 call s:NetrwInit("g:netrw_http_xcmd","-q -O") | |
17433 | 241 elseif executable("elinks") |
242 let g:netrw_http_cmd = "elinks" | |
243 call s:NetrwInit("g:netrw_http_xcmd","-source >") | |
559 | 244 elseif executable("fetch") |
2034 | 245 let g:netrw_http_cmd = "fetch" |
246 call s:NetrwInit("g:netrw_http_xcmd","-o") | |
17433 | 247 elseif executable("links") |
248 let g:netrw_http_cmd = "links" | |
249 call s:NetrwInit("g:netrw_http_xcmd","-http.extra-header ".shellescape("Accept-Encoding: identity", 1)." -source >") | |
559 | 250 else |
251 let g:netrw_http_cmd = "" | |
252 endif | |
253 endif | |
5618 | 254 call s:NetrwInit("g:netrw_http_put_cmd","curl -T") |
6476 | 255 call s:NetrwInit("g:netrw_keepj","keepj") |
2034 | 256 call s:NetrwInit("g:netrw_rcp_cmd" , "rcp") |
257 call s:NetrwInit("g:netrw_rsync_cmd", "rsync") | |
17433 | 258 call s:NetrwInit("g:netrw_rsync_sep", "/") |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
259 if !exists("g:netrw_scp_cmd") |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
260 if executable("scp") |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
261 call s:NetrwInit("g:netrw_scp_cmd" , "scp -q") |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
262 elseif executable("pscp") |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
263 if (has("win32") || has("win95") || has("win64") || has("win16")) && filereadable('c:\private.ppk') |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
264 call s:NetrwInit("g:netrw_scp_cmd", 'pscp -i c:\private.ppk') |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
265 else |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
266 call s:NetrwInit("g:netrw_scp_cmd", 'pscp -q') |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
267 endif |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
268 else |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
269 call s:NetrwInit("g:netrw_scp_cmd" , "scp -q") |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
270 endif |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
271 endif |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
272 |
2034 | 273 call s:NetrwInit("g:netrw_sftp_cmd" , "sftp") |
274 call s:NetrwInit("g:netrw_ssh_cmd" , "ssh") | |
559 | 275 |
719 | 276 if (has("win32") || has("win95") || has("win64") || has("win16")) |
559 | 277 \ && exists("g:netrw_use_nt_rcp") |
278 \ && g:netrw_use_nt_rcp | |
279 \ && executable( $SystemRoot .'/system32/rcp.exe') | |
280 let s:netrw_has_nt_rcp = 1 | |
281 let s:netrw_rcpmode = '-b' | |
1121 | 282 else |
559 | 283 let s:netrw_has_nt_rcp = 0 |
284 let s:netrw_rcpmode = '' | |
285 endif | |
286 | |
287 " --------------------------------------------------------------------- | |
650 | 288 " Default values for netrw's global variables {{{2 |
1621 | 289 " Cygwin Detection ------- {{{3 |
290 if !exists("g:netrw_cygwin") | |
291 if has("win32") || has("win95") || has("win64") || has("win16") | |
3920 | 292 if has("win32unix") && &shell =~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$' |
1621 | 293 let g:netrw_cygwin= 1 |
294 else | |
295 let g:netrw_cygwin= 0 | |
296 endif | |
297 else | |
298 let g:netrw_cygwin= 0 | |
299 endif | |
300 endif | |
650 | 301 " Default values - a-c ---------- {{{3 |
2034 | 302 call s:NetrwInit("g:netrw_alto" , &sb) |
303 call s:NetrwInit("g:netrw_altv" , &spr) | |
304 call s:NetrwInit("g:netrw_banner" , 1) | |
305 call s:NetrwInit("g:netrw_browse_split", 0) | |
5929 | 306 call s:NetrwInit("g:netrw_bufsettings" , "noma nomod nonu nobl nowrap ro nornu") |
2034 | 307 call s:NetrwInit("g:netrw_chgwin" , -1) |
308 call s:NetrwInit("g:netrw_compress" , "gzip") | |
309 call s:NetrwInit("g:netrw_ctags" , "ctags") | |
2751 | 310 if exists("g:netrw_cursorline") && !exists("g:netrw_cursor") |
311 call netrw#ErrorMsg(s:NOTE,'g:netrw_cursorline is deprecated; use g:netrw_cursor instead',77) | |
312 let g:netrw_cursor= g:netrw_cursorline | |
1621 | 313 endif |
2751 | 314 call s:NetrwInit("g:netrw_cursor" , 2) |
315 let s:netrw_usercul = &cursorline | |
316 let s:netrw_usercuc = &cursorcolumn | |
5618 | 317 call s:NetrwInit("g:netrw_cygdrive","/cygdrive") |
1621 | 318 " Default values - d-g ---------- {{{3 |
4339 | 319 call s:NetrwInit("s:didstarstar",0) |
17433 | 320 call s:NetrwInit("g:netrw_dirhistcnt" , 0) |
2420
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
321 call s:NetrwInit("g:netrw_decompress" , '{ ".gz" : "gunzip", ".bz2" : "bunzip2", ".zip" : "unzip", ".tar" : "tar -xf", ".xz" : "unxz" }') |
2034 | 322 call s:NetrwInit("g:netrw_dirhistmax" , 10) |
3456 | 323 call s:NetrwInit("g:netrw_errorlvl" , s:NOTE) |
2034 | 324 call s:NetrwInit("g:netrw_fastbrowse" , 1) |
325 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 | 326 if !exists("g:netrw_ftp_list_cmd") |
1121 | 327 if has("unix") || (exists("g:netrw_cygwin") && g:netrw_cygwin) |
328 let g:netrw_ftp_list_cmd = "ls -lF" | |
329 let g:netrw_ftp_timelist_cmd = "ls -tlF" | |
330 let g:netrw_ftp_sizelist_cmd = "ls -slF" | |
482 | 331 else |
1121 | 332 let g:netrw_ftp_list_cmd = "dir" |
333 let g:netrw_ftp_timelist_cmd = "dir" | |
334 let g:netrw_ftp_sizelist_cmd = "dir" | |
482 | 335 endif |
336 endif | |
2034 | 337 call s:NetrwInit("g:netrw_ftpmode",'binary') |
650 | 338 " Default values - h-lh ---------- {{{3 |
2034 | 339 call s:NetrwInit("g:netrw_hide",1) |
1121 | 340 if !exists("g:netrw_ignorenetrc") |
341 if &shell =~ '\c\<\%(cmd\|4nt\)\.exe$' | |
342 let g:netrw_ignorenetrc= 1 | |
343 else | |
344 let g:netrw_ignorenetrc= 0 | |
345 endif | |
346 endif | |
2034 | 347 call s:NetrwInit("g:netrw_keepdir",1) |
559 | 348 if !exists("g:netrw_list_cmd") |
1121 | 349 if g:netrw_scp_cmd =~ '^pscp' && executable("pscp") |
350 if (has("win32") || has("win95") || has("win64") || has("win16")) && filereadable("c:\\private.ppk") | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
351 " provide a pscp-based listing command |
1121 | 352 let g:netrw_scp_cmd ="pscp -i C:\\private.ppk" |
353 endif | |
6476 | 354 if exists("g:netrw_list_cmd_options") |
355 let g:netrw_list_cmd= g:netrw_scp_cmd." -ls USEPORT HOSTNAME: ".g:netrw_list_cmd_options | |
356 else | |
357 let g:netrw_list_cmd= g:netrw_scp_cmd." -ls USEPORT HOSTNAME:" | |
358 endif | |
1121 | 359 elseif executable(g:netrw_ssh_cmd) |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
360 " provide a scp-based default listing command |
6476 | 361 if exists("g:netrw_list_cmd_options") |
362 let g:netrw_list_cmd= g:netrw_ssh_cmd." USEPORT HOSTNAME ls -FLa ".g:netrw_list_cmd_options | |
363 else | |
364 let g:netrw_list_cmd= g:netrw_ssh_cmd." USEPORT HOSTNAME ls -FLa" | |
365 endif | |
559 | 366 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
367 " call Decho(g:netrw_ssh_cmd." is not executable",'~'.expand("<slnum>")) |
559 | 368 let g:netrw_list_cmd= "" |
369 endif | |
370 endif | |
2034 | 371 call s:NetrwInit("g:netrw_list_hide","") |
650 | 372 " Default values - lh-lz ---------- {{{3 |
3456 | 373 if exists("g:netrw_local_copycmd") |
4339 | 374 let g:netrw_localcopycmd= g:netrw_local_copycmd |
3456 | 375 call netrw#ErrorMsg(s:NOTE,"g:netrw_local_copycmd is deprecated in favor of g:netrw_localcopycmd",84) |
376 endif | |
3920 | 377 if !exists("g:netrw_localcmdshell") |
378 let g:netrw_localcmdshell= "" | |
379 endif | |
1621 | 380 if !exists("g:netrw_localcopycmd") |
381 if has("win32") || has("win95") || has("win64") || has("win16") | |
382 if g:netrw_cygwin | |
383 let g:netrw_localcopycmd= "cp" | |
384 else | |
17433 | 385 let g:netrw_localcopycmd = expand("$COMSPEC") |
386 let g:netrw_localcopycmdopt= " /c copy" | |
1621 | 387 endif |
388 elseif has("unix") || has("macunix") | |
389 let g:netrw_localcopycmd= "cp" | |
390 else | |
391 let g:netrw_localcopycmd= "" | |
392 endif | |
393 endif | |
6476 | 394 if !exists("g:netrw_localcopydircmd") |
395 if has("win32") || has("win95") || has("win64") || has("win16") | |
396 if g:netrw_cygwin | |
17433 | 397 let g:netrw_localcopydircmd = "cp" |
398 let g:netrw_localcopydircmdopt= " -R" | |
399 else | |
400 let g:netrw_localcopydircmd = expand("$COMSPEC") | |
401 let g:netrw_localcopydircmdopt= " /c xcopy /e /c /h /i /k" | |
402 endif | |
403 elseif has("unix") | |
404 let g:netrw_localcopydircmd = "cp" | |
405 let g:netrw_localcopydircmdopt= " -R" | |
406 elseif has("macunix") | |
407 let g:netrw_localcopydircmd = "cp" | |
408 let g:netrw_localcopydircmdopt= " -R" | |
6476 | 409 else |
17433 | 410 let g:netrw_localcopydircmd= "" |
6476 | 411 endif |
412 endif | |
3456 | 413 if exists("g:netrw_local_mkdir") |
3920 | 414 let g:netrw_localmkdir= g:netrw_local_mkdir |
3456 | 415 call netrw#ErrorMsg(s:NOTE,"g:netrw_local_mkdir is deprecated in favor of g:netrw_localmkdir",87) |
416 endif | |
5929 | 417 if has("win32") || has("win95") || has("win64") || has("win16") |
418 if g:netrw_cygwin | |
419 call s:NetrwInit("g:netrw_localmkdir","mkdir") | |
420 else | |
17433 | 421 let g:netrw_localmkdir = expand("$COMSPEC") |
422 let g:netrw_localmkdiropt= " /c mkdir" | |
5929 | 423 endif |
424 else | |
425 call s:NetrwInit("g:netrw_localmkdir","mkdir") | |
426 endif | |
3153 | 427 call s:NetrwInit("g:netrw_remote_mkdir","mkdir") |
3456 | 428 if exists("g:netrw_local_movecmd") |
4339 | 429 let g:netrw_localmovecmd= g:netrw_local_movecmd |
3456 | 430 call netrw#ErrorMsg(s:NOTE,"g:netrw_local_movecmd is deprecated in favor of g:netrw_localmovecmd",88) |
431 endif | |
1621 | 432 if !exists("g:netrw_localmovecmd") |
433 if has("win32") || has("win95") || has("win64") || has("win16") | |
434 if g:netrw_cygwin | |
435 let g:netrw_localmovecmd= "mv" | |
436 else | |
17433 | 437 let g:netrw_localmovecmd = expand("$COMSPEC") |
438 let g:netrw_localmovecmdopt= " /c move" | |
1621 | 439 endif |
440 elseif has("unix") || has("macunix") | |
441 let g:netrw_localmovecmd= "mv" | |
442 else | |
443 let g:netrw_localmovecmd= "" | |
444 endif | |
445 endif | |
17433 | 446 if v:version < 704 || (v:version == 704 && !has("patch1107")) |
447 " 1109 provides for delete(tmpdir,"d") which is what will be used | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
448 if exists("g:netrw_local_rmdir") |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
449 let g:netrw_localrmdir= g:netrw_local_rmdir |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
450 call netrw#ErrorMsg(s:NOTE,"g:netrw_local_rmdir is deprecated in favor of g:netrw_localrmdir",86) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
451 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
452 if has("win32") || has("win95") || has("win64") || has("win16") |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
453 if g:netrw_cygwin |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
454 call s:NetrwInit("g:netrw_localrmdir","rmdir") |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
455 else |
17433 | 456 let g:netrw_localrmdir = expand("$COMSPEC") |
457 let g:netrw_localrmdiropt= " /c rmdir" | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
458 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
459 else |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
460 call s:NetrwInit("g:netrw_localrmdir","rmdir") |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
461 endif |
5929 | 462 endif |
2034 | 463 call s:NetrwInit("g:netrw_liststyle" , s:THINLIST) |
464 " sanity checks | |
1121 | 465 if g:netrw_liststyle < 0 || g:netrw_liststyle >= s:MAXLIST |
466 let g:netrw_liststyle= s:THINLIST | |
559 | 467 endif |
1121 | 468 if g:netrw_liststyle == s:LONGLIST && g:netrw_scp_cmd !~ '^pscp' |
559 | 469 let g:netrw_list_cmd= g:netrw_list_cmd." -l" |
470 endif | |
650 | 471 " Default values - m-r ---------- {{{3 |
2034 | 472 call s:NetrwInit("g:netrw_markfileesc" , '*./[\~') |
473 call s:NetrwInit("g:netrw_maxfilenamelen", 32) | |
474 call s:NetrwInit("g:netrw_menu" , 1) | |
475 call s:NetrwInit("g:netrw_mkdir_cmd" , g:netrw_ssh_cmd." USEPORT HOSTNAME mkdir") | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
476 call s:NetrwInit("g:netrw_mousemaps" , (exists("+mouse") && &mouse =~# '[anh]')) |
2034 | 477 call s:NetrwInit("g:netrw_retmap" , 0) |
478 if has("unix") || (exists("g:netrw_cygwin") && g:netrw_cygwin) | |
479 call s:NetrwInit("g:netrw_chgperm" , "chmod PERM FILENAME") | |
480 elseif has("win32") || has("win95") || has("win64") || has("win16") | |
481 call s:NetrwInit("g:netrw_chgperm" , "cacls FILENAME /e /p PERM") | |
482 else | |
483 call s:NetrwInit("g:netrw_chgperm" , "chmod PERM FILENAME") | |
1121 | 484 endif |
2034 | 485 call s:NetrwInit("g:netrw_preview" , 0) |
486 call s:NetrwInit("g:netrw_scpport" , "-P") | |
6476 | 487 call s:NetrwInit("g:netrw_servername" , "NETRWSERVER") |
2034 | 488 call s:NetrwInit("g:netrw_sshport" , "-p") |
489 call s:NetrwInit("g:netrw_rename_cmd" , g:netrw_ssh_cmd." USEPORT HOSTNAME mv") | |
490 call s:NetrwInit("g:netrw_rm_cmd" , g:netrw_ssh_cmd." USEPORT HOSTNAME rm") | |
491 call s:NetrwInit("g:netrw_rmdir_cmd" , g:netrw_ssh_cmd." USEPORT HOSTNAME rmdir") | |
5734 | 492 call s:NetrwInit("g:netrw_rmf_cmd" , g:netrw_ssh_cmd." USEPORT HOSTNAME rm -f ") |
493 " Default values - q-s ---------- {{{3 | |
494 call s:NetrwInit("g:netrw_quickhelp",0) | |
495 let s:QuickHelp= ["-:go up dir D:delete R:rename s:sort-by x:special", | |
6476 | 496 \ "(create new) %:file d:directory", |
497 \ "(windows split&open) o:horz v:vert p:preview", | |
498 \ "i:style qf:file info O:obtain r:reverse", | |
499 \ "(marks) mf:mark file mt:set target mm:move mc:copy", | |
500 \ "(bookmarks) mb:make mB:delete qb:list gb:go to", | |
501 \ "(history) qb:list u:go up U:go down", | |
502 \ "(targets) mt:target Tb:use bookmark Th:use history"] | |
2034 | 503 " g:netrw_sepchr: picking a character that doesn't appear in filenames that can be used to separate priority from filename |
504 call s:NetrwInit("g:netrw_sepchr" , (&enc == "euc-jp")? "\<Char-0x01>" : "\<Char-0xff>") | |
6476 | 505 if !exists("g:netrw_keepj") || g:netrw_keepj == "keepj" |
506 call s:NetrwInit("s:netrw_silentxfer" , (exists("g:netrw_silent") && g:netrw_silent != 0)? "sil keepj " : "keepj ") | |
507 else | |
508 call s:NetrwInit("s:netrw_silentxfer" , (exists("g:netrw_silent") && g:netrw_silent != 0)? "sil " : " ") | |
509 endif | |
2034 | 510 call s:NetrwInit("g:netrw_sort_by" , "name") " alternatives: date , size |
511 call s:NetrwInit("g:netrw_sort_options" , "") | |
512 call s:NetrwInit("g:netrw_sort_direction", "normal") " alternative: reverse (z y x ...) | |
513 if !exists("g:netrw_sort_sequence") | |
514 if has("unix") | |
3153 | 515 let g:netrw_sort_sequence= '[\/]$,\<core\%(\.\d\+\)\=\>,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$' |
1621 | 516 else |
2034 | 517 let g:netrw_sort_sequence= '[\/]$,\.h$,\.c$,\.cpp$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$' |
1621 | 518 endif |
519 endif | |
2034 | 520 call s:NetrwInit("g:netrw_special_syntax" , 0) |
521 call s:NetrwInit("g:netrw_ssh_browse_reject", '^total\s\+\d\+$') | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
522 call s:NetrwInit("g:netrw_suppress_gx_mesg", 1) |
5734 | 523 call s:NetrwInit("g:netrw_use_noswf" , 1) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
524 call s:NetrwInit("g:netrw_sizestyle" ,"b") |
650 | 525 " Default values - t-w ---------- {{{3 |
2034 | 526 call s:NetrwInit("g:netrw_timefmt","%c") |
4339 | 527 if !exists("g:netrw_xstrlen") |
528 if exists("g:Align_xstrlen") | |
529 let g:netrw_xstrlen= g:Align_xstrlen | |
530 elseif exists("g:drawit_xstrlen") | |
531 let g:netrw_xstrlen= g:drawit_xstrlen | |
532 elseif &enc == "latin1" || !has("multi_byte") | |
533 let g:netrw_xstrlen= 0 | |
534 else | |
535 let g:netrw_xstrlen= 1 | |
536 endif | |
537 endif | |
2034 | 538 call s:NetrwInit("g:NetrwTopLvlMenu","Netrw.") |
539 call s:NetrwInit("g:netrw_win95ftp",1) | |
2908 | 540 call s:NetrwInit("g:netrw_winsize",50) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
541 call s:NetrwInit("g:netrw_wiw",1) |
3456 | 542 if g:netrw_winsize > 100|let g:netrw_winsize= 100|endif |
559 | 543 " --------------------------------------------------------------------- |
650 | 544 " Default values for netrw's script variables: {{{2 |
2034 | 545 call s:NetrwInit("g:netrw_fname_escape",' ?&;%') |
2152 | 546 if has("win32") || has("win95") || has("win64") || has("win16") |
4339 | 547 call s:NetrwInit("g:netrw_glob_escape",'*?`{[]$') |
2152 | 548 else |
4339 | 549 call s:NetrwInit("g:netrw_glob_escape",'*[]?`{~$\') |
2152 | 550 endif |
4339 | 551 call s:NetrwInit("g:netrw_menu_escape",'.&? \') |
2034 | 552 call s:NetrwInit("g:netrw_tmpfile_escape",' &;') |
553 call s:NetrwInit("s:netrw_map_escape","<|\n\r\\\<C-V>\"") | |
5734 | 554 if has("gui_running") && (&enc == 'utf-8' || &enc == 'utf-16' || &enc == 'ucs-4') |
5618 | 555 let s:treedepthstring= "│ " |
556 else | |
557 let s:treedepthstring= "| " | |
558 endif | |
17433 | 559 call s:NetrwInit("s:netrw_posn",'{}') |
482 | 560 |
561 " BufEnter event ignored by decho when following variable is true | |
562 " Has a side effect that doau BufReadPost doesn't work, so | |
563 " files read by network transfer aren't appropriately highlighted. | |
564 "let g:decho_bufenter = 1 "Decho | |
565 | |
2751 | 566 " ====================== |
567 " Netrw Initialization: {{{1 | |
568 " ====================== | |
3153 | 569 if v:version >= 700 && has("balloon_eval") && !exists("s:initbeval") && !exists("g:netrw_nobeval") && has("syntax") && exists("g:syntax_on") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
570 " call Decho("installed beval events",'~'.expand("<slnum>")) |
5734 | 571 let &l:bexpr = "netrw#BalloonHelp()" |
572 au FileType netrw setl beval | |
5618 | 573 au WinLeave * if &ft == "netrw" && exists("s:initbeval")|let &beval= s:initbeval|endif |
574 au VimEnter * let s:initbeval= &beval | |
575 "else " Decho | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
576 " if v:version < 700 | call Decho("did not install beval events: v:version=".v:version." < 700","~".expand("<slnum>")) | endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
577 " if !has("balloon_eval") | call Decho("did not install beval events: does not have balloon_eval","~".expand("<slnum>")) | endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
578 " if exists("s:initbeval") | call Decho("did not install beval events: s:initbeval exists","~".expand("<slnum>")) | endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
579 " if exists("g:netrw_nobeval") | call Decho("did not install beval events: g:netrw_nobeval exists","~".expand("<slnum>")) | endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
580 " if !has("syntax") | call Decho("did not install beval events: does not have syntax highlighting","~".expand("<slnum>")) | endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
581 " if exists("g:syntax_on") | call Decho("did not install beval events: g:syntax_on exists","~".expand("<slnum>")) | endif |
2751 | 582 endif |
3456 | 583 au WinEnter * if &ft == "netrw"|call s:NetrwInsureWinVars()|endif |
2751 | 584 |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
585 if g:netrw_keepj =~# "keepj" |
6476 | 586 com! -nargs=* NetrwKeepj keepj <args> |
587 else | |
588 let g:netrw_keepj= "" | |
589 com! -nargs=* NetrwKeepj <args> | |
590 endif | |
591 | |
650 | 592 " ============================== |
593 " Netrw Utility Functions: {{{1 | |
594 " ============================== | |
595 | |
2751 | 596 " --------------------------------------------------------------------- |
5734 | 597 " netrw#BalloonHelp: {{{2 |
5618 | 598 if v:version >= 700 && has("balloon_eval") && has("syntax") && exists("g:syntax_on") && !exists("g:netrw_nobeval") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
599 " call Decho("loading netrw#BalloonHelp()",'~'.expand("<slnum>")) |
5734 | 600 fun! netrw#BalloonHelp() |
5618 | 601 if &ft != "netrw" |
602 return "" | |
603 endif | |
604 if !exists("w:netrw_bannercnt") || v:beval_lnum >= w:netrw_bannercnt || (exists("g:netrw_nobeval") && g:netrw_nobeval) | |
605 let mesg= "" | |
606 elseif v:beval_text == "Netrw" || v:beval_text == "Directory" || v:beval_text == "Listing" | |
607 let mesg = "i: thin-long-wide-tree gh: quick hide/unhide of dot-files qf: quick file info %:open new file" | |
608 elseif getline(v:beval_lnum) =~ '^"\s*/' | |
609 let mesg = "<cr>: edit/enter o: edit/enter in horiz window t: edit/enter in new tab v:edit/enter in vert window" | |
610 elseif v:beval_text == "Sorted" || v:beval_text == "by" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
611 let mesg = 's: sort by name, time, file size, extension r: reverse sorting order mt: mark target' |
5618 | 612 elseif v:beval_text == "Sort" || v:beval_text == "sequence" |
613 let mesg = "S: edit sorting sequence" | |
614 elseif v:beval_text == "Hiding" || v:beval_text == "Showing" | |
615 let mesg = "a: hiding-showing-all ctrl-h: editing hiding list mh: hide/show by suffix" | |
616 elseif v:beval_text == "Quick" || v:beval_text == "Help" | |
617 let mesg = "Help: press <F1>" | |
618 elseif v:beval_text == "Copy/Move" || v:beval_text == "Tgt" | |
619 let mesg = "mt: mark target mc: copy marked file to target mm: move marked file to target" | |
620 else | |
621 let mesg= "" | |
622 endif | |
623 return mesg | |
624 endfun | |
625 "else " Decho | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
626 " if v:version < 700 |call Decho("did not load netrw#BalloonHelp(): vim version ".v:version." < 700 -","~".expand("<slnum>"))|endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
627 " if !has("balloon_eval") |call Decho("did not load netrw#BalloonHelp(): does not have balloon eval","~".expand("<slnum>")) |endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
628 " if !has("syntax") |call Decho("did not load netrw#BalloonHelp(): syntax disabled","~".expand("<slnum>")) |endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
629 " if !exists("g:syntax_on") |call Decho("did not load netrw#BalloonHelp(): g:syntax_on n/a","~".expand("<slnum>")) |endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
630 " if exists("g:netrw_nobeval") |call Decho("did not load netrw#BalloonHelp(): g:netrw_nobeval exists","~".expand("<slnum>")) |endif |
2751 | 631 endif |
632 | |
482 | 633 " ------------------------------------------------------------------------ |
4339 | 634 " netrw#Explore: launch the local browser in the directory of the current file {{{2 |
635 " indx: == -1: Nexplore | |
636 " == -2: Pexplore | |
637 " == +: this is overloaded: | |
638 " * If Nexplore/Pexplore is in use, then this refers to the | |
639 " indx'th item in the w:netrw_explore_list[] of items which | |
640 " matched the */pattern **/pattern *//pattern **//pattern | |
641 " * If Hexplore or Vexplore, then this will override | |
642 " g:netrw_winsize to specify the qty of rows or columns the | |
643 " newly split window should have. | |
5618 | 644 " dosplit==0: the window will be split iff the current file has been modified and hidden not set |
4339 | 645 " dosplit==1: the window will be split before running the local browser |
646 " style == 0: Explore style == 1: Explore! | |
647 " == 2: Hexplore style == 3: Hexplore! | |
648 " == 4: Vexplore style == 5: Vexplore! | |
649 " == 6: Texplore | |
650 fun! netrw#Explore(indx,dosplit,style,...) | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
651 " call Dfunc("netrw#Explore(indx=".a:indx." dosplit=".a:dosplit." style=".a:style.",a:1<".a:1.">) &modified=".&modified." modifiable=".&modifiable." a:0=".a:0." win#".winnr()." buf#".bufnr("%")." ft=".&ft) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
652 " call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>")) |
4339 | 653 if !exists("b:netrw_curdir") |
654 let b:netrw_curdir= getcwd() | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
655 " call Decho("set b:netrw_curdir<".b:netrw_curdir."> (used getcwd)",'~'.expand("<slnum>")) |
5734 | 656 endif |
657 | |
658 " record current file for Rexplore's benefit | |
659 if &ft != "netrw" | |
660 let w:netrw_rexfile= expand("%:p") | |
661 endif | |
662 | |
663 " record current directory | |
4339 | 664 let curdir = simplify(b:netrw_curdir) |
665 let curfiledir = substitute(expand("%:p"),'^\(.*[/\\]\)[^/\\]*$','\1','e') | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
666 if !exists("g:netrw_cygwin") && (has("win32") || has("win95") || has("win64") || has("win16")) |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
667 let curdir= substitute(curdir,'\','/','g') |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
668 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
669 " call Decho("curdir<".curdir."> curfiledir<".curfiledir.">",'~'.expand("<slnum>")) |
5734 | 670 |
671 " using completion, directories with spaces in their names (thanks, Bill Gates, for a truly dumb idea) | |
672 " will end up with backslashes here. Solution: strip off backslashes that precede white space and | |
673 " try Explore again. | |
674 if a:0 > 0 | |
675 " call Decho('considering retry: a:1<'.a:1.'>: '. | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
676 \ ((a:1 =~ "\\\s")? 'has backslash whitespace' : 'does not have backslash whitespace').', '. |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
677 \ ((filereadable(s:NetrwFile(a:1)))? 'is readable' : 'is not readable').', '. |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
678 \ ((isdirectory(s:NetrwFile(a:1))))? 'is a directory' : 'is not a directory', |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
679 \ '~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
680 if a:1 =~ "\\\s" && !filereadable(s:NetrwFile(a:1)) && !isdirectory(s:NetrwFile(a:1)) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
681 " call Decho("re-trying Explore with <".substitute(a:1,'\\\(\s\)','\1','g').">",'~'.expand("<slnum>")) |
5734 | 682 call netrw#Explore(a:indx,a:dosplit,a:style,substitute(a:1,'\\\(\s\)','\1','g')) |
683 " call Dret("netrw#Explore : returning from retry") | |
684 return | |
685 " else " Decho | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
686 " call Decho("retry not needed",'~'.expand("<slnum>")) |
5734 | 687 endif |
688 endif | |
4339 | 689 |
690 " save registers | |
5734 | 691 if has("clipboard") |
692 sil! let keepregstar = @* | |
693 sil! let keepregplus = @+ | |
694 endif | |
4339 | 695 sil! let keepregslash= @/ |
696 | |
5618 | 697 " if dosplit |
698 " -or- file has been modified AND file not hidden when abandoned | |
699 " -or- Texplore used | |
700 if a:dosplit || (&modified && &hidden == 0 && &bufhidden != "hide") || a:style == 6 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
701 " call Decho("case dosplit=".a:dosplit." modified=".&modified." a:style=".a:style.": dosplit or file has been modified",'~'.expand("<slnum>")) |
4339 | 702 call s:SaveWinVars() |
703 let winsz= g:netrw_winsize | |
704 if a:indx > 0 | |
705 let winsz= a:indx | |
706 endif | |
707 | |
708 if a:style == 0 " Explore, Sexplore | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
709 " call Decho("style=0: Explore or Sexplore",'~'.expand("<slnum>")) |
4339 | 710 let winsz= (winsz > 0)? (winsz*winheight(0))/100 : -winsz |
5929 | 711 if winsz == 0|let winsz= ""|endif |
712 exe "noswapfile ".winsz."wincmd s" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
713 " call Decho("exe noswapfile ".winsz."wincmd s",'~'.expand("<slnum>")) |
4339 | 714 |
715 elseif a:style == 1 "Explore!, Sexplore! | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
716 " call Decho("style=1: Explore! or Sexplore!",'~'.expand("<slnum>")) |
4339 | 717 let winsz= (winsz > 0)? (winsz*winwidth(0))/100 : -winsz |
5929 | 718 if winsz == 0|let winsz= ""|endif |
719 exe "keepalt noswapfile ".winsz."wincmd v" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
720 " call Decho("exe keepalt noswapfile ".winsz."wincmd v",'~'.expand("<slnum>")) |
4339 | 721 |
722 elseif a:style == 2 " Hexplore | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
723 " call Decho("style=2: Hexplore",'~'.expand("<slnum>")) |
4339 | 724 let winsz= (winsz > 0)? (winsz*winheight(0))/100 : -winsz |
5929 | 725 if winsz == 0|let winsz= ""|endif |
726 exe "keepalt noswapfile bel ".winsz."wincmd s" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
727 " call Decho("exe keepalt noswapfile bel ".winsz."wincmd s",'~'.expand("<slnum>")) |
4339 | 728 |
729 elseif a:style == 3 " Hexplore! | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
730 " call Decho("style=3: Hexplore!",'~'.expand("<slnum>")) |
4339 | 731 let winsz= (winsz > 0)? (winsz*winheight(0))/100 : -winsz |
5929 | 732 if winsz == 0|let winsz= ""|endif |
733 exe "keepalt noswapfile abo ".winsz."wincmd s" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
734 " call Decho("exe keepalt noswapfile abo ".winsz."wincmd s",'~'.expand("<slnum>")) |
4339 | 735 |
736 elseif a:style == 4 " Vexplore | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
737 " call Decho("style=4: Vexplore",'~'.expand("<slnum>")) |
4339 | 738 let winsz= (winsz > 0)? (winsz*winwidth(0))/100 : -winsz |
5929 | 739 if winsz == 0|let winsz= ""|endif |
740 exe "keepalt noswapfile lefta ".winsz."wincmd v" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
741 " call Decho("exe keepalt noswapfile lefta ".winsz."wincmd v",'~'.expand("<slnum>")) |
4339 | 742 |
743 elseif a:style == 5 " Vexplore! | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
744 " call Decho("style=5: Vexplore!",'~'.expand("<slnum>")) |
4339 | 745 let winsz= (winsz > 0)? (winsz*winwidth(0))/100 : -winsz |
5929 | 746 if winsz == 0|let winsz= ""|endif |
747 exe "keepalt noswapfile rightb ".winsz."wincmd v" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
748 " call Decho("exe keepalt noswapfile rightb ".winsz."wincmd v",'~'.expand("<slnum>")) |
4339 | 749 |
750 elseif a:style == 6 " Texplore | |
751 call s:SaveBufVars() | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
752 " call Decho("style = 6: Texplore",'~'.expand("<slnum>")) |
4339 | 753 exe "keepalt tabnew ".fnameescape(curdir) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
754 " call Decho("exe keepalt tabnew ".fnameescape(curdir),'~'.expand("<slnum>")) |
4339 | 755 call s:RestoreBufVars() |
756 endif | |
757 call s:RestoreWinVars() | |
758 " else " Decho | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
759 " call Decho("case a:dosplit=".a:dosplit." AND modified=".&modified." AND a:style=".a:style." is not 6",'~'.expand("<slnum>")) |
4339 | 760 endif |
6476 | 761 NetrwKeepj norm! 0 |
4339 | 762 |
763 if a:0 > 0 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
764 " call Decho("case [a:0=".a:0."] > 0: a:1<".a:1.">",'~'.expand("<slnum>")) |
4339 | 765 if a:1 =~ '^\~' && (has("unix") || (exists("g:netrw_cygwin") && g:netrw_cygwin)) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
766 " call Decho("..case a:1<".a:1.">: starts with ~ and unix or cygwin",'~'.expand("<slnum>")) |
4339 | 767 let dirname= simplify(substitute(a:1,'\~',expand("$HOME"),'')) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
768 " call Decho("..using dirname<".dirname."> (case: ~ && unix||cygwin)",'~'.expand("<slnum>")) |
4339 | 769 elseif a:1 == '.' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
770 " call Decho("..case a:1<".a:1.">: matches .",'~'.expand("<slnum>")) |
4339 | 771 let dirname= simplify(exists("b:netrw_curdir")? b:netrw_curdir : getcwd()) |
772 if dirname !~ '/$' | |
773 let dirname= dirname."/" | |
774 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
775 " call Decho("..using dirname<".dirname."> (case: ".(exists("b:netrw_curdir")? "b:netrw_curdir" : "getcwd()").")",'~'.expand("<slnum>")) |
4339 | 776 elseif a:1 =~ '\$' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
777 " call Decho("..case a:1<".a:1.">: matches ending $",'~'.expand("<slnum>")) |
4339 | 778 let dirname= simplify(expand(a:1)) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
779 " call Decho("..using user-specified dirname<".dirname."> with $env-var",'~'.expand("<slnum>")) |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
780 elseif a:1 !~ '^\*\{1,2}/' && a:1 !~ '^\a\{3,}://' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
781 " call Decho("..case a:1<".a:1.">: other, not pattern or filepattern",'~'.expand("<slnum>")) |
4339 | 782 let dirname= simplify(a:1) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
783 " call Decho("..using user-specified dirname<".dirname.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
784 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
785 " call Decho("..case a:1: pattern or filepattern",'~'.expand("<slnum>")) |
4339 | 786 let dirname= a:1 |
787 endif | |
788 else | |
789 " clear explore | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
790 " call Decho("case a:0=".a:0.": clearing Explore list",'~'.expand("<slnum>")) |
4339 | 791 call s:NetrwClearExplore() |
792 " call Dret("netrw#Explore : cleared list") | |
793 return | |
794 endif | |
795 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
796 " call Decho("dirname<".dirname.">",'~'.expand("<slnum>")) |
4339 | 797 if dirname =~ '\.\./\=$' |
798 let dirname= simplify(fnamemodify(dirname,':p:h')) | |
799 elseif dirname =~ '\.\.' || dirname == '.' | |
800 let dirname= simplify(fnamemodify(dirname,':p')) | |
801 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
802 " call Decho("dirname<".dirname."> (after simplify)",'~'.expand("<slnum>")) |
4339 | 803 |
804 if dirname =~ '^\*//' | |
805 " starpat=1: Explore *//pattern (current directory only search for files containing pattern) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
806 " call Decho("case starpat=1: Explore *//pattern",'~'.expand("<slnum>")) |
4339 | 807 let pattern= substitute(dirname,'^\*//\(.*\)$','\1','') |
808 let starpat= 1 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
809 " call Decho("..Explore *//pat: (starpat=".starpat.") dirname<".dirname."> -> pattern<".pattern.">",'~'.expand("<slnum>")) |
4339 | 810 if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif |
811 | |
812 elseif dirname =~ '^\*\*//' | |
813 " starpat=2: Explore **//pattern (recursive descent search for files containing pattern) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
814 " call Decho("case starpat=2: Explore **//pattern",'~'.expand("<slnum>")) |
4339 | 815 let pattern= substitute(dirname,'^\*\*//','','') |
816 let starpat= 2 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
817 " call Decho("..Explore **//pat: (starpat=".starpat.") dirname<".dirname."> -> pattern<".pattern.">",'~'.expand("<slnum>")) |
4339 | 818 |
819 elseif dirname =~ '/\*\*/' | |
820 " handle .../**/.../filepat | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
821 " call Decho("case starpat=4: Explore .../**/.../filepat",'~'.expand("<slnum>")) |
4339 | 822 let prefixdir= substitute(dirname,'^\(.\{-}\)\*\*.*$','\1','') |
823 if prefixdir =~ '^/' || (prefixdir =~ '^\a:/' && (has("win32") || has("win95") || has("win64") || has("win16"))) | |
824 let b:netrw_curdir = prefixdir | |
825 else | |
826 let b:netrw_curdir= getcwd().'/'.prefixdir | |
827 endif | |
828 let dirname= substitute(dirname,'^.\{-}\(\*\*/.*\)$','\1','') | |
829 let starpat= 4 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
830 " call Decho("..pwd<".getcwd()."> dirname<".dirname.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
831 " call Decho("..case Explore ../**/../filepat (starpat=".starpat.")",'~'.expand("<slnum>")) |
4339 | 832 |
833 elseif dirname =~ '^\*/' | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
834 " case starpat=3: Explore */filepat (search in current directory for filenames matching filepat) |
4339 | 835 let starpat= 3 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
836 " call Decho("case starpat=3: Explore */filepat (starpat=".starpat.")",'~'.expand("<slnum>")) |
4339 | 837 |
838 elseif dirname=~ '^\*\*/' | |
839 " starpat=4: Explore **/filepat (recursive descent search for filenames matching filepat) | |
840 let starpat= 4 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
841 " call Decho("case starpat=4: Explore **/filepat (starpat=".starpat.")",'~'.expand("<slnum>")) |
4339 | 842 |
843 else | |
844 let starpat= 0 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
845 " call Decho("case starpat=0: default",'~'.expand("<slnum>")) |
4339 | 846 endif |
847 | |
848 if starpat == 0 && a:indx >= 0 | |
849 " [Explore Hexplore Vexplore Sexplore] [dirname] | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
850 " call Decho("case starpat==0 && a:indx=".a:indx.": dirname<".dirname.">, handles Explore Hexplore Vexplore Sexplore",'~'.expand("<slnum>")) |
4339 | 851 if dirname == "" |
852 let dirname= curfiledir | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
853 " call Decho("..empty dirname, using current file's directory<".dirname.">",'~'.expand("<slnum>")) |
4339 | 854 endif |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
855 if dirname =~# '^scp://' || dirname =~ '^ftp://' |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
856 call netrw#Nread(2,dirname) |
4339 | 857 else |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
858 if dirname == "" |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
859 let dirname= getcwd() |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
860 elseif (has("win32") || has("win95") || has("win64") || has("win16")) && !g:netrw_cygwin |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
861 " Windows : check for a drive specifier, or else for a remote share name ('\\Foo' or '//Foo', |
5734 | 862 " depending on whether backslashes have been converted to forward slashes by earlier code). |
863 if dirname !~ '^[a-zA-Z]:' && dirname !~ '^\\\\\w\+' && dirname !~ '^//\w\+' | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
864 let dirname= b:netrw_curdir."/".dirname |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
865 endif |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
866 elseif dirname !~ '^/' |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
867 let dirname= b:netrw_curdir."/".dirname |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
868 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
869 " call Decho("..calling LocalBrowseCheck(dirname<".dirname.">)",'~'.expand("<slnum>")) |
4339 | 870 call netrw#LocalBrowseCheck(dirname) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
871 " call Decho(" modified=".&modified." modifiable=".&modifiable." readonly=".&readonly,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
872 " call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>")) |
4339 | 873 endif |
874 if exists("w:netrw_bannercnt") | |
875 " done to handle P08-Ingelrest. :Explore will _Always_ go to the line just after the banner. | |
876 " If one wants to return the same place in the netrw window, use :Rex instead. | |
877 exe w:netrw_bannercnt | |
878 endif | |
879 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
880 " call Decho("curdir<".curdir.">",'~'.expand("<slnum>")) |
4339 | 881 " --------------------------------------------------------------------- |
882 " Jan 24, 2013: not sure why the following was present. See P08-Ingelrest | |
883 " if has("win32") || has("win95") || has("win64") || has("win16") | |
6476 | 884 " NetrwKeepj call search('\<'.substitute(curdir,'^.*[/\\]','','e').'\>','cW') |
4339 | 885 " else |
6476 | 886 " NetrwKeepj call search('\<'.substitute(curdir,'^.*/','','e').'\>','cW') |
4339 | 887 " endif |
888 " --------------------------------------------------------------------- | |
889 | |
890 " starpat=1: Explore *//pattern (current directory only search for files containing pattern) | |
891 " starpat=2: Explore **//pattern (recursive descent search for files containing pattern) | |
892 " starpat=3: Explore */filepat (search in current directory for filenames matching filepat) | |
893 " starpat=4: Explore **/filepat (recursive descent search for filenames matching filepat) | |
894 elseif a:indx <= 0 | |
895 " Nexplore, Pexplore, Explore: handle starpat | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
896 " call Decho("case a:indx<=0: Nexplore, Pexplore, <s-down>, <s-up> starpat=".starpat." a:indx=".a:indx,'~'.expand("<slnum>")) |
4339 | 897 if !mapcheck("<s-up>","n") && !mapcheck("<s-down>","n") && exists("b:netrw_curdir") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
898 " call Decho("..set up <s-up> and <s-down> maps",'~'.expand("<slnum>")) |
4339 | 899 let s:didstarstar= 1 |
900 nnoremap <buffer> <silent> <s-up> :Pexplore<cr> | |
901 nnoremap <buffer> <silent> <s-down> :Nexplore<cr> | |
902 endif | |
903 | |
904 if has("path_extra") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
905 " call Decho("..starpat=".starpat.": has +path_extra",'~'.expand("<slnum>")) |
4339 | 906 if !exists("w:netrw_explore_indx") |
907 let w:netrw_explore_indx= 0 | |
908 endif | |
909 | |
910 let indx = a:indx | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
911 " call Decho("..starpat=".starpat.": set indx= [a:indx=".indx."]",'~'.expand("<slnum>")) |
4339 | 912 |
913 if indx == -1 | |
914 " Nexplore | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
915 " call Decho("..case Nexplore with starpat=".starpat.": (indx=".indx.")",'~'.expand("<slnum>")) |
4339 | 916 if !exists("w:netrw_explore_list") " sanity check |
6476 | 917 NetrwKeepj call netrw#ErrorMsg(s:WARNING,"using Nexplore or <s-down> improperly; see help for netrw-starstar",40) |
5734 | 918 if has("clipboard") |
919 sil! let @* = keepregstar | |
17433 | 920 sil! let @+ = keepregplus |
5734 | 921 endif |
4339 | 922 sil! let @/ = keepregslash |
923 " call Dret("netrw#Explore") | |
924 return | |
925 endif | |
926 let indx= w:netrw_explore_indx | |
927 if indx < 0 | let indx= 0 | endif | |
928 if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif | |
929 let curfile= w:netrw_explore_list[indx] | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
930 " call Decho("....indx=".indx." curfile<".curfile.">",'~'.expand("<slnum>")) |
4339 | 931 while indx < w:netrw_explore_listlen && curfile == w:netrw_explore_list[indx] |
932 let indx= indx + 1 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
933 " call Decho("....indx=".indx." (Nexplore while loop)",'~'.expand("<slnum>")) |
4339 | 934 endwhile |
935 if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
936 " call Decho("....Nexplore: indx= [w:netrw_explore_indx=".w:netrw_explore_indx."]=".indx,'~'.expand("<slnum>")) |
4339 | 937 |
938 elseif indx == -2 | |
939 " Pexplore | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
940 " call Decho("case Pexplore with starpat=".starpat.": (indx=".indx.")",'~'.expand("<slnum>")) |
4339 | 941 if !exists("w:netrw_explore_list") " sanity check |
6476 | 942 NetrwKeepj call netrw#ErrorMsg(s:WARNING,"using Pexplore or <s-up> improperly; see help for netrw-starstar",41) |
5734 | 943 if has("clipboard") |
944 sil! let @* = keepregstar | |
17433 | 945 sil! let @+ = keepregplus |
5734 | 946 endif |
4339 | 947 sil! let @/ = keepregslash |
948 " call Dret("netrw#Explore") | |
949 return | |
950 endif | |
951 let indx= w:netrw_explore_indx | |
952 if indx < 0 | let indx= 0 | endif | |
953 if indx >= w:netrw_explore_listlen | let indx= w:netrw_explore_listlen - 1 | endif | |
954 let curfile= w:netrw_explore_list[indx] | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
955 " call Decho("....indx=".indx." curfile<".curfile.">",'~'.expand("<slnum>")) |
4339 | 956 while indx >= 0 && curfile == w:netrw_explore_list[indx] |
957 let indx= indx - 1 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
958 " call Decho("....indx=".indx." (Pexplore while loop)",'~'.expand("<slnum>")) |
4339 | 959 endwhile |
960 if indx < 0 | let indx= 0 | endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
961 " call Decho("....Pexplore: indx= [w:netrw_explore_indx=".w:netrw_explore_indx."]=".indx,'~'.expand("<slnum>")) |
4339 | 962 |
963 else | |
964 " Explore -- initialize | |
965 " build list of files to Explore with Nexplore/Pexplore | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
966 " call Decho("..starpat=".starpat.": case Explore: initialize (indx=".indx.")",'~'.expand("<slnum>")) |
6476 | 967 NetrwKeepj keepalt call s:NetrwClearExplore() |
4339 | 968 let w:netrw_explore_indx= 0 |
969 if !exists("b:netrw_curdir") | |
970 let b:netrw_curdir= getcwd() | |
971 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
972 " call Decho("....starpat=".starpat.": b:netrw_curdir<".b:netrw_curdir.">",'~'.expand("<slnum>")) |
4339 | 973 |
974 " switch on starpat to build the w:netrw_explore_list of files | |
975 if starpat == 1 | |
976 " starpat=1: Explore *//pattern (current directory only search for files containing pattern) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
977 " call Decho("..case starpat=".starpat.": build *//pattern list (curdir-only srch for files containing pattern) &hls=".&hls,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
978 " call Decho("....pattern<".pattern.">",'~'.expand("<slnum>")) |
4339 | 979 try |
6476 | 980 exe "NetrwKeepj noautocmd vimgrep /".pattern."/gj ".fnameescape(b:netrw_curdir)."/*" |
4339 | 981 catch /^Vim\%((\a\+)\)\=:E480/ |
982 keepalt call netrw#ErrorMsg(s:WARNING,"no match with pattern<".pattern.">",76) | |
983 " call Dret("netrw#Explore : unable to find pattern<".pattern.">") | |
984 return | |
985 endtry | |
986 let w:netrw_explore_list = s:NetrwExploreListUniq(map(getqflist(),'bufname(v:val.bufnr)')) | |
987 if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif | |
988 | |
989 elseif starpat == 2 | |
990 " starpat=2: Explore **//pattern (recursive descent search for files containing pattern) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
991 " call Decho("..case starpat=".starpat.": build **//pattern list (recursive descent files containing pattern)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
992 " call Decho("....pattern<".pattern.">",'~'.expand("<slnum>")) |
4339 | 993 try |
6476 | 994 exe "sil NetrwKeepj noautocmd keepalt vimgrep /".pattern."/gj "."**/*" |
4339 | 995 catch /^Vim\%((\a\+)\)\=:E480/ |
996 keepalt call netrw#ErrorMsg(s:WARNING,'no files matched pattern<'.pattern.'>',45) | |
997 if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif | |
5734 | 998 if has("clipboard") |
17433 | 999 sil! let @* = keepregstar |
1000 sil! let @+ = keepregplus | |
5734 | 1001 endif |
4339 | 1002 sil! let @/ = keepregslash |
1003 " call Dret("netrw#Explore : no files matched pattern") | |
1004 return | |
1005 endtry | |
1006 let s:netrw_curdir = b:netrw_curdir | |
1007 let w:netrw_explore_list = getqflist() | |
1008 let w:netrw_explore_list = s:NetrwExploreListUniq(map(w:netrw_explore_list,'s:netrw_curdir."/".bufname(v:val.bufnr)')) | |
1009 if &hls | let keepregslash= s:ExplorePatHls(pattern) | endif | |
1010 | |
1011 elseif starpat == 3 | |
1012 " starpat=3: Explore */filepat (search in current directory for filenames matching filepat) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1013 " call Decho("..case starpat=".starpat.": build */filepat list (curdir-only srch filenames matching filepat) &hls=".&hls,'~'.expand("<slnum>")) |
4339 | 1014 let filepat= substitute(dirname,'^\*/','','') |
1015 let filepat= substitute(filepat,'^[%#<]','\\&','') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1016 " call Decho("....b:netrw_curdir<".b:netrw_curdir.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1017 " call Decho("....filepat<".filepat.">",'~'.expand("<slnum>")) |
4339 | 1018 let w:netrw_explore_list= s:NetrwExploreListUniq(split(expand(b:netrw_curdir."/".filepat),'\n')) |
1019 if &hls | let keepregslash= s:ExplorePatHls(filepat) | endif | |
1020 | |
1021 elseif starpat == 4 | |
1022 " starpat=4: Explore **/filepat (recursive descent search for filenames matching filepat) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1023 " call Decho("..case starpat=".starpat.": build **/filepat list (recursive descent srch filenames matching filepat) &hls=".&hls,'~'.expand("<slnum>")) |
4339 | 1024 let w:netrw_explore_list= s:NetrwExploreListUniq(split(expand(b:netrw_curdir."/".dirname),'\n')) |
1025 if &hls | let keepregslash= s:ExplorePatHls(dirname) | endif | |
1026 endif " switch on starpat to build w:netrw_explore_list | |
1027 | |
1028 let w:netrw_explore_listlen = len(w:netrw_explore_list) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1029 " call Decho("....w:netrw_explore_list<".string(w:netrw_explore_list).">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1030 " call Decho("....w:netrw_explore_listlen=".w:netrw_explore_listlen,'~'.expand("<slnum>")) |
4339 | 1031 |
1032 if w:netrw_explore_listlen == 0 || (w:netrw_explore_listlen == 1 && w:netrw_explore_list[0] =~ '\*\*\/') | |
6476 | 1033 keepalt NetrwKeepj call netrw#ErrorMsg(s:WARNING,"no files matched",42) |
5734 | 1034 if has("clipboard") |
1035 sil! let @* = keepregstar | |
17433 | 1036 sil! let @+ = keepregplus |
5734 | 1037 endif |
4339 | 1038 sil! let @/ = keepregslash |
1039 " call Dret("netrw#Explore : no files matched") | |
1040 return | |
1041 endif | |
1042 endif " if indx ... endif | |
1043 | |
1044 " NetrwStatusLine support - for exploring support | |
1045 let w:netrw_explore_indx= indx | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1046 " call Decho("....w:netrw_explore_list<".join(w:netrw_explore_list,',')."> len=".w:netrw_explore_listlen,'~'.expand("<slnum>")) |
4339 | 1047 |
1048 " wrap the indx around, but issue a note | |
1049 if indx >= w:netrw_explore_listlen || indx < 0 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1050 " call Decho("....wrap indx (indx=".indx." listlen=".w:netrw_explore_listlen.")",'~'.expand("<slnum>")) |
4339 | 1051 let indx = (indx < 0)? ( w:netrw_explore_listlen - 1 ) : 0 |
1052 let w:netrw_explore_indx= indx | |
6476 | 1053 keepalt NetrwKeepj call netrw#ErrorMsg(s:NOTE,"no more files match Explore pattern",43) |
4339 | 1054 endif |
1055 | |
1056 exe "let dirfile= w:netrw_explore_list[".indx."]" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1057 " call Decho("....dirfile=w:netrw_explore_list[indx=".indx."]= <".dirfile.">",'~'.expand("<slnum>")) |
4339 | 1058 let newdir= substitute(dirfile,'/[^/]*$','','e') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1059 " call Decho("....newdir<".newdir.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1060 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1061 " call Decho("....calling LocalBrowseCheck(newdir<".newdir.">)",'~'.expand("<slnum>")) |
4339 | 1062 call netrw#LocalBrowseCheck(newdir) |
1063 if !exists("w:netrw_liststyle") | |
1064 let w:netrw_liststyle= g:netrw_liststyle | |
1065 endif | |
1066 if w:netrw_liststyle == s:THINLIST || w:netrw_liststyle == s:LONGLIST | |
6476 | 1067 keepalt NetrwKeepj call search('^'.substitute(dirfile,"^.*/","","").'\>',"W") |
4339 | 1068 else |
6476 | 1069 keepalt NetrwKeepj call search('\<'.substitute(dirfile,"^.*/","","").'\>',"w") |
4339 | 1070 endif |
1071 let w:netrw_explore_mtchcnt = indx + 1 | |
1072 let w:netrw_explore_bufnr = bufnr("%") | |
1073 let w:netrw_explore_line = line(".") | |
6476 | 1074 keepalt NetrwKeepj call s:SetupNetrwStatusLine('%f %h%m%r%=%9*%{NetrwStatusLine()}') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1075 " call Decho("....explore: mtchcnt=".w:netrw_explore_mtchcnt." bufnr=".w:netrw_explore_bufnr." line#".w:netrw_explore_line,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1076 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1077 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1078 " call Decho("..your vim does not have +path_extra",'~'.expand("<slnum>")) |
4339 | 1079 if !exists("g:netrw_quiet") |
6476 | 1080 keepalt NetrwKeepj call netrw#ErrorMsg(s:WARNING,"your vim needs the +path_extra feature for Exploring with **!",44) |
4339 | 1081 endif |
5734 | 1082 if has("clipboard") |
1083 sil! let @* = keepregstar | |
17433 | 1084 sil! let @+ = keepregplus |
5734 | 1085 endif |
4339 | 1086 sil! let @/ = keepregslash |
1087 " call Dret("netrw#Explore : missing +path_extra") | |
1088 return | |
1089 endif | |
1090 | |
1091 else | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1092 " call Decho("..default case: Explore newdir<".dirname.">",'~'.expand("<slnum>")) |
4339 | 1093 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && dirname =~ '/' |
1094 sil! unlet w:netrw_treedict | |
1095 sil! unlet w:netrw_treetop | |
1096 endif | |
1097 let newdir= dirname | |
1098 if !exists("b:netrw_curdir") | |
6476 | 1099 NetrwKeepj call netrw#LocalBrowseCheck(getcwd()) |
1100 else | |
1101 NetrwKeepj call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,newdir)) | |
4339 | 1102 endif |
1103 endif | |
1104 | |
1105 " visual display of **/ **// */ Exploration files | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1106 " call Decho("w:netrw_explore_indx=".(exists("w:netrw_explore_indx")? w:netrw_explore_indx : "doesn't exist"),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1107 " call Decho("b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "n/a").">",'~'.expand("<slnum>")) |
4339 | 1108 if exists("w:netrw_explore_indx") && exists("b:netrw_curdir") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1109 " call Decho("s:explore_prvdir<".(exists("s:explore_prvdir")? s:explore_prvdir : "-doesn't exist-"),'~'.expand("<slnum>")) |
4339 | 1110 if !exists("s:explore_prvdir") || s:explore_prvdir != b:netrw_curdir |
5618 | 1111 " only update match list when current directory isn't the same as before |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1112 " call Decho("only update match list when current directory not the same as before",'~'.expand("<slnum>")) |
4339 | 1113 let s:explore_prvdir = b:netrw_curdir |
1114 let s:explore_match = "" | |
5618 | 1115 let dirlen = strlen(b:netrw_curdir) |
4339 | 1116 if b:netrw_curdir !~ '/$' |
1117 let dirlen= dirlen + 1 | |
1118 endif | |
1119 let prvfname= "" | |
1120 for fname in w:netrw_explore_list | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1121 " call Decho("fname<".fname.">",'~'.expand("<slnum>")) |
4339 | 1122 if fname =~ '^'.b:netrw_curdir |
1123 if s:explore_match == "" | |
1124 let s:explore_match= '\<'.escape(strpart(fname,dirlen),g:netrw_markfileesc).'\>' | |
1125 else | |
1126 let s:explore_match= s:explore_match.'\|\<'.escape(strpart(fname,dirlen),g:netrw_markfileesc).'\>' | |
1127 endif | |
1128 elseif fname !~ '^/' && fname != prvfname | |
1129 if s:explore_match == "" | |
1130 let s:explore_match= '\<'.escape(fname,g:netrw_markfileesc).'\>' | |
1131 else | |
1132 let s:explore_match= s:explore_match.'\|\<'.escape(fname,g:netrw_markfileesc).'\>' | |
1133 endif | |
1134 endif | |
1135 let prvfname= fname | |
1136 endfor | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1137 " call Decho("explore_match<".s:explore_match.">",'~'.expand("<slnum>")) |
17433 | 1138 if has("syntax") && exists("g:syntax_on") && g:syntax_on |
1139 exe "2match netrwMarkFile /".s:explore_match."/" | |
1140 endif | |
4339 | 1141 endif |
1142 echo "<s-up>==Pexplore <s-down>==Nexplore" | |
1143 else | |
1144 2match none | |
1145 if exists("s:explore_match") | unlet s:explore_match | endif | |
1146 if exists("s:explore_prvdir") | unlet s:explore_prvdir | endif | |
1147 echo " " | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1148 " call Decho("cleared explore match list",'~'.expand("<slnum>")) |
5734 | 1149 endif |
1150 | |
1151 " since Explore may be used to initialize netrw's browser, | |
1152 " there's no danger of a late FocusGained event on initialization. | |
1153 " Consequently, set s:netrw_events to 2. | |
1154 let s:netrw_events= 2 | |
1155 if has("clipboard") | |
1156 sil! let @* = keepregstar | |
17433 | 1157 sil! let @+ = keepregplus |
5734 | 1158 endif |
4339 | 1159 sil! let @/ = keepregslash |
1160 " call Dret("netrw#Explore : @/<".@/.">") | |
1161 endfun | |
1162 | |
1163 " --------------------------------------------------------------------- | |
5618 | 1164 " netrw#Lexplore: toggle Explorer window, keeping it on the left of the current tab {{{2 |
6476 | 1165 fun! netrw#Lexplore(count,rightside,...) |
17433 | 1166 " call Dfunc("netrw#Lexplore(count=".a:count." rightside=".a:rightside.",...) a:0=".a:0." ft=".&ft) |
6476 | 1167 let curwin= winnr() |
1168 | |
5734 | 1169 if a:0 > 0 && a:1 != "" |
1170 " if a netrw window is already on the left-side of the tab | |
1171 " and a directory has been specified, explore with that | |
1172 " directory. | |
17433 | 1173 " call Decho("case has input argument(s) (a:1<".a:1.">)") |
6476 | 1174 let a1 = expand(a:1) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1175 " call Decho("a:1<".a:1."> curwin#".curwin,'~'.expand("<slnum>")) |
5734 | 1176 exe "1wincmd w" |
1177 if &ft == "netrw" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1178 " call Decho("exe Explore ".fnameescape(a:1),'~'.expand("<slnum>")) |
6476 | 1179 exe "Explore ".fnameescape(a1) |
1180 exe curwin."wincmd w" | |
1181 if exists("t:netrw_lexposn") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1182 " call Decho("forgetting t:netrw_lexposn",'~'.expand("<slnum>")) |
6476 | 1183 unlet t:netrw_lexposn |
1184 endif | |
1185 " call Dret("netrw#Lexplore") | |
1186 return | |
1187 endif | |
1188 exe curwin."wincmd w" | |
1189 else | |
1190 let a1= "" | |
17433 | 1191 " call Decho("no input arguments") |
5734 | 1192 endif |
1193 | |
5618 | 1194 if exists("t:netrw_lexbufnr") |
6476 | 1195 " check if t:netrw_lexbufnr refers to a netrw window |
5618 | 1196 let lexwinnr = bufwinnr(t:netrw_lexbufnr) |
17433 | 1197 " call Decho("lexwinnr= bufwinnr(t:netrw_lexbufnr#".t:netrw_lexbufnr.")=".lexwinnr) |
6476 | 1198 else |
1199 let lexwinnr= 0 | |
17433 | 1200 " call Decho("t:netrw_lexbufnr doesn't exist") |
1201 endif | |
1202 " call Decho("lexwinnr=".lexwinnr,'~'.expand("<slnum>")) | |
6476 | 1203 |
1204 if lexwinnr > 0 | |
1205 " close down netrw explorer window | |
17433 | 1206 " call Decho("t:netrw_lexbufnr#".t:netrw_lexbufnr.": close down netrw window",'~'.expand("<slnum>")) |
6476 | 1207 exe lexwinnr."wincmd w" |
1208 let g:netrw_winsize = -winwidth(0) | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
1209 let t:netrw_lexposn = winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
1210 " call Decho("saving posn to t:netrw_lexposn<".string(t:netrw_lexposn).">",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1211 " call Decho("saving t:netrw_lexposn",'~'.expand("<slnum>")) |
6476 | 1212 close |
1213 if lexwinnr < curwin | |
1214 let curwin= curwin - 1 | |
1215 endif | |
17433 | 1216 if lexwinnr != curwin |
1217 exe curwin."wincmd w" | |
1218 endif | |
5618 | 1219 unlet t:netrw_lexbufnr |
17433 | 1220 " call Decho("unlet t:netrw_lexbufnr") |
5618 | 1221 |
1222 else | |
1223 " open netrw explorer window | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1224 " call Decho("t:netrw_lexbufnr<n/a>: open netrw explorer window",'~'.expand("<slnum>")) |
5618 | 1225 exe "1wincmd w" |
1226 let keep_altv = g:netrw_altv | |
1227 let g:netrw_altv = 0 | |
6476 | 1228 if a:count != 0 |
1229 let netrw_winsize = g:netrw_winsize | |
1230 let g:netrw_winsize = a:count | |
1231 endif | |
1232 let curfile= expand("%") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1233 " call Decho("curfile<".curfile.">",'~'.expand("<slnum>")) |
6476 | 1234 exe (a:rightside? "botright" : "topleft")." vertical ".((g:netrw_winsize > 0)? (g:netrw_winsize*winwidth(0))/100 : -g:netrw_winsize) . " new" |
17433 | 1235 " call Decho("new buf#".bufnr("%")." win#".winnr()) |
6476 | 1236 if a:0 > 0 && a1 != "" |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1237 " call Decho("case 1: Explore ".a1,'~'.expand("<slnum>")) |
17433 | 1238 call netrw#Explore(0,0,0,a1) |
6476 | 1239 exe "Explore ".fnameescape(a1) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1240 elseif curfile =~ '^\a\{3,}://' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1241 " call Decho("case 2: Explore ".substitute(curfile,'[^/\\]*$','',''),'~'.expand("<slnum>")) |
17433 | 1242 call netrw#Explore(0,0,0,substitute(curfile,'[^/\\]*$','','')) |
6476 | 1243 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1244 " call Decho("case 3: Explore .",'~'.expand("<slnum>")) |
17433 | 1245 call netrw#Explore(0,0,0,".") |
6476 | 1246 endif |
1247 if a:count != 0 | |
1248 let g:netrw_winsize = netrw_winsize | |
1249 endif | |
1250 setlocal winfixwidth | |
5618 | 1251 let g:netrw_altv = keep_altv |
1252 let t:netrw_lexbufnr = bufnr("%") | |
17433 | 1253 " call Decho("let t:netrw_lexbufnr=".t:netrw_lexbufnr) |
1254 " call Decho("t:netrw_lexposn".(exists("t:netrw_lexposn")? string(t:netrw_lexposn) : " n/a")) | |
6476 | 1255 if exists("t:netrw_lexposn") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1256 " call Decho("restoring to t:netrw_lexposn",'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
1257 " call Decho("restoring posn to t:netrw_lexposn<".string(t:netrw_lexposn).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
1258 call winrestview(t:netrw_lexposn) |
6476 | 1259 unlet t:netrw_lexposn |
1260 endif | |
1261 endif | |
1262 | |
1263 " set up default window for editing via <cr> | |
5734 | 1264 if exists("g:netrw_chgwin") && g:netrw_chgwin == -1 |
6476 | 1265 if a:rightside |
1266 let g:netrw_chgwin= 1 | |
1267 else | |
1268 let g:netrw_chgwin= 2 | |
1269 endif | |
17433 | 1270 " call Decho("let g:netrw_chgwin=".g:netrw_chgwin) |
6476 | 1271 endif |
1272 | |
5618 | 1273 " call Dret("netrw#Lexplore") |
1274 endfun | |
1275 | |
1276 " --------------------------------------------------------------------- | |
5734 | 1277 " netrw#Clean: remove netrw {{{2 |
1621 | 1278 " supports :NetrwClean -- remove netrw from first directory on runtimepath |
1279 " :NetrwClean! -- remove netrw from all directories on runtimepath | |
5734 | 1280 fun! netrw#Clean(sys) |
1281 " call Dfunc("netrw#Clean(sys=".a:sys.")") | |
1621 | 1282 |
1283 if a:sys | |
1284 let choice= confirm("Remove personal and system copies of netrw?","&Yes\n&No") | |
1285 else | |
1286 let choice= confirm("Remove personal copy of netrw?","&Yes\n&No") | |
1287 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1288 " call Decho("choice=".choice,'~'.expand("<slnum>")) |
1621 | 1289 let diddel= 0 |
1290 let diddir= "" | |
1291 | |
1292 if choice == 1 | |
1293 for dir in split(&rtp,',') | |
1294 if filereadable(dir."/plugin/netrwPlugin.vim") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1295 " call Decho("removing netrw-related files from ".dir,'~'.expand("<slnum>")) |
1668 | 1296 if s:NetrwDelete(dir."/plugin/netrwPlugin.vim") |call netrw#ErrorMsg(1,"unable to remove ".dir."/plugin/netrwPlugin.vim",55) |endif |
1297 if s:NetrwDelete(dir."/autoload/netrwFileHandlers.vim")|call netrw#ErrorMsg(1,"unable to remove ".dir."/autoload/netrwFileHandlers.vim",55)|endif | |
1298 if s:NetrwDelete(dir."/autoload/netrwSettings.vim") |call netrw#ErrorMsg(1,"unable to remove ".dir."/autoload/netrwSettings.vim",55) |endif | |
1299 if s:NetrwDelete(dir."/autoload/netrw.vim") |call netrw#ErrorMsg(1,"unable to remove ".dir."/autoload/netrw.vim",55) |endif | |
1300 if s:NetrwDelete(dir."/syntax/netrw.vim") |call netrw#ErrorMsg(1,"unable to remove ".dir."/syntax/netrw.vim",55) |endif | |
1301 if s:NetrwDelete(dir."/syntax/netrwlist.vim") |call netrw#ErrorMsg(1,"unable to remove ".dir."/syntax/netrwlist.vim",55) |endif | |
1621 | 1302 let diddir= dir |
1303 let diddel= diddel + 1 | |
1304 if !a:sys|break|endif | |
1305 endif | |
1306 endfor | |
1307 endif | |
1308 | |
1309 echohl WarningMsg | |
1310 if diddel == 0 | |
1311 echomsg "netrw is either not installed or not removable" | |
1312 elseif diddel == 1 | |
1313 echomsg "removed one copy of netrw from <".diddir.">" | |
1314 else | |
1315 echomsg "removed ".diddel." copies of netrw" | |
1316 endif | |
1317 echohl None | |
1318 | |
5734 | 1319 " call Dret("netrw#Clean") |
1320 endfun | |
1321 | |
1322 " --------------------------------------------------------------------- | |
1323 " netrw#MakeTgt: make a target out of the directory name provided {{{2 | |
1324 fun! netrw#MakeTgt(dname) | |
1325 " call Dfunc("netrw#MakeTgt(dname<".a:dname.">)") | |
1326 " simplify the target (eg. /abc/def/../ghi -> /abc/ghi) | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
1327 let svpos = winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
1328 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1329 let s:netrwmftgt_islocal= (a:dname !~ '^\a\{3,}://') |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1330 " call Decho("s:netrwmftgt_islocal=".s:netrwmftgt_islocal,'~'.expand("<slnum>")) |
5734 | 1331 if s:netrwmftgt_islocal |
1332 let netrwmftgt= simplify(a:dname) | |
1333 else | |
1334 let netrwmftgt= a:dname | |
1335 endif | |
1336 if exists("s:netrwmftgt") && netrwmftgt == s:netrwmftgt | |
1337 " re-selected target, so just clear it | |
1338 unlet s:netrwmftgt s:netrwmftgt_islocal | |
1339 else | |
1340 let s:netrwmftgt= netrwmftgt | |
1341 endif | |
1342 if g:netrw_fastbrowse <= 1 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1343 call s:NetrwRefresh((b:netrw_curdir !~ '\a\{3,}://'),b:netrw_curdir) |
5734 | 1344 endif |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
1345 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))" |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
1346 call winrestview(svpos) |
5734 | 1347 " call Dret("netrw#MakeTgt") |
1348 endfun | |
1349 | |
1350 " --------------------------------------------------------------------- | |
1351 " netrw#Obtain: {{{2 | |
1352 " netrw#Obtain(islocal,fname[,tgtdirectory]) | |
4339 | 1353 " islocal=0 obtain from remote source |
1354 " =1 obtain from local source | |
1355 " fname : a filename or a list of filenames | |
1356 " tgtdir : optional place where files are to go (not present, uses getcwd()) | |
5734 | 1357 fun! netrw#Obtain(islocal,fname,...) |
1358 " call Dfunc("netrw#Obtain(islocal=".a:islocal." fname<".((type(a:fname) == 1)? a:fname : string(a:fname)).">) a:0=".a:0) | |
4339 | 1359 " NetrwStatusLine support - for obtaining support |
1360 | |
1361 if type(a:fname) == 1 | |
1362 let fnamelist= [ a:fname ] | |
1363 elseif type(a:fname) == 3 | |
1364 let fnamelist= a:fname | |
1365 else | |
1366 call netrw#ErrorMsg(s:ERROR,"attempting to use NetrwObtain on something not a filename or a list",62) | |
5734 | 1367 " call Dret("netrw#Obtain") |
4339 | 1368 return |
1369 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1370 " call Decho("fnamelist<".string(fnamelist).">",'~'.expand("<slnum>")) |
4339 | 1371 if a:0 > 0 |
1372 let tgtdir= a:1 | |
1373 else | |
1374 let tgtdir= getcwd() | |
1375 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1376 " call Decho("tgtdir<".tgtdir.">",'~'.expand("<slnum>")) |
4339 | 1377 |
1378 if exists("b:netrw_islocal") && b:netrw_islocal | |
1379 " obtain a file from local b:netrw_curdir to (local) tgtdir | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1380 " call Decho("obtain a file from local ".b:netrw_curdir." to ".tgtdir,'~'.expand("<slnum>")) |
4339 | 1381 if exists("b:netrw_curdir") && getcwd() != b:netrw_curdir |
1382 let topath= s:ComposePath(tgtdir,"") | |
1383 if (has("win32") || has("win95") || has("win64") || has("win16")) | |
1384 " transfer files one at time | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1385 " call Decho("transfer files one at a time",'~'.expand("<slnum>")) |
4339 | 1386 for fname in fnamelist |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1387 " call Decho("system(".g:netrw_localcopycmd." ".s:ShellEscape(fname)." ".s:ShellEscape(topath).")",'~'.expand("<slnum>")) |
17433 | 1388 call system(g:netrw_localcopycmd.g:netrw_localcopycmdopt." ".s:ShellEscape(fname)." ".s:ShellEscape(topath)) |
4339 | 1389 if v:shell_error != 0 |
1390 call netrw#ErrorMsg(s:WARNING,"consider setting g:netrw_localcopycmd<".g:netrw_localcopycmd."> to something that works",80) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1391 " call Dret("s:NetrwObtain 0 : failed: ".g:netrw_localcopycmd." ".s:ShellEscape(fname)." ".s:ShellEscape(topath)) |
4339 | 1392 return |
1393 endif | |
1394 endfor | |
1395 else | |
1396 " transfer files with one command | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1397 " call Decho("transfer files with one command",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1398 let filelist= join(map(deepcopy(fnamelist),"s:ShellEscape(v:val)")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1399 " call Decho("system(".g:netrw_localcopycmd." ".filelist." ".s:ShellEscape(topath).")",'~'.expand("<slnum>")) |
17433 | 1400 call system(g:netrw_localcopycmd.g:netrw_localcopycmdopt." ".filelist." ".s:ShellEscape(topath)) |
4339 | 1401 if v:shell_error != 0 |
1402 call netrw#ErrorMsg(s:WARNING,"consider setting g:netrw_localcopycmd<".g:netrw_localcopycmd."> to something that works",80) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1403 " call Dret("s:NetrwObtain 0 : failed: ".g:netrw_localcopycmd." ".filelist." ".s:ShellEscape(topath)) |
4339 | 1404 return |
1405 endif | |
1406 endif | |
1407 elseif !exists("b:netrw_curdir") | |
1408 call netrw#ErrorMsg(s:ERROR,"local browsing directory doesn't exist!",36) | |
1409 else | |
1410 call netrw#ErrorMsg(s:WARNING,"local browsing directory and current directory are identical",37) | |
1411 endif | |
1412 | |
1413 else | |
1414 " obtain files from remote b:netrw_curdir to local tgtdir | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1415 " call Decho("obtain a file from remote ".b:netrw_curdir." to ".tgtdir,'~'.expand("<slnum>")) |
4339 | 1416 if type(a:fname) == 1 |
1417 call s:SetupNetrwStatusLine('%f %h%m%r%=%9*Obtaining '.a:fname) | |
1418 endif | |
1419 call s:NetrwMethod(b:netrw_curdir) | |
1420 | |
1421 if b:netrw_method == 4 | |
1422 " obtain file using scp | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1423 " call Decho("obtain via scp (method#4)",'~'.expand("<slnum>")) |
4339 | 1424 if exists("g:netrw_port") && g:netrw_port != "" |
1425 let useport= " ".g:netrw_scpport." ".g:netrw_port | |
1426 else | |
1427 let useport= "" | |
1428 endif | |
1429 if b:netrw_fname =~ '/' | |
1430 let path= substitute(b:netrw_fname,'^\(.*/\).\{-}$','\1','') | |
1431 else | |
1432 let path= "" | |
1433 endif | |
17433 | 1434 let filelist= join(map(deepcopy(fnamelist),'escape(s:ShellEscape(g:netrw_machine.":".path.v:val,1)," ")')) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1435 call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_scp_cmd.s:ShellEscape(useport,1)." ".filelist." ".s:ShellEscape(tgtdir,1)) |
4339 | 1436 |
1437 elseif b:netrw_method == 2 | |
1438 " obtain file using ftp + .netrc | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1439 " call Decho("obtain via ftp+.netrc (method #2)",'~'.expand("<slnum>")) |
6476 | 1440 call s:SaveBufVars()|sil NetrwKeepj new|call s:RestoreBufVars() |
4339 | 1441 let tmpbufnr= bufnr("%") |
1442 setl ff=unix | |
1443 if exists("g:netrw_ftpmode") && g:netrw_ftpmode != "" | |
6476 | 1444 NetrwKeepj put =g:netrw_ftpmode |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1445 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
4339 | 1446 endif |
1447 | |
1448 if exists("b:netrw_fname") && b:netrw_fname != "" | |
1449 call setline(line("$")+1,'cd "'.b:netrw_fname.'"') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1450 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
4339 | 1451 endif |
1452 | |
1453 if exists("g:netrw_ftpextracmd") | |
6476 | 1454 NetrwKeepj put =g:netrw_ftpextracmd |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1455 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
4339 | 1456 endif |
1457 for fname in fnamelist | |
1458 call setline(line("$")+1,'get "'.fname.'"') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1459 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
4339 | 1460 endfor |
1461 if exists("g:netrw_port") && g:netrw_port != "" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1462 call s:NetrwExe(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".s:ShellEscape(g:netrw_machine,1)." ".s:ShellEscape(g:netrw_port,1)) |
4339 | 1463 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1464 call s:NetrwExe(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".s:ShellEscape(g:netrw_machine,1)) |
4339 | 1465 endif |
1466 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) | |
1467 if getline(1) !~ "^$" && !exists("g:netrw_quiet") && getline(1) !~ '^Trying ' | |
1468 let debugkeep= &debug | |
1469 setl debug=msg | |
1470 call netrw#ErrorMsg(s:ERROR,getline(1),4) | |
1471 let &debug= debugkeep | |
1472 endif | |
1473 | |
1474 elseif b:netrw_method == 3 | |
1475 " obtain with ftp + machine, id, passwd, and fname (ie. no .netrc) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1476 " call Decho("obtain via ftp+mipf (method #3)",'~'.expand("<slnum>")) |
6476 | 1477 call s:SaveBufVars()|sil NetrwKeepj new|call s:RestoreBufVars() |
4339 | 1478 let tmpbufnr= bufnr("%") |
1479 setl ff=unix | |
1480 | |
1481 if exists("g:netrw_port") && g:netrw_port != "" | |
6476 | 1482 NetrwKeepj put ='open '.g:netrw_machine.' '.g:netrw_port |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1483 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
4339 | 1484 else |
6476 | 1485 NetrwKeepj put ='open '.g:netrw_machine |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1486 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
4339 | 1487 endif |
1488 | |
1489 if exists("g:netrw_uid") && g:netrw_uid != "" | |
1490 if exists("g:netrw_ftp") && g:netrw_ftp == 1 | |
6476 | 1491 NetrwKeepj put =g:netrw_uid |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1492 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
4339 | 1493 if exists("s:netrw_passwd") && s:netrw_passwd != "" |
6476 | 1494 NetrwKeepj put ='\"'.s:netrw_passwd.'\"' |
4339 | 1495 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1496 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
4339 | 1497 elseif exists("s:netrw_passwd") |
6476 | 1498 NetrwKeepj put ='user \"'.g:netrw_uid.'\" \"'.s:netrw_passwd.'\"' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1499 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
4339 | 1500 endif |
1501 endif | |
1502 | |
1503 if exists("g:netrw_ftpmode") && g:netrw_ftpmode != "" | |
6476 | 1504 NetrwKeepj put =g:netrw_ftpmode |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1505 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
4339 | 1506 endif |
1507 | |
1508 if exists("b:netrw_fname") && b:netrw_fname != "" | |
6476 | 1509 NetrwKeepj call setline(line("$")+1,'cd "'.b:netrw_fname.'"') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1510 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
4339 | 1511 endif |
1512 | |
1513 if exists("g:netrw_ftpextracmd") | |
6476 | 1514 NetrwKeepj put =g:netrw_ftpextracmd |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1515 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
4339 | 1516 endif |
1517 | |
1518 if exists("g:netrw_ftpextracmd") | |
6476 | 1519 NetrwKeepj put =g:netrw_ftpextracmd |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1520 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
4339 | 1521 endif |
1522 for fname in fnamelist | |
6476 | 1523 NetrwKeepj call setline(line("$")+1,'get "'.fname.'"') |
4339 | 1524 endfor |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1525 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
4339 | 1526 |
1527 " perform ftp: | |
1528 " -i : turns off interactive prompting from ftp | |
1529 " -n unix : DON'T use <.netrc>, even though it exists | |
1530 " -n win32: quit being obnoxious about password | |
6476 | 1531 NetrwKeepj norm! 1Gdd |
1532 call s:NetrwExe(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." ".g:netrw_ftp_options) | |
4339 | 1533 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) |
1534 if getline(1) !~ "^$" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1535 " call Decho("error<".getline(1).">",'~'.expand("<slnum>")) |
4339 | 1536 if !exists("g:netrw_quiet") |
6476 | 1537 NetrwKeepj call netrw#ErrorMsg(s:ERROR,getline(1),5) |
4339 | 1538 endif |
1539 endif | |
5929 | 1540 |
1541 elseif b:netrw_method == 9 | |
1542 " obtain file using sftp | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1543 " call Decho("obtain via sftp (method #9)",'~'.expand("<slnum>")) |
5929 | 1544 if a:fname =~ '/' |
1545 let localfile= substitute(a:fname,'^.*/','','') | |
1546 else | |
1547 let localfile= a:fname | |
1548 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1549 call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_sftp_cmd." ".s:ShellEscape(g:netrw_machine.":".b:netrw_fname,1).s:ShellEscape(localfile)." ".s:ShellEscape(tgtdir)) |
5929 | 1550 |
4339 | 1551 elseif !exists("b:netrw_method") || b:netrw_method < 0 |
5929 | 1552 " probably a badly formed url; protocol not recognized |
1553 " call Dret("netrw#Obtain : unsupported method") | |
1554 return | |
1555 | |
1556 else | |
1557 " protocol recognized but not supported for Obtain (yet?) | |
1558 if !exists("g:netrw_quiet") | |
6476 | 1559 NetrwKeepj call netrw#ErrorMsg(s:ERROR,"current protocol not supported for obtaining file",97) |
5929 | 1560 endif |
1561 " call Dret("netrw#Obtain : current protocol not supported for obtaining file") | |
4339 | 1562 return |
1563 endif | |
1564 | |
1565 " restore status line | |
1566 if type(a:fname) == 1 && exists("s:netrw_users_stl") | |
6476 | 1567 NetrwKeepj call s:SetupNetrwStatusLine(s:netrw_users_stl) |
4339 | 1568 endif |
1569 | |
1570 endif | |
1571 | |
1572 " cleanup | |
1573 if exists("tmpbufnr") | |
1574 if bufnr("%") != tmpbufnr | |
1575 exe tmpbufnr."bw!" | |
1576 else | |
1577 q! | |
1578 endif | |
1579 endif | |
1580 | |
5734 | 1581 " call Dret("netrw#Obtain") |
1582 endfun | |
1583 | |
1584 " --------------------------------------------------------------------- | |
1585 " netrw#Nread: save position, call netrw#NetRead(), and restore position {{{2 | |
1586 fun! netrw#Nread(mode,fname) | |
1587 " call Dfunc("netrw#Nread(mode=".a:mode." fname<".a:fname.">)") | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
1588 let svpos= winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
1589 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
5734 | 1590 call netrw#NetRead(a:mode,a:fname) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
1591 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
1592 call winrestview(svpos) |
5734 | 1593 |
1594 if exists("w:netrw_liststyle") && w:netrw_liststyle != s:TREELIST | |
1595 if exists("w:netrw_bannercnt") | |
1596 " start with cursor just after the banner | |
1597 exe w:netrw_bannercnt | |
1598 endif | |
1599 endif | |
1600 " call Dret("netrw#Nread") | |
1601 endfun | |
1602 | |
1603 " ------------------------------------------------------------------------ | |
17433 | 1604 " s:NetrwOptionsSave: save options prior to setting to "netrw-buffer-standard" form {{{2 |
1605 " Options get restored by s:NetrwOptionsRestore() | |
1606 " | |
1607 " Option handling: | |
1608 " * save user's options (s:NetrwOptionsSave) | |
1609 " * set netrw-safe options (s:NetrwOptionsSafe) | |
1610 " - change an option only when user option != safe option (s:netrwSetSafeSetting) | |
1611 " * restore user's options (s:netrwOPtionsRestore) | |
1612 " - restore a user option when != safe option (s:NetrwRestoreSetting) | |
1613 " vt: (variable type) normally its either "w:" or "s:" | |
1614 fun! s:NetrwOptionsSave(vt) | |
1615 " call Dfunc("s:NetrwOptionsSave(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")."<".bufname(bufnr("%")).">"." winnr($)=".winnr("$")." mod=".&mod." ma=".&ma) | |
1616 " call Decho(a:vt."netrw_optionsave".(exists("{a:vt}netrw_optionsave")? ("=".{a:vt}netrw_optionsave) : " doesn't exist"),'~'.expand("<slnum>")) | |
1617 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand("<slnum>")) | |
1618 | |
1619 if !exists("{a:vt}netrw_optionsave") | |
1620 let {a:vt}netrw_optionsave= 1 | |
1621 else | |
1622 " call Dret("s:NetrwOptionsSave : options already saved") | |
1623 return | |
1624 endif | |
1625 " call Decho("prior to save: fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist")." diff=".&l:diff,'~'.expand("<slnum>")) | |
1626 | |
1627 " Save current settings and current directory | |
1628 " call Decho("saving current settings and current directory",'~'.expand("<slnum>")) | |
1629 let s:yykeep = @@ | |
1630 if exists("&l:acd")|let {a:vt}netrw_acdkeep = &l:acd|endif | |
1631 let {a:vt}netrw_aikeep = &l:ai | |
1632 let {a:vt}netrw_awkeep = &l:aw | |
1633 let {a:vt}netrw_bhkeep = &l:bh | |
1634 let {a:vt}netrw_blkeep = &l:bl | |
1635 let {a:vt}netrw_btkeep = &l:bt | |
1636 let {a:vt}netrw_bombkeep = &l:bomb | |
1637 let {a:vt}netrw_cedit = &cedit | |
1638 let {a:vt}netrw_cikeep = &l:ci | |
1639 let {a:vt}netrw_cinkeep = &l:cin | |
1640 let {a:vt}netrw_cinokeep = &l:cino | |
1641 let {a:vt}netrw_comkeep = &l:com | |
1642 let {a:vt}netrw_cpokeep = &l:cpo | |
1643 let {a:vt}netrw_diffkeep = &l:diff | |
1644 let {a:vt}netrw_fenkeep = &l:fen | |
1645 " call Decho("saving current settings: got here#1",'~'.expand("<slnum>")) | |
1646 if !exists("g:netrw_ffkeep") || g:netrw_ffkeep | |
1647 let {a:vt}netrw_ffkeep = &l:ff | |
1648 endif | |
1649 let {a:vt}netrw_fokeep = &l:fo " formatoptions | |
1650 let {a:vt}netrw_gdkeep = &l:gd " gdefault | |
1651 let {a:vt}netrw_hidkeep = &l:hidden | |
1652 let {a:vt}netrw_imkeep = &l:im | |
1653 let {a:vt}netrw_iskkeep = &l:isk | |
1654 let {a:vt}netrw_lskeep = &l:ls | |
1655 let {a:vt}netrw_makeep = &l:ma | |
1656 let {a:vt}netrw_magickeep = &l:magic | |
1657 let {a:vt}netrw_modkeep = &l:mod | |
1658 let {a:vt}netrw_nukeep = &l:nu | |
1659 let {a:vt}netrw_rnukeep = &l:rnu | |
1660 let {a:vt}netrw_repkeep = &l:report | |
1661 let {a:vt}netrw_rokeep = &l:ro | |
1662 let {a:vt}netrw_selkeep = &l:sel | |
1663 let {a:vt}netrw_spellkeep = &l:spell | |
1664 " call Decho("saving current settings: got here#2",'~'.expand("<slnum>")) | |
1665 if !g:netrw_use_noswf | |
1666 let {a:vt}netrw_swfkeep = &l:swf | |
1667 endif | |
1668 let {a:vt}netrw_tskeep = &l:ts | |
1669 let {a:vt}netrw_twkeep = &l:tw " textwidth | |
1670 let {a:vt}netrw_wigkeep = &l:wig " wildignore | |
1671 let {a:vt}netrw_wrapkeep = &l:wrap | |
1672 let {a:vt}netrw_writekeep = &l:write | |
1673 | |
1674 " save a few selected netrw-related variables | |
1675 " call Decho("saving a few selected netrw-related variables",'~'.expand("<slnum>")) | |
1676 if g:netrw_keepdir | |
1677 let {a:vt}netrw_dirkeep = getcwd() | |
1678 endif | |
1679 if has("clipboard") | |
1680 sil! let {a:vt}netrw_starkeep = @* | |
1681 sil! let {a:vt}netrw_pluskeep = @+ | |
1682 endif | |
1683 sil! let {a:vt}netrw_slashkeep= @/ | |
1684 | |
1685 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand("<slnum>")) | |
1686 " call Dret("s:NetrwOptionsSave : tab#".tabpagenr()." win#".winnr()) | |
1687 endfun | |
1688 | |
1689 " --------------------------------------------------------------------- | |
1690 " s:NetrwOptionsSafe: sets options to help netrw do its job {{{2 | |
1691 " Use s:NetrwSaveOptions() to save user settings | |
1692 " Use s:NetrwOptionsRestore() to restore user settings | |
1693 fun! s:NetrwOptionsSafe(islocal) | |
1694 " call Dfunc("s:NetrwOptionsSafe(islocal=".a:islocal.") win#".winnr()." buf#".bufnr("%")."<".bufname(bufnr("%"))."> winnr($)=".winnr("$")) | |
1695 " call Decho("win#".winnr()."'s ft=".&ft,'~'.expand("<slnum>")) | |
1696 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("<slnum>")) | |
1697 if exists("+acd") | call s:NetrwSetSafeSetting("&l:acd",0)|endif | |
1698 call s:NetrwSetSafeSetting("&l:ai",0) | |
1699 call s:NetrwSetSafeSetting("&l:aw",0) | |
1700 call s:NetrwSetSafeSetting("&l:bl",0) | |
1701 call s:NetrwSetSafeSetting("&l:bomb",0) | |
1702 if a:islocal | |
1703 call s:NetrwSetSafeSetting("&l:bt","nofile") | |
1704 else | |
1705 call s:NetrwSetSafeSetting("&l:bt","acwrite") | |
1706 endif | |
1707 call s:NetrwSetSafeSetting("&l:ci",0) | |
1708 call s:NetrwSetSafeSetting("&l:cin",0) | |
1709 call s:NetrwSetSafeSetting("&l:bh","hide") | |
1710 call s:NetrwSetSafeSetting("&l:cino","") | |
1711 call s:NetrwSetSafeSetting("&l:com","") | |
1712 if &cpo =~ 'a' | call s:NetrwSetSafeSetting("&cpo",substitute(&cpo,'a','','g')) | endif | |
1713 if &cpo =~ 'A' | call s:NetrwSetSafeSetting("&cpo",substitute(&cpo,'A','','g')) | endif | |
1714 setl fo=nroql2 | |
1715 call s:NetrwSetSafeSetting("&l:hid",0) | |
1716 call s:NetrwSetSafeSetting("&l:im",0) | |
1717 setl isk+=@ isk+=* isk+=/ | |
1718 call s:NetrwSetSafeSetting("&l:magic",1) | |
1719 if g:netrw_use_noswf | |
1720 call s:NetrwSetSafeSetting("swf",0) | |
1721 endif | |
1722 call s:NetrwSetSafeSetting("&l:report",10000) | |
1723 call s:NetrwSetSafeSetting("&l:sel","inclusive") | |
1724 call s:NetrwSetSafeSetting("&l:spell",0) | |
1725 call s:NetrwSetSafeSetting("&l:tw",0) | |
1726 call s:NetrwSetSafeSetting("&l:wig","") | |
1727 setl cedit& | |
1728 call s:NetrwCursor() | |
1729 | |
1730 " allow the user to override safe options | |
1731 " call Decho("ft<".&ft."> ei=".&ei,'~'.expand("<slnum>")) | |
1732 if &ft == "netrw" | |
1733 " call Decho("do any netrw FileType autocmds (doau FileType netrw)",'~'.expand("<slnum>")) | |
1734 keepalt NetrwKeepj doau FileType netrw | |
1735 endif | |
1736 | |
1737 " call Decho("fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist")." bh=".&l:bh." bt<".&bt.">",'~'.expand("<slnum>")) | |
1738 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("<slnum>")) | |
1739 " call Dret("s:NetrwOptionsSafe") | |
1740 endfun | |
1741 | |
1742 " --------------------------------------------------------------------- | |
1743 " s:NetrwOptionsRestore: restore options (based on prior s:NetrwOptionsSave) {{{2 | |
1744 fun! s:NetrwOptionsRestore(vt) | |
1745 " call Dfunc("s:NetrwOptionsRestore(vt<".a:vt.">) win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> winnr($)=".winnr("$")) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1746 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand("<slnum>")) |
5734 | 1747 if !exists("{a:vt}netrw_optionsave") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1748 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1749 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
17433 | 1750 " call Dret("s:NetrwOptionsRestore : ".a:vt."netrw_optionsave doesn't exist") |
5734 | 1751 return |
1752 endif | |
1753 unlet {a:vt}netrw_optionsave | |
1754 | |
1755 if exists("+acd") | |
1756 if exists("{a:vt}netrw_acdkeep") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1757 " call Decho("g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd,'~'.expand("<slnum>")) |
5734 | 1758 let curdir = getcwd() |
1759 let &l:acd = {a:vt}netrw_acdkeep | |
1760 unlet {a:vt}netrw_acdkeep | |
1761 if &l:acd | |
1762 call s:NetrwLcd(curdir) | |
1763 endif | |
1764 endif | |
1765 endif | |
17433 | 1766 call s:NetrwRestoreSetting(a:vt."netrw_aikeep","&l:ai") |
1767 call s:NetrwRestoreSetting(a:vt."netrw_awkeep","&l:aw") | |
1768 call s:NetrwRestoreSetting(a:vt."netrw_blkeep","&l:bl") | |
1769 call s:NetrwRestoreSetting(a:vt."netrw_btkeep","&l:bt") | |
1770 call s:NetrwRestoreSetting(a:vt."netrw_bombkeep","&l:bomb") | |
1771 call s:NetrwRestoreSetting(a:vt."netrw_cedit","&cedit") | |
1772 call s:NetrwRestoreSetting(a:vt."netrw_cikeep","&l:ci") | |
1773 call s:NetrwRestoreSetting(a:vt."netrw_cinkeep","&l:cin") | |
1774 call s:NetrwRestoreSetting(a:vt."netrw_cinokeep","&l:cino") | |
1775 call s:NetrwRestoreSetting(a:vt."netrw_comkeep","&l:com") | |
1776 call s:NetrwRestoreSetting(a:vt."netrw_cpokeep","&l:cpo") | |
1777 call s:NetrwRestoreSetting(a:vt."netrw_diffkeep","&l:diff") | |
1778 call s:NetrwRestoreSetting(a:vt."netrw_fenkeep","&l:fen") | |
1779 if exists("g:netrw_ffkeep") && g:netrw_ffkeep | |
1780 call s:NetrwRestoreSetting(a:vt."netrw_ffkeep")","&l:ff") | |
1781 endif | |
1782 call s:NetrwRestoreSetting(a:vt."netrw_fokeep","&l:fo") | |
1783 call s:NetrwRestoreSetting(a:vt."netrw_gdkeep","&l:gd") | |
1784 call s:NetrwRestoreSetting(a:vt."netrw_hidkeep","&l:hidden") | |
1785 call s:NetrwRestoreSetting(a:vt."netrw_imkeep","&l:im") | |
1786 call s:NetrwRestoreSetting(a:vt."netrw_iskkeep","&l:isk") | |
1787 call s:NetrwRestoreSetting(a:vt."netrw_lskeep","&l:ls") | |
1788 call s:NetrwRestoreSetting(a:vt."netrw_makeep","&l:ma") | |
1789 call s:NetrwRestoreSetting(a:vt."netrw_magickeep","&l:magic") | |
1790 call s:NetrwRestoreSetting(a:vt."netrw_modkeep","&l:mod") | |
1791 call s:NetrwRestoreSetting(a:vt."netrw_nukeep","&l:nu") | |
1792 call s:NetrwRestoreSetting(a:vt."netrw_rnukeep","&l:rnu") | |
1793 call s:NetrwRestoreSetting(a:vt."netrw_repkeep","&l:report") | |
1794 call s:NetrwRestoreSetting(a:vt."netrw_rokeep","&l:ro") | |
1795 call s:NetrwRestoreSetting(a:vt."netrw_selkeep","&l:sel") | |
1796 call s:NetrwRestoreSetting(a:vt."netrw_spellkeep","&l:spell") | |
1797 call s:NetrwRestoreSetting(a:vt."netrw_twkeep","&l:tw") | |
1798 call s:NetrwRestoreSetting(a:vt."netrw_wigkeep","&l:wig") | |
1799 call s:NetrwRestoreSetting(a:vt."netrw_wrapkeep","&l:wrap") | |
1800 call s:NetrwRestoreSetting(a:vt."netrw_writekeep","&l:write") | |
1801 call s:NetrwRestoreSetting("s:yykeep","@@") | |
1802 " former problem: start with liststyle=0; press <i> : result, following line resets l:ts. | |
1803 " Fixed; in s:PerformListing, when w:netrw_liststyle is s:LONGLIST, will use a printf to pad filename with spaces | |
1804 " rather than by appending a tab which previously was using "&ts" to set the desired spacing. (Sep 28, 2018) | |
1805 call s:NetrwRestoreSetting(a:vt."netrw_tskeep","&l:ts") | |
1806 | |
5734 | 1807 if exists("{a:vt}netrw_swfkeep") |
1808 if &directory == "" | |
1809 " user hasn't specified a swapfile directory; | |
1810 " netrw will temporarily set the swapfile directory | |
1811 " to the current directory as returned by getcwd(). | |
1812 let &l:directory= getcwd() | |
1813 sil! let &l:swf = {a:vt}netrw_swfkeep | |
1814 setl directory= | |
1815 unlet {a:vt}netrw_swfkeep | |
1816 elseif &l:swf != {a:vt}netrw_swfkeep | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
1817 if !g:netrw_use_noswf |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
1818 " following line causes a Press ENTER in windows -- can't seem to work around it!!! |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
1819 sil! let &l:swf= {a:vt}netrw_swfkeep |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
1820 endif |
5734 | 1821 unlet {a:vt}netrw_swfkeep |
1822 endif | |
1823 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1824 if exists("{a:vt}netrw_dirkeep") && isdirectory(s:NetrwFile({a:vt}netrw_dirkeep)) && g:netrw_keepdir |
5734 | 1825 let dirkeep = substitute({a:vt}netrw_dirkeep,'\\','/','g') |
1826 if exists("{a:vt}netrw_dirkeep") | |
1827 call s:NetrwLcd(dirkeep) | |
1828 unlet {a:vt}netrw_dirkeep | |
1829 endif | |
1830 endif | |
1831 if has("clipboard") | |
17433 | 1832 call s:NetrwRestoreSetting(a:vt."netrw_starkeep","@*") |
1833 call s:NetrwRestoreSetting(a:vt."netrw_pluskeep","@+") | |
1834 endif | |
1835 call s:NetrwRestoreSetting(a:vt."netrw_slashkeep","@/") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1836 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1837 " call Decho("g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1838 " call Decho("fo=".&fo.(exists("+acd")? " acd=".&acd : " acd doesn't exist"),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1839 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1840 " call Decho("diff=".&l:diff." win#".winnr()." w:netrw_diffkeep=".(exists("w:netrw_diffkeep")? w:netrw_diffkeep : "doesn't exist"),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1841 " call Decho("ts=".&l:ts,'~'.expand("<slnum>")) |
5734 | 1842 " Moved the filetype detect here from NetrwGetFile() because remote files |
1843 " were having their filetype detect-generated settings overwritten by | |
1844 " NetrwOptionRestore. | |
1845 if &ft != "netrw" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1846 " call Decho("filetype detect (ft=".&ft.")",'~'.expand("<slnum>")) |
5734 | 1847 filetype detect |
1848 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1849 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo." a:vt=".a:vt,'~'.expand("<slnum>")) |
17433 | 1850 " call Dret("s:NetrwOptionsRestore : tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> modified=".&modified." modifiable=".&modifiable." readonly=".&readonly) |
1851 endfun | |
1852 | |
1853 " --------------------------------------------------------------------- | |
1854 " s:NetrwSetSafeSetting: sets an option to a safe setting {{{2 | |
1855 " but only when the options' value and the safe setting differ | |
1856 " Doing this means that netrw will not come up as having changed a | |
1857 " setting last when it really didn't actually change it. | |
1858 " | |
1859 " Called from s:NetrwOptionsSafe | |
1860 " ex. call s:NetrwSetSafeSetting("&l:sel","inclusive") | |
1861 fun! s:NetrwSetSafeSetting(setting,safesetting) | |
1862 " call Dfunc("s:NetrwSetSafeSetting(setting<".a:setting."> safesetting<".a:safesetting.">)") | |
1863 | |
1864 if a:setting =~ '^&' | |
1865 " call Decho("fyi: a:setting starts with &") | |
1866 exe "let settingval= ".a:setting | |
1867 " call Decho("fyi: settingval<".settingval.">") | |
1868 | |
1869 if settingval != a:safesetting | |
1870 " call Decho("set setting<".a:setting."> to option value<".a:safesetting.">") | |
1871 if type(a:safesetting) == 0 | |
1872 exe "let ".a:setting."=".a:safesetting | |
1873 elseif type(a:safesetting) == 1 | |
1874 exe "let ".a:setting."= '".a:safesetting."'" | |
1875 else | |
1876 call netrw#ErrorMsg(s:ERROR,"(s:NetrwRestoreSetting) doesn't know how to restore ".a:setting." with a safesetting of type#".type(a:safesetting),105) | |
1877 endif | |
1878 endif | |
1879 endif | |
1880 | |
1881 " call Dret("s:NetrwSetSafeSetting") | |
5734 | 1882 endfun |
1883 | |
1884 " ------------------------------------------------------------------------ | |
17433 | 1885 " s:NetrwRestoreSetting: restores specified setting using associated keepvar, {{{2 |
1886 " but only if the setting value differs from the associated keepvar. | |
1887 " Doing this means that netrw will not come up as having changed a | |
1888 " setting last when it really didn't actually change it. | |
1889 " | |
1890 " Used by s:NetrwOptionsRestore() to restore each netrw-senstive setting | |
1891 " keepvars are set up by s:NetrwOptionsSave | |
1892 fun! s:NetrwRestoreSetting(keepvar,setting) | |
1893 "" call Dfunc("s:NetrwRestoreSetting(a:keepvar<".a:keepvar."> a:setting<".a:setting.">)") | |
1894 | |
1895 " typically called from s:NetrwOptionsRestore | |
1896 " call s:NetrwRestoreSettings(keep-option-variable-name,'associated-option') | |
1897 " ex. call s:NetrwRestoreSetting(a:vt."netrw_selkeep","&l:sel") | |
1898 " Restores option (if different) from a keepvar | |
1899 if exists(a:keepvar) | |
1900 exe "let keepvarval= ".a:keepvar | |
1901 exe "let setting= ".a:setting | |
1902 | |
1903 "" call Decho("fyi: a:keepvar<".a:keepvar."> exists") | |
1904 "" call Decho("fyi: keepvarval=".keepvarval) | |
1905 "" call Decho("fyi: a:setting<".a:setting."> setting<".setting.">") | |
1906 | |
1907 if setting != keepvarval | |
1908 "" call Decho("restore setting<".a:setting."=".setting."> to keepvarval<".keepvarval.">") | |
1909 if type(a:setting) == 0 | |
1910 exe "let ".a:setting."= ".keepvarval | |
1911 elseif type(a:setting) == 1 | |
1912 exe "let ".a:setting."= '".keepvarval."'" | |
1913 else | |
1914 call netrw#ErrorMsg(s:ERROR,"(s:NetrwRestoreSetting) doesn't know how to restore ".a:keepvar." with a setting of type#".type(a:setting),105) | |
1915 endif | |
1916 endif | |
1917 | |
1918 exe "unlet ".a:keepvar | |
1919 endif | |
1920 | |
1921 "" call Dret("s:NetrwRestoreSetting") | |
4339 | 1922 endfun |
1923 | |
1924 " --------------------------------------------------------------------- | |
1925 " NetrwStatusLine: {{{2 | |
1926 fun! NetrwStatusLine() | |
1927 | |
1928 " vvv NetrwStatusLine() debugging vvv | |
1929 " let g:stlmsg="" | |
1930 " if !exists("w:netrw_explore_bufnr") | |
1931 " let g:stlmsg="!X<explore_bufnr>" | |
1932 " elseif w:netrw_explore_bufnr != bufnr("%") | |
1933 " let g:stlmsg="explore_bufnr!=".bufnr("%") | |
1934 " endif | |
1935 " if !exists("w:netrw_explore_line") | |
1936 " let g:stlmsg=" !X<explore_line>" | |
1937 " elseif w:netrw_explore_line != line(".") | |
1938 " let g:stlmsg=" explore_line!={line(.)<".line(".").">" | |
1939 " endif | |
1940 " if !exists("w:netrw_explore_list") | |
1941 " let g:stlmsg=" !X<explore_list>" | |
1942 " endif | |
1943 " ^^^ NetrwStatusLine() debugging ^^^ | |
1944 | |
1945 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") | |
1946 " restore user's status line | |
1947 let &stl = s:netrw_users_stl | |
1948 let &laststatus = s:netrw_users_ls | |
1949 if exists("w:netrw_explore_bufnr")|unlet w:netrw_explore_bufnr|endif | |
1950 if exists("w:netrw_explore_line") |unlet w:netrw_explore_line |endif | |
1951 return "" | |
1952 else | |
1953 return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen | |
1954 endif | |
1955 endfun | |
1956 | |
17433 | 1957 " =============================== |
650 | 1958 " Netrw Transfer Functions: {{{1 |
1959 " =============================== | |
1960 | |
482 | 1961 " ------------------------------------------------------------------------ |
1621 | 1962 " netrw#NetRead: responsible for reading a file over the net {{{2 |
1121 | 1963 " mode: =0 read remote file and insert before current line |
1964 " =1 read remote file and insert after current line | |
1965 " =2 replace with remote file | |
1966 " =3 obtain file, but leave in temporary format | |
719 | 1967 fun! netrw#NetRead(mode,...) |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
1968 " call Dfunc("netrw#NetRead(mode=".a:mode.",...) a:0=".a:0." ".g:loaded_netrw.((a:0 > 0)? " a:1<".a:1.">" : "")) |
1121 | 1969 |
2034 | 1970 " NetRead: save options {{{3 |
17433 | 1971 call s:NetrwOptionsSave("w:") |
1972 call s:NetrwOptionsSafe(0) | |
2152 | 1973 call s:RestoreCursorline() |
6476 | 1974 " NetrwSafeOptions sets a buffer up for a netrw listing, which includes buflisting off. |
1975 " However, this setting is not wanted for a remote editing session. The buffer should be "nofile", still. | |
1976 setl bl | |
17433 | 1977 " call Decho("buf#".bufnr("%")."<".bufname("%")."> bl=".&bl." bt=".&bt." bh=".&bh,'~'.expand("<slnum>")) |
719 | 1978 |
2034 | 1979 " NetRead: interpret mode into a readcmd {{{3 |
719 | 1980 if a:mode == 0 " read remote file before current line |
482 | 1981 let readcmd = "0r" |
719 | 1982 elseif a:mode == 1 " read file after current line |
482 | 1983 let readcmd = "r" |
719 | 1984 elseif a:mode == 2 " replace with remote file |
1985 let readcmd = "%r" | |
1121 | 1986 elseif a:mode == 3 " skip read of file (leave as temporary) |
1987 let readcmd = "t" | |
719 | 1988 else |
1989 exe a:mode | |
1990 let readcmd = "r" | |
482 | 1991 endif |
719 | 1992 let ichoice = (a:0 == 0)? 0 : 1 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
1993 " call Decho("readcmd<".readcmd."> ichoice=".ichoice,'~'.expand("<slnum>")) |
719 | 1994 |
2034 | 1995 " NetRead: get temporary filename {{{3 |
1121 | 1996 let tmpfile= s:GetTempfile("") |
1997 if tmpfile == "" | |
1998 " call Dret("netrw#NetRead : unable to get a tempfile!") | |
482 | 1999 return |
2000 endif | |
719 | 2001 |
482 | 2002 while ichoice <= a:0 |
719 | 2003 |
482 | 2004 " attempt to repeat with previous host-file-etc |
2005 if exists("b:netrw_lastfile") && a:0 == 0 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2006 " call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">",'~'.expand("<slnum>")) |
482 | 2007 let choice = b:netrw_lastfile |
2008 let ichoice= ichoice + 1 | |
719 | 2009 |
482 | 2010 else |
2011 exe "let choice= a:" . ichoice | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2012 " call Decho("no lastfile: choice<" . choice . ">",'~'.expand("<slnum>")) |
719 | 2013 |
482 | 2014 if match(choice,"?") == 0 |
2015 " give help | |
2016 echomsg 'NetRead Usage:' | |
2017 echomsg ':Nread machine:path uses rcp' | |
2018 echomsg ':Nread "machine path" uses ftp with <.netrc>' | |
2019 echomsg ':Nread "machine id password path" uses ftp' | |
2020 echomsg ':Nread dav://machine[:port]/path uses cadaver' | |
2021 echomsg ':Nread fetch://machine/path uses fetch' | |
2022 echomsg ':Nread ftp://[user@]machine[:port]/path uses ftp autodetects <.netrc>' | |
2023 echomsg ':Nread http://[user@]machine/path uses http wget' | |
6476 | 2024 echomsg ':Nread file:///path uses elinks' |
5734 | 2025 echomsg ':Nread https://[user@]machine/path uses http wget' |
482 | 2026 echomsg ':Nread rcp://[user@]machine/path uses rcp' |
2027 echomsg ':Nread rsync://machine[:port]/path uses rsync' | |
2028 echomsg ':Nread scp://[user@]machine[[:#]port]/path uses scp' | |
2029 echomsg ':Nread sftp://[user@]machine[[:#]port]/path uses sftp' | |
1121 | 2030 sleep 4 |
482 | 2031 break |
2032 | |
1121 | 2033 elseif match(choice,'^"') != -1 |
482 | 2034 " Reconstruct Choice if choice starts with '"' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2035 " call Decho("reconstructing choice",'~'.expand("<slnum>")) |
1121 | 2036 if match(choice,'"$') != -1 |
482 | 2037 " case "..." |
2751 | 2038 let choice= strpart(choice,1,strlen(choice)-2) |
482 | 2039 else |
2040 " case "... ... ..." | |
2041 let choice = strpart(choice,1,strlen(choice)-1) | |
2042 let wholechoice = "" | |
719 | 2043 |
1121 | 2044 while match(choice,'"$') == -1 |
482 | 2045 let wholechoice = wholechoice . " " . choice |
2046 let ichoice = ichoice + 1 | |
2047 if ichoice > a:0 | |
2048 if !exists("g:netrw_quiet") | |
1121 | 2049 call netrw#ErrorMsg(s:ERROR,"Unbalanced string in filename '". wholechoice ."'",3) |
482 | 2050 endif |
1121 | 2051 " call Dret("netrw#NetRead :2 getcwd<".getcwd().">") |
482 | 2052 return |
2053 endif | |
2054 let choice= a:{ichoice} | |
2055 endwhile | |
2056 let choice= strpart(wholechoice,1,strlen(wholechoice)-1) . " " . strpart(choice,0,strlen(choice)-1) | |
2057 endif | |
2058 endif | |
2059 endif | |
2060 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2061 " call Decho("choice<" . choice . ">",'~'.expand("<slnum>")) |
482 | 2062 let ichoice= ichoice + 1 |
719 | 2063 |
2034 | 2064 " NetRead: Determine method of read (ftp, rcp, etc) {{{3 |
1621 | 2065 call s:NetrwMethod(choice) |
2034 | 2066 if !exists("b:netrw_method") || b:netrw_method < 0 |
17433 | 2067 " call Dret("netrw#NetRead : unsupported method") |
2034 | 2068 return |
2069 endif | |
1121 | 2070 let tmpfile= s:GetTempfile(b:netrw_fname) " apply correct suffix |
719 | 2071 |
5618 | 2072 " Check whether or not NetrwBrowse() should be handling this request |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2073 " call Decho("checking if NetrwBrowse() should handle choice<".choice."> with netrw_list_cmd<".g:netrw_list_cmd.">",'~'.expand("<slnum>")) |
3153 | 2074 if choice =~ "^.*[\/]$" && b:netrw_method != 5 && choice !~ '^https\=://' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2075 " call Decho("yes, choice matches '^.*[\/]$'",'~'.expand("<slnum>")) |
6476 | 2076 NetrwKeepj call s:NetrwBrowse(0,choice) |
1121 | 2077 " call Dret("netrw#NetRead :3 getcwd<".getcwd().">") |
482 | 2078 return |
2079 endif | |
559 | 2080 |
482 | 2081 " ============ |
2034 | 2082 " NetRead: Perform Protocol-Based Read {{{3 |
650 | 2083 " =========================== |
559 | 2084 if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1 |
2085 echo "(netrw) Processing your read request..." | |
2086 endif | |
719 | 2087 |
482 | 2088 "......................................... |
2034 | 2089 " NetRead: (rcp) NetRead Method #1 {{{3 |
482 | 2090 if b:netrw_method == 1 " read with rcp |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2091 " call Decho("read via rcp (method #1)",'~'.expand("<slnum>")) |
857 | 2092 " ER: nothing done with g:netrw_uid yet? |
482 | 2093 " ER: on Win2K" rcp machine[.user]:file tmpfile |
5618 | 2094 " ER: when machine contains '.' adding .user is required (use $USERNAME) |
482 | 2095 " ER: the tmpfile is full path: rcp sees C:\... as host C |
2096 if s:netrw_has_nt_rcp == 1 | |
2097 if exists("g:netrw_uid") && ( g:netrw_uid != "" ) | |
2098 let uid_machine = g:netrw_machine .'.'. g:netrw_uid | |
2099 else | |
2100 " Any way needed it machine contains a '.' | |
2101 let uid_machine = g:netrw_machine .'.'. $USERNAME | |
2102 endif | |
2103 else | |
2104 if exists("g:netrw_uid") && ( g:netrw_uid != "" ) | |
2105 let uid_machine = g:netrw_uid .'@'. g:netrw_machine | |
2106 else | |
2107 let uid_machine = g:netrw_machine | |
2108 endif | |
2109 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2110 call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".s:ShellEscape(uid_machine.":".b:netrw_fname,1)." ".s:ShellEscape(tmpfile,1)) |
1621 | 2111 let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) |
482 | 2112 let b:netrw_lastfile = choice |
719 | 2113 |
482 | 2114 "......................................... |
2034 | 2115 " NetRead: (ftp + <.netrc>) NetRead Method #2 {{{3 |
482 | 2116 elseif b:netrw_method == 2 " read with ftp + <.netrc> |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2117 " call Decho("read via ftp+.netrc (method #2)",'~'.expand("<slnum>")) |
820 | 2118 let netrw_fname= b:netrw_fname |
6476 | 2119 NetrwKeepj call s:SaveBufVars()|new|NetrwKeepj call s:RestoreBufVars() |
1698 | 2120 let filtbuf= bufnr("%") |
4339 | 2121 setl ff=unix |
6476 | 2122 NetrwKeepj put =g:netrw_ftpmode |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2123 " call Decho("filter input: ".getline(line("$")),'~'.expand("<slnum>")) |
1121 | 2124 if exists("g:netrw_ftpextracmd") |
6476 | 2125 NetrwKeepj put =g:netrw_ftpextracmd |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2126 " call Decho("filter input: ".getline(line("$")),'~'.expand("<slnum>")) |
1121 | 2127 endif |
1698 | 2128 call setline(line("$")+1,'get "'.netrw_fname.'" '.tmpfile) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2129 " call Decho("filter input: ".getline(line("$")),'~'.expand("<slnum>")) |
482 | 2130 if exists("g:netrw_port") && g:netrw_port != "" |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2131 call s:NetrwExe(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".s:ShellEscape(g:netrw_machine,1)." ".s:ShellEscape(g:netrw_port,1)) |
482 | 2132 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2133 call s:NetrwExe(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".s:ShellEscape(g:netrw_machine,1)) |
482 | 2134 endif |
2135 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) | |
2136 if getline(1) !~ "^$" && !exists("g:netrw_quiet") && getline(1) !~ '^Trying ' | |
1668 | 2137 let debugkeep = &debug |
4339 | 2138 setl debug=msg |
6476 | 2139 NetrwKeepj call netrw#ErrorMsg(s:ERROR,getline(1),4) |
1668 | 2140 let &debug = debugkeep |
482 | 2141 endif |
1702 | 2142 call s:SaveBufVars() |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2143 keepj bd! |
2034 | 2144 if bufname("%") == "" && getline("$") == "" && line('$') == 1 |
2145 " needed when one sources a file in a nolbl setting window via ftp | |
1702 | 2146 q! |
2147 endif | |
2148 call s:RestoreBufVars() | |
1621 | 2149 let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) |
482 | 2150 let b:netrw_lastfile = choice |
719 | 2151 |
482 | 2152 "......................................... |
2034 | 2153 " NetRead: (ftp + machine,id,passwd,filename) NetRead Method #3 {{{3 |
482 | 2154 elseif b:netrw_method == 3 " read with ftp + machine, id, passwd, and fname |
2155 " Construct execution string (four lines) which will be passed through filter | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2156 " call Decho("read via ftp+mipf (method #3)",'~'.expand("<slnum>")) |
719 | 2157 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape) |
6476 | 2158 NetrwKeepj call s:SaveBufVars()|new|NetrwKeepj call s:RestoreBufVars() |
1698 | 2159 let filtbuf= bufnr("%") |
4339 | 2160 setl ff=unix |
482 | 2161 if exists("g:netrw_port") && g:netrw_port != "" |
6476 | 2162 NetrwKeepj put ='open '.g:netrw_machine.' '.g:netrw_port |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2163 " call Decho("filter input: ".getline('.'),'~'.expand("<slnum>")) |
482 | 2164 else |
6476 | 2165 NetrwKeepj put ='open '.g:netrw_machine |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2166 " call Decho("filter input: ".getline('.'),'~'.expand("<slnum>")) |
482 | 2167 endif |
719 | 2168 |
3920 | 2169 if exists("g:netrw_uid") && g:netrw_uid != "" |
3456 | 2170 if exists("g:netrw_ftp") && g:netrw_ftp == 1 |
6476 | 2171 NetrwKeepj put =g:netrw_uid |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2172 " call Decho("filter input: ".getline('.'),'~'.expand("<slnum>")) |
3456 | 2173 if exists("s:netrw_passwd") |
6476 | 2174 NetrwKeepj put ='\"'.s:netrw_passwd.'\"' |
3456 | 2175 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2176 " call Decho("filter input: ".getline('.'),'~'.expand("<slnum>")) |
3456 | 2177 elseif exists("s:netrw_passwd") |
6476 | 2178 NetrwKeepj put ='user \"'.g:netrw_uid.'\" \"'.s:netrw_passwd.'\"' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2179 " call Decho("filter input: ".getline('.'),'~'.expand("<slnum>")) |
3456 | 2180 endif |
482 | 2181 endif |
719 | 2182 |
482 | 2183 if exists("g:netrw_ftpmode") && g:netrw_ftpmode != "" |
6476 | 2184 NetrwKeepj put =g:netrw_ftpmode |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2185 " call Decho("filter input: ".getline('.'),'~'.expand("<slnum>")) |
482 | 2186 endif |
1121 | 2187 if exists("g:netrw_ftpextracmd") |
6476 | 2188 NetrwKeepj put =g:netrw_ftpextracmd |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2189 " call Decho("filter input: ".getline('.'),'~'.expand("<slnum>")) |
1121 | 2190 endif |
6476 | 2191 NetrwKeepj put ='get \"'.netrw_fname.'\" '.tmpfile |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2192 " call Decho("filter input: ".getline('.'),'~'.expand("<slnum>")) |
719 | 2193 |
482 | 2194 " perform ftp: |
2195 " -i : turns off interactive prompting from ftp | |
2196 " -n unix : DON'T use <.netrc>, even though it exists | |
2197 " -n win32: quit being obnoxious about password | |
6476 | 2198 NetrwKeepj norm! 1Gdd |
2199 call s:NetrwExe(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." ".g:netrw_ftp_options) | |
482 | 2200 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) |
2201 if getline(1) !~ "^$" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2202 " call Decho("error<".getline(1).">",'~'.expand("<slnum>")) |
482 | 2203 if !exists("g:netrw_quiet") |
1121 | 2204 call netrw#ErrorMsg(s:ERROR,getline(1),5) |
482 | 2205 endif |
2206 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2207 call s:SaveBufVars()|keepj bd!|call s:RestoreBufVars() |
1621 | 2208 let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) |
482 | 2209 let b:netrw_lastfile = choice |
719 | 2210 |
482 | 2211 "......................................... |
2034 | 2212 " NetRead: (scp) NetRead Method #4 {{{3 |
482 | 2213 elseif b:netrw_method == 4 " read with scp |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2214 " call Decho("read via scp (method #4)",'~'.expand("<slnum>")) |
482 | 2215 if exists("g:netrw_port") && g:netrw_port != "" |
1209 | 2216 let useport= " ".g:netrw_scpport." ".g:netrw_port |
482 | 2217 else |
2218 let useport= "" | |
2219 endif | |
6476 | 2220 " 'C' in 'C:\path\to\file' is handled as hostname on windows. |
2221 " This is workaround to avoid mis-handle windows local-path: | |
2222 if g:netrw_scp_cmd =~ '^scp' && (has("win32") || has("win95") || has("win64") || has("win16")) | |
2223 let tmpfile_get = substitute(tr(tmpfile, '\', '/'), '^\(\a\):[/\\]\(.*\)$', '/\1/\2', '') | |
2224 else | |
2225 let tmpfile_get = tmpfile | |
2226 endif | |
17433 | 2227 call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".escape(s:ShellEscape(g:netrw_machine.":".b:netrw_fname,1),' ')." ".s:ShellEscape(tmpfile_get,1)) |
1621 | 2228 let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) |
482 | 2229 let b:netrw_lastfile = choice |
719 | 2230 |
482 | 2231 "......................................... |
2034 | 2232 " NetRead: (http) NetRead Method #5 (wget) {{{3 |
650 | 2233 elseif b:netrw_method == 5 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2234 " call Decho("read via http (method #5)",'~'.expand("<slnum>")) |
482 | 2235 if g:netrw_http_cmd == "" |
2236 if !exists("g:netrw_quiet") | |
1121 | 2237 call netrw#ErrorMsg(s:ERROR,"neither the wget nor the fetch command is available",6) |
482 | 2238 endif |
1121 | 2239 " call Dret("netrw#NetRead :4 getcwd<".getcwd().">") |
559 | 2240 return |
482 | 2241 endif |
719 | 2242 |
1698 | 2243 if match(b:netrw_fname,"#") == -1 || exists("g:netrw_http_xcmd") |
2244 " using g:netrw_http_cmd (usually elinks, links, curl, wget, or fetch) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2245 " call Decho('using '.g:netrw_http_cmd.' (# not in b:netrw_fname<'.b:netrw_fname.">)",'~'.expand("<slnum>")) |
1698 | 2246 if exists("g:netrw_http_xcmd") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2247 call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_http_cmd." ".s:ShellEscape(b:netrw_http."://".g:netrw_machine.b:netrw_fname,1)." ".g:netrw_http_xcmd." ".s:ShellEscape(tmpfile,1)) |
1698 | 2248 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2249 call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_http_cmd." ".s:ShellEscape(tmpfile,1)." ".s:ShellEscape(b:netrw_http."://".g:netrw_machine.b:netrw_fname,1)) |
1698 | 2250 endif |
1621 | 2251 let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) |
719 | 2252 |
482 | 2253 else |
1698 | 2254 " wget/curl/fetch plus a jump to an in-page marker (ie. http://abc/def.html#aMarker) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2255 " call Decho("wget/curl plus jump (# in b:netrw_fname<".b:netrw_fname.">)",'~'.expand("<slnum>")) |
1668 | 2256 let netrw_html= substitute(b:netrw_fname,"#.*$","","") |
2257 let netrw_tag = substitute(b:netrw_fname,"^.*#","","") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2258 " call Decho("netrw_html<".netrw_html.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2259 " call Decho("netrw_tag <".netrw_tag.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2260 call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_http_cmd." ".s:ShellEscape(tmpfile,1)." ".s:ShellEscape(b:netrw_http."://".g:netrw_machine.netrw_html,1)) |
1621 | 2261 let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2262 " call Decho('<\s*a\s*name=\s*"'.netrw_tag.'"/','~'.expand("<slnum>")) |
6476 | 2263 exe 'NetrwKeepj norm! 1G/<\s*a\s*name=\s*"'.netrw_tag.'"/'."\<CR>" |
482 | 2264 endif |
2265 let b:netrw_lastfile = choice | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2266 " call Decho("setl ro",'~'.expand("<slnum>")) |
5929 | 2267 setl ro nomod |
719 | 2268 |
482 | 2269 "......................................... |
2034 | 2270 " NetRead: (dav) NetRead Method #6 {{{3 |
650 | 2271 elseif b:netrw_method == 6 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2272 " call Decho("read via cadaver (method #6)",'~'.expand("<slnum>")) |
719 | 2273 |
2034 | 2274 if !executable(g:netrw_dav_cmd) |
2275 call netrw#ErrorMsg(s:ERROR,g:netrw_dav_cmd." is not executable",73) | |
2276 " call Dret("netrw#NetRead : ".g:netrw_dav_cmd." not executable") | |
2277 return | |
2278 endif | |
2279 if g:netrw_dav_cmd =~ "curl" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2280 call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_dav_cmd." ".s:ShellEscape("dav://".g:netrw_machine.b:netrw_fname,1)." ".s:ShellEscape(tmpfile,1)) |
482 | 2281 else |
2034 | 2282 " Construct execution string (four lines) which will be passed through filter |
2283 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape) | |
2284 new | |
4339 | 2285 setl ff=unix |
2034 | 2286 if exists("g:netrw_port") && g:netrw_port != "" |
6476 | 2287 NetrwKeepj put ='open '.g:netrw_machine.' '.g:netrw_port |
2034 | 2288 else |
6476 | 2289 NetrwKeepj put ='open '.g:netrw_machine |
2034 | 2290 endif |
3456 | 2291 if exists("g:netrw_uid") && exists("s:netrw_passwd") && g:netrw_uid != "" |
6476 | 2292 NetrwKeepj put ='user '.g:netrw_uid.' '.s:netrw_passwd |
2293 endif | |
2294 NetrwKeepj put ='get '.netrw_fname.' '.tmpfile | |
2295 NetrwKeepj put ='quit' | |
2034 | 2296 |
2297 " perform cadaver operation: | |
6476 | 2298 NetrwKeepj norm! 1Gdd |
2299 call s:NetrwExe(s:netrw_silentxfer."%!".g:netrw_dav_cmd) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2300 keepj bd! |
2034 | 2301 endif |
1621 | 2302 let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) |
482 | 2303 let b:netrw_lastfile = choice |
719 | 2304 |
482 | 2305 "......................................... |
2034 | 2306 " NetRead: (rsync) NetRead Method #7 {{{3 |
650 | 2307 elseif b:netrw_method == 7 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2308 " call Decho("read via rsync (method #7)",'~'.expand("<slnum>")) |
17433 | 2309 call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_rsync_cmd." ".s:ShellEscape(g:netrw_machine.g:netrw_rsync_sep.b:netrw_fname,1)." ".s:ShellEscape(tmpfile,1)) |
1621 | 2310 let result = s:NetrwGetFile(readcmd,tmpfile, b:netrw_method) |
482 | 2311 let b:netrw_lastfile = choice |
719 | 2312 |
482 | 2313 "......................................... |
2034 | 2314 " NetRead: (fetch) NetRead Method #8 {{{3 |
482 | 2315 " fetch://[user@]host[:http]/path |
650 | 2316 elseif b:netrw_method == 8 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2317 " call Decho("read via fetch (method #8)",'~'.expand("<slnum>")) |
482 | 2318 if g:netrw_fetch_cmd == "" |
2319 if !exists("g:netrw_quiet") | |
6476 | 2320 NetrwKeepj call netrw#ErrorMsg(s:ERROR,"fetch command not available",7) |
482 | 2321 endif |
559 | 2322 " call Dret("NetRead") |
3456 | 2323 return |
482 | 2324 endif |
5734 | 2325 if exists("g:netrw_option") && g:netrw_option =~ ":https\=" |
482 | 2326 let netrw_option= "http" |
2327 else | |
2328 let netrw_option= "ftp" | |
2329 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2330 " call Decho("read via fetch for ".netrw_option,'~'.expand("<slnum>")) |
719 | 2331 |
1621 | 2332 if exists("g:netrw_uid") && g:netrw_uid != "" && exists("s:netrw_passwd") && s:netrw_passwd != "" |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2333 call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_fetch_cmd." ".s:ShellEscape(tmpfile,1)." ".s:ShellEscape(netrw_option."://".g:netrw_uid.':'.s:netrw_passwd.'@'.g:netrw_machine."/".b:netrw_fname,1)) |
482 | 2334 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2335 call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_fetch_cmd." ".s:ShellEscape(tmpfile,1)." ".s:ShellEscape(netrw_option."://".g:netrw_machine."/".b:netrw_fname,1)) |
1621 | 2336 endif |
2337 | |
2338 let result = s:NetrwGetFile(readcmd,tmpfile, b:netrw_method) | |
482 | 2339 let b:netrw_lastfile = choice |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2340 " call Decho("setl ro",'~'.expand("<slnum>")) |
5929 | 2341 setl ro nomod |
719 | 2342 |
482 | 2343 "......................................... |
2034 | 2344 " NetRead: (sftp) NetRead Method #9 {{{3 |
650 | 2345 elseif b:netrw_method == 9 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2346 " call Decho("read via sftp (method #9)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2347 call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_sftp_cmd." ".s:ShellEscape(g:netrw_machine.":".b:netrw_fname,1)." ".tmpfile) |
1621 | 2348 let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) |
482 | 2349 let b:netrw_lastfile = choice |
719 | 2350 |
482 | 2351 "......................................... |
6476 | 2352 " NetRead: (file) NetRead Method #10 {{{3 |
2353 elseif b:netrw_method == 10 && exists("g:netrw_file_cmd") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2354 " " call Decho("read via ".b:netrw_file_cmd." (method #10)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2355 call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_file_cmd." ".s:ShellEscape(b:netrw_fname,1)." ".tmpfile) |
6476 | 2356 let result = s:NetrwGetFile(readcmd, tmpfile, b:netrw_method) |
2357 let b:netrw_lastfile = choice | |
2358 | |
2359 "......................................... | |
2034 | 2360 " NetRead: Complain {{{3 |
650 | 2361 else |
1121 | 2362 call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . choice . ">",8) |
482 | 2363 endif |
2364 endwhile | |
719 | 2365 |
2034 | 2366 " NetRead: cleanup {{{3 |
482 | 2367 if exists("b:netrw_method") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2368 " call Decho("cleanup b:netrw_method and b:netrw_fname",'~'.expand("<slnum>")) |
482 | 2369 unlet b:netrw_method |
2370 unlet b:netrw_fname | |
2371 endif | |
2420
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
2372 if s:FileReadable(tmpfile) && tmpfile !~ '.tar.bz2$' && tmpfile !~ '.tar.gz$' && tmpfile !~ '.zip' && tmpfile !~ '.tar' && readcmd != 't' && tmpfile !~ '.tar.xz$' && tmpfile !~ '.txz' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2373 " call Decho("cleanup by deleting tmpfile<".tmpfile.">",'~'.expand("<slnum>")) |
6476 | 2374 NetrwKeepj call s:NetrwDelete(tmpfile) |
2375 endif | |
17433 | 2376 NetrwKeepj call s:NetrwOptionsRestore("w:") |
1121 | 2377 |
2378 " call Dret("netrw#NetRead :5 getcwd<".getcwd().">") | |
482 | 2379 endfun |
2380 | |
2381 " ------------------------------------------------------------------------ | |
1621 | 2382 " netrw#NetWrite: responsible for writing a file over the net {{{2 |
482 | 2383 fun! netrw#NetWrite(...) range |
1121 | 2384 " call Dfunc("netrw#NetWrite(a:0=".a:0.") ".g:loaded_netrw) |
719 | 2385 |
2034 | 2386 " NetWrite: option handling {{{3 |
482 | 2387 let mod= 0 |
17433 | 2388 call s:NetrwOptionsSave("w:") |
2389 call s:NetrwOptionsSafe(0) | |
719 | 2390 |
2034 | 2391 " NetWrite: Get Temporary Filename {{{3 |
1121 | 2392 let tmpfile= s:GetTempfile("") |
2393 if tmpfile == "" | |
2394 " call Dret("netrw#NetWrite : unable to get a tempfile!") | |
482 | 2395 return |
2396 endif | |
719 | 2397 |
482 | 2398 if a:0 == 0 |
2399 let ichoice = 0 | |
2400 else | |
2401 let ichoice = 1 | |
2402 endif | |
719 | 2403 |
1121 | 2404 let curbufname= expand("%") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2405 " call Decho("curbufname<".curbufname.">",'~'.expand("<slnum>")) |
559 | 2406 if &binary |
1121 | 2407 " For binary writes, always write entire file. |
2408 " (line numbers don't really make sense for that). | |
2409 " Also supports the writing of tar and zip files. | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2410 " call Decho("(write entire file) sil exe w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile),'~'.expand("<slnum>")) |
6476 | 2411 exe "sil NetrwKeepj w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile) |
1121 | 2412 elseif g:netrw_cygwin |
2413 " write (selected portion of) file to temporary | |
5618 | 2414 let cygtmpfile= substitute(tmpfile,g:netrw_cygdrive.'/\(.\)','\1:','') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2415 " call Decho("(write selected portion) sil exe ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(cygtmpfile),'~'.expand("<slnum>")) |
6476 | 2416 exe "sil NetrwKeepj ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(cygtmpfile) |
559 | 2417 else |
2418 " write (selected portion of) file to temporary | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2419 " call Decho("(write selected portion) sil exe ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile),'~'.expand("<slnum>")) |
6476 | 2420 exe "sil NetrwKeepj ".a:firstline."," . a:lastline . "w! ".fnameescape(v:cmdarg)." ".fnameescape(tmpfile) |
559 | 2421 endif |
719 | 2422 |
1121 | 2423 if curbufname == "" |
5618 | 2424 " when the file is [No Name], and one attempts to Nwrite it, the buffer takes |
1121 | 2425 " on the temporary file's name. Deletion of the temporary file during |
2426 " cleanup then causes an error message. | |
2427 0file! | |
2428 endif | |
2429 | |
2034 | 2430 " NetWrite: while choice loop: {{{3 |
482 | 2431 while ichoice <= a:0 |
719 | 2432 |
1121 | 2433 " Process arguments: {{{4 |
482 | 2434 " attempt to repeat with previous host-file-etc |
2435 if exists("b:netrw_lastfile") && a:0 == 0 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2436 " call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">",'~'.expand("<slnum>")) |
482 | 2437 let choice = b:netrw_lastfile |
2438 let ichoice= ichoice + 1 | |
2439 else | |
2440 exe "let choice= a:" . ichoice | |
719 | 2441 |
5618 | 2442 " Reconstruct Choice when choice starts with '"' |
482 | 2443 if match(choice,"?") == 0 |
2444 echomsg 'NetWrite Usage:"' | |
2445 echomsg ':Nwrite machine:path uses rcp' | |
2446 echomsg ':Nwrite "machine path" uses ftp with <.netrc>' | |
2447 echomsg ':Nwrite "machine id password path" uses ftp' | |
2448 echomsg ':Nwrite dav://[user@]machine/path uses cadaver' | |
2449 echomsg ':Nwrite fetch://[user@]machine/path uses fetch' | |
2450 echomsg ':Nwrite ftp://machine[#port]/path uses ftp (autodetects <.netrc>)' | |
2451 echomsg ':Nwrite rcp://machine/path uses rcp' | |
2452 echomsg ':Nwrite rsync://[user@]machine/path uses rsync' | |
2453 echomsg ':Nwrite scp://[user@]machine[[:#]port]/path uses scp' | |
2454 echomsg ':Nwrite sftp://[user@]machine/path uses sftp' | |
1121 | 2455 sleep 4 |
482 | 2456 break |
719 | 2457 |
482 | 2458 elseif match(choice,"^\"") != -1 |
2459 if match(choice,"\"$") != -1 | |
2460 " case "..." | |
2461 let choice=strpart(choice,1,strlen(choice)-2) | |
2462 else | |
2463 " case "... ... ..." | |
2464 let choice = strpart(choice,1,strlen(choice)-1) | |
2465 let wholechoice = "" | |
719 | 2466 |
482 | 2467 while match(choice,"\"$") == -1 |
2468 let wholechoice= wholechoice . " " . choice | |
2469 let ichoice = ichoice + 1 | |
2470 if choice > a:0 | |
2471 if !exists("g:netrw_quiet") | |
1121 | 2472 call netrw#ErrorMsg(s:ERROR,"Unbalanced string in filename '". wholechoice ."'",13) |
482 | 2473 endif |
1121 | 2474 " call Dret("netrw#NetWrite") |
482 | 2475 return |
2476 endif | |
2477 let choice= a:{ichoice} | |
2478 endwhile | |
2479 let choice= strpart(wholechoice,1,strlen(wholechoice)-1) . " " . strpart(choice,0,strlen(choice)-1) | |
2480 endif | |
2481 endif | |
2482 endif | |
2483 let ichoice= ichoice + 1 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2484 " call Decho("choice<" . choice . "> ichoice=".ichoice,'~'.expand("<slnum>")) |
1121 | 2485 |
2486 " Determine method of write (ftp, rcp, etc) {{{4 | |
6476 | 2487 NetrwKeepj call s:NetrwMethod(choice) |
2034 | 2488 if !exists("b:netrw_method") || b:netrw_method < 0 |
2489 " call Dfunc("netrw#NetWrite : unsupported method") | |
2490 return | |
2491 endif | |
719 | 2492 |
482 | 2493 " ============= |
2034 | 2494 " NetWrite: Perform Protocol-Based Write {{{3 |
650 | 2495 " ============================ |
559 | 2496 if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1 |
2497 echo "(netrw) Processing your write request..." | |
17433 | 2498 " call Decho("Processing your write request...",'~'.expand("<slnum>")) |
559 | 2499 endif |
719 | 2500 |
482 | 2501 "......................................... |
2034 | 2502 " NetWrite: (rcp) NetWrite Method #1 {{{3 |
650 | 2503 if b:netrw_method == 1 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2504 " call Decho("write via rcp (method #1)",'~'.expand("<slnum>")) |
482 | 2505 if s:netrw_has_nt_rcp == 1 |
2506 if exists("g:netrw_uid") && ( g:netrw_uid != "" ) | |
2507 let uid_machine = g:netrw_machine .'.'. g:netrw_uid | |
2508 else | |
2509 let uid_machine = g:netrw_machine .'.'. $USERNAME | |
2510 endif | |
2511 else | |
2512 if exists("g:netrw_uid") && ( g:netrw_uid != "" ) | |
2513 let uid_machine = g:netrw_uid .'@'. g:netrw_machine | |
2514 else | |
2515 let uid_machine = g:netrw_machine | |
2516 endif | |
2517 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2518 call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".s:ShellEscape(tmpfile,1)." ".s:ShellEscape(uid_machine.":".b:netrw_fname,1)) |
482 | 2519 let b:netrw_lastfile = choice |
719 | 2520 |
482 | 2521 "......................................... |
2034 | 2522 " NetWrite: (ftp + <.netrc>) NetWrite Method #2 {{{3 |
650 | 2523 elseif b:netrw_method == 2 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2524 " call Decho("write via ftp+.netrc (method #2)",'~'.expand("<slnum>")) |
2034 | 2525 let netrw_fname = b:netrw_fname |
2526 | |
2527 " formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead | |
2528 let bhkeep = &l:bh | |
2529 let curbuf = bufnr("%") | |
4339 | 2530 setl bh=hide |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2531 keepj keepalt enew |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2532 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2533 " call Decho("filter input window#".winnr(),'~'.expand("<slnum>")) |
4339 | 2534 setl ff=unix |
6476 | 2535 NetrwKeepj put =g:netrw_ftpmode |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2536 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
1121 | 2537 if exists("g:netrw_ftpextracmd") |
6476 | 2538 NetrwKeepj put =g:netrw_ftpextracmd |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2539 " call Decho("filter input: ".getline("$"),'~'.expand("<slnum>")) |
1698 | 2540 endif |
6476 | 2541 NetrwKeepj call setline(line("$")+1,'put "'.tmpfile.'" "'.netrw_fname.'"') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2542 " call Decho("filter input: ".getline("$"),'~'.expand("<slnum>")) |
482 | 2543 if exists("g:netrw_port") && g:netrw_port != "" |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2544 call s:NetrwExe(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".s:ShellEscape(g:netrw_machine,1)." ".s:ShellEscape(g:netrw_port,1)) |
482 | 2545 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2546 " call Decho("filter input window#".winnr(),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2547 call s:NetrwExe(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".s:ShellEscape(g:netrw_machine,1)) |
482 | 2548 endif |
2549 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) | |
2550 if getline(1) !~ "^$" | |
2551 if !exists("g:netrw_quiet") | |
6476 | 2552 NetrwKeepj call netrw#ErrorMsg(s:ERROR,getline(1),14) |
482 | 2553 endif |
2554 let mod=1 | |
2555 endif | |
2034 | 2556 |
2557 " remove enew buffer (quietly) | |
2558 let filtbuf= bufnr("%") | |
2559 exe curbuf."b!" | |
2560 let &l:bh = bhkeep | |
2561 exe filtbuf."bw!" | |
2562 | |
482 | 2563 let b:netrw_lastfile = choice |
719 | 2564 |
482 | 2565 "......................................... |
2034 | 2566 " NetWrite: (ftp + machine, id, passwd, filename) NetWrite Method #3 {{{3 |
650 | 2567 elseif b:netrw_method == 3 |
2034 | 2568 " Construct execution string (three or more lines) which will be passed through filter |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2569 " call Decho("read via ftp+mipf (method #3)",'~'.expand("<slnum>")) |
2034 | 2570 let netrw_fname = b:netrw_fname |
2571 let bhkeep = &l:bh | |
2572 | |
2573 " formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead | |
2574 let curbuf = bufnr("%") | |
4339 | 2575 setl bh=hide |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2576 keepj keepalt enew |
4339 | 2577 setl ff=unix |
2034 | 2578 |
482 | 2579 if exists("g:netrw_port") && g:netrw_port != "" |
6476 | 2580 NetrwKeepj put ='open '.g:netrw_machine.' '.g:netrw_port |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2581 " call Decho("filter input: ".getline('.'),'~'.expand("<slnum>")) |
482 | 2582 else |
6476 | 2583 NetrwKeepj put ='open '.g:netrw_machine |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2584 " call Decho("filter input: ".getline('.'),'~'.expand("<slnum>")) |
482 | 2585 endif |
3456 | 2586 if exists("g:netrw_uid") && g:netrw_uid != "" |
2587 if exists("g:netrw_ftp") && g:netrw_ftp == 1 | |
6476 | 2588 NetrwKeepj put =g:netrw_uid |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2589 " call Decho("filter input: ".getline('.'),'~'.expand("<slnum>")) |
3456 | 2590 if exists("s:netrw_passwd") && s:netrw_passwd != "" |
6476 | 2591 NetrwKeepj put ='\"'.s:netrw_passwd.'\"' |
3456 | 2592 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2593 " call Decho("filter input: ".getline('.'),'~'.expand("<slnum>")) |
3456 | 2594 elseif exists("s:netrw_passwd") && s:netrw_passwd != "" |
6476 | 2595 NetrwKeepj put ='user \"'.g:netrw_uid.'\" \"'.s:netrw_passwd.'\"' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2596 " call Decho("filter input: ".getline('.'),'~'.expand("<slnum>")) |
3456 | 2597 endif |
482 | 2598 endif |
6476 | 2599 NetrwKeepj put =g:netrw_ftpmode |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2600 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
2034 | 2601 if exists("g:netrw_ftpextracmd") |
6476 | 2602 NetrwKeepj put =g:netrw_ftpextracmd |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2603 " call Decho("filter input: ".getline("$"),'~'.expand("<slnum>")) |
2034 | 2604 endif |
6476 | 2605 NetrwKeepj put ='put \"'.tmpfile.'\" \"'.netrw_fname.'\"' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2606 " call Decho("filter input: ".getline('.'),'~'.expand("<slnum>")) |
482 | 2607 " save choice/id/password for future use |
2608 let b:netrw_lastfile = choice | |
719 | 2609 |
482 | 2610 " perform ftp: |
2611 " -i : turns off interactive prompting from ftp | |
2612 " -n unix : DON'T use <.netrc>, even though it exists | |
2613 " -n win32: quit being obnoxious about password | |
6476 | 2614 NetrwKeepj norm! 1Gdd |
2615 call s:NetrwExe(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." ".g:netrw_ftp_options) | |
482 | 2616 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) |
2617 if getline(1) !~ "^$" | |
2618 if !exists("g:netrw_quiet") | |
1121 | 2619 call netrw#ErrorMsg(s:ERROR,getline(1),15) |
482 | 2620 endif |
2621 let mod=1 | |
2622 endif | |
2034 | 2623 |
2624 " remove enew buffer (quietly) | |
2625 let filtbuf= bufnr("%") | |
2626 exe curbuf."b!" | |
2627 let &l:bh= bhkeep | |
2628 exe filtbuf."bw!" | |
719 | 2629 |
482 | 2630 "......................................... |
2034 | 2631 " NetWrite: (scp) NetWrite Method #4 {{{3 |
650 | 2632 elseif b:netrw_method == 4 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2633 " call Decho("write via scp (method #4)",'~'.expand("<slnum>")) |
482 | 2634 if exists("g:netrw_port") && g:netrw_port != "" |
1668 | 2635 let useport= " ".g:netrw_scpport." ".fnameescape(g:netrw_port) |
482 | 2636 else |
2637 let useport= "" | |
2638 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2639 call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".s:ShellEscape(tmpfile,1)." ".s:ShellEscape(g:netrw_machine.":".b:netrw_fname,1)) |
482 | 2640 let b:netrw_lastfile = choice |
719 | 2641 |
482 | 2642 "......................................... |
2034 | 2643 " NetWrite: (http) NetWrite Method #5 {{{3 |
482 | 2644 elseif b:netrw_method == 5 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2645 " call Decho("write via http (method #5)",'~'.expand("<slnum>")) |
5618 | 2646 let curl= substitute(g:netrw_http_put_cmd,'\s\+.*$',"","") |
2647 if executable(curl) | |
2648 let url= g:netrw_choice | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2649 call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_http_put_cmd." ".s:ShellEscape(tmpfile,1)." ".s:ShellEscape(url,1) ) |
5618 | 2650 elseif !exists("g:netrw_quiet") |
17433 | 2651 call netrw#ErrorMsg(s:ERROR,"can't write to http using <".g:netrw_http_put_cmd.">".",16) |
482 | 2652 endif |
719 | 2653 |
482 | 2654 "......................................... |
2034 | 2655 " NetWrite: (dav) NetWrite Method #6 (cadaver) {{{3 |
650 | 2656 elseif b:netrw_method == 6 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2657 " call Decho("write via cadaver (method #6)",'~'.expand("<slnum>")) |
719 | 2658 |
482 | 2659 " Construct execution string (four lines) which will be passed through filter |
2034 | 2660 let netrw_fname = escape(b:netrw_fname,g:netrw_fname_escape) |
2661 let bhkeep = &l:bh | |
2662 | |
2663 " formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead | |
2664 let curbuf = bufnr("%") | |
4339 | 2665 setl bh=hide |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2666 keepj keepalt enew |
4339 | 2667 |
2668 setl ff=unix | |
482 | 2669 if exists("g:netrw_port") && g:netrw_port != "" |
6476 | 2670 NetrwKeepj put ='open '.g:netrw_machine.' '.g:netrw_port |
482 | 2671 else |
6476 | 2672 NetrwKeepj put ='open '.g:netrw_machine |
482 | 2673 endif |
3456 | 2674 if exists("g:netrw_uid") && exists("s:netrw_passwd") && g:netrw_uid != "" |
6476 | 2675 NetrwKeepj put ='user '.g:netrw_uid.' '.s:netrw_passwd |
2676 endif | |
2677 NetrwKeepj put ='put '.tmpfile.' '.netrw_fname | |
719 | 2678 |
482 | 2679 " perform cadaver operation: |
6476 | 2680 NetrwKeepj norm! 1Gdd |
2681 call s:NetrwExe(s:netrw_silentxfer."%!".g:netrw_dav_cmd) | |
2034 | 2682 |
2683 " remove enew buffer (quietly) | |
2684 let filtbuf= bufnr("%") | |
2685 exe curbuf."b!" | |
2686 let &l:bh = bhkeep | |
2687 exe filtbuf."bw!" | |
2688 | |
482 | 2689 let b:netrw_lastfile = choice |
719 | 2690 |
482 | 2691 "......................................... |
2034 | 2692 " NetWrite: (rsync) NetWrite Method #7 {{{3 |
650 | 2693 elseif b:netrw_method == 7 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2694 " call Decho("write via rsync (method #7)",'~'.expand("<slnum>")) |
17433 | 2695 call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_rsync_cmd." ".s:ShellEscape(tmpfile,1)." ".s:ShellEscape(g:netrw_machine.g:netrw_rsync_sep.b:netrw_fname,1)) |
482 | 2696 let b:netrw_lastfile = choice |
719 | 2697 |
482 | 2698 "......................................... |
2034 | 2699 " NetWrite: (sftp) NetWrite Method #9 {{{3 |
650 | 2700 elseif b:netrw_method == 9 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2701 " call Decho("write via sftp (method #9)",'~'.expand("<slnum>")) |
719 | 2702 let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape) |
482 | 2703 if exists("g:netrw_uid") && ( g:netrw_uid != "" ) |
2704 let uid_machine = g:netrw_uid .'@'. g:netrw_machine | |
2705 else | |
2706 let uid_machine = g:netrw_machine | |
2707 endif | |
2034 | 2708 |
2709 " formerly just a "new...bd!", that changed the window sizes when equalalways. Using enew workaround instead | |
2710 let bhkeep = &l:bh | |
2711 let curbuf = bufnr("%") | |
4339 | 2712 setl bh=hide |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2713 keepj keepalt enew |
4339 | 2714 |
2715 setl ff=unix | |
2034 | 2716 call setline(1,'put "'.escape(tmpfile,'\').'" '.netrw_fname) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2717 " call Decho("filter input: ".getline('.'),'~'.expand("<slnum>")) |
3920 | 2718 let sftpcmd= substitute(g:netrw_sftp_cmd,"%TEMPFILE%",escape(tmpfile,'\'),"g") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2719 call s:NetrwExe(s:netrw_silentxfer."%!".sftpcmd.' '.s:ShellEscape(uid_machine,1)) |
2034 | 2720 let filtbuf= bufnr("%") |
2721 exe curbuf."b!" | |
2722 let &l:bh = bhkeep | |
2723 exe filtbuf."bw!" | |
2724 let b:netrw_lastfile = choice | |
719 | 2725 |
482 | 2726 "......................................... |
2034 | 2727 " NetWrite: Complain {{{3 |
650 | 2728 else |
1121 | 2729 call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . choice . ">",17) |
2751 | 2730 let leavemod= 1 |
482 | 2731 endif |
2732 endwhile | |
719 | 2733 |
2034 | 2734 " NetWrite: Cleanup: {{{3 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2735 " call Decho("cleanup",'~'.expand("<slnum>")) |
1121 | 2736 if s:FileReadable(tmpfile) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2737 " call Decho("tmpfile<".tmpfile."> readable, will now delete it",'~'.expand("<slnum>")) |
1668 | 2738 call s:NetrwDelete(tmpfile) |
1121 | 2739 endif |
17433 | 2740 call s:NetrwOptionsRestore("w:") |
719 | 2741 |
482 | 2742 if a:firstline == 1 && a:lastline == line("$") |
1121 | 2743 " restore modifiability; usually equivalent to set nomod |
2744 let &mod= mod | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2745 " call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
2751 | 2746 elseif !exists("leavemod") |
2747 " indicate that the buffer has not been modified since last written | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2748 " call Decho("set nomod",'~'.expand("<slnum>")) |
5734 | 2749 setl nomod |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2750 " call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
2751 | 2751 endif |
2752 | |
1121 | 2753 " call Dret("netrw#NetWrite") |
482 | 2754 endfun |
2755 | |
519 | 2756 " --------------------------------------------------------------------- |
1621 | 2757 " netrw#NetSource: source a remotely hosted vim script {{{2 |
1121 | 2758 " uses NetRead to get a copy of the file into a temporarily file, |
2759 " then sources that file, | |
2760 " then removes that file. | |
2761 fun! netrw#NetSource(...) | |
2762 " call Dfunc("netrw#NetSource() a:0=".a:0) | |
2763 if a:0 > 0 && a:1 == '?' | |
2764 " give help | |
2765 echomsg 'NetSource Usage:' | |
2766 echomsg ':Nsource dav://machine[:port]/path uses cadaver' | |
2767 echomsg ':Nsource fetch://machine/path uses fetch' | |
2768 echomsg ':Nsource ftp://[user@]machine[:port]/path uses ftp autodetects <.netrc>' | |
3153 | 2769 echomsg ':Nsource http[s]://[user@]machine/path uses http wget' |
1121 | 2770 echomsg ':Nsource rcp://[user@]machine/path uses rcp' |
2771 echomsg ':Nsource rsync://machine[:port]/path uses rsync' | |
2772 echomsg ':Nsource scp://[user@]machine[[:#]port]/path uses scp' | |
2773 echomsg ':Nsource sftp://[user@]machine[[:#]port]/path uses sftp' | |
2774 sleep 4 | |
650 | 2775 else |
1121 | 2776 let i= 1 |
2777 while i <= a:0 | |
2778 call netrw#NetRead(3,a:{i}) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2779 " call Decho("s:netread_tmpfile<".s:netrw_tmpfile.">",'~'.expand("<slnum>")) |
1121 | 2780 if s:FileReadable(s:netrw_tmpfile) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2781 " call Decho("exe so ".fnameescape(s:netrw_tmpfile),'~'.expand("<slnum>")) |
1698 | 2782 exe "so ".fnameescape(s:netrw_tmpfile) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2783 " call Decho("delete(".s:netrw_tmpfile.")",'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
2784 if delete(s:netrw_tmpfile) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
2785 call netrw#ErrorMsg(s:ERROR,"unable to delete directory <".s:netrw_tmpfile.">!",103) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
2786 endif |
1121 | 2787 unlet s:netrw_tmpfile |
2788 else | |
2789 call netrw#ErrorMsg(s:ERROR,"unable to source <".a:{i}.">!",48) | |
719 | 2790 endif |
1121 | 2791 let i= i + 1 |
2792 endwhile | |
719 | 2793 endif |
1121 | 2794 " call Dret("netrw#NetSource") |
482 | 2795 endfun |
2796 | |
5618 | 2797 " --------------------------------------------------------------------- |
5734 | 2798 " netrw#SetTreetop: resets the tree top to the current directory/specified directory {{{2 |
2799 " (implements the :Ntree command) | |
17433 | 2800 fun! netrw#SetTreetop(iscmd,...) |
2801 " call Dfunc("netrw#SetTreetop(iscmd=".a:iscmd." ".((a:0 > 0)? a:1 : "").") a:0=".a:0) | |
2802 " call Decho("w:netrw_treetop<".w:netrw_treetop.">") | |
2803 | |
2804 " iscmd==0: netrw#SetTreetop called using gn mapping | |
2805 " iscmd==1: netrw#SetTreetop called using :Ntree from the command line | |
2806 " call Decho("(iscmd=".a:iscmd.": called using :Ntree from command line",'~'.expand("<slnum>")) | |
5618 | 2807 " clear out the current tree |
2808 if exists("w:netrw_treetop") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2809 " call Decho("clearing out current tree",'~'.expand("<slnum>")) |
5618 | 2810 let inittreetop= w:netrw_treetop |
2811 unlet w:netrw_treetop | |
2812 endif | |
2813 if exists("w:netrw_treedict") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2814 " call Decho("freeing w:netrw_treedict",'~'.expand("<slnum>")) |
5618 | 2815 unlet w:netrw_treedict |
2816 endif | |
17433 | 2817 " call Decho("inittreetop<".(exists("inittreetop")? inittreetop : "n/a").">") |
2818 | |
2819 if (a:iscmd == 0 || a:1 == "") && exists("inittreetop") | |
5618 | 2820 let treedir= s:NetrwTreePath(inittreetop) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2821 " call Decho("treedir<".treedir.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2822 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2823 if isdirectory(s:NetrwFile(a:1)) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2824 " call Decho("a:1<".a:1."> is a directory",'~'.expand("<slnum>")) |
5618 | 2825 let treedir= a:1 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2826 elseif exists("b:netrw_curdir") && (isdirectory(s:NetrwFile(b:netrw_curdir."/".a:1)) || a:1 =~ '^\a\{3,}://') |
5618 | 2827 let treedir= b:netrw_curdir."/".a:1 |
17433 | 2828 " call Decho("a:1<".a:1."> is NOT a directory, using treedir<".treedir.">",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2829 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2830 " normally the cursor is left in the message window. |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2831 " However, here this results in the directory being listed in the message window, which is not wanted. |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2832 let netrwbuf= bufnr("%") |
5618 | 2833 call netrw#ErrorMsg(s:ERROR,"sorry, ".a:1." doesn't seem to be a directory!",95) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2834 exe bufwinnr(netrwbuf)."wincmd w" |
5734 | 2835 let treedir= "." |
5618 | 2836 endif |
2837 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2838 " call Decho("treedir<".treedir.">",'~'.expand("<slnum>")) |
17433 | 2839 |
2840 " determine if treedir is remote or local | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2841 let islocal= expand("%") !~ '^\a\{3,}://' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2842 " call Decho("islocal=".islocal,'~'.expand("<slnum>")) |
17433 | 2843 |
2844 " browse the resulting directory | |
5734 | 2845 if islocal |
2846 call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(islocal,treedir)) | |
2847 else | |
2848 call s:NetrwBrowse(islocal,s:NetrwBrowseChgDir(islocal,treedir)) | |
2849 endif | |
17433 | 2850 |
5734 | 2851 " call Dret("netrw#SetTreetop") |
5618 | 2852 endfun |
2853 | |
1121 | 2854 " =========================================== |
1621 | 2855 " s:NetrwGetFile: Function to read temporary file "tfile" with command "readcmd". {{{2 |
1121 | 2856 " readcmd == %r : replace buffer with newly read file |
2857 " == 0r : read file at top of buffer | |
2858 " == r : read file after current line | |
2859 " == t : leave file in temporary form (ie. don't read into buffer) | |
1621 | 2860 fun! s:NetrwGetFile(readcmd, tfile, method) |
2861 " call Dfunc("NetrwGetFile(readcmd<".a:readcmd.">,tfile<".a:tfile."> method<".a:method.">)") | |
1121 | 2862 |
2863 " readcmd=='t': simply do nothing | |
2864 if a:readcmd == 't' | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2865 " call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
1621 | 2866 " call Dret("NetrwGetFile : skip read of <".a:tfile.">") |
482 | 2867 return |
2868 endif | |
2869 | |
1121 | 2870 " get name of remote filename (ie. url and all) |
2871 let rfile= bufname("%") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2872 " call Decho("rfile<".rfile.">",'~'.expand("<slnum>")) |
1121 | 2873 |
2874 if exists("*NetReadFixup") | |
2875 " for the use of NetReadFixup (not otherwise used internally) | |
2876 let line2= line("$") | |
482 | 2877 endif |
2878 | |
1121 | 2879 if a:readcmd[0] == '%' |
2880 " get file into buffer | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2881 " call Decho("get file into buffer",'~'.expand("<slnum>")) |
1121 | 2882 |
2883 " rename the current buffer to the temp file (ie. tfile) | |
2884 if g:netrw_cygwin | |
5618 | 2885 let tfile= substitute(a:tfile,g:netrw_cygdrive.'/\(.\)','\1:','') |
482 | 2886 else |
1121 | 2887 let tfile= a:tfile |
482 | 2888 endif |
17433 | 2889 call s:NetrwBufRename(tfile) |
1121 | 2890 |
2891 " edit temporary file (ie. read the temporary file in) | |
2892 if rfile =~ '\.zip$' | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2893 " call Decho("handling remote zip file with zip#Browse(tfile<".tfile.">)",'~'.expand("<slnum>")) |
1121 | 2894 call zip#Browse(tfile) |
2895 elseif rfile =~ '\.tar$' | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2896 " call Decho("handling remote tar file with tar#Browse(tfile<".tfile.">)",'~'.expand("<slnum>")) |
1121 | 2897 call tar#Browse(tfile) |
2420
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
2898 elseif rfile =~ '\.tar\.gz$' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2899 " call Decho("handling remote gzip-compressed tar file",'~'.expand("<slnum>")) |
1121 | 2900 call tar#Browse(tfile) |
2420
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
2901 elseif rfile =~ '\.tar\.bz2$' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2902 " call Decho("handling remote bz2-compressed tar file",'~'.expand("<slnum>")) |
1121 | 2903 call tar#Browse(tfile) |
2420
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
2904 elseif rfile =~ '\.tar\.xz$' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2905 " call Decho("handling remote xz-compressed tar file",'~'.expand("<slnum>")) |
2420
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
2906 call tar#Browse(tfile) |
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
2907 elseif rfile =~ '\.txz$' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2908 " call Decho("handling remote xz-compressed tar file (.txz)",'~'.expand("<slnum>")) |
2420
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
2909 call tar#Browse(tfile) |
482 | 2910 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2911 " call Decho("edit temporary file",'~'.expand("<slnum>")) |
6476 | 2912 NetrwKeepj e! |
482 | 2913 endif |
2914 | |
1121 | 2915 " rename buffer back to remote filename |
17433 | 2916 call s:NetrwBufRename(rfile) |
3456 | 2917 |
3920 | 2918 " Detect filetype of local version of remote file. |
3456 | 2919 " Note that isk must not include a "/" for scripts.vim |
2920 " to process this detection correctly. | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2921 " call Decho("detect filetype of local version of remote file",'~'.expand("<slnum>")) |
3920 | 2922 let iskkeep= &l:isk |
2923 setl isk-=/ | |
2924 let &l:isk= iskkeep | |
17433 | 2925 " call Dredir("ls!","NetrwGetFile (renamed buffer back to remote filename<".rfile."> : expand(%)<".expand("%").">)") |
1121 | 2926 let line1 = 1 |
2927 let line2 = line("$") | |
2928 | |
5618 | 2929 elseif !&ma |
2930 " attempting to read a file after the current line in the file, but the buffer is not modifiable | |
6476 | 2931 NetrwKeepj call netrw#ErrorMsg(s:WARNING,"attempt to read<".a:tfile."> into a non-modifiable buffer!",94) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2932 " call Dret("NetrwGetFile : attempt to read<".a:tfile."> into a non-modifiable buffer!") |
5618 | 2933 return |
2934 | |
1121 | 2935 elseif s:FileReadable(a:tfile) |
2936 " read file after current line | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2937 " call Decho("read file<".a:tfile."> after current line",'~'.expand("<slnum>")) |
1121 | 2938 let curline = line(".") |
2939 let lastline= line("$") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2940 " call Decho("exe<".a:readcmd." ".fnameescape(v:cmdarg)." ".fnameescape(a:tfile)."> line#".curline,'~'.expand("<slnum>")) |
6476 | 2941 exe "NetrwKeepj ".a:readcmd." ".fnameescape(v:cmdarg)." ".fnameescape(a:tfile) |
1121 | 2942 let line1= curline + 1 |
2943 let line2= line("$") - lastline + 1 | |
482 | 2944 |
2945 else | |
1121 | 2946 " not readable |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2947 " call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2948 " call Decho("tfile<".a:tfile."> not readable",'~'.expand("<slnum>")) |
6476 | 2949 NetrwKeepj call netrw#ErrorMsg(s:WARNING,"file <".a:tfile."> not readable",9) |
1621 | 2950 " call Dret("NetrwGetFile : tfile<".a:tfile."> not readable") |
1121 | 2951 return |
482 | 2952 endif |
2953 | |
1121 | 2954 " User-provided (ie. optional) fix-it-up command |
2955 if exists("*NetReadFixup") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2956 " call Decho("calling NetReadFixup(method<".a:method."> line1=".line1." line2=".line2.")",'~'.expand("<slnum>")) |
6476 | 2957 NetrwKeepj call NetReadFixup(a:method, line1, line2) |
1121 | 2958 " else " Decho |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2959 " call Decho("NetReadFixup() not called, doesn't exist (line1=".line1." line2=".line2.")",'~'.expand("<slnum>")) |
766 | 2960 endif |
2961 | |
2751 | 2962 if has("gui") && has("menu") && has("gui_running") && &go =~# 'm' && g:netrw_menu |
1621 | 2963 " update the Buffers menu |
6476 | 2964 NetrwKeepj call s:UpdateBuffersMenu() |
766 | 2965 endif |
2966 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2967 " call Decho("readcmd<".a:readcmd."> cmdarg<".v:cmdarg."> tfile<".a:tfile."> readable=".s:FileReadable(a:tfile),'~'.expand("<slnum>")) |
1121 | 2968 |
2969 " make sure file is being displayed | |
1621 | 2970 " redraw! |
2971 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2972 " call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
1621 | 2973 " call Dret("NetrwGetFile") |
482 | 2974 endfun |
2975 | |
1121 | 2976 " ------------------------------------------------------------------------ |
1621 | 2977 " s:NetrwMethod: determine method of transfer {{{2 |
2034 | 2978 " Input: |
2979 " choice = url [protocol:]//[userid@]hostname[:port]/[path-to-file] | |
2980 " Output: | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2981 " b:netrw_method= 1: rcp |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2982 " 2: ftp + <.netrc> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2983 " 3: ftp + machine, id, password, and [path]filename |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2984 " 4: scp |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2985 " 5: http[s] (wget) |
2034 | 2986 " 6: dav |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2987 " 7: rsync |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2988 " 8: fetch |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
2989 " 9: sftp |
6476 | 2990 " 10: file |
2034 | 2991 " g:netrw_machine= hostname |
2992 " b:netrw_fname = filename | |
2993 " g:netrw_port = optional port number (for ftp) | |
2994 " g:netrw_choice = copy of input url (choice) | |
2995 fun! s:NetrwMethod(choice) | |
17433 | 2996 " call Dfunc("s:NetrwMethod(a:choice<".a:choice.">)") |
719 | 2997 |
2908 | 2998 " sanity check: choice should have at least three slashes in it |
2999 if strlen(substitute(a:choice,'[^/]','','g')) < 3 | |
3000 call netrw#ErrorMsg(s:ERROR,"not a netrw-style url; netrw uses protocol://[user@]hostname[:port]/[path])",78) | |
3001 let b:netrw_method = -1 | |
17433 | 3002 " call Dret("s:NetrwMethod : incorrect url format<".a:choice.">") |
2908 | 3003 return |
3004 endif | |
3005 | |
2034 | 3006 " record current g:netrw_machine, if any |
3007 " curmachine used if protocol == ftp and no .netrc | |
3008 if exists("g:netrw_machine") | |
3009 let curmachine= g:netrw_machine | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3010 " call Decho("curmachine<".curmachine.">",'~'.expand("<slnum>")) |
2034 | 3011 else |
3012 let curmachine= "N O T A HOST" | |
3013 endif | |
2751 | 3014 if exists("g:netrw_port") |
3015 let netrw_port= g:netrw_port | |
3016 endif | |
3017 | |
3018 " insure that netrw_ftp_cmd starts off every method determination | |
3019 " with the current g:netrw_ftp_cmd | |
3020 let s:netrw_ftp_cmd= g:netrw_ftp_cmd | |
2034 | 3021 |
482 | 3022 " initialization |
3023 let b:netrw_method = 0 | |
3024 let g:netrw_machine = "" | |
3025 let b:netrw_fname = "" | |
3026 let g:netrw_port = "" | |
719 | 3027 let g:netrw_choice = a:choice |
3028 | |
482 | 3029 " Patterns: |
3030 " mipf : a:machine a:id password filename Use ftp | |
1621 | 3031 " mf : a:machine filename Use ftp + <.netrc> or g:netrw_uid s:netrw_passwd |
3032 " ftpurm : ftp://[user@]host[[#:]port]/filename Use ftp + <.netrc> or g:netrw_uid s:netrw_passwd | |
482 | 3033 " rcpurm : rcp://[user@]host/filename Use rcp |
3034 " rcphf : [user@]host:filename Use rcp | |
3035 " scpurm : scp://[user@]host[[#:]port]/filename Use scp | |
3153 | 3036 " httpurm : http[s]://[user@]host/filename Use wget |
2034 | 3037 " davurm : dav[s]://host[:port]/path Use cadaver/curl |
482 | 3038 " rsyncurm : rsync://host[:port]/path Use rsync |
3039 " fetchurm : fetch://[user@]host[:http]/filename Use fetch (defaults to ftp, override for http) | |
3040 " sftpurm : sftp://[user@]host/filename Use scp | |
6476 | 3041 " fileurm : file://[user@]host/filename Use elinks or links |
482 | 3042 let mipf = '^\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)$' |
3043 let mf = '^\(\S\+\)\s\+\(\S\+\)$' | |
3153 | 3044 let ftpurm = '^ftp://\(\([^/]*\)@\)\=\([^/#:]\{-}\)\([#:]\d\+\)\=/\(.*\)$' |
3045 let rcpurm = '^rcp://\%(\([^/]*\)@\)\=\([^/]\{-}\)/\(.*\)$' | |
482 | 3046 let rcphf = '^\(\(\h\w*\)@\)\=\(\h\w*\):\([^@]\+\)$' |
559 | 3047 let scpurm = '^scp://\([^/#:]\+\)\%([#:]\(\d\+\)\)\=/\(.*\)$' |
3153 | 3048 let httpurm = '^https\=://\([^/]\{-}\)\(/.*\)\=$' |
1621 | 3049 let davurm = '^davs\=://\([^/]\+\)/\(.*/\)\([-_.~[:alnum:]]\+\)$' |
482 | 3050 let rsyncurm = '^rsync://\([^/]\{-}\)/\(.*\)\=$' |
3153 | 3051 let fetchurm = '^fetch://\(\([^/]*\)@\)\=\([^/#:]\{-}\)\(:http\)\=/\(.*\)$' |
482 | 3052 let sftpurm = '^sftp://\([^/]\{-}\)/\(.*\)\=$' |
6476 | 3053 let fileurm = '^file\=://\(.*\)$' |
719 | 3054 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3055 " call Decho("determine method:",'~'.expand("<slnum>")) |
482 | 3056 " Determine Method |
2751 | 3057 " Method#1: rcp://user@hostname/...path-to-file {{{3 |
482 | 3058 if match(a:choice,rcpurm) == 0 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3059 " call Decho("rcp://...",'~'.expand("<slnum>")) |
482 | 3060 let b:netrw_method = 1 |
3061 let userid = substitute(a:choice,rcpurm,'\1',"") | |
3062 let g:netrw_machine = substitute(a:choice,rcpurm,'\2',"") | |
3063 let b:netrw_fname = substitute(a:choice,rcpurm,'\3',"") | |
3064 if userid != "" | |
3065 let g:netrw_uid= userid | |
3066 endif | |
719 | 3067 |
2751 | 3068 " Method#4: scp://user@hostname/...path-to-file {{{3 |
482 | 3069 elseif match(a:choice,scpurm) == 0 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3070 " call Decho("scp://...",'~'.expand("<slnum>")) |
519 | 3071 let b:netrw_method = 4 |
482 | 3072 let g:netrw_machine = substitute(a:choice,scpurm,'\1',"") |
3073 let g:netrw_port = substitute(a:choice,scpurm,'\2',"") | |
3074 let b:netrw_fname = substitute(a:choice,scpurm,'\3',"") | |
719 | 3075 |
3153 | 3076 " Method#5: http[s]://user@hostname/...path-to-file {{{3 |
482 | 3077 elseif match(a:choice,httpurm) == 0 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3078 " call Decho("http[s]://...",'~'.expand("<slnum>")) |
482 | 3079 let b:netrw_method = 5 |
3080 let g:netrw_machine= substitute(a:choice,httpurm,'\1',"") | |
3081 let b:netrw_fname = substitute(a:choice,httpurm,'\2',"") | |
5734 | 3082 let b:netrw_http = (a:choice =~ '^https:')? "https" : "http" |
719 | 3083 |
2751 | 3084 " Method#6: dav://hostname[:port]/..path-to-file.. {{{3 |
482 | 3085 elseif match(a:choice,davurm) == 0 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3086 " call Decho("dav://...",'~'.expand("<slnum>")) |
482 | 3087 let b:netrw_method= 6 |
3153 | 3088 if a:choice =~ 'davs:' |
482 | 3089 let g:netrw_machine= 'https://'.substitute(a:choice,davurm,'\1/\2',"") |
3090 else | |
3091 let g:netrw_machine= 'http://'.substitute(a:choice,davurm,'\1/\2',"") | |
3092 endif | |
3093 let b:netrw_fname = substitute(a:choice,davurm,'\3',"") | |
719 | 3094 |
2751 | 3095 " Method#7: rsync://user@hostname/...path-to-file {{{3 |
482 | 3096 elseif match(a:choice,rsyncurm) == 0 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3097 " call Decho("rsync://...",'~'.expand("<slnum>")) |
482 | 3098 let b:netrw_method = 7 |
3099 let g:netrw_machine= substitute(a:choice,rsyncurm,'\1',"") | |
3100 let b:netrw_fname = substitute(a:choice,rsyncurm,'\2',"") | |
719 | 3101 |
2751 | 3102 " Methods 2,3: ftp://[user@]hostname[[:#]port]/...path-to-file {{{3 |
482 | 3103 elseif match(a:choice,ftpurm) == 0 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3104 " call Decho("ftp://...",'~'.expand("<slnum>")) |
519 | 3105 let userid = substitute(a:choice,ftpurm,'\2',"") |
482 | 3106 let g:netrw_machine= substitute(a:choice,ftpurm,'\3',"") |
3107 let g:netrw_port = substitute(a:choice,ftpurm,'\4',"") | |
3108 let b:netrw_fname = substitute(a:choice,ftpurm,'\5',"") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3109 " call Decho("g:netrw_machine<".g:netrw_machine.">",'~'.expand("<slnum>")) |
482 | 3110 if userid != "" |
3111 let g:netrw_uid= userid | |
3112 endif | |
3456 | 3113 |
2751 | 3114 if curmachine != g:netrw_machine |
17433 | 3115 if exists("s:netrw_hup[".g:netrw_machine."]") |
3456 | 3116 call NetUserPass("ftp:".g:netrw_machine) |
3117 elseif exists("s:netrw_passwd") | |
2751 | 3118 " if there's a change in hostname, require password re-entry |
3119 unlet s:netrw_passwd | |
3120 endif | |
3121 if exists("netrw_port") | |
3122 unlet netrw_port | |
3123 endif | |
2034 | 3124 endif |
3456 | 3125 |
1621 | 3126 if exists("g:netrw_uid") && exists("s:netrw_passwd") |
482 | 3127 let b:netrw_method = 3 |
3128 else | |
3456 | 3129 let host= substitute(g:netrw_machine,'\..*$','','') |
3130 if exists("s:netrw_hup[host]") | |
3131 call NetUserPass("ftp:".host) | |
3132 | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
3133 elseif (has("win32") || has("win95") || has("win64") || has("win16")) && s:netrw_ftp_cmd =~# '-[sS]:' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3134 " call Decho("has -s: : s:netrw_ftp_cmd<".s:netrw_ftp_cmd.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3135 " call Decho(" g:netrw_ftp_cmd<".g:netrw_ftp_cmd.">",'~'.expand("<slnum>")) |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
3136 if g:netrw_ftp_cmd =~# '-[sS]:\S*MACHINE\>' |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
3137 let s:netrw_ftp_cmd= substitute(g:netrw_ftp_cmd,'\<MACHINE\>',g:netrw_machine,'') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3138 " call Decho("s:netrw_ftp_cmd<".s:netrw_ftp_cmd.">",'~'.expand("<slnum>")) |
2751 | 3139 endif |
3140 let b:netrw_method= 2 | |
3141 elseif s:FileReadable(expand("$HOME/.netrc")) && !g:netrw_ignorenetrc | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3142 " call Decho("using <".expand("$HOME/.netrc")."> (readable)",'~'.expand("<slnum>")) |
482 | 3143 let b:netrw_method= 2 |
3144 else | |
3145 if !exists("g:netrw_uid") || g:netrw_uid == "" | |
3146 call NetUserPass() | |
1621 | 3147 elseif !exists("s:netrw_passwd") || s:netrw_passwd == "" |
482 | 3148 call NetUserPass(g:netrw_uid) |
1621 | 3149 " else just use current g:netrw_uid and s:netrw_passwd |
482 | 3150 endif |
3151 let b:netrw_method= 3 | |
3152 endif | |
3153 endif | |
719 | 3154 |
2751 | 3155 " Method#8: fetch {{{3 |
482 | 3156 elseif match(a:choice,fetchurm) == 0 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3157 " call Decho("fetch://...",'~'.expand("<slnum>")) |
482 | 3158 let b:netrw_method = 8 |
3159 let g:netrw_userid = substitute(a:choice,fetchurm,'\2',"") | |
3160 let g:netrw_machine= substitute(a:choice,fetchurm,'\3',"") | |
3161 let b:netrw_option = substitute(a:choice,fetchurm,'\4',"") | |
3162 let b:netrw_fname = substitute(a:choice,fetchurm,'\5',"") | |
719 | 3163 |
2751 | 3164 " Method#3: Issue an ftp : "machine id password [path/]filename" {{{3 |
482 | 3165 elseif match(a:choice,mipf) == 0 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3166 " call Decho("(ftp) host id pass file",'~'.expand("<slnum>")) |
482 | 3167 let b:netrw_method = 3 |
3168 let g:netrw_machine = substitute(a:choice,mipf,'\1',"") | |
3169 let g:netrw_uid = substitute(a:choice,mipf,'\2',"") | |
1621 | 3170 let s:netrw_passwd = substitute(a:choice,mipf,'\3',"") |
482 | 3171 let b:netrw_fname = substitute(a:choice,mipf,'\4',"") |
3456 | 3172 call NetUserPass(g:netrw_machine,g:netrw_uid,s:netrw_passwd) |
719 | 3173 |
2751 | 3174 " Method#3: Issue an ftp: "hostname [path/]filename" {{{3 |
482 | 3175 elseif match(a:choice,mf) == 0 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3176 " call Decho("(ftp) host file",'~'.expand("<slnum>")) |
1621 | 3177 if exists("g:netrw_uid") && exists("s:netrw_passwd") |
482 | 3178 let b:netrw_method = 3 |
3179 let g:netrw_machine = substitute(a:choice,mf,'\1',"") | |
3180 let b:netrw_fname = substitute(a:choice,mf,'\2',"") | |
719 | 3181 |
1121 | 3182 elseif s:FileReadable(expand("$HOME/.netrc")) |
482 | 3183 let b:netrw_method = 2 |
3184 let g:netrw_machine = substitute(a:choice,mf,'\1',"") | |
3185 let b:netrw_fname = substitute(a:choice,mf,'\2',"") | |
3186 endif | |
719 | 3187 |
2751 | 3188 " Method#9: sftp://user@hostname/...path-to-file {{{3 |
482 | 3189 elseif match(a:choice,sftpurm) == 0 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3190 " call Decho("sftp://...",'~'.expand("<slnum>")) |
482 | 3191 let b:netrw_method = 9 |
3192 let g:netrw_machine= substitute(a:choice,sftpurm,'\1',"") | |
3193 let b:netrw_fname = substitute(a:choice,sftpurm,'\2',"") | |
719 | 3194 |
2751 | 3195 " Method#1: Issue an rcp: hostname:filename" (this one should be last) {{{3 |
482 | 3196 elseif match(a:choice,rcphf) == 0 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3197 " call Decho("(rcp) [user@]host:file) rcphf<".rcphf.">",'~'.expand("<slnum>")) |
1621 | 3198 let b:netrw_method = 1 |
3199 let userid = substitute(a:choice,rcphf,'\2',"") | |
3200 let g:netrw_machine = substitute(a:choice,rcphf,'\3',"") | |
3201 let b:netrw_fname = substitute(a:choice,rcphf,'\4',"") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3202 " call Decho('\1<'.substitute(a:choice,rcphf,'\1',"").">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3203 " call Decho('\2<'.substitute(a:choice,rcphf,'\2',"").">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3204 " call Decho('\3<'.substitute(a:choice,rcphf,'\3',"").">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3205 " call Decho('\4<'.substitute(a:choice,rcphf,'\4',"").">",'~'.expand("<slnum>")) |
482 | 3206 if userid != "" |
3207 let g:netrw_uid= userid | |
3208 endif | |
719 | 3209 |
6476 | 3210 " Method#10: file://user@hostname/...path-to-file {{{3 |
3211 elseif match(a:choice,fileurm) == 0 && exists("g:netrw_file_cmd") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3212 " call Decho("http[s]://...",'~'.expand("<slnum>")) |
6476 | 3213 let b:netrw_method = 10 |
3214 let b:netrw_fname = substitute(a:choice,fileurm,'\1',"") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3215 " call Decho('\1<'.substitute(a:choice,fileurm,'\1',"").">",'~'.expand("<slnum>")) |
6476 | 3216 |
2751 | 3217 " Cannot Determine Method {{{3 |
482 | 3218 else |
3219 if !exists("g:netrw_quiet") | |
2034 | 3220 call netrw#ErrorMsg(s:WARNING,"cannot determine method (format: protocol://[user@]hostname[:port]/[path])",45) |
482 | 3221 endif |
3222 let b:netrw_method = -1 | |
3223 endif | |
2751 | 3224 "}}}3 |
3225 | |
482 | 3226 if g:netrw_port != "" |
2751 | 3227 " remove any leading [:#] from port number |
3228 let g:netrw_port = substitute(g:netrw_port,'[#:]\+','','') | |
3229 elseif exists("netrw_port") | |
3230 " retain port number as implicit for subsequent ftp operations | |
3231 let g:netrw_port= netrw_port | |
482 | 3232 endif |
719 | 3233 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3234 " call Decho("a:choice <".a:choice.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3235 " call Decho("b:netrw_method <".b:netrw_method.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3236 " call Decho("g:netrw_machine<".g:netrw_machine.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3237 " call Decho("g:netrw_port <".g:netrw_port.">",'~'.expand("<slnum>")) |
482 | 3238 " if exists("g:netrw_uid") "Decho |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3239 " call Decho("g:netrw_uid <".g:netrw_uid.">",'~'.expand("<slnum>")) |
482 | 3240 " endif "Decho |
1621 | 3241 " if exists("s:netrw_passwd") "Decho |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3242 " call Decho("s:netrw_passwd <".s:netrw_passwd.">",'~'.expand("<slnum>")) |
482 | 3243 " endif "Decho |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3244 " call Decho("b:netrw_fname <".b:netrw_fname.">",'~'.expand("<slnum>")) |
17433 | 3245 " call Dret("s:NetrwMethod : b:netrw_method=".b:netrw_method." g:netrw_port=".g:netrw_port) |
482 | 3246 endfun |
3247 | |
3248 " ------------------------------------------------------------------------ | |
1121 | 3249 " NetReadFixup: this sort of function is typically written by the user {{{2 |
3250 " to handle extra junk that their system's ftp dumps | |
3251 " into the transfer. This function is provided as an | |
3252 " example and as a fix for a Windows 95 problem: in my | |
3253 " experience, win95's ftp always dumped four blank lines | |
3254 " at the end of the transfer. | |
3255 if has("win95") && exists("g:netrw_win95ftp") && g:netrw_win95ftp | |
3256 fun! NetReadFixup(method, line1, line2) | |
3257 " call Dfunc("NetReadFixup(method<".a:method."> line1=".a:line1." line2=".a:line2.")") | |
2034 | 3258 |
3259 " sanity checks -- attempt to convert inputs to integers | |
3260 let method = a:method + 0 | |
3261 let line1 = a:line1 + 0 | |
3262 let line2 = a:line2 + 0 | |
3263 if type(method) != 0 || type(line1) != 0 || type(line2) != 0 || method < 0 || line1 <= 0 || line2 <= 0 | |
3264 " call Dret("NetReadFixup") | |
3265 return | |
3266 endif | |
3267 | |
1121 | 3268 if method == 3 " ftp (no <.netrc>) |
3269 let fourblanklines= line2 - 3 | |
2034 | 3270 if fourblanklines >= line1 |
6476 | 3271 exe "sil NetrwKeepj ".fourblanklines.",".line2."g/^\s*$/d" |
2034 | 3272 call histdel("/",-1) |
3273 endif | |
3274 endif | |
3275 | |
1121 | 3276 " call Dret("NetReadFixup") |
3277 endfun | |
3278 endif | |
3279 | |
3280 " --------------------------------------------------------------------- | |
650 | 3281 " NetUserPass: set username and password for subsequent ftp transfer {{{2 |
3456 | 3282 " Usage: :call NetUserPass() -- will prompt for userid and password |
3283 " :call NetUserPass("uid") -- will prompt for password | |
3284 " :call NetUserPass("uid","password") -- sets global userid and password | |
3285 " :call NetUserPass("ftp:host") -- looks up userid and password using hup dictionary | |
3286 " :call NetUserPass("host","uid","password") -- sets hup dictionary with host, userid, password | |
482 | 3287 fun! NetUserPass(...) |
3288 | |
3456 | 3289 " call Dfunc("NetUserPass() a:0=".a:0) |
3290 | |
3291 if !exists('s:netrw_hup') | |
3292 let s:netrw_hup= {} | |
3293 endif | |
3294 | |
482 | 3295 if a:0 == 0 |
3920 | 3296 " case: no input arguments |
3297 | |
3298 " change host and username if not previously entered; get new password | |
3299 if !exists("g:netrw_machine") | |
3300 let g:netrw_machine= input('Enter hostname: ') | |
3301 endif | |
482 | 3302 if !exists("g:netrw_uid") || g:netrw_uid == "" |
3920 | 3303 " get username (user-id) via prompt |
482 | 3304 let g:netrw_uid= input('Enter username: ') |
3305 endif | |
3920 | 3306 " get password via prompting |
3456 | 3307 let s:netrw_passwd= inputsecret("Enter Password: ") |
3308 | |
3309 " set up hup database | |
3310 let host = substitute(g:netrw_machine,'\..*$','','') | |
3311 if !exists('s:netrw_hup[host]') | |
3312 let s:netrw_hup[host]= {} | |
3313 endif | |
3314 let s:netrw_hup[host].uid = g:netrw_uid | |
3315 let s:netrw_hup[host].passwd = s:netrw_passwd | |
3316 | |
3317 elseif a:0 == 1 | |
3920 | 3318 " case: one input argument |
3456 | 3319 |
3320 if a:1 =~ '^ftp:' | |
3920 | 3321 " get host from ftp:... url |
3456 | 3322 " access userid and password from hup (host-user-passwd) dictionary |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3323 " call Decho("case a:0=1: a:1<".a:1."> (get host from ftp:... url)",'~'.expand("<slnum>")) |
3456 | 3324 let host = substitute(a:1,'^ftp:','','') |
3325 let host = substitute(host,'\..*','','') | |
3326 if exists("s:netrw_hup[host]") | |
3327 let g:netrw_uid = s:netrw_hup[host].uid | |
3328 let s:netrw_passwd = s:netrw_hup[host].passwd | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3329 " call Decho("get s:netrw_hup[".host."].uid <".s:netrw_hup[host].uid.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3330 " call Decho("get s:netrw_hup[".host."].passwd<".s:netrw_hup[host].passwd.">",'~'.expand("<slnum>")) |
3456 | 3331 else |
3332 let g:netrw_uid = input("Enter UserId: ") | |
3333 let s:netrw_passwd = inputsecret("Enter Password: ") | |
3334 endif | |
3920 | 3335 |
3456 | 3336 else |
3920 | 3337 " case: one input argument, not an url. Using it as a new user-id. |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3338 " call Decho("case a:0=1: a:1<".a:1."> (get host from input argument, not an url)",'~'.expand("<slnum>")) |
3456 | 3339 if exists("g:netrw_machine") |
5734 | 3340 if g:netrw_machine =~ '[0-9.]\+' |
3341 let host= g:netrw_machine | |
3342 else | |
3343 let host= substitute(g:netrw_machine,'\..*$','','') | |
3344 endif | |
3920 | 3345 else |
3346 let g:netrw_machine= input('Enter hostname: ') | |
3347 endif | |
3348 let g:netrw_uid = a:1 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3349 " call Decho("set g:netrw_uid= <".g:netrw_uid.">",'~'.expand("<slnum>")) |
3920 | 3350 if exists("g:netrw_passwd") |
3351 " ask for password if one not previously entered | |
3352 let s:netrw_passwd= g:netrw_passwd | |
3353 else | |
3354 let s:netrw_passwd = inputsecret("Enter Password: ") | |
3355 endif | |
3456 | 3356 endif |
3357 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3358 " call Decho("host<".host.">",'~'.expand("<slnum>")) |
3456 | 3359 if exists("host") |
3360 if !exists('s:netrw_hup[host]') | |
3361 let s:netrw_hup[host]= {} | |
3362 endif | |
3363 let s:netrw_hup[host].uid = g:netrw_uid | |
3364 let s:netrw_hup[host].passwd = s:netrw_passwd | |
3365 endif | |
3366 | |
3367 elseif a:0 == 2 | |
3368 let g:netrw_uid = a:1 | |
3369 let s:netrw_passwd = a:2 | |
3370 | |
3371 elseif a:0 == 3 | |
3372 " enter hostname, user-id, and password into the hup dictionary | |
3373 let host = substitute(a:1,'^\a\+:','','') | |
3374 let host = substitute(host,'\..*$','','') | |
3375 if !exists('s:netrw_hup[host]') | |
3376 let s:netrw_hup[host]= {} | |
3377 endif | |
3378 let s:netrw_hup[host].uid = a:2 | |
3379 let s:netrw_hup[host].passwd = a:3 | |
3380 let g:netrw_uid = s:netrw_hup[host].uid | |
3381 let s:netrw_passwd = s:netrw_hup[host].passwd | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3382 " call Decho("set s:netrw_hup[".host."].uid <".s:netrw_hup[host].uid.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3383 " call Decho("set s:netrw_hup[".host."].passwd<".s:netrw_hup[host].passwd.">",'~'.expand("<slnum>")) |
482 | 3384 endif |
3385 | |
3456 | 3386 " call Dret("NetUserPass : uid<".g:netrw_uid."> passwd<".s:netrw_passwd.">") |
482 | 3387 endfun |
3388 | |
17433 | 3389 " ================================= |
1121 | 3390 " Shared Browsing Support: {{{1 |
17433 | 3391 " ================================= |
1121 | 3392 |
3393 " --------------------------------------------------------------------- | |
1621 | 3394 " s:ExplorePatHls: converts an Explore pattern into a regular expression search pattern {{{2 |
3395 fun! s:ExplorePatHls(pattern) | |
3396 " call Dfunc("s:ExplorePatHls(pattern<".a:pattern.">)") | |
3397 let repat= substitute(a:pattern,'^**/\{1,2}','','') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3398 " call Decho("repat<".repat.">",'~'.expand("<slnum>")) |
1621 | 3399 let repat= escape(repat,'][.\') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3400 " call Decho("repat<".repat.">",'~'.expand("<slnum>")) |
1621 | 3401 let repat= '\<'.substitute(repat,'\*','\\(\\S\\+ \\)*\\S\\+','g').'\>' |
3402 " call Dret("s:ExplorePatHls repat<".repat.">") | |
3403 return repat | |
1121 | 3404 endfun |
3405 | |
3406 " --------------------------------------------------------------------- | |
2034 | 3407 " s:NetrwBookHistHandler: {{{2 |
1621 | 3408 " 0: (user: <mb>) bookmark current directory |
3409 " 1: (user: <gb>) change to the bookmarked directory | |
3410 " 2: (user: <qb>) list bookmarks | |
6476 | 3411 " 3: (browsing) records current directory history |
3412 " 4: (user: <u>) go up (previous) directory, using history | |
3413 " 5: (user: <U>) go down (next) directory, using history | |
1621 | 3414 " 6: (user: <mB>) delete bookmark |
2034 | 3415 fun! s:NetrwBookHistHandler(chg,curdir) |
17433 | 3416 " call Dfunc("s:NetrwBookHistHandler(chg=".a:chg." curdir<".a:curdir.">) cnt=".v:count." histcnt=".g:netrw_dirhistcnt." histmax=".g:netrw_dirhistmax) |
4339 | 3417 if !exists("g:netrw_dirhistmax") || g:netrw_dirhistmax <= 0 |
3418 " " call Dret("s:NetrwBookHistHandler - suppressed due to g:netrw_dirhistmax") | |
3419 return | |
3420 endif | |
1121 | 3421 |
6476 | 3422 let ykeep = @@ |
3423 let curbufnr = bufnr("%") | |
3424 | |
1121 | 3425 if a:chg == 0 |
3426 " bookmark the current directory | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3427 " call Decho("(user: <b>) bookmark the current directory",'~'.expand("<slnum>")) |
6476 | 3428 if exists("s:netrwmarkfilelist_{curbufnr}") |
3429 call s:NetrwBookmark(0) | |
3430 echo "bookmarked marked files" | |
3431 else | |
3432 call s:MakeBookmark(a:curdir) | |
3433 echo "bookmarked the current directory" | |
3434 endif | |
1121 | 3435 |
3436 elseif a:chg == 1 | |
3437 " change to the bookmarked directory | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3438 " call Decho("(user: <".v:count."gb>) change to the bookmarked directory",'~'.expand("<slnum>")) |
2034 | 3439 if exists("g:netrw_bookmarklist[v:count-1]") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3440 " call Decho("(user: <".v:count."gb>) bookmarklist=".string(g:netrw_bookmarklist),'~'.expand("<slnum>")) |
6476 | 3441 exe "NetrwKeepj e ".fnameescape(g:netrw_bookmarklist[v:count-1]) |
1121 | 3442 else |
3443 echomsg "Sorry, bookmark#".v:count." doesn't exist!" | |
3444 endif | |
3445 | |
3446 elseif a:chg == 2 | |
1621 | 3447 " redraw! |
1121 | 3448 let didwork= 0 |
3449 " list user's bookmarks | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3450 " call Decho("(user: <q>) list user's bookmarks",'~'.expand("<slnum>")) |
2034 | 3451 if exists("g:netrw_bookmarklist") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3452 " call Decho('list '.len(g:netrw_bookmarklist).' bookmarks','~'.expand("<slnum>")) |
2034 | 3453 let cnt= 1 |
3454 for bmd in g:netrw_bookmarklist | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3455 " call Decho("Netrw Bookmark#".cnt.": ".g:netrw_bookmarklist[cnt-1],'~'.expand("<slnum>")) |
4339 | 3456 echo printf("Netrw Bookmark#%-2d: %s",cnt,g:netrw_bookmarklist[cnt-1]) |
2034 | 3457 let didwork = 1 |
3458 let cnt = cnt + 1 | |
3459 endfor | |
1121 | 3460 endif |
3461 | |
3462 " list directory history | |
17433 | 3463 " Note: history is saved only when PerformListing is done; |
3464 " ie. when netrw can re-use a netrw buffer, the current directory is not saved in the history. | |
3465 let cnt = g:netrw_dirhistcnt | |
1121 | 3466 let first = 1 |
3467 let histcnt = 0 | |
2751 | 3468 if g:netrw_dirhistmax > 0 |
17433 | 3469 while ( first || cnt != g:netrw_dirhistcnt ) |
3470 " call Decho("first=".first." cnt=".cnt." dirhistcnt=".g:netrw_dirhistcnt,'~'.expand("<slnum>")) | |
2751 | 3471 if exists("g:netrw_dirhist_{cnt}") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3472 " call Decho("Netrw History#".histcnt.": ".g:netrw_dirhist_{cnt},'~'.expand("<slnum>")) |
4339 | 3473 echo printf("Netrw History#%-2d: %s",histcnt,g:netrw_dirhist_{cnt}) |
2751 | 3474 let didwork= 1 |
3475 endif | |
4339 | 3476 let histcnt = histcnt + 1 |
3477 let first = 0 | |
3478 let cnt = ( cnt - 1 ) % g:netrw_dirhistmax | |
2751 | 3479 if cnt < 0 |
3480 let cnt= cnt + g:netrw_dirhistmax | |
3481 endif | |
3482 endwhile | |
3483 else | |
17433 | 3484 let g:netrw_dirhistcnt= 0 |
2751 | 3485 endif |
1121 | 3486 if didwork |
3487 call inputsave()|call input("Press <cr> to continue")|call inputrestore() | |
3488 endif | |
3489 | |
3490 elseif a:chg == 3 | |
3491 " saves most recently visited directories (when they differ) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3492 " call Decho("(browsing) record curdir history",'~'.expand("<slnum>")) |
17433 | 3493 if !exists("g:netrw_dirhistcnt") || !exists("g:netrw_dirhist_{g:netrw_dirhistcnt}") || g:netrw_dirhist_{g:netrw_dirhistcnt} != a:curdir |
2751 | 3494 if g:netrw_dirhistmax > 0 |
17433 | 3495 let g:netrw_dirhistcnt = ( g:netrw_dirhistcnt + 1 ) % g:netrw_dirhistmax |
3496 let g:netrw_dirhist_{g:netrw_dirhistcnt} = a:curdir | |
3497 endif | |
3498 " call Decho("save dirhist#".g:netrw_dirhistcnt."<".g:netrw_dirhist_{g:netrw_dirhistcnt}.">",'~'.expand("<slnum>")) | |
1121 | 3499 endif |
3500 | |
3501 elseif a:chg == 4 | |
3502 " u: change to the previous directory stored on the history list | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3503 " call Decho("(user: <u>) chg to prev dir from history",'~'.expand("<slnum>")) |
2751 | 3504 if g:netrw_dirhistmax > 0 |
17433 | 3505 let g:netrw_dirhistcnt= ( g:netrw_dirhistcnt - v:count1 ) % g:netrw_dirhistmax |
3506 if g:netrw_dirhistcnt < 0 | |
3507 let g:netrw_dirhistcnt= g:netrw_dirhistcnt + g:netrw_dirhistmax | |
3508 endif | |
3509 else | |
3510 let g:netrw_dirhistcnt= 0 | |
3511 endif | |
3512 if exists("g:netrw_dirhist_{g:netrw_dirhistcnt}") | |
3513 " call Decho("changedir u#".g:netrw_dirhistcnt."<".g:netrw_dirhist_{g:netrw_dirhistcnt}.">",'~'.expand("<slnum>")) | |
1121 | 3514 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir") |
3456 | 3515 setl ma noro |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3516 " call Decho("setl ma noro",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3517 sil! NetrwKeepj %d _ |
3456 | 3518 setl nomod |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3519 " call Decho("setl nomod",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3520 " call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3521 endif |
17433 | 3522 " call Decho("exe e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhistcnt}),'~'.expand("<slnum>")) |
3523 exe "NetrwKeepj e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhistcnt}) | |
1121 | 3524 else |
2751 | 3525 if g:netrw_dirhistmax > 0 |
17433 | 3526 let g:netrw_dirhistcnt= ( g:netrw_dirhistcnt + v:count1 ) % g:netrw_dirhistmax |
3527 else | |
3528 let g:netrw_dirhistcnt= 0 | |
2751 | 3529 endif |
1121 | 3530 echo "Sorry, no predecessor directory exists yet" |
3531 endif | |
3532 | |
3533 elseif a:chg == 5 | |
3534 " U: change to the subsequent directory stored on the history list | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3535 " call Decho("(user: <U>) chg to next dir from history",'~'.expand("<slnum>")) |
2751 | 3536 if g:netrw_dirhistmax > 0 |
17433 | 3537 let g:netrw_dirhistcnt= ( g:netrw_dirhistcnt + 1 ) % g:netrw_dirhistmax |
3538 if exists("g:netrw_dirhist_{g:netrw_dirhistcnt}") | |
3539 " call Decho("changedir U#".g:netrw_dirhistcnt."<".g:netrw_dirhist_{g:netrw_dirhistcnt}.">",'~'.expand("<slnum>")) | |
2751 | 3540 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3541 " call Decho("setl ma noro",'~'.expand("<slnum>")) |
3456 | 3542 setl ma noro |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3543 sil! NetrwKeepj %d _ |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3544 " call Decho("removed all lines from buffer (%d)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3545 " call Decho("setl nomod",'~'.expand("<slnum>")) |
3456 | 3546 setl nomod |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3547 " call Decho("(set nomod) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3548 endif |
17433 | 3549 " call Decho("exe e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhistcnt}),'~'.expand("<slnum>")) |
3550 exe "NetrwKeepj e! ".fnameescape(g:netrw_dirhist_{g:netrw_dirhistcnt}) | |
3551 else | |
3552 let g:netrw_dirhistcnt= ( g:netrw_dirhistcnt - 1 ) % g:netrw_dirhistmax | |
3553 if g:netrw_dirhistcnt < 0 | |
3554 let g:netrw_dirhistcnt= g:netrw_dirhistcnt + g:netrw_dirhistmax | |
2751 | 3555 endif |
3556 echo "Sorry, no successor directory exists yet" | |
3557 endif | |
1121 | 3558 else |
17433 | 3559 let g:netrw_dirhistcnt= 0 |
2751 | 3560 echo "Sorry, no successor directory exists yet (g:netrw_dirhistmax is ".g:netrw_dirhistmax.")" |
1121 | 3561 endif |
1621 | 3562 |
3563 elseif a:chg == 6 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3564 " call Decho("(user: <mB>) delete bookmark'd directory",'~'.expand("<slnum>")) |
6476 | 3565 if exists("s:netrwmarkfilelist_{curbufnr}") |
3566 call s:NetrwBookmark(1) | |
3567 echo "removed marked files from bookmarks" | |
3568 else | |
3569 " delete the v:count'th bookmark | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3570 let iremove = v:count |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3571 let dremove = g:netrw_bookmarklist[iremove - 1] |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3572 " call Decho("delete bookmark#".iremove."<".g:netrw_bookmarklist[iremove - 1].">",'~'.expand("<slnum>")) |
6476 | 3573 call s:MergeBookmarks() |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3574 " call Decho("remove g:netrw_bookmarklist[".(iremove-1)."]<".g:netrw_bookmarklist[(iremove-1)].">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3575 NetrwKeepj call remove(g:netrw_bookmarklist,iremove-1) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3576 echo "removed ".dremove." from g:netrw_bookmarklist" |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3577 " call Decho("g:netrw_bookmarklist=".string(g:netrw_bookmarklist),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3578 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3579 " call Decho("resulting g:netrw_bookmarklist=".string(g:netrw_bookmarklist),'~'.expand("<slnum>")) |
1621 | 3580 endif |
3581 call s:NetrwBookmarkMenu() | |
4339 | 3582 call s:NetrwTgtMenu() |
3920 | 3583 let @@= ykeep |
2152 | 3584 " call Dret("s:NetrwBookHistHandler") |
2034 | 3585 endfun |
3586 | |
3587 " --------------------------------------------------------------------- | |
3588 " s:NetrwBookHistRead: this function reads bookmarks and history {{{2 | |
6476 | 3589 " Will source the history file (.netrwhist) only if the g:netrw_disthistmax is > 0. |
2034 | 3590 " Sister function: s:NetrwBookHistSave() |
3591 fun! s:NetrwBookHistRead() | |
3592 " call Dfunc("s:NetrwBookHistRead()") | |
4339 | 3593 if !exists("g:netrw_dirhistmax") || g:netrw_dirhistmax <= 0 |
17433 | 3594 " call Dret("s:NetrwBookHistRead - nothing read (suppressed due to dirhistmax=".(exists("g:netrw_dirhistmax")? g:netrw_dirhistmax : "n/a").")") |
4339 | 3595 return |
3596 endif | |
3920 | 3597 let ykeep= @@ |
17433 | 3598 |
3599 " read bookmarks | |
2034 | 3600 if !exists("s:netrw_initbookhist") |
3601 let home = s:NetrwHome() | |
3602 let savefile= home."/.netrwbook" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3603 if filereadable(s:NetrwFile(savefile)) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3604 " call Decho("sourcing .netrwbook",'~'.expand("<slnum>")) |
6476 | 3605 exe "keepalt NetrwKeepj so ".savefile |
2751 | 3606 endif |
17433 | 3607 |
3608 " read history | |
2751 | 3609 if g:netrw_dirhistmax > 0 |
3610 let savefile= home."/.netrwhist" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3611 if filereadable(s:NetrwFile(savefile)) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3612 " call Decho("sourcing .netrwhist",'~'.expand("<slnum>")) |
6476 | 3613 exe "keepalt NetrwKeepj so ".savefile |
2751 | 3614 endif |
3615 let s:netrw_initbookhist= 1 | |
3616 au VimLeave * call s:NetrwBookHistSave() | |
3617 endif | |
2034 | 3618 endif |
17433 | 3619 |
3920 | 3620 let @@= ykeep |
17433 | 3621 " call Decho("dirhistmax=".(exists("g:netrw_dirhistmax")? g:netrw_dirhistmax : "n/a"),'~'.expand("<slnum>")) |
3622 " call Decho("dirhistcnt=".(exists("g:netrw_dirhistcnt")? g:netrw_dirhistcnt : "n/a"),'~'.expand("<slnum>")) | |
2034 | 3623 " call Dret("s:NetrwBookHistRead") |
3624 endfun | |
3625 | |
3626 " --------------------------------------------------------------------- | |
17433 | 3627 " s:NetrwBookHistSave: this function saves bookmarks and history to files {{{2 |
2034 | 3628 " Sister function: s:NetrwBookHistRead() |
3629 " I used to do this via viminfo but that appears to | |
3630 " be unreliable for long-term storage | |
6476 | 3631 " If g:netrw_dirhistmax is <= 0, no history or bookmarks |
3632 " will be saved. | |
17433 | 3633 " (s:NetrwBookHistHandler(3,...) used to record history) |
2034 | 3634 fun! s:NetrwBookHistSave() |
17433 | 3635 " call Dfunc("s:NetrwBookHistSave() dirhistmax=".g:netrw_dirhistmax." dirhistcnt=".g:netrw_dirhistcnt) |
4339 | 3636 if !exists("g:netrw_dirhistmax") || g:netrw_dirhistmax <= 0 |
17433 | 3637 " call Dret("s:NetrwBookHistSave : nothing saved (dirhistmax=".g:netrw_dirhistmax.")") |
2751 | 3638 return |
3639 endif | |
3640 | |
2034 | 3641 let savefile= s:NetrwHome()."/.netrwhist" |
17433 | 3642 " call Decho("savefile<".savefile.">",'~'.expand("<slnum>")) |
2034 | 3643 1split |
3644 call s:NetrwEnew() | |
17433 | 3645 " call Decho("case g:netrw_use_noswf=".g:netrw_use_noswf.(exists("+acd")? " +acd" : " -acd"),'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
3646 if g:netrw_use_noswf |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
3647 setl cino= com= cpo-=a cpo-=A fo=nroql2 tw=0 report=10000 noswf |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
3648 else |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
3649 setl cino= com= cpo-=a cpo-=A fo=nroql2 tw=0 report=10000 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
3650 endif |
4339 | 3651 setl nocin noai noci magic nospell nohid wig= noaw |
3652 setl ma noro write | |
3653 if exists("+acd") | setl noacd | endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3654 sil! NetrwKeepj keepalt %d _ |
2034 | 3655 |
17433 | 3656 " rename enew'd file: .netrwhist -- no attempt to merge |
3657 " record dirhistmax and current dirhistcnt | |
3658 " save history | |
3659 " call Decho("saving history: dirhistmax=".g:netrw_dirhistmax." dirhistcnt=".g:netrw_dirhistcnt." lastline=".line("$"),'~'.expand("<slnum>")) | |
4339 | 3660 sil! keepalt file .netrwhist |
2034 | 3661 call setline(1,"let g:netrw_dirhistmax =".g:netrw_dirhistmax) |
17433 | 3662 call setline(2,"let g:netrw_dirhistcnt =".g:netrw_dirhistcnt) |
3663 if g:netrw_dirhistmax > 0 | |
3664 let lastline = line("$") | |
3665 let cnt = g:netrw_dirhistcnt | |
3666 let first = 1 | |
3667 while ( first || cnt != g:netrw_dirhistcnt ) | |
3668 let lastline= lastline + 1 | |
3669 if exists("g:netrw_dirhist_{cnt}") | |
3670 call setline(lastline,'let g:netrw_dirhist_'.cnt."='".g:netrw_dirhist_{cnt}."'") | |
3671 " call Decho("..".lastline.'let g:netrw_dirhist_'.cnt."='".g:netrw_dirhist_{cnt}."'",'~'.expand("<slnum>")) | |
3672 endif | |
3673 let first = 0 | |
3674 let cnt = ( cnt - 1 ) % g:netrw_dirhistmax | |
3675 if cnt < 0 | |
3676 let cnt= cnt + g:netrw_dirhistmax | |
3677 endif | |
3678 endwhile | |
3679 exe "sil! w! ".savefile | |
3680 " call Decho("exe sil! w! ".savefile,'~'.expand("<slnum>")) | |
3681 endif | |
3682 | |
3683 " save bookmarks | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3684 sil NetrwKeepj %d _ |
2034 | 3685 if exists("g:netrw_bookmarklist") && g:netrw_bookmarklist != [] |
17433 | 3686 " call Decho("saving bookmarks",'~'.expand("<slnum>")) |
2034 | 3687 " merge and write .netrwbook |
3688 let savefile= s:NetrwHome()."/.netrwbook" | |
3689 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3690 if filereadable(s:NetrwFile(savefile)) |
2034 | 3691 let booklist= deepcopy(g:netrw_bookmarklist) |
6476 | 3692 exe "sil NetrwKeepj keepalt so ".savefile |
2034 | 3693 for bdm in booklist |
3694 if index(g:netrw_bookmarklist,bdm) == -1 | |
3695 call add(g:netrw_bookmarklist,bdm) | |
3696 endif | |
3697 endfor | |
3698 call sort(g:netrw_bookmarklist) | |
3699 endif | |
3700 | |
3701 " construct and save .netrwbook | |
3702 call setline(1,"let g:netrw_bookmarklist= ".string(g:netrw_bookmarklist)) | |
2152 | 3703 exe "sil! w! ".savefile |
17433 | 3704 " call Decho("exe sil! w! ".savefile,'~'.expand("<slnum>")) |
3705 endif | |
3706 | |
3707 " cleanup -- remove buffer used to construct history | |
2034 | 3708 let bgone= bufnr("%") |
3709 q! | |
4339 | 3710 exe "keepalt ".bgone."bwipe!" |
2034 | 3711 |
3712 " call Dret("s:NetrwBookHistSave") | |
1621 | 3713 endfun |
3714 | |
3715 " --------------------------------------------------------------------- | |
3716 " s:NetrwBrowse: This function uses the command in g:netrw_list_cmd to provide a {{{2 | |
3717 " list of the contents of a local or remote directory. It is assumed that the | |
3718 " g:netrw_list_cmd has a string, USEPORT HOSTNAME, that needs to be substituted | |
3719 " with the requested remote hostname first. | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3720 " Often called via: Explore/e dirname/etc -> netrw#LocalBrowseCheck() -> s:NetrwBrowse() |
1621 | 3721 fun! s:NetrwBrowse(islocal,dirname) |
3722 if !exists("w:netrw_liststyle")|let w:netrw_liststyle= g:netrw_liststyle|endif | |
2152 | 3723 " call Dfunc("s:NetrwBrowse(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".w:netrw_liststyle." ".g:loaded_netrw." buf#".bufnr("%")."<".bufname("%")."> win#".winnr()) |
17433 | 3724 " call Decho("fyi: modified=".&modified." modifiable=".&modifiable." readonly=".&readonly,'~'.expand("<slnum>")) |
3725 " call Decho("fyi: tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>")) | |
3726 " call Dredir("ls!","s:NetrwBrowse") | |
5734 | 3727 |
6476 | 3728 " save alternate-file's filename if w:netrw_rexlocal doesn't exist |
3729 " This is useful when one edits a local file, then :e ., then :Rex | |
3730 if a:islocal && !exists("w:netrw_rexfile") && bufname("#") != "" | |
3731 let w:netrw_rexfile= bufname("#") | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
3732 " call Decho("setting w:netrw_rexfile<".w:netrw_rexfile."> win#".winnr(),'~'.expand("<slnum>")) |
6476 | 3733 endif |
3734 | |
3735 " s:NetrwBrowse : initialize history {{{3 | |
2034 | 3736 if !exists("s:netrw_initbookhist") |
6476 | 3737 NetrwKeepj call s:NetrwBookHistRead() |
3738 endif | |
3739 | |
3740 " s:NetrwBrowse : simplify the dirname (especially for ".."s in dirnames) {{{3 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3741 if a:dirname !~ '^\a\{3,}://' |
2034 | 3742 let dirname= simplify(a:dirname) |
17433 | 3743 " call Decho("simplified dirname<".dirname.">") |
2034 | 3744 else |
3745 let dirname= a:dirname | |
3746 endif | |
1621 | 3747 |
17433 | 3748 " repoint t:netrw_lexbufnr if appropriate |
3749 if exists("t:netrw_lexbufnr") && bufnr("%") == t:netrw_lexbufnr | |
3750 " call Decho("set repointlexbufnr to true!") | |
3751 let repointlexbufnr= 1 | |
3752 endif | |
3753 | |
3754 " s:NetrwBrowse : sanity checks: {{{3 | |
1621 | 3755 if exists("s:netrw_skipbrowse") |
3756 unlet s:netrw_skipbrowse | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3757 " call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." filename<".expand("%")."> win#".winnr()." ft<".&ft.">",'~'.expand("<slnum>")) |
5734 | 3758 " call Dret("s:NetrwBrowse : s:netrw_skipbrowse existed") |
1621 | 3759 return |
3760 endif | |
3761 if !exists("*shellescape") | |
6476 | 3762 NetrwKeepj call netrw#ErrorMsg(s:ERROR,"netrw can't run -- your vim is missing shellescape()",69) |
1621 | 3763 " call Dret("s:NetrwBrowse : missing shellescape()") |
3764 return | |
3765 endif | |
3766 if !exists("*fnameescape") | |
6476 | 3767 NetrwKeepj call netrw#ErrorMsg(s:ERROR,"netrw can't run -- your vim is missing fnameescape()",70) |
1621 | 3768 " call Dret("s:NetrwBrowse : missing fnameescape()") |
3769 return | |
3770 endif | |
3771 | |
6476 | 3772 " s:NetrwBrowse : save options: {{{3 |
17433 | 3773 call s:NetrwOptionsSave("w:") |
1621 | 3774 |
6476 | 3775 " s:NetrwBrowse : re-instate any marked files {{{3 |
17433 | 3776 if has("syntax") && exists("g:syntax_on") && g:syntax_on |
3777 if exists("s:netrwmarkfilelist_{bufnr('%')}") | |
3778 " call Decho("clearing marked files",'~'.expand("<slnum>")) | |
3779 exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/" | |
3780 endif | |
1621 | 3781 endif |
3782 | |
3783 if a:islocal && exists("w:netrw_acdkeep") && w:netrw_acdkeep | |
6476 | 3784 " s:NetrwBrowse : set up "safe" options for local directory/file {{{3 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3785 " call Decho("handle w:netrw_acdkeep:",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3786 " call Decho("NetrwKeepj lcd ".fnameescape(dirname)." (due to w:netrw_acdkeep=".w:netrw_acdkeep." - acd=".&acd.")",'~'.expand("<slnum>")) |
17433 | 3787 if s:NetrwLcd(dirname) |
3788 " call Dret("s:NetrwBrowse : lcd failure") | |
3789 return | |
3790 endif | |
3791 " call s:NetrwOptionsSafe() " tst952 failed with this enabled. | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3792 " call Decho("getcwd<".getcwd().">",'~'.expand("<slnum>")) |
1621 | 3793 |
2034 | 3794 elseif !a:islocal && dirname !~ '[\/]$' && dirname !~ '^"' |
6476 | 3795 " s:NetrwBrowse : remote regular file handler {{{3 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3796 " call Decho("handle remote regular file: dirname<".dirname.">",'~'.expand("<slnum>")) |
6476 | 3797 if bufname(dirname) != "" |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3798 " call Decho("edit buf#".bufname(dirname)." in win#".winnr(),'~'.expand("<slnum>")) |
6476 | 3799 exe "NetrwKeepj b ".bufname(dirname) |
3800 else | |
3801 " attempt transfer of remote regular file | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3802 " call Decho("attempt transfer as regular file<".dirname.">",'~'.expand("<slnum>")) |
6476 | 3803 |
3804 " remove any filetype indicator from end of dirname, except for the | |
3805 " "this is a directory" indicator (/). | |
3806 " There shouldn't be one of those here, anyway. | |
3807 let path= substitute(dirname,'[*=@|]\r\=$','','e') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3808 " call Decho("new path<".path.">",'~'.expand("<slnum>")) |
6476 | 3809 call s:RemotePathAnalysis(dirname) |
3810 | |
3811 " s:NetrwBrowse : remote-read the requested file into current buffer {{{3 | |
3812 call s:NetrwEnew(dirname) | |
17433 | 3813 call s:NetrwOptionsSafe(a:islocal) |
6476 | 3814 setl ma noro |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3815 " call Decho("setl ma noro",'~'.expand("<slnum>")) |
6476 | 3816 let b:netrw_curdir = dirname |
3817 let url = s:method."://".((s:user == "")? "" : s:user."@").s:machine.(s:port ? ":".s:port : "")."/".s:path | |
17433 | 3818 call s:NetrwBufRename(url) |
6476 | 3819 exe "sil! NetrwKeepj keepalt doau BufReadPre ".fnameescape(s:fname) |
3820 sil call netrw#NetRead(2,url) | |
3821 " netrw.vim and tar.vim have already handled decompression of the tarball; avoiding gzip.vim error | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3822 " call Decho("url<".url.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3823 " call Decho("s:path<".s:path.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3824 " call Decho("s:fname<".s:fname.">",'~'.expand("<slnum>")) |
6476 | 3825 if s:path =~ '.bz2' |
3826 exe "sil NetrwKeepj keepalt doau BufReadPost ".fnameescape(substitute(s:fname,'\.bz2$','','')) | |
3827 elseif s:path =~ '.gz' | |
3828 exe "sil NetrwKeepj keepalt doau BufReadPost ".fnameescape(substitute(s:fname,'\.gz$','','')) | |
3829 elseif s:path =~ '.gz' | |
3830 exe "sil NetrwKeepj keepalt doau BufReadPost ".fnameescape(substitute(s:fname,'\.txz$','','')) | |
3831 else | |
3832 exe "sil NetrwKeepj keepalt doau BufReadPost ".fnameescape(s:fname) | |
3833 endif | |
3834 endif | |
3835 | |
3836 " s:NetrwBrowse : save certain window-oriented variables into buffer-oriented variables {{{3 | |
1621 | 3837 call s:SetBufWinVars() |
17433 | 3838 call s:NetrwOptionsRestore("w:") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3839 " call Decho("setl ma nomod",'~'.expand("<slnum>")) |
6476 | 3840 setl ma nomod noro |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3841 " call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
3456 | 3842 |
1621 | 3843 " call Dret("s:NetrwBrowse : file<".s:fname.">") |
3844 return | |
3845 endif | |
3846 | |
2751 | 3847 " use buffer-oriented WinVars if buffer variables exist but associated window variables don't {{{3 |
1621 | 3848 call s:UseBufWinVars() |
3849 | |
3850 " set up some variables {{{3 | |
3851 let b:netrw_browser_active = 1 | |
2034 | 3852 let dirname = dirname |
1621 | 3853 let s:last_sort_by = g:netrw_sort_by |
3854 | |
3855 " set up menu {{{3 | |
6476 | 3856 NetrwKeepj call s:NetrwMenu(1) |
1621 | 3857 |
3920 | 3858 " get/set-up buffer {{{3 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3859 " call Decho("saving position across a buffer refresh",'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
3860 let svpos = winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
3861 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
1621 | 3862 let reusing= s:NetrwGetBuffer(a:islocal,dirname) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3863 |
1621 | 3864 " maintain markfile highlighting |
17433 | 3865 if has("syntax") && exists("g:syntax_on") && g:syntax_on |
3866 if exists("s:netrwmarkfilemtch_{bufnr('%')}") && s:netrwmarkfilemtch_{bufnr("%")} != "" | |
3867 " " call Decho("bufnr(%)=".bufnr('%'),'~'.expand("<slnum>")) | |
3868 " " call Decho("exe 2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/",'~'.expand("<slnum>")) | |
3869 exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/" | |
3870 else | |
3871 " " call Decho("2match none",'~'.expand("<slnum>")) | |
3872 2match none | |
3873 endif | |
1621 | 3874 endif |
4339 | 3875 if reusing && line("$") > 1 |
17433 | 3876 call s:NetrwOptionsRestore("w:") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3877 " call Decho("setl noma nomod nowrap",'~'.expand("<slnum>")) |
3456 | 3878 setl noma nomod nowrap |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3879 " call Decho("(set noma nomod nowrap) ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
6476 | 3880 " call Dret("s:NetrwBrowse : re-using not-cleared buffer") |
1621 | 3881 return |
3882 endif | |
3883 | |
3884 " set b:netrw_curdir to the new directory name {{{3 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3885 " call Decho("set b:netrw_curdir to the new directory name<".dirname."> (buf#".bufnr("%").")",'~'.expand("<slnum>")) |
2420
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
3886 let b:netrw_curdir= dirname |
1621 | 3887 if b:netrw_curdir =~ '[/\\]$' |
3888 let b:netrw_curdir= substitute(b:netrw_curdir,'[/\\]$','','e') | |
3889 endif | |
5618 | 3890 if b:netrw_curdir =~ '\a:$' && (has("win32") || has("win95") || has("win64") || has("win16")) |
3891 let b:netrw_curdir= b:netrw_curdir."/" | |
3892 endif | |
1621 | 3893 if b:netrw_curdir == '' |
3894 if has("amiga") | |
3895 " On the Amiga, the empty string connotes the current directory | |
3896 let b:netrw_curdir= getcwd() | |
3897 else | |
3898 " under unix, when the root directory is encountered, the result | |
3899 " from the preceding substitute is an empty string. | |
3900 let b:netrw_curdir= '/' | |
3901 endif | |
3902 endif | |
3903 if !a:islocal && b:netrw_curdir !~ '/$' | |
3904 let b:netrw_curdir= b:netrw_curdir.'/' | |
3905 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3906 " call Decho("b:netrw_curdir<".b:netrw_curdir.">",'~'.expand("<slnum>")) |
1621 | 3907 |
3908 " ------------ | |
3909 " (local only) {{{3 | |
3910 " ------------ | |
3911 if a:islocal | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3912 " call Decho("local only:",'~'.expand("<slnum>")) |
1621 | 3913 |
3914 " Set up ShellCmdPost handling. Append current buffer to browselist | |
3915 call s:LocalFastBrowser() | |
3916 | |
3917 " handle g:netrw_keepdir: set vim's current directory to netrw's notion of the current directory {{{3 | |
3918 if !g:netrw_keepdir | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3919 " call Decho("handle g:netrw_keepdir=".g:netrw_keepdir.": getcwd<".getcwd()."> acd=".&acd,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3920 " call Decho("l:acd".(exists("&l:acd")? "=".&l:acd : " doesn't exist"),'~'.expand("<slnum>")) |
1621 | 3921 if !exists("&l:acd") || !&l:acd |
17433 | 3922 if s:NetrwLcd(b:netrw_curdir) |
3923 " call Dret("s:NetrwBrowse : lcd failure") | |
3924 return | |
3925 endif | |
1621 | 3926 endif |
3927 endif | |
3928 | |
3929 " -------------------------------- | |
3930 " remote handling: {{{3 | |
3931 " -------------------------------- | |
3932 else | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3933 " call Decho("remote only:",'~'.expand("<slnum>")) |
1621 | 3934 |
3920 | 3935 " analyze dirname and g:netrw_list_cmd {{{3 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3936 " call Decho("b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "doesn't exist")."> dirname<".dirname.">",'~'.expand("<slnum>")) |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
3937 if dirname =~# "^NetrwTreeListing\>" |
1621 | 3938 let dirname= b:netrw_curdir |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3939 " call Decho("(dirname was <NetrwTreeListing>) dirname<".dirname.">",'~'.expand("<slnum>")) |
1621 | 3940 elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir") |
3941 let dirname= substitute(b:netrw_curdir,'\\','/','g') | |
3942 if dirname !~ '/$' | |
3943 let dirname= dirname.'/' | |
3944 endif | |
3945 let b:netrw_curdir = dirname | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3946 " call Decho("(liststyle is TREELIST) dirname<".dirname.">",'~'.expand("<slnum>")) |
1621 | 3947 else |
2034 | 3948 let dirname = substitute(dirname,'\\','/','g') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3949 " call Decho("(normal) dirname<".dirname.">",'~'.expand("<slnum>")) |
1621 | 3950 endif |
3951 | |
3952 let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/]\+\)/\(.*\)$' | |
3953 if dirname !~ dirpat | |
3954 if !exists("g:netrw_quiet") | |
6476 | 3955 NetrwKeepj call netrw#ErrorMsg(s:ERROR,"netrw doesn't understand your dirname<".dirname.">",20) |
3956 endif | |
17433 | 3957 NetrwKeepj call s:NetrwOptionsRestore("w:") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3958 " call Decho("setl noma nomod nowrap",'~'.expand("<slnum>")) |
3456 | 3959 setl noma nomod nowrap |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3960 " call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
1621 | 3961 " call Dret("s:NetrwBrowse : badly formatted dirname<".dirname.">") |
3962 return | |
3963 endif | |
3964 let b:netrw_curdir= dirname | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3965 " call Decho("b:netrw_curdir<".b:netrw_curdir."> (remote)",'~'.expand("<slnum>")) |
1621 | 3966 endif " (additional remote handling) |
3967 | |
17433 | 3968 " ------------------------------- |
3969 " Perform Directory Listing: {{{3 | |
3970 " ------------------------------- | |
6476 | 3971 NetrwKeepj call s:NetrwMaps(a:islocal) |
3972 NetrwKeepj call s:NetrwCommands(a:islocal) | |
3973 NetrwKeepj call s:PerformListing(a:islocal) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3974 |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
3975 " restore option(s) |
17433 | 3976 call s:NetrwOptionsRestore("w:") |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
3977 " call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
3978 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3979 " If there is a rexposn: restore position with rexposn |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3980 " Otherwise : set rexposn |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3981 if exists("s:rexposn_".bufnr("%")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
3982 " call Decho("restoring posn to s:rexposn_".bufnr('%')."<".string(s:rexposn_{bufnr('%')}).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
3983 NetrwKeepj call winrestview(s:rexposn_{bufnr('%')}) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
3984 if exists("w:netrw_bannercnt") && line(".") < w:netrw_bannercnt |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
3985 NetrwKeepj exe w:netrw_bannercnt |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
3986 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3987 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3988 NetrwKeepj call s:SetRexDir(a:islocal,b:netrw_curdir) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3989 endif |
3153 | 3990 if v:version >= 700 && has("balloon_eval") && &beval == 0 && &l:bexpr == "" && !exists("g:netrw_nobeval") |
5734 | 3991 let &l:bexpr= "netrw#BalloonHelp()" |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3992 " call Decho("set up balloon help: l:bexpr=".&l:bexpr,'~'.expand("<slnum>")) |
5734 | 3993 setl beval |
2751 | 3994 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
3995 |
17433 | 3996 " repoint t:netrw_lexbufnr if appropriate |
3997 if exists("repointlexbufnr") | |
3998 let t:netrw_lexbufnr= bufnr("%") | |
3999 " call Decho("repoint t:netrw_lexbufnr to #".t:netrw_lexbufnr) | |
4000 endif | |
4001 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4002 " restore position |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4003 if reusing |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4004 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4005 call winrestview(svpos) |
6476 | 4006 endif |
4007 | |
5734 | 4008 " The s:LocalBrowseRefresh() function is called by an autocmd |
17433 | 4009 " installed by s:LocalFastBrowser() when g:netrw_fastbrowse <= 1 (ie. slow or medium speed). |
4010 " However, s:NetrwBrowse() causes the FocusGained event to fire the first time. | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4011 " call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4012 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
2751 | 4013 " call Dret("s:NetrwBrowse : did PerformListing ft<".&ft.">") |
1621 | 4014 return |
4015 endfun | |
4016 | |
4017 " --------------------------------------------------------------------- | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4018 " s:NetrwFile: because of g:netrw_keepdir, isdirectory(), type(), etc may or {{{2 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4019 " may not apply correctly; ie. netrw's idea of the current directory may |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4020 " differ from vim's. This function insures that netrw's idea of the current |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4021 " directory is used. |
17433 | 4022 " Returns a path to the file specified by a:fname |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4023 fun! s:NetrwFile(fname) |
17433 | 4024 " "" call Dfunc("s:NetrwFile(fname<".a:fname.">) win#".winnr()) |
4025 " "" call Decho("g:netrw_keepdir =".(exists("g:netrw_keepdir")? g:netrw_keepdir : 'n/a'),'~'.expand("<slnum>")) | |
4026 " "" call Decho("g:netrw_cygwin =".(exists("g:netrw_cygwin")? g:netrw_cygwin : 'n/a'),'~'.expand("<slnum>")) | |
4027 " "" call Decho("g:netrw_liststyle=".(exists("g:netrw_liststyle")? g:netrw_liststyle : 'n/a'),'~'.expand("<slnum>")) | |
4028 " "" call Decho("w:netrw_liststyle=".(exists("w:netrw_liststyle")? w:netrw_liststyle : 'n/a'),'~'.expand("<slnum>")) | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4029 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4030 " clean up any leading treedepthstring |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4031 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4032 let fname= substitute(a:fname,'^'.s:treedepthstring.'\+','','') |
17433 | 4033 " "" call Decho("clean up any leading treedepthstring: fname<".fname.">",'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4034 else |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4035 let fname= a:fname |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4036 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4037 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4038 if g:netrw_keepdir |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4039 " vim's idea of the current directory possibly may differ from netrw's |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4040 if !exists("b:netrw_curdir") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4041 let b:netrw_curdir= getcwd() |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4042 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4043 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4044 if !exists("g:netrw_cygwin") && (has("win32") || has("win95") || has("win64") || has("win16")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4045 if fname =~ '^\' || fname =~ '^\a:\' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4046 " windows, but full path given |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4047 let ret= fname |
17433 | 4048 " "" call Decho("windows+full path: isdirectory(".fname.")",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4049 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4050 " windows, relative path given |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4051 let ret= s:ComposePath(b:netrw_curdir,fname) |
17433 | 4052 " "" call Decho("windows+rltv path: isdirectory(".fname.")",'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4053 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4054 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4055 elseif fname =~ '^/' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4056 " not windows, full path given |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4057 let ret= fname |
17433 | 4058 " "" call Decho("unix+full path: isdirectory(".fname.")",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4059 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4060 " not windows, relative path given |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4061 let ret= s:ComposePath(b:netrw_curdir,fname) |
17433 | 4062 " "" call Decho("unix+rltv path: isdirectory(".fname.")",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4063 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4064 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4065 " vim and netrw agree on the current directory |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4066 let ret= fname |
17433 | 4067 " "" call Decho("vim and netrw agree on current directory (g:netrw_keepdir=".g:netrw_keepdir.")",'~'.expand("<slnum>")) |
4068 " "" call Decho("vim directory: ".getcwd(),'~'.expand("<slnum>")) | |
4069 " "" call Decho("netrw directory: ".(exists("b:netrw_curdir")? b:netrw_curdir : 'n/a'),'~'.expand("<slnum>")) | |
4070 endif | |
4071 | |
4072 " "" call Dret("s:NetrwFile ".ret) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4073 return ret |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4074 endfun |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4075 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4076 " --------------------------------------------------------------------- |
1621 | 4077 " s:NetrwFileInfo: supports qf (query for file information) {{{2 |
4078 fun! s:NetrwFileInfo(islocal,fname) | |
5618 | 4079 " call Dfunc("s:NetrwFileInfo(islocal=".a:islocal." fname<".a:fname.">) b:netrw_curdir<".b:netrw_curdir.">") |
3920 | 4080 let ykeep= @@ |
1621 | 4081 if a:islocal |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4082 let lsopt= "-lsad" |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4083 if g:netrw_sizestyle =~# 'H' |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4084 let lsopt= "-lsadh" |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4085 elseif g:netrw_sizestyle =~# 'h' |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4086 let lsopt= "-lsadh --si" |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4087 endif |
1621 | 4088 if (has("unix") || has("macunix")) && executable("/bin/ls") |
5618 | 4089 |
4090 if getline(".") == "../" | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4091 echo system("/bin/ls ".lsopt." ".s:ShellEscape("..")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4092 " call Decho("#1: echo system(/bin/ls -lsad ".s:ShellEscape(..).")",'~'.expand("<slnum>")) |
5618 | 4093 |
5734 | 4094 elseif w:netrw_liststyle == s:TREELIST && getline(".") !~ '^'.s:treedepthstring |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4095 echo system("/bin/ls ".lsopt." ".s:ShellEscape(b:netrw_curdir)) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4096 " call Decho("#2: echo system(/bin/ls -lsad ".s:ShellEscape(b:netrw_curdir).")",'~'.expand("<slnum>")) |
5618 | 4097 |
4098 elseif exists("b:netrw_curdir") | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4099 echo system("/bin/ls ".lsopt." ".s:ShellEscape(s:ComposePath(b:netrw_curdir,a:fname))) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4100 " call Decho("#3: echo system(/bin/ls -lsad ".s:ShellEscape(b:netrw_curdir.a:fname).")",'~'.expand("<slnum>")) |
5618 | 4101 |
1621 | 4102 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4103 " call Decho('using ls '.a:fname." using cwd<".getcwd().">",'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4104 echo system("/bin/ls ".lsopt." ".s:ShellEscape(s:NetrwFile(a:fname))) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4105 " call Decho("#5: echo system(/bin/ls -lsad ".s:ShellEscape(a:fname).")",'~'.expand("<slnum>")) |
1621 | 4106 endif |
4107 else | |
4108 " use vim functions to return information about file below cursor | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4109 " call Decho("using vim functions to query for file info",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4110 if !isdirectory(s:NetrwFile(a:fname)) && !filereadable(s:NetrwFile(a:fname)) && a:fname =~ '[*@/]' |
1621 | 4111 let fname= substitute(a:fname,".$","","") |
4112 else | |
4113 let fname= a:fname | |
4114 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4115 let t = getftime(s:NetrwFile(fname)) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4116 let sz = getfsize(s:NetrwFile(fname)) |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4117 if g:netrw_sizestyle =~# "[hH]" |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4118 let sz= s:NetrwHumanReadable(sz) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4119 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4120 echo a:fname.": ".sz." ".strftime(g:netrw_timefmt,getftime(s:NetrwFile(fname))) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4121 " call Decho("fname.": ".sz." ".strftime(g:netrw_timefmt,getftime(fname)),'~'.expand("<slnum>")) |
1621 | 4122 endif |
4123 else | |
4124 echo "sorry, \"qf\" not supported yet for remote files" | |
4125 endif | |
3920 | 4126 let @@= ykeep |
1621 | 4127 " call Dret("s:NetrwFileInfo") |
1121 | 4128 endfun |
4129 | |
4130 " --------------------------------------------------------------------- | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4131 " s:NetrwFullPath: returns the full path to a directory and/or file {{{2 |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4132 fun! s:NetrwFullPath(filename) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4133 " " call Dfunc("s:NetrwFullPath(filename<".a:filename.">)") |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4134 let filename= a:filename |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4135 if filename !~ '^/' |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4136 let filename= resolve(getcwd().'/'.filename) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4137 endif |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4138 if filename != "/" && filename =~ '/$' |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4139 let filename= substitute(filename,'/$','','') |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4140 endif |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4141 " " call Dret("s:NetrwFullPath <".filename.">") |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4142 return filename |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4143 endfun |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4144 |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4145 " --------------------------------------------------------------------- |
17433 | 4146 " s:NetrwGetBuffer: [get a new|find an old netrw] buffer for a netrw listing {{{2 |
1621 | 4147 " returns 0=cleared buffer |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4148 " 1=re-used buffer (buffer not cleared) |
1621 | 4149 fun! s:NetrwGetBuffer(islocal,dirname) |
4150 " call Dfunc("s:NetrwGetBuffer(islocal=".a:islocal." dirname<".a:dirname.">) liststyle=".g:netrw_liststyle) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4151 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("<slnum>")) |
17433 | 4152 " call Decho("netrwbuf dictionary=".(exists("s:netrwbuf")? string(s:netrwbuf) : 'n/a'),'~'.expand("<slnum>")) |
4153 " call Dredir("ls!","s:NetrwGetBuffer") | |
1621 | 4154 let dirname= a:dirname |
4155 | |
4156 " re-use buffer if possible {{{3 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4157 " call Decho("--re-use a buffer if possible--",'~'.expand("<slnum>")) |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4158 if !exists("s:netrwbuf") |
17433 | 4159 " call Decho(" s:netrwbuf initialized to {}",'~'.expand("<slnum>")) |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4160 let s:netrwbuf= {} |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4161 endif |
17433 | 4162 " call Decho(" s:netrwbuf =".string(s:netrwbuf),'~'.expand("<slnum>")) |
4163 " call Decho(" w:netrw_liststyle =".(exists("w:netrw_liststyle")? w:netrw_liststyle : "n/a"),'~'.expand("<slnum>")) | |
4164 | |
4165 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST | |
4166 let bufnum = -1 | |
4167 | |
4168 if !empty(s:netrwbuf) && has_key(s:netrwbuf,s:NetrwFullPath(dirname)) | |
4169 if has_key(s:netrwbuf,"NetrwTreeListing") | |
4170 let bufnum= s:netrwbuf["NetrwTreeListing"] | |
4171 else | |
4172 let bufnum= s:netrwbuf[s:NetrwFullPath(dirname)] | |
4173 endif | |
4174 " call Decho(" NetrwTreeListing: bufnum#".bufnum,'~'.expand("<slnum>")) | |
4175 if !bufexists(bufnum) | |
4176 call remove(s:netrwbuf,"NetrwTreeListing"]) | |
4177 let bufnum= -1 | |
4178 endif | |
4179 elseif bufnr("NetrwTreeListing") != -1 | |
4180 let bufnum= bufnr("NetrwTreeListing") | |
4181 " call Decho(" NetrwTreeListing".": bufnum#".bufnum,'~'.expand("<slnum>")) | |
4182 else | |
4183 " call Decho(" did not find a NetrwTreeListing buffer",'~'.expand("<slnum>")) | |
4184 let bufnum= -1 | |
4185 endif | |
4186 | |
4187 elseif has_key(s:netrwbuf,s:NetrwFullPath(dirname)) | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4188 let bufnum= s:netrwbuf[s:NetrwFullPath(dirname)] |
17433 | 4189 " call Decho(" lookup netrwbuf dictionary: s:netrwbuf[".s:NetrwFullPath(dirname)."]=".bufnum,'~'.expand("<slnum>")) |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4190 if !bufexists(bufnum) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4191 call remove(s:netrwbuf,s:NetrwFullPath(dirname)) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4192 let bufnum= -1 |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4193 endif |
17433 | 4194 |
4195 else | |
4196 " call Decho(" lookup netrwbuf dictionary: s:netrwbuf[".s:NetrwFullPath(dirname)."] not a key",'~'.expand("<slnum>")) | |
1621 | 4197 let bufnum= -1 |
4198 endif | |
17433 | 4199 " call Decho(" bufnum#".bufnum,'~'.expand("<slnum>")) |
4200 | |
4201 " highjack the current buffer if | |
4202 " it has the desired name | |
4203 " it is empty | |
4204 " call Decho("deciding if I can highjack the current buffer#".bufnr("%"),'~'.expand("<slnum>")) | |
4205 " call Decho("..dirname<".dirname.">",'~'.expand("<slnum>")) | |
4206 " call Decho("..bufname<".bufname("%").">",'~'.expand("<slnum>")) | |
4207 " call Decho("..getline($)<".getline("$").">",'~'.expand("<slnum>")) | |
4208 if dirname == bufname("%") && line("$") == 1 && getline("%") == "" | |
4209 " call Dret("s:NetrwGetBuffer 0<cleared buffer> : highjacking buffer#".bufnr("%")) | |
4210 return 0 | |
4211 endif | |
1621 | 4212 |
4213 " get enew buffer and name it -or- re-use buffer {{{3 | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4214 if bufnum < 0 " get enew buffer and name it |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4215 " call Decho("--get enew buffer and name it (bufnum#".bufnum."<0 OR bufexists(".bufnum.")=".bufexists(bufnum)."==0)",'~'.expand("<slnum>")) |
1621 | 4216 call s:NetrwEnew(dirname) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4217 " call Decho(" got enew buffer#".bufnr("%")." (altbuf<".expand("#").">)",'~'.expand("<slnum>")) |
1621 | 4218 " name the buffer |
4219 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST | |
4220 " Got enew buffer; transform into a NetrwTreeListing | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4221 " call Decho("--transform enew buffer#".bufnr("%")." into a NetrwTreeListing --",'~'.expand("<slnum>")) |
17433 | 4222 let w:netrw_treebufnr = bufnr("%") |
4223 call s:NetrwBufRename("NetrwTreeListing") | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4224 if g:netrw_use_noswf |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4225 setl nobl bt=nofile noswf |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4226 else |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4227 setl nobl bt=nofile |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4228 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4229 nnoremap <silent> <buffer> [[ :sil call <SID>TreeListMove('[[')<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4230 nnoremap <silent> <buffer> ]] :sil call <SID>TreeListMove(']]')<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4231 nnoremap <silent> <buffer> [] :sil call <SID>TreeListMove('[]')<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4232 nnoremap <silent> <buffer> ][ :sil call <SID>TreeListMove('][')<cr> |
17433 | 4233 " call Decho(" tree listing bufnr=".w:netrw_treebufnr,'~'.expand("<slnum>")) |
4234 else | |
4235 call s:NetrwBufRename(dirname) | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4236 " enter the new buffer into the s:netrwbuf dictionary |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4237 let s:netrwbuf[s:NetrwFullPath(dirname)]= bufnr("%") |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4238 " call Decho("update netrwbuf dictionary: s:netrwbuf[".s:NetrwFullPath(dirname)."]=".bufnr("%"),'~'.expand("<slnum>")) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4239 " call Decho("netrwbuf dictionary=".string(s:netrwbuf),'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4240 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4241 " call Decho(" named enew buffer#".bufnr("%")."<".bufname("%").">",'~'.expand("<slnum>")) |
1621 | 4242 |
4243 else " Re-use the buffer | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4244 " call Decho("--re-use buffer#".bufnum." (bufnum#".bufnum.">=0 AND bufexists(".bufnum.")=".bufexists(bufnum)."!=0)",'~'.expand("<slnum>")) |
1621 | 4245 let eikeep= &ei |
5734 | 4246 setl ei=all |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4247 if getline(2) =~# '^" Netrw Directory Listing' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4248 " call Decho(" getline(2)<".getline(2).'> matches "Netrw Directory Listing" : using keepalt b '.bufnum,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4249 exe "sil! NetrwKeepj noswapfile keepalt b ".bufnum |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4250 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4251 " call Decho(" getline(2)<".getline(2).'> does not match "Netrw Directory Listing" : using b '.bufnum,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4252 exe "sil! NetrwKeepj noswapfile keepalt b ".bufnum |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4253 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4254 " call Decho(" line($)=".line("$"),'~'.expand("<slnum>")) |
1621 | 4255 if bufname("%") == '.' |
17433 | 4256 call s:NetrwBufRename(getcwd()) |
1621 | 4257 endif |
4258 let &ei= eikeep | |
6476 | 4259 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4260 if line("$") <= 1 && getline(1) == "" |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4261 " empty buffer |
6476 | 4262 NetrwKeepj call s:NetrwListSettings(a:islocal) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4263 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4264 " call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>")) |
3920 | 4265 " call Dret("s:NetrwGetBuffer 0<buffer empty> : re-using buffer#".bufnr("%").", but its empty, so refresh it") |
4266 return 0 | |
6476 | 4267 |
3920 | 4268 elseif g:netrw_fastbrowse == 0 || (a:islocal && g:netrw_fastbrowse == 1) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4269 " call Decho("g:netrw_fastbrowse=".g:netrw_fastbrowse." a:islocal=".a:islocal.": clear buffer",'~'.expand("<slnum>")) |
6476 | 4270 NetrwKeepj call s:NetrwListSettings(a:islocal) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4271 sil NetrwKeepj %d _ |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4272 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4273 " call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>")) |
3920 | 4274 " call Dret("s:NetrwGetBuffer 0<cleared buffer> : re-using buffer#".bufnr("%").", but refreshing due to g:netrw_fastbrowse=".g:netrw_fastbrowse) |
1621 | 4275 return 0 |
6476 | 4276 |
1621 | 4277 elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4278 " call Decho("--re-use tree listing--",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4279 " call Decho(" clear buffer<".expand("%")."> with :%d",'~'.expand("<slnum>")) |
17433 | 4280 setl ma |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4281 sil NetrwKeepj %d _ |
6476 | 4282 NetrwKeepj call s:NetrwListSettings(a:islocal) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4283 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4284 " call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>")) |
3920 | 4285 " call Dret("s:NetrwGetBuffer 0<cleared buffer> : re-using buffer#".bufnr("%").", but treelist mode always needs a refresh") |
1621 | 4286 return 0 |
6476 | 4287 |
1621 | 4288 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4289 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4290 " call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4291 " call Dret("s:NetrwGetBuffer 1<buffer not cleared>") |
1621 | 4292 return 1 |
4293 endif | |
4294 endif | |
4295 | |
4296 " do netrw settings: make this buffer not-a-file, modifiable, not line-numbered, etc {{{3 | |
4297 " fastbrowse Local Remote Hiding a buffer implies it may be re-used (fast) | |
4298 " slow 0 D D Deleting a buffer implies it will not be re-used (slow) | |
4299 " med 1 D H | |
4300 " fast 2 H H | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4301 " call Decho("--do netrw settings: make this buffer#".bufnr("%")." not-a-file, modifiable, not line-numbered, etc--",'~'.expand("<slnum>")) |
1621 | 4302 let fname= expand("%") |
6476 | 4303 NetrwKeepj call s:NetrwListSettings(a:islocal) |
17433 | 4304 call s:NetrwBufRename(fname) |
1621 | 4305 |
4306 " delete all lines from buffer {{{3 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4307 " call Decho("--delete all lines from buffer--",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4308 " call Decho(" clear buffer<".expand("%")."> with :%d",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4309 sil! keepalt NetrwKeepj %d _ |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4310 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4311 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4312 " call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4313 " call Dret("s:NetrwGetBuffer 0<cleared buffer>") |
1621 | 4314 return 0 |
4315 endfun | |
4316 | |
4317 " --------------------------------------------------------------------- | |
4318 " s:NetrwGetcwd: get the current directory. {{{2 | |
4319 " Change backslashes to forward slashes, if any. | |
4320 " If doesc is true, escape certain troublesome characters | |
4321 fun! s:NetrwGetcwd(doesc) | |
4322 " call Dfunc("NetrwGetcwd(doesc=".a:doesc.")") | |
4323 let curdir= substitute(getcwd(),'\\','/','ge') | |
4324 if curdir !~ '[\/]$' | |
4325 let curdir= curdir.'/' | |
4326 endif | |
4327 if a:doesc | |
4328 let curdir= fnameescape(curdir) | |
4329 endif | |
4330 " call Dret("NetrwGetcwd <".curdir.">") | |
4331 return curdir | |
4332 endfun | |
4333 | |
4334 " --------------------------------------------------------------------- | |
4335 " s:NetrwGetWord: it gets the directory/file named under the cursor {{{2 | |
4336 fun! s:NetrwGetWord() | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4337 " call Dfunc("s:NetrwGetWord() liststyle=".s:ShowStyle()." virtcol=".virtcol(".")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4338 " call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4339 let keepsol= &l:sol |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4340 setl nosol |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4341 |
1621 | 4342 call s:UseBufWinVars() |
4343 | |
4344 " insure that w:netrw_liststyle is set up | |
4345 if !exists("w:netrw_liststyle") | |
4346 if exists("g:netrw_liststyle") | |
4347 let w:netrw_liststyle= g:netrw_liststyle | |
4348 else | |
4349 let w:netrw_liststyle= s:THINLIST | |
4350 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4351 " call Decho("w:netrw_liststyle=".w:netrw_liststyle,'~'.expand("<slnum>")) |
1621 | 4352 endif |
4353 | |
4354 if exists("w:netrw_bannercnt") && line(".") < w:netrw_bannercnt | |
4355 " Active Banner support | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4356 " call Decho("active banner handling",'~'.expand("<slnum>")) |
6476 | 4357 NetrwKeepj norm! 0 |
1621 | 4358 let dirname= "./" |
4359 let curline= getline('.') | |
4360 | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4361 if curline =~# '"\s*Sorted by\s' |
17433 | 4362 NetrwKeepj norm! s |
1621 | 4363 let s:netrw_skipbrowse= 1 |
4364 echo 'Pressing "s" also works' | |
4365 | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4366 elseif curline =~# '"\s*Sort sequence:' |
1621 | 4367 let s:netrw_skipbrowse= 1 |
4368 echo 'Press "S" to edit sorting sequence' | |
4369 | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4370 elseif curline =~# '"\s*Quick Help:' |
17433 | 4371 NetrwKeepj norm! ? |
1621 | 4372 let s:netrw_skipbrowse= 1 |
4373 | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4374 elseif curline =~# '"\s*\%(Hiding\|Showing\):' |
17433 | 4375 NetrwKeepj norm! a |
1621 | 4376 let s:netrw_skipbrowse= 1 |
4377 echo 'Pressing "a" also works' | |
4378 | |
4379 elseif line("$") > w:netrw_bannercnt | |
6476 | 4380 exe 'sil NetrwKeepj '.w:netrw_bannercnt |
1621 | 4381 endif |
4382 | |
4383 elseif w:netrw_liststyle == s:THINLIST | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4384 " call Decho("thin column handling",'~'.expand("<slnum>")) |
6476 | 4385 NetrwKeepj norm! 0 |
4386 let dirname= substitute(getline('.'),'\t -->.*$','','') | |
1621 | 4387 |
4388 elseif w:netrw_liststyle == s:LONGLIST | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4389 " call Decho("long column handling",'~'.expand("<slnum>")) |
6476 | 4390 NetrwKeepj norm! 0 |
1621 | 4391 let dirname= substitute(getline('.'),'^\(\%(\S\+ \)*\S\+\).\{-}$','\1','e') |
4392 | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4393 elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4394 " call Decho("treelist handling",'~'.expand("<slnum>")) |
5618 | 4395 let dirname= substitute(getline('.'),'^\('.s:treedepthstring.'\)*','','e') |
6476 | 4396 let dirname= substitute(dirname,'\t -->.*$','','') |
4397 | |
4398 else | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4399 " call Decho("obtain word from wide listing",'~'.expand("<slnum>")) |
1621 | 4400 let dirname= getline('.') |
4401 | |
4402 if !exists("b:netrw_cpf") | |
4403 let b:netrw_cpf= 0 | |
6476 | 4404 exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$g/^./if virtcol("$") > b:netrw_cpf|let b:netrw_cpf= virtcol("$")|endif' |
2034 | 4405 call histdel("/",-1) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4406 " "call Decho("computed cpf=".b:netrw_cpf,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4407 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4408 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4409 " call Decho("buf#".bufnr("%")."<".bufname("%").">",'~'.expand("<slnum>")) |
1621 | 4410 let filestart = (virtcol(".")/b:netrw_cpf)*b:netrw_cpf |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4411 " call Decho("filestart= ([virtcol=".virtcol(".")."]/[b:netrw_cpf=".b:netrw_cpf."])*b:netrw_cpf=".filestart." bannercnt=".w:netrw_bannercnt,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4412 " call Decho("1: dirname<".dirname.">",'~'.expand("<slnum>")) |
1621 | 4413 if filestart == 0 |
6476 | 4414 NetrwKeepj norm! 0ma |
1621 | 4415 else |
4416 call cursor(line("."),filestart+1) | |
6476 | 4417 NetrwKeepj norm! ma |
1621 | 4418 endif |
4419 let rega= @a | |
1668 | 4420 let eofname= filestart + b:netrw_cpf + 1 |
4421 if eofname <= col("$") | |
4422 call cursor(line("."),filestart+b:netrw_cpf+1) | |
6476 | 4423 NetrwKeepj norm! "ay`a |
4424 else | |
4425 NetrwKeepj norm! "ay$ | |
1668 | 4426 endif |
1621 | 4427 let dirname = @a |
4428 let @a = rega | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4429 " call Decho("2: dirname<".dirname.">",'~'.expand("<slnum>")) |
1621 | 4430 let dirname= substitute(dirname,'\s\+$','','e') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4431 " call Decho("3: dirname<".dirname.">",'~'.expand("<slnum>")) |
1621 | 4432 endif |
4433 | |
4434 " symlinks are indicated by a trailing "@". Remove it before further processing. | |
4435 let dirname= substitute(dirname,"@$","","") | |
4436 | |
4437 " executables are indicated by a trailing "*". Remove it before further processing. | |
4438 let dirname= substitute(dirname,"\*$","","") | |
4439 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4440 let &l:sol= keepsol |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4441 |
1621 | 4442 " call Dret("s:NetrwGetWord <".dirname.">") |
4443 return dirname | |
4444 endfun | |
4445 | |
4446 " --------------------------------------------------------------------- | |
17433 | 4447 " s:NetrwListSettings: make standard settings for making a netrw listing {{{2 |
4448 " g:netrw_bufsettings will be used after the listing is produced. | |
4449 " Called by s:NetrwGetBuffer() | |
1621 | 4450 fun! s:NetrwListSettings(islocal) |
4451 " call Dfunc("s:NetrwListSettings(islocal=".a:islocal.")") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4452 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("<slnum>")) |
1621 | 4453 let fname= bufname("%") |
17433 | 4454 " " call Decho("setl bt=nofile nobl ma nonu nowrap noro nornu",'~'.expand("<slnum>")) |
4455 " nobl noma nomod nonu noma nowrap ro nornu (std g:netrw_bufsettings) | |
4456 setl bt=nofile nobl ma nonu nowrap noro nornu | |
4457 call s:NetrwBufRename(fname) | |
1621 | 4458 if g:netrw_use_noswf |
4339 | 4459 setl noswf |
1621 | 4460 endif |
17433 | 4461 " call Dredir("ls!","s:NetrwListSettings") |
4462 " call Decho("exe setl ts=".(g:netrw_maxfilenamelen+1),'~'.expand("<slnum>")) | |
3920 | 4463 exe "setl ts=".(g:netrw_maxfilenamelen+1) |
4339 | 4464 setl isk+=.,~,- |
1621 | 4465 if g:netrw_fastbrowse > a:islocal |
4339 | 4466 setl bh=hide |
1621 | 4467 else |
4339 | 4468 setl bh=delete |
1621 | 4469 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4470 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("<slnum>")) |
1621 | 4471 " call Dret("s:NetrwListSettings") |
4472 endfun | |
4473 | |
4474 " --------------------------------------------------------------------- | |
17433 | 4475 " s:NetrwListStyle: change list style (thin - long - wide - tree) {{{2 |
1621 | 4476 " islocal=0: remote browsing |
4477 " =1: local browsing | |
4478 fun! s:NetrwListStyle(islocal) | |
4479 " call Dfunc("NetrwListStyle(islocal=".a:islocal.") w:netrw_liststyle=".w:netrw_liststyle) | |
5929 | 4480 |
3920 | 4481 let ykeep = @@ |
1621 | 4482 let fname = s:NetrwGetWord() |
4483 if !exists("w:netrw_liststyle")|let w:netrw_liststyle= g:netrw_liststyle|endif | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4484 let svpos = winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4485 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
1621 | 4486 let w:netrw_liststyle = (w:netrw_liststyle + 1) % s:MAXLIST |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4487 " call Decho("fname<".fname.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4488 " call Decho("chgd w:netrw_liststyle to ".w:netrw_liststyle,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4489 " call Decho("b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "doesn't exist").">",'~'.expand("<slnum>")) |
1621 | 4490 |
17433 | 4491 " repoint t:netrw_lexbufnr if appropriate |
4492 if exists("t:netrw_lexbufnr") && bufnr("%") == t:netrw_lexbufnr | |
4493 " call Decho("set repointlexbufnr to true!") | |
4494 let repointlexbufnr= 1 | |
4495 endif | |
4496 | |
1621 | 4497 if w:netrw_liststyle == s:THINLIST |
4498 " use one column listing | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4499 " call Decho("use one column list",'~'.expand("<slnum>")) |
1621 | 4500 let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge') |
4501 | |
4502 elseif w:netrw_liststyle == s:LONGLIST | |
4503 " use long list | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4504 " call Decho("use long list",'~'.expand("<slnum>")) |
1621 | 4505 let g:netrw_list_cmd = g:netrw_list_cmd." -l" |
4506 | |
4507 elseif w:netrw_liststyle == s:WIDELIST | |
4508 " give wide list | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4509 " call Decho("use wide list",'~'.expand("<slnum>")) |
1621 | 4510 let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge') |
4511 | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4512 elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4513 " call Decho("use tree list",'~'.expand("<slnum>")) |
1621 | 4514 let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge') |
4515 | |
4516 else | |
6476 | 4517 NetrwKeepj call netrw#ErrorMsg(s:WARNING,"bad value for g:netrw_liststyle (=".w:netrw_liststyle.")",46) |
1621 | 4518 let g:netrw_liststyle = s:THINLIST |
4519 let w:netrw_liststyle = g:netrw_liststyle | |
4520 let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge') | |
4521 endif | |
4339 | 4522 setl ma noro |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4523 " call Decho("setl ma noro",'~'.expand("<slnum>")) |
1621 | 4524 |
4525 " clear buffer - this will cause NetrwBrowse/LocalBrowseCheck to do a refresh | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4526 " call Decho("clear buffer<".expand("%")."> with :%d",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4527 sil! NetrwKeepj %d _ |
2152 | 4528 " following prevents tree listing buffer from being marked "modified" |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4529 " call Decho("setl nomod",'~'.expand("<slnum>")) |
3456 | 4530 setl nomod |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4531 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
1621 | 4532 |
4533 " refresh the listing | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4534 " call Decho("refresh the listing",'~'.expand("<slnum>")) |
6476 | 4535 NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) |
4536 NetrwKeepj call s:NetrwCursor() | |
1621 | 4537 |
17433 | 4538 " repoint t:netrw_lexbufnr if appropriate |
4539 if exists("repointlexbufnr") | |
4540 let t:netrw_lexbufnr= bufnr("%") | |
4541 " call Decho("repoint t:netrw_lexbufnr to #".t:netrw_lexbufnr) | |
4542 endif | |
4543 | |
5929 | 4544 " restore position; keep cursor on the filename |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4545 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4546 NetrwKeepj call winrestview(svpos) |
3920 | 4547 let @@= ykeep |
1621 | 4548 |
4549 " call Dret("NetrwListStyle".(exists("w:netrw_liststyle")? ' : w:netrw_liststyle='.w:netrw_liststyle : "")) | |
4550 endfun | |
4551 | |
4552 " --------------------------------------------------------------------- | |
2034 | 4553 " s:NetrwBannerCtrl: toggles the display of the banner {{{2 |
4554 fun! s:NetrwBannerCtrl(islocal) | |
4555 " call Dfunc("s:NetrwBannerCtrl(islocal=".a:islocal.") g:netrw_banner=".g:netrw_banner) | |
4556 | |
3920 | 4557 let ykeep= @@ |
2034 | 4558 " toggle the banner (enable/suppress) |
4559 let g:netrw_banner= !g:netrw_banner | |
4560 | |
4561 " refresh the listing | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4562 let svpos= winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4563 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
2034 | 4564 call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) |
4565 | |
4566 " keep cursor on the filename | |
17433 | 4567 if g:netrw_banner && exists("w:netrw_bannercnt") && line(".") >= w:netrw_bannercnt |
4568 let fname= s:NetrwGetWord() | |
4569 sil NetrwKeepj $ | |
4570 let result= search('\%(^\%(|\+\s\)\=\|\s\{2,}\)\zs'.escape(fname,'.\[]*$^').'\%(\s\{2,}\|$\)','bc') | |
4571 " " call Decho("search result=".result." w:netrw_bannercnt=".(exists("w:netrw_bannercnt")? w:netrw_bannercnt : 'N/A'),'~'.expand("<slnum>")) | |
4572 if result <= 0 && exists("w:netrw_bannercnt") | |
4573 exe "NetrwKeepj ".w:netrw_bannercnt | |
4574 endif | |
2034 | 4575 endif |
3920 | 4576 let @@= ykeep |
2034 | 4577 " call Dret("s:NetrwBannerCtrl : g:netrw_banner=".g:netrw_banner) |
4578 endfun | |
4579 | |
4580 " --------------------------------------------------------------------- | |
6476 | 4581 " s:NetrwBookmark: supports :NetrwMB[!] [file]s {{{2 |
4582 " | |
4583 " No bang: enters files/directories into Netrw's bookmark system | |
4584 " No argument and in netrw buffer: | |
4585 " if there are marked files: bookmark marked files | |
4586 " otherwise : bookmark file/directory under cursor | |
4587 " No argument and not in netrw buffer: bookmarks current open file | |
4588 " Has arguments: globs them individually and bookmarks them | |
4589 " | |
4590 " With bang: deletes files/directories from Netrw's bookmark system | |
4591 fun! s:NetrwBookmark(del,...) | |
4592 " call Dfunc("s:NetrwBookmark(del=".a:del.",...) a:0=".a:0) | |
4593 if a:0 == 0 | |
4594 if &ft == "netrw" | |
4595 let curbufnr = bufnr("%") | |
4596 | |
4597 if exists("s:netrwmarkfilelist_{curbufnr}") | |
4598 " for every filename in the marked list | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4599 " call Decho("bookmark every filename in marked list",'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4600 let svpos = winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4601 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4602 let islocal= expand("%") !~ '^\a\{3,}://' |
6476 | 4603 for fname in s:netrwmarkfilelist_{curbufnr} |
4604 if a:del|call s:DeleteBookmark(fname)|else|call s:MakeBookmark(fname)|endif | |
4605 endfor | |
4606 let curdir = exists("b:netrw_curdir")? b:netrw_curdir : getcwd() | |
4607 call s:NetrwUnmarkList(curbufnr,curdir) | |
4608 NetrwKeepj call s:NetrwRefresh(islocal,s:NetrwBrowseChgDir(islocal,'./')) | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4609 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4610 NetrwKeepj call winrestview(svpos) |
6476 | 4611 else |
4612 let fname= s:NetrwGetWord() | |
4613 if a:del|call s:DeleteBookmark(fname)|else|call s:MakeBookmark(fname)|endif | |
4614 endif | |
4615 | |
4616 else | |
4617 " bookmark currently open file | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4618 " call Decho("bookmark currently open file",'~'.expand("<slnum>")) |
6476 | 4619 let fname= expand("%") |
4620 if a:del|call s:DeleteBookmark(fname)|else|call s:MakeBookmark(fname)|endif | |
4621 endif | |
4622 | |
4623 else | |
4624 " bookmark specified files | |
4625 " attempts to infer if working remote or local | |
4626 " by deciding if the current file begins with an url | |
4627 " Globbing cannot be done remotely. | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4628 let islocal= expand("%") !~ '^\a\{3,}://' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4629 " call Decho("bookmark specified file".((a:0>1)? "s" : ""),'~'.expand("<slnum>")) |
6476 | 4630 let i = 1 |
4631 while i <= a:0 | |
4632 if islocal | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4633 if v:version > 704 || (v:version == 704 && has("patch656")) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4634 let mbfiles= glob(fnameescape(a:{i}),0,1,1) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4635 else |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4636 let mbfiles= glob(fnameescape(a:{i}),0,1) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4637 endif |
6476 | 4638 else |
4639 let mbfiles= [a:{i}] | |
4640 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4641 " call Decho("mbfiles".string(mbfiles),'~'.expand("<slnum>")) |
6476 | 4642 for mbfile in mbfiles |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4643 " call Decho("mbfile<".mbfile.">",'~'.expand("<slnum>")) |
6476 | 4644 if a:del|call s:DeleteBookmark(mbfile)|else|call s:MakeBookmark(mbfile)|endif |
4645 endfor | |
4646 let i= i + 1 | |
4647 endwhile | |
4648 endif | |
4649 | |
4650 " update the menu | |
4651 call s:NetrwBookmarkMenu() | |
4652 | |
4653 " call Dret("s:NetrwBookmark") | |
4654 endfun | |
4655 | |
4656 " --------------------------------------------------------------------- | |
1621 | 4657 " s:NetrwBookmarkMenu: Uses menu priorities {{{2 |
4658 " .2.[cnt] for bookmarks, and | |
4659 " .3.[cnt] for history | |
4660 " (see s:NetrwMenu()) | |
4661 fun! s:NetrwBookmarkMenu() | |
1121 | 4662 if !exists("s:netrw_menucnt") |
4663 return | |
4664 endif | |
17433 | 4665 " call Dfunc("NetrwBookmarkMenu() histcnt=".g:netrw_dirhistcnt." menucnt=".s:netrw_menucnt) |
1621 | 4666 |
4667 " the following test assures that gvim is running, has menus available, and has menus enabled. | |
2751 | 4668 if has("gui") && has("menu") && has("gui_running") && &go =~# 'm' && g:netrw_menu |
1121 | 4669 if exists("g:NetrwTopLvlMenu") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4670 " call Decho("removing ".g:NetrwTopLvlMenu."Bookmarks menu item(s)",'~'.expand("<slnum>")) |
2152 | 4671 exe 'sil! unmenu '.g:NetrwTopLvlMenu.'Bookmarks' |
4672 exe 'sil! unmenu '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Bookmark\ Delete' | |
2034 | 4673 endif |
4674 if !exists("s:netrw_initbookhist") | |
4675 call s:NetrwBookHistRead() | |
1121 | 4676 endif |
4677 | |
4678 " show bookmarked places | |
4339 | 4679 if exists("g:netrw_bookmarklist") && g:netrw_bookmarklist != [] && g:netrw_dirhistmax > 0 |
2034 | 4680 let cnt= 1 |
4681 for bmd in g:netrw_bookmarklist | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4682 " call Decho('sil! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmark.'.bmd.' :e '.bmd,'~'.expand("<slnum>")) |
5618 | 4683 let bmd= escape(bmd,g:netrw_menu_escape) |
2034 | 4684 |
4685 " show bookmarks for goto menu | |
5618 | 4686 exe 'sil! menu '.g:NetrwMenuPriority.".2.".cnt." ".g:NetrwTopLvlMenu.'Bookmarks.'.bmd.' :e '.bmd."\<cr>" |
2034 | 4687 |
4688 " show bookmarks for deletion menu | |
5618 | 4689 exe 'sil! menu '.g:NetrwMenuPriority.".8.2.".cnt." ".g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Bookmark\ Delete.'.bmd.' '.cnt."mB" |
2034 | 4690 let cnt= cnt + 1 |
4691 endfor | |
4692 | |
4693 endif | |
1121 | 4694 |
4695 " show directory browsing history | |
2751 | 4696 if g:netrw_dirhistmax > 0 |
17433 | 4697 let cnt = g:netrw_dirhistcnt |
2751 | 4698 let first = 1 |
4699 let histcnt = 0 | |
17433 | 4700 while ( first || cnt != g:netrw_dirhistcnt ) |
2751 | 4701 let histcnt = histcnt + 1 |
17433 | 4702 let priority = g:netrw_dirhistcnt + histcnt |
2751 | 4703 if exists("g:netrw_dirhist_{cnt}") |
4704 let histdir= escape(g:netrw_dirhist_{cnt},g:netrw_menu_escape) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4705 " call Decho('sil! menu '.g:NetrwMenuPriority.".3.".priority." ".g:NetrwTopLvlMenu.'History.'.histdir.' :e '.histdir,'~'.expand("<slnum>")) |
2751 | 4706 exe 'sil! menu '.g:NetrwMenuPriority.".3.".priority." ".g:NetrwTopLvlMenu.'History.'.histdir.' :e '.histdir."\<cr>" |
4707 endif | |
4708 let first = 0 | |
4709 let cnt = ( cnt - 1 ) % g:netrw_dirhistmax | |
4710 if cnt < 0 | |
4711 let cnt= cnt + g:netrw_dirhistmax | |
4712 endif | |
4713 endwhile | |
4714 endif | |
2034 | 4715 |
1121 | 4716 endif |
1621 | 4717 " call Dret("NetrwBookmarkMenu") |
1121 | 4718 endfun |
4719 | |
4720 " --------------------------------------------------------------------- | |
1621 | 4721 " s:NetrwBrowseChgDir: constructs a new directory based on the current {{{2 |
4722 " directory and a new directory name. Also, if the | |
4723 " "new directory name" is actually a file, | |
4724 " NetrwBrowseChgDir() edits the file. | |
4725 fun! s:NetrwBrowseChgDir(islocal,newdir,...) | |
4726 " 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 : "").">") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4727 " call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>")) |
1621 | 4728 |
3920 | 4729 let ykeep= @@ |
1621 | 4730 if !exists("b:netrw_curdir") |
4731 " Don't try to change-directory: this can happen, for example, when netrw#ErrorMsg has been called | |
4732 " and the current window is the NetrwMessage window. | |
3920 | 4733 let @@= ykeep |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4734 " call Decho("b:netrw_curdir doesn't exist!",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4735 " call Decho("getcwd<".getcwd().">",'~'.expand("<slnum>")) |
17433 | 4736 " call Dredir("ls!","s:NetrwBrowseChgDir") |
1621 | 4737 " call Dret("s:NetrwBrowseChgDir") |
4738 return | |
4739 endif | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4740 " call Decho("b:netrw_curdir<".b:netrw_curdir.">") |
1621 | 4741 |
3920 | 4742 " NetrwBrowseChgDir: save options and initialize {{{3 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4743 " call Decho("saving options",'~'.expand("<slnum>")) |
17433 | 4744 call s:SavePosn(s:netrw_posn) |
4745 NetrwKeepj call s:NetrwOptionsSave("s:") | |
4746 NetrwKeepj call s:NetrwOptionsSafe(a:islocal) | |
2152 | 4747 if (has("win32") || has("win95") || has("win64") || has("win16")) |
5734 | 4748 let dirname = substitute(b:netrw_curdir,'\\','/','ge') |
4749 else | |
4750 let dirname = b:netrw_curdir | |
2152 | 4751 endif |
4752 let newdir = a:newdir | |
4753 let dolockout = 0 | |
5929 | 4754 let dorestore = 1 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4755 " call Decho("dirname<".dirname.">",'~'.expand("<slnum>")) |
17433 | 4756 " call Decho("newdir<".newdir.">",'~'.expand("<slnum>")) |
5734 | 4757 |
4758 " ignore <cr>s when done in the banner | |
17433 | 4759 " call Decho('(s:NetrwBrowseChgDir) ignore [return]s when done in banner (g:netrw_banner='.g:netrw_banner.")",'~'.expand("<slnum>")) |
5734 | 4760 if g:netrw_banner |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4761 " call Decho("w:netrw_bannercnt=".(exists("w:netrw_bannercnt")? w:netrw_bannercnt : 'n/a')." line(.)#".line('.')." line($)#".line("#"),'~'.expand("<slnum>")) |
5734 | 4762 if exists("w:netrw_bannercnt") && line(".") < w:netrw_bannercnt && line("$") >= w:netrw_bannercnt |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4763 if getline(".") =~# 'Quick Help' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4764 " call Decho("#1: quickhelp=".g:netrw_quickhelp." ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
5734 | 4765 let g:netrw_quickhelp= (g:netrw_quickhelp + 1)%len(s:QuickHelp) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4766 " call Decho("#2: quickhelp=".g:netrw_quickhelp." ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
5929 | 4767 setl ma noro nowrap |
6476 | 4768 NetrwKeepj call setline(line('.'),'" Quick Help: <F1>:help '.s:QuickHelp[g:netrw_quickhelp]) |
5734 | 4769 setl noma nomod nowrap |
17433 | 4770 NetrwKeepj call s:NetrwOptionsRestore("s:") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4771 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
5734 | 4772 endif |
4773 endif | |
4774 " else " Decho | |
17433 | 4775 " call Decho("g:netrw_banner=".g:netrw_banner." (no banner)",'~'.expand("<slnum>")) |
5734 | 4776 endif |
1621 | 4777 |
4778 " set up o/s-dependent directory recognition pattern | |
4779 if has("amiga") | |
4780 let dirpat= '[\/:]$' | |
1121 | 4781 else |
1621 | 4782 let dirpat= '[\/]$' |
4783 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4784 " call Decho("set up o/s-dependent directory recognition pattern: dirname<".dirname."> dirpat<".dirpat.">",'~'.expand("<slnum>")) |
1621 | 4785 |
4786 if dirname !~ dirpat | |
4787 " apparently vim is "recognizing" that it is in a directory and | |
2751 | 4788 " is removing the trailing "/". Bad idea, so let's put it back. |
1621 | 4789 let dirname= dirname.'/' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4790 " call Decho("adjusting dirname<".dirname.'> (put trailing "/" back)','~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4791 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4792 |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4793 " call Decho("[newdir<".newdir."> ".((newdir =~ dirpat)? "=~" : "!~")." dirpat<".dirpat.">] && [islocal=".a:islocal."] && [newdir is ".(isdirectory(s:NetrwFile(newdir))? "" : "not ")."a directory]",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4794 if newdir !~ dirpat && !(a:islocal && isdirectory(s:NetrwFile(s:ComposePath(dirname,newdir)))) |
3920 | 4795 " ------------------------------ |
4796 " NetrwBrowseChgDir: edit a file {{{3 | |
4797 " ------------------------------ | |
17433 | 4798 " call Decho('(s:NetrwBrowseChgDir) edit-a-file: case "handling a file": newdir<'.newdir.'> !~ dirpat<'.dirpat.">",'~'.expand("<slnum>")) |
3456 | 4799 |
3920 | 4800 " save position for benefit of Rexplore |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4801 let s:rexposn_{bufnr("%")}= winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4802 " call Decho("edit-a-file: saving posn to s:rexposn_".bufnr("%")."<".string(s:rexposn_{bufnr("%")}).">",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4803 " call Decho("edit-a-file: win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> ft=".&ft,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4804 " call Decho("edit-a-file: w:netrw_liststyle=".(exists("w:netrw_liststyle")? w:netrw_liststyle : 'n/a')." w:netrw_treedict:".(exists("w:netrw_treedict")? "exists" : 'n/a')." newdir<".newdir.">",'~'.expand("<slnum>")) |
5734 | 4805 |
1621 | 4806 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") && newdir !~ '^\(/\|\a:\)' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4807 " call Decho("edit-a-file: handle tree listing: w:netrw_treedict<".(exists("w:netrw_treedict")? string(w:netrw_treedict) : 'n/a').">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4808 " call Decho("edit-a-file: newdir<".newdir.">",'~'.expand("<slnum>")) |
6476 | 4809 let dirname= s:NetrwTreeDir(a:islocal) |
17433 | 4810 "COMBAK : not working for a symlink -- but what about a regular file? a directory? |
4811 " call Decho("COMBAK : not working for a symlink -- but what about a regular file? a directory?") | |
4812 " Feb 17, 2019: following if-else-endif restored -- wasn't editing a file in tree mode | |
1621 | 4813 if dirname =~ '/$' |
4814 let dirname= dirname.newdir | |
4815 else | |
5618 | 4816 let dirname= dirname."/".newdir |
1621 | 4817 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4818 " call Decho("edit-a-file: dirname<".dirname.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4819 " call Decho("edit-a-file: tree listing",'~'.expand("<slnum>")) |
1621 | 4820 elseif newdir =~ '^\(/\|\a:\)' |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4821 " call Decho("edit-a-file: handle an url or path starting with /: <".newdir.">",'~'.expand("<slnum>")) |
1621 | 4822 let dirname= newdir |
1121 | 4823 else |
1621 | 4824 let dirname= s:ComposePath(dirname,newdir) |
4825 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4826 " call Decho("edit-a-file: handling a file: dirname<".dirname."> (a:0=".a:0.")",'~'.expand("<slnum>")) |
6476 | 4827 " this lets netrw#BrowseX avoid the edit |
1621 | 4828 if a:0 < 1 |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4829 " call Decho("edit-a-file: (a:0=".a:0."<1) set up windows for editing<".fnameescape(dirname)."> didsplit=".(exists("s:didsplit")? s:didsplit : "doesn't exist"),'~'.expand("<slnum>")) |
17433 | 4830 NetrwKeepj call s:NetrwOptionsRestore("s:") |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4831 let curdir= b:netrw_curdir |
1621 | 4832 if !exists("s:didsplit") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4833 " call Decho("edit-a-file: s:didsplit does not exist; g:netrw_browse_split=".string(g:netrw_browse_split)." win#".winnr(),'~'.expand("<slnum>")) |
6476 | 4834 if type(g:netrw_browse_split) == 3 |
4835 " open file in server | |
4836 " Note that g:netrw_browse_split is a List: [servername,tabnr,winnr] | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4837 " call Decho("edit-a-file: open file in server",'~'.expand("<slnum>")) |
6476 | 4838 call s:NetrwServerEdit(a:islocal,dirname) |
4839 " call Dret("s:NetrwBrowseChgDir") | |
4840 return | |
4841 elseif g:netrw_browse_split == 1 | |
3920 | 4842 " horizontally splitting the window first |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4843 " call Decho("edit-a-file: horizontally splitting window prior to edit",'~'.expand("<slnum>")) |
4339 | 4844 keepalt new |
2034 | 4845 if !&ea |
4339 | 4846 keepalt wincmd _ |
2034 | 4847 endif |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4848 call s:SetRexDir(a:islocal,curdir) |
1621 | 4849 elseif g:netrw_browse_split == 2 |
3920 | 4850 " vertically splitting the window first |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4851 " call Decho("edit-a-file: vertically splitting window prior to edit",'~'.expand("<slnum>")) |
4339 | 4852 keepalt rightb vert new |
2034 | 4853 if !&ea |
4339 | 4854 keepalt wincmd | |
2034 | 4855 endif |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4856 call s:SetRexDir(a:islocal,curdir) |
1621 | 4857 elseif g:netrw_browse_split == 3 |
3920 | 4858 " open file in new tab |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4859 " call Decho("edit-a-file: opening new tab prior to edit",'~'.expand("<slnum>")) |
4339 | 4860 keepalt tabnew |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4861 if !exists("b:netrw_curdir") |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4862 let b:netrw_curdir= getcwd() |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4863 endif |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4864 call s:SetRexDir(a:islocal,curdir) |
1621 | 4865 elseif g:netrw_browse_split == 4 |
3920 | 4866 " act like "P" (ie. open previous window) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4867 " call Decho("edit-a-file: use previous window for edit",'~'.expand("<slnum>")) |
1621 | 4868 if s:NetrwPrevWinOpen(2) == 3 |
3920 | 4869 let @@= ykeep |
1621 | 4870 " call Dret("s:NetrwBrowseChgDir") |
4871 return | |
4872 endif | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
4873 call s:SetRexDir(a:islocal,curdir) |
1621 | 4874 else |
4875 " handling a file, didn't split, so remove menu | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4876 " call Decho("edit-a-file: handling a file+didn't split, so remove menu",'~'.expand("<slnum>")) |
1621 | 4877 call s:NetrwMenu(0) |
4878 " optional change to window | |
4879 if g:netrw_chgwin >= 1 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4880 " call Decho("edit-a-file: changing window to #".g:netrw_chgwin,'~'.expand("<slnum>")) |
5929 | 4881 if winnr("$")+1 == g:netrw_chgwin |
4882 " if g:netrw_chgwin is set to one more than the last window, then | |
4883 " vertically split the last window to make that window available. | |
4884 let curwin= winnr() | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4885 exe "NetrwKeepj keepalt ".winnr("$")."wincmd w" |
5929 | 4886 vs |
6476 | 4887 exe "NetrwKeepj keepalt ".g:netrw_chgwin."wincmd ".curwin |
5929 | 4888 endif |
6476 | 4889 exe "NetrwKeepj keepalt ".g:netrw_chgwin."wincmd w" |
1621 | 4890 endif |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
4891 call s:SetRexDir(a:islocal,curdir) |
1621 | 4892 endif |
4893 endif | |
2420
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
4894 |
1621 | 4895 " the point where netrw actually edits the (local) file |
4896 " if its local only: LocalBrowseCheck() doesn't edit a file, but NetrwBrowse() will | |
5618 | 4897 " no keepalt to support :e # to return to a directory listing |
1621 | 4898 if a:islocal |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4899 " call Decho("edit-a-file: edit local file: exe e! ".fnameescape(dirname),'~'.expand("<slnum>")) |
5618 | 4900 " some like c-^ to return to the last edited file |
4901 " others like c-^ to return to the netrw buffer | |
4902 if exists("g:netrw_altfile") && g:netrw_altfile | |
6476 | 4903 exe "NetrwKeepj keepalt e! ".fnameescape(dirname) |
5618 | 4904 else |
6476 | 4905 exe "NetrwKeepj e! ".fnameescape(dirname) |
4906 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4907 " call Decho("edit-a-file: after e! ".dirname.": hidden=".&hidden." bufhidden<".&bufhidden."> mod=".&mod,'~'.expand("<slnum>")) |
3920 | 4908 call s:NetrwCursor() |
5929 | 4909 if &hidden || &bufhidden == "hide" |
4910 " file came from vim's hidden storage. Don't "restore" options with it. | |
4911 let dorestore= 0 | |
4912 endif | |
1621 | 4913 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4914 " call Decho("edit-a-file: remote file: NetrwBrowse will edit it",'~'.expand("<slnum>")) |
1621 | 4915 endif |
4916 let dolockout= 1 | |
2034 | 4917 |
4918 " handle g:Netrw_funcref -- call external-to-netrw functions | |
4919 " This code will handle g:Netrw_funcref as an individual function reference | |
4920 " or as a list of function references. It will ignore anything that's not | |
4921 " a function reference. See :help Funcref for information about function references. | |
4922 if exists("g:Netrw_funcref") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4923 " call Decho("edit-a-file: handle optional Funcrefs",'~'.expand("<slnum>")) |
2034 | 4924 if type(g:Netrw_funcref) == 2 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4925 " call Decho("edit-a-file: handling a g:Netrw_funcref",'~'.expand("<slnum>")) |
6476 | 4926 NetrwKeepj call g:Netrw_funcref() |
2034 | 4927 elseif type(g:Netrw_funcref) == 3 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4928 " call Decho("edit-a-file: handling a list of g:Netrw_funcrefs",'~'.expand("<slnum>")) |
2034 | 4929 for Fncref in g:Netrw_funcref |
4930 if type(FncRef) == 2 | |
6476 | 4931 NetrwKeepj call FncRef() |
2034 | 4932 endif |
4933 endfor | |
4934 endif | |
4935 endif | |
1621 | 4936 endif |
4937 | |
4938 elseif newdir =~ '^/' | |
3920 | 4939 " ---------------------------------------------------- |
4940 " NetrwBrowseChgDir: just go to the new directory spec {{{3 | |
4941 " ---------------------------------------------------- | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4942 " call Decho('goto-newdir: case "just go to new directory spec": newdir<'.newdir.'>','~'.expand("<slnum>")) |
6476 | 4943 let dirname = newdir |
4944 NetrwKeepj call s:SetRexDir(a:islocal,dirname) | |
17433 | 4945 NetrwKeepj call s:NetrwOptionsRestore("s:") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4946 norm! m` |
1621 | 4947 |
4948 elseif newdir == './' | |
3920 | 4949 " --------------------------------------------- |
4950 " NetrwBrowseChgDir: refresh the directory list {{{3 | |
4951 " --------------------------------------------- | |
17433 | 4952 " call Decho('(s:NetrwBrowseChgDir)refresh-dirlist: case "refresh directory listing": newdir == "./"','~'.expand("<slnum>")) |
6476 | 4953 NetrwKeepj call s:SetRexDir(a:islocal,dirname) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4954 norm! m` |
1621 | 4955 |
4956 elseif newdir == '../' | |
3920 | 4957 " -------------------------------------- |
4958 " NetrwBrowseChgDir: go up one directory {{{3 | |
4959 " -------------------------------------- | |
17433 | 4960 " call Decho('(s:NetrwBrowseChgDir)go-up: case "go up one directory": newdir == "../"','~'.expand("<slnum>")) |
1621 | 4961 |
4962 if w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") | |
4963 " force a refresh | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4964 " call Decho("go-up: clear buffer<".expand("%")."> with :%d",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4965 " call Decho("go-up: setl noro ma",'~'.expand("<slnum>")) |
3456 | 4966 setl noro ma |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4967 NetrwKeepj %d _ |
1621 | 4968 endif |
4969 | |
4970 if has("amiga") | |
4971 " amiga | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4972 " call Decho('go-up: case "go up one directory": newdir == "../" and amiga','~'.expand("<slnum>")) |
1621 | 4973 if a:islocal |
4974 let dirname= substitute(dirname,'^\(.*[/:]\)\([^/]\+$\)','\1','') | |
4975 let dirname= substitute(dirname,'/$','','') | |
4976 else | |
4977 let dirname= substitute(dirname,'^\(.*[/:]\)\([^/]\+/$\)','\1','') | |
4978 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4979 " call Decho("go-up: amiga: dirname<".dirname."> (go up one dir)",'~'.expand("<slnum>")) |
1621 | 4980 |
5618 | 4981 elseif !g:netrw_cygwin && (has("win32") || has("win95") || has("win64") || has("win16")) |
4982 " windows | |
4983 if a:islocal | |
4984 let dirname= substitute(dirname,'^\(.*\)/\([^/]\+\)/$','\1','') | |
4985 if dirname == "" | |
4986 let dirname= '/' | |
4987 endif | |
4988 else | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4989 let dirname= substitute(dirname,'^\(\a\{3,}://.\{-}/\{1,2}\)\(.\{-}\)\([^/]\+\)/$','\1\2','') |
5618 | 4990 endif |
4991 if dirname =~ '^\a:$' | |
4992 let dirname= dirname.'/' | |
4993 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
4994 " call Decho("go-up: windows: dirname<".dirname."> (go up one dir)",'~'.expand("<slnum>")) |
5618 | 4995 |
1621 | 4996 else |
4997 " unix or cygwin | |
17433 | 4998 " call Decho('(s:NetrwBrowseChgDir)go-up: case "go up one directory": newdir == "../" and unix or cygwin','~'.expand("<slnum>")) |
1621 | 4999 if a:islocal |
5000 let dirname= substitute(dirname,'^\(.*\)/\([^/]\+\)/$','\1','') | |
5001 if dirname == "" | |
5002 let dirname= '/' | |
5003 endif | |
5004 else | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5005 let dirname= substitute(dirname,'^\(\a\{3,}://.\{-}/\{1,2}\)\(.\{-}\)\([^/]\+\)/$','\1\2','') |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5006 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5007 " call Decho("go-up: unix: dirname<".dirname."> (go up one dir)",'~'.expand("<slnum>")) |
1621 | 5008 endif |
6476 | 5009 NetrwKeepj call s:SetRexDir(a:islocal,dirname) |
17433 | 5010 norm! m` |
1621 | 5011 |
5012 elseif exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") | |
3920 | 5013 " -------------------------------------- |
5014 " NetrwBrowseChgDir: Handle Tree Listing {{{3 | |
5015 " -------------------------------------- | |
17433 | 5016 " call Decho('(s:NetrwBrowseChgDir)tree-list: case liststyle is TREELIST and w:netrw_treedict exists','~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5017 " force a refresh (for TREELIST, NetrwTreeDir() will force the refresh) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5018 " call Decho("tree-list: setl noro ma",'~'.expand("<slnum>")) |
3456 | 5019 setl noro ma |
1621 | 5020 if !(exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("b:netrw_curdir")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5021 " call Decho("tree-list: clear buffer<".expand("%")."> with :%d (force refresh)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5022 NetrwKeepj %d _ |
6476 | 5023 endif |
5024 let treedir = s:NetrwTreeDir(a:islocal) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5025 " call Decho("tree-list: treedir<".treedir.">",'~'.expand("<slnum>")) |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5026 let s:treecurpos = winsaveview() |
6476 | 5027 let haskey = 0 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5028 " call Decho("tree-list: w:netrw_treedict<".string(w:netrw_treedict).">",'~'.expand("<slnum>")) |
1621 | 5029 |
5030 " search treedict for tree dir as-is | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5031 " call Decho("tree-list: search treedict for tree dir as-is",'~'.expand("<slnum>")) |
1621 | 5032 if has_key(w:netrw_treedict,treedir) |
17433 | 5033 " call Decho('(s:NetrwBrowseChgDir)tree-list: ....searched for treedir<'.treedir.'> : found it!','~'.expand("<slnum>")) |
1621 | 5034 let haskey= 1 |
5035 else | |
17433 | 5036 " call Decho('(s:NetrwBrowseChgDir)tree-list: ....searched for treedir<'.treedir.'> : not found','~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5037 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5038 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5039 " search treedict for treedir with a [/@] appended |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5040 " call Decho("tree-list: search treedict for treedir with a [/@] appended",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5041 if !haskey && treedir !~ '[/@]$' |
1621 | 5042 if has_key(w:netrw_treedict,treedir."/") |
5043 let treedir= treedir."/" | |
17433 | 5044 " call Decho('(s:NetrwBrowseChgDir)tree-list: ....searched.for treedir<'.treedir.'> found it!','~'.expand("<slnum>")) |
1621 | 5045 let haskey = 1 |
5046 else | |
17433 | 5047 " call Decho('(s:NetrwBrowseChgDir)tree-list: ....searched for treedir<'.treedir.'/> : not found','~'.expand("<slnum>")) |
1621 | 5048 endif |
5049 endif | |
5050 | |
5051 " search treedict for treedir with any trailing / elided | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5052 " call Decho("tree-list: search treedict for treedir with any trailing / elided",'~'.expand("<slnum>")) |
1621 | 5053 if !haskey && treedir =~ '/$' |
5054 let treedir= substitute(treedir,'/$','','') | |
5055 if has_key(w:netrw_treedict,treedir) | |
17433 | 5056 " call Decho('(s:NetrwBrowseChgDir)tree-list: ....searched.for treedir<'.treedir.'> found it!','~'.expand("<slnum>")) |
1621 | 5057 let haskey = 1 |
5058 else | |
17433 | 5059 " call Decho('(s:NetrwBrowseChgDir)tree-list: ....searched for treedir<'.treedir.'> : not found','~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5060 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5061 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5062 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5063 " call Decho("haskey=".haskey,'~'.expand("<slnum>")) |
1621 | 5064 if haskey |
5065 " close tree listing for selected subdirectory | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5066 " call Decho("tree-list: closing selected subdirectory<".dirname.">",'~'.expand("<slnum>")) |
1621 | 5067 call remove(w:netrw_treedict,treedir) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5068 " call Decho("tree-list: removed entry<".treedir."> from treedict",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5069 " call Decho("tree-list: yielding treedict<".string(w:netrw_treedict).">",'~'.expand("<slnum>")) |
2152 | 5070 let dirname= w:netrw_treetop |
1621 | 5071 else |
5072 " go down one directory | |
5073 let dirname= substitute(treedir,'/*$','/','') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5074 " call Decho("tree-list: go down one dir: treedir<".treedir.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5075 " call Decho("tree-list: ... : dirname<".dirname.">",'~'.expand("<slnum>")) |
6476 | 5076 endif |
5077 NetrwKeepj call s:SetRexDir(a:islocal,dirname) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5078 " call Decho("setting s:treeforceredraw to true",'~'.expand("<slnum>")) |
2034 | 5079 let s:treeforceredraw = 1 |
1621 | 5080 |
5081 else | |
3920 | 5082 " ---------------------------------------- |
5083 " NetrwBrowseChgDir: Go down one directory {{{3 | |
5084 " ---------------------------------------- | |
5085 let dirname = s:ComposePath(dirname,newdir) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5086 " call Decho("go down one dir: dirname<".dirname."> newdir<".newdir.">",'~'.expand("<slnum>")) |
6476 | 5087 NetrwKeepj call s:SetRexDir(a:islocal,dirname) |
17433 | 5088 norm! m` |
2751 | 5089 endif |
5090 | |
3920 | 5091 " -------------------------------------- |
5092 " NetrwBrowseChgDir: Restore and Cleanup {{{3 | |
5093 " -------------------------------------- | |
5929 | 5094 if dorestore |
5095 " dorestore is zero'd when a local file was hidden or bufhidden; | |
5096 " in such a case, we want to keep whatever settings it may have. | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5097 " call Decho("doing option restore (dorestore=".dorestore.")",'~'.expand("<slnum>")) |
17433 | 5098 NetrwKeepj call s:NetrwOptionsRestore("s:") |
5929 | 5099 " else " Decho |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5100 " call Decho("skipping option restore (dorestore==0): hidden=".&hidden." bufhidden=".&bufhidden." mod=".&mod,'~'.expand("<slnum>")) |
5929 | 5101 endif |
5102 if dolockout && dorestore | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5103 " call Decho("restore: filewritable(dirname<".dirname.">)=".filewritable(dirname),'~'.expand("<slnum>")) |
2420
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
5104 if filewritable(dirname) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5105 " call Decho("restore: doing modification lockout settings: ma nomod noro",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5106 " call Decho("restore: setl ma nomod noro",'~'.expand("<slnum>")) |
5929 | 5107 setl ma noro nomod |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5108 " call Decho("restore: ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5109 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5110 " call Decho("restore: doing modification lockout settings: ma nomod ro",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5111 " call Decho("restore: setl ma nomod noro",'~'.expand("<slnum>")) |
5929 | 5112 setl ma ro nomod |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5113 " call Decho("restore: ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
3456 | 5114 endif |
1621 | 5115 endif |
17433 | 5116 call s:RestorePosn(s:netrw_posn) |
3920 | 5117 let @@= ykeep |
1621 | 5118 |
5119 " call Dret("s:NetrwBrowseChgDir <".dirname."> : curpos<".string(getpos(".")).">") | |
5120 return dirname | |
1121 | 5121 endfun |
5122 | |
5123 " --------------------------------------------------------------------- | |
5734 | 5124 " s:NetrwBrowseUpDir: implements the "-" mappings {{{2 |
5125 " for thin, long, and wide: cursor placed just after banner | |
5126 " for tree, keeps cursor on current filename | |
5127 fun! s:NetrwBrowseUpDir(islocal) | |
5128 " call Dfunc("s:NetrwBrowseUpDir(islocal=".a:islocal.")") | |
6476 | 5129 if exists("w:netrw_bannercnt") && line(".") < w:netrw_bannercnt-1 |
5130 " this test needed because occasionally this function seems to be incorrectly called | |
5131 " when multiple leftmouse clicks are taken when atop the one line help in the banner. | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5132 " I'm allowing the very bottom line to permit a "-" exit so that one may escape empty |
6476 | 5133 " directories. |
5134 " call Dret("s:NetrwBrowseUpDir : cursor not in file area") | |
5135 return | |
5136 endif | |
5137 | |
5734 | 5138 norm! 0 |
5139 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5140 " call Decho("case: treestyle",'~'.expand("<slnum>")) |
5734 | 5141 let curline= getline(".") |
5142 let swwline= winline() - 1 | |
5143 if exists("w:netrw_treetop") | |
5144 let b:netrw_curdir= w:netrw_treetop | |
17433 | 5145 elseif exists("b:netrw_curdir") |
5146 let w:netrw_treetop= b:netrw_curdir | |
5147 else | |
5148 let w:netrw_treetop= getcwd() | |
5149 let b:netrw_curdir = w:netrw_treetop | |
5150 endif | |
5151 let curfile = getline(".") | |
5152 let curpath = s:NetrwTreePath(w:netrw_treetop) | |
5734 | 5153 if a:islocal |
5154 call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,'../')) | |
5155 else | |
5156 call s:NetrwBrowse(0,s:NetrwBrowseChgDir(0,'../')) | |
5157 endif | |
17433 | 5158 " call Decho("looking for curfile<^".s:treedepthstring.curfile.">",'~'.expand("<slnum>")) |
5159 " call Decho("having curpath<".curpath.">",'~'.expand("<slnum>")) | |
5160 if w:netrw_treetop == '/' | |
5161 keepj call search('^\M'.curfile,"w") | |
5162 elseif curfile == '../' | |
5163 keepj call search('^\M'.curfile,"wb") | |
5164 else | |
5165 " call Decho("search(^\\M".s:treedepthstring.curfile.") backwards")) | |
5166 while 1 | |
5167 keepj call search('^\M'.s:treedepthstring.curfile,"wb") | |
5168 let treepath= s:NetrwTreePath(w:netrw_treetop) | |
5169 " call Decho("..current treepath<".treepath.">",'~'.expand("<slnum>")) | |
5170 if treepath == curpath | |
5171 break | |
5172 endif | |
5173 endwhile | |
5174 endif | |
5175 | |
5734 | 5176 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5177 " call Decho("case: not treestyle",'~'.expand("<slnum>")) |
17433 | 5178 call s:SavePosn(s:netrw_posn) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5179 if exists("b:netrw_curdir") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5180 let curdir= b:netrw_curdir |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5181 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5182 let curdir= expand(getcwd()) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5183 endif |
5734 | 5184 if a:islocal |
5185 call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,'../')) | |
5186 else | |
5187 call s:NetrwBrowse(0,s:NetrwBrowseChgDir(0,'../')) | |
5188 endif | |
17433 | 5189 call s:RestorePosn(s:netrw_posn) |
5190 let curdir= substitute(curdir,'^.*[\/]','','') | |
5191 call search('\<'.curdir.'/','wc') | |
5192 endif | |
5734 | 5193 " call Dret("s:NetrwBrowseUpDir") |
5194 endfun | |
5195 | |
5196 " --------------------------------------------------------------------- | |
6476 | 5197 " netrw#BrowseX: (implements "x") executes a special "viewer" script or program for the {{{2 |
2034 | 5198 " given filename; typically this means given their extension. |
5199 " 0=local, 1=remote | |
6476 | 5200 fun! netrw#BrowseX(fname,remote) |
5201 " call Dfunc("netrw#BrowseX(fname<".a:fname."> remote=".a:remote.")") | |
5202 | |
17433 | 5203 " if its really just a local directory, then do a "gf" instead |
5204 if (a:remote == 0 && isdirectory(a:fname)) || (a:remote == 1 && a:fname =~ '/$' && a:fname !~ '^https\=:') | |
6476 | 5205 norm! gf |
17433 | 5206 " call Dret("(netrw#BrowseX) did gf instead") |
5207 endif | |
1621 | 5208 |
3920 | 5209 let ykeep = @@ |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5210 let screenposn = winsaveview() |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5211 " call Decho("saving posn to screenposn<".string(screenposn).">",'~'.expand("<slnum>")) |
3920 | 5212 |
6476 | 5213 " need to save and restore aw setting as gx can invoke this function from non-netrw buffers |
5214 let awkeep = &aw | |
5215 set noaw | |
5216 | |
2034 | 5217 " special core dump handler |
5218 if a:fname =~ '/core\(\.\d\+\)\=$' | |
5219 if exists("g:Netrw_corehandler") | |
5220 if type(g:Netrw_corehandler) == 2 | |
5221 " g:Netrw_corehandler is a function reference (see :help Funcref) | |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5222 " call Decho("g:Netrw_corehandler is a funcref",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5223 call g:Netrw_corehandler(s:NetrwFile(a:fname)) |
4339 | 5224 elseif type(g:Netrw_corehandler) == 3 |
2034 | 5225 " g:Netrw_corehandler is a List of function references (see :help Funcref) |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5226 " call Decho("g:Netrw_corehandler is a List",'~'.expand("<slnum>")) |
2034 | 5227 for Fncref in g:Netrw_corehandler |
5228 if type(FncRef) == 2 | |
5229 call FncRef(a:fname) | |
5230 endif | |
5231 endfor | |
5232 endif | |
17433 | 5233 " call Decho("restoring posn: screenposn<".string(screenposn).">,'~'.expand("<slnum>"))" |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5234 call winrestview(screenposn) |
3920 | 5235 let @@= ykeep |
6476 | 5236 let &aw= awkeep |
5237 " call Dret("netrw#BrowseX : coredump handler invoked") | |
2034 | 5238 return |
5239 endif | |
5240 endif | |
5241 | |
1621 | 5242 " set up the filename |
5243 " (lower case the extension, make a local copy of a remote file) | |
5244 let exten= substitute(a:fname,'.*\.\(.\{-}\)','\1','e') | |
5245 if has("win32") || has("win95") || has("win64") || has("win16") | |
5246 let exten= substitute(exten,'^.*$','\L&\E','') | |
5247 endif | |
17433 | 5248 if exten =~ "[\\/]" |
5249 let exten= "" | |
5250 endif | |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5251 " call Decho("exten<".exten.">",'~'.expand("<slnum>")) |
1621 | 5252 |
5253 if a:remote == 1 | |
5254 " create a local copy | |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5255 " call Decho("remote: a:remote=".a:remote.": create a local copy of <".a:fname.">",'~'.expand("<slnum>")) |
4339 | 5256 setl bh=delete |
2034 | 5257 call netrw#NetRead(3,a:fname) |
5258 " attempt to rename tempfile | |
5259 let basename= substitute(a:fname,'^\(.*\)/\(.*\)\.\([^.]*\)$','\2','') | |
3920 | 5260 let newname = substitute(s:netrw_tmpfile,'^\(.*\)/\(.*\)\.\([^.]*\)$','\1/'.basename.'.\3','') |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5261 " call Decho("basename<".basename.">",'~'.expand("<slnum>")) |
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5262 " call Decho("newname <".newname.">",'~'.expand("<slnum>")) |
17433 | 5263 if s:netrw_tmpfile != newname && newname != "" |
5264 if rename(s:netrw_tmpfile,newname) == 0 | |
5265 " renaming succeeded | |
5266 " call Decho("renaming succeeded (tmpfile<".s:netrw_tmpfile."> to <".newname.">)") | |
5267 let fname= newname | |
5268 else | |
5269 " renaming failed | |
5270 " call Decho("renaming failed (tmpfile<".s:netrw_tmpfile."> to <".newname.">)") | |
5271 let fname= s:netrw_tmpfile | |
5272 endif | |
5273 else | |
2034 | 5274 let fname= s:netrw_tmpfile |
5275 endif | |
1668 | 5276 else |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5277 " call Decho("local: a:remote=".a:remote.": handling local copy of <".a:fname.">",'~'.expand("<slnum>")) |
1668 | 5278 let fname= a:fname |
2152 | 5279 " special ~ handler for local |
5280 if fname =~ '^\~' && expand("$HOME") != "" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5281 " call Decho('invoking special ~ handler','~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5282 let fname= s:NetrwFile(substitute(fname,'^\~',expand("$HOME"),'')) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5283 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5284 endif |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5285 " call Decho("fname<".fname.">",'~'.expand("<slnum>")) |
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5286 " call Decho("exten<".exten."> "."netrwFileHandlers#NFH_".exten."():exists=".exists("*netrwFileHandlers#NFH_".exten),'~'.expand("<slnum>")) |
1621 | 5287 |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5288 " set up redirection (avoids browser messages) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5289 " by default, g:netrw_suppress_gx_mesg is true |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5290 if g:netrw_suppress_gx_mesg |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5291 if &srr =~ "%s" |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5292 if (has("win32") || has("win95") || has("win64") || has("win16")) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5293 let redir= substitute(&srr,"%s","nul","") |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5294 else |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5295 let redir= substitute(&srr,"%s","/dev/null","") |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5296 endif |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5297 elseif (has("win32") || has("win95") || has("win64") || has("win16")) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5298 let redir= &srr . "nul" |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5299 else |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5300 let redir= &srr . "/dev/null" |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5301 endif |
1621 | 5302 endif |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5303 " call Decho("set up redirection: redir{".redir."} srr{".&srr."}",'~'.expand("<slnum>")) |
1621 | 5304 |
5305 " extract any viewing options. Assumes that they're set apart by quotes. | |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5306 " call Decho("extract any viewing options",'~'.expand("<slnum>")) |
1621 | 5307 if exists("g:netrw_browsex_viewer") |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5308 " call Decho("g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">",'~'.expand("<slnum>")) |
1621 | 5309 if g:netrw_browsex_viewer =~ '\s' |
5310 let viewer = substitute(g:netrw_browsex_viewer,'\s.*$','','') | |
5311 let viewopt = substitute(g:netrw_browsex_viewer,'^\S\+\s*','','')." " | |
5312 let oviewer = '' | |
5313 let cnt = 1 | |
5314 while !executable(viewer) && viewer != oviewer | |
5315 let viewer = substitute(g:netrw_browsex_viewer,'^\(\(^\S\+\s\+\)\{'.cnt.'}\S\+\)\(.*\)$','\1','') | |
5316 let viewopt = substitute(g:netrw_browsex_viewer,'^\(\(^\S\+\s\+\)\{'.cnt.'}\S\+\)\(.*\)$','\3','')." " | |
5317 let cnt = cnt + 1 | |
5318 let oviewer = viewer | |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5319 " call Decho("!exe: viewer<".viewer."> viewopt<".viewopt.">",'~'.expand("<slnum>")) |
1621 | 5320 endwhile |
1121 | 5321 else |
1621 | 5322 let viewer = g:netrw_browsex_viewer |
5323 let viewopt = "" | |
5324 endif | |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5325 " call Decho("viewer<".viewer."> viewopt<".viewopt.">",'~'.expand("<slnum>")) |
1621 | 5326 endif |
5327 | |
5328 " execute the file handler | |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5329 " call Decho("execute the file handler (if any)",'~'.expand("<slnum>")) |
1621 | 5330 if exists("g:netrw_browsex_viewer") && g:netrw_browsex_viewer == '-' |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5331 " call Decho("g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">",'~'.expand("<slnum>")) |
1621 | 5332 let ret= netrwFileHandlers#Invoke(exten,fname) |
5333 | |
5334 elseif exists("g:netrw_browsex_viewer") && executable(viewer) | |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5335 " call Decho("g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5336 call s:NetrwExe("sil !".viewer." ".viewopt.s:ShellEscape(fname,1).redir) |
1621 | 5337 let ret= v:shell_error |
5338 | |
5339 elseif has("win32") || has("win64") | |
17433 | 5340 " call Decho("win".(has("win32")? "32" : "64")",'~'.expand("<slnum>")) |
2034 | 5341 if executable("start") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5342 call s:NetrwExe('sil! !start rundll32 url.dll,FileProtocolHandler '.s:ShellEscape(fname,1)) |
2034 | 5343 elseif executable("rundll32") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5344 call s:NetrwExe('sil! !rundll32 url.dll,FileProtocolHandler '.s:ShellEscape(fname,1)) |
2034 | 5345 else |
5346 call netrw#ErrorMsg(s:WARNING,"rundll32 not on path",74) | |
5347 endif | |
17433 | 5348 " call inputsave()|call input("Press <cr> to continue")|call inputrestore() |
1621 | 5349 let ret= v:shell_error |
5350 | |
3920 | 5351 elseif has("win32unix") |
5352 let winfname= 'c:\cygwin'.substitute(fname,'/','\\','g') | |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5353 " call Decho("cygwin: winfname<".s:ShellEscape(winfname,1).">",'~'.expand("<slnum>")) |
3920 | 5354 if executable("start") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5355 call s:NetrwExe('sil !start rundll32 url.dll,FileProtocolHandler '.s:ShellEscape(winfname,1)) |
3920 | 5356 elseif executable("rundll32") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5357 call s:NetrwExe('sil !rundll32 url.dll,FileProtocolHandler '.s:ShellEscape(winfname,1)) |
6476 | 5358 elseif executable("cygstart") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5359 call s:NetrwExe('sil !cygstart '.s:ShellEscape(fname,1)) |
3920 | 5360 else |
5361 call netrw#ErrorMsg(s:WARNING,"rundll32 not on path",74) | |
5362 endif | |
17433 | 5363 " call inputsave()|call input("Press <cr> to continue")|call inputrestore() |
3920 | 5364 let ret= v:shell_error |
5365 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5366 elseif has("unix") && executable("kfmclient") && s:CheckIfKde() |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5367 " call Decho("unix and kfmclient",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5368 call s:NetrwExe("sil !kfmclient exec ".s:ShellEscape(fname,1)." ".redir) |
1621 | 5369 let ret= v:shell_error |
5370 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5371 elseif has("unix") && executable("exo-open") && executable("xdg-open") && executable("setsid") |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5372 " call Decho("unix, exo-open, xdg-open",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5373 call s:NetrwExe("sil !setsid xdg-open ".s:ShellEscape(fname,1).redir) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5374 let ret= v:shell_error |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5375 |
17433 | 5376 elseif has("unix") && $DESKTOP_SESSION == "mate" && executable("atril") |
5377 " call Decho("unix and atril",'~'.expand("<slnum>")) | |
5378 call s:NetrwExe("sil !atril ".s:ShellEscape(fname,1).redir) | |
5379 let ret= v:shell_error | |
5380 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5381 elseif has("unix") && executable("xdg-open") |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5382 " call Decho("unix and xdg-open",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5383 call s:NetrwExe("sil !xdg-open ".s:ShellEscape(fname,1).redir) |
1621 | 5384 let ret= v:shell_error |
5385 | |
5386 elseif has("macunix") && executable("open") | |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5387 " call Decho("macunix and open",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5388 call s:NetrwExe("sil !open ".s:ShellEscape(fname,1)." ".redir) |
1621 | 5389 let ret= v:shell_error |
5390 | |
1121 | 5391 else |
1621 | 5392 " netrwFileHandlers#Invoke() always returns 0 |
5393 let ret= netrwFileHandlers#Invoke(exten,fname) | |
5394 endif | |
5395 | |
5396 " if unsuccessful, attempt netrwFileHandlers#Invoke() | |
5397 if ret | |
5398 let ret= netrwFileHandlers#Invoke(exten,fname) | |
5399 endif | |
5400 | |
1668 | 5401 " restoring redraw! after external file handlers |
5402 redraw! | |
1621 | 5403 |
5404 " cleanup: remove temporary file, | |
5405 " delete current buffer if success with handler, | |
5406 " return to prior buffer (directory listing) | |
5407 " Feb 12, 2008: had to de-activiate removal of | |
5408 " temporary file because it wasn't getting seen. | |
5409 " if a:remote == 1 && fname != a:fname | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5410 "" call Decho("deleting temporary file<".fname.">",'~'.expand("<slnum>")) |
1668 | 5411 " call s:NetrwDelete(fname) |
1621 | 5412 " endif |
5413 | |
5414 if a:remote == 1 | |
4339 | 5415 setl bh=delete bt=nofile |
1621 | 5416 if g:netrw_use_noswf |
4339 | 5417 setl noswf |
1621 | 5418 endif |
6476 | 5419 exe "sil! NetrwKeepj norm! \<c-o>" |
1621 | 5420 " redraw! |
5421 endif | |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
5422 " call Decho("restoring posn to screenposn<".string(screenposn).">",'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5423 call winrestview(screenposn) |
6476 | 5424 let @@ = ykeep |
5425 let &aw= awkeep | |
5426 | |
5427 " call Dret("netrw#BrowseX") | |
5428 endfun | |
5429 | |
5430 " --------------------------------------------------------------------- | |
17433 | 5431 " netrw#GX: gets word under cursor for gx support {{{2 |
5432 " See also: netrw#BrowseXVis | |
5433 " netrw#BrowseX | |
5434 fun! netrw#GX() | |
5435 " call Dfunc("netrw#GX()") | |
5436 if &ft == "netrw" | |
5437 let fname= s:NetrwGetWord() | |
5438 else | |
5439 let fname= expand((exists("g:netrw_gx")? g:netrw_gx : '<cfile>')) | |
5440 endif | |
5441 " call Dret("netrw#GX <".fname.">") | |
5442 return fname | |
5443 endfun | |
5444 | |
5445 " --------------------------------------------------------------------- | |
6476 | 5446 " netrw#BrowseXVis: used by gx in visual mode to select a file for browsing {{{2 |
5447 fun! netrw#BrowseXVis() | |
5448 " call Dfunc("netrw#BrowseXVis()") | |
5449 let atkeep = @@ | |
5450 norm! gvy | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5451 " call Decho("@@<".@@.">",'~'.expand("<slnum>")) |
17433 | 5452 call netrw#BrowseX(@@,netrw#CheckIfRemote(@@)) |
6476 | 5453 let @@ = atkeep |
5454 " call Dret("netrw#BrowseXVis") | |
5455 endfun | |
5456 | |
5457 " --------------------------------------------------------------------- | |
17433 | 5458 " s:NetrwBufRename: renames a buffer without the side effect of retaining an unlisted buffer having the old name {{{2 |
5459 " Using the file command on a "[No Name]" buffer does not seem to cause the old "[No Name]" buffer | |
5460 " to become an unlisted buffer, so in that case don't bwipe it. | |
5461 fun! s:NetrwBufRename(newname) | |
5462 " call Dfunc("s:NetrwBufRename(newname<".a:newname.">) buf(%)#".bufnr("%")."<".bufname(bufnr("%")).">") | |
5463 " call Dredir("ls!","s:NetrwBufRename (before rename)") | |
5464 let oldbufname= bufname(bufnr("%")) | |
5465 " call Decho("buf#".bufnr("%").": oldbufname<".oldbufname.">",'~'.expand("<slnum>")) | |
5466 | |
5467 if oldbufname != a:newname | |
5468 " call Decho("do buffer rename: oldbufname<".oldbufname."> ≠a:newname<".a:newname.">",'~'.expand("<slnum>")) | |
5469 let b:junk= 1 | |
5470 " call Decho("rename buffer: sil! keepj keepalt file ".fnameescape(a:newname),'~'.expand("<slnum>")) | |
5471 exe 'sil! keepj keepalt file '.fnameescape(a:newname) | |
5472 " call Dredir("ls!","s:NetrwBufRename (before bwipe)") | |
5473 let oldbufnr= bufnr(oldbufname) | |
5474 " call Decho("oldbufname<".oldbufname."> oldbufnr#".oldbufnr,'~'.expand("<slnum>")) | |
5475 " call Decho("bufnr(%)=".bufnr("%"),'~'.expand("<slnum>")) | |
5476 if oldbufname != "" && oldbufnr != -1 && oldbufnr != bufnr("%") | |
5477 " call Decho("bwipe ".oldbufnr,'~'.expand("<slnum>")) | |
5478 exe "bwipe! ".oldbufnr | |
5479 " else " Decho | |
5480 " call Decho("did *not* bwipe buf#".oldbufnr,'~'.expand("<slnum>")) | |
5481 endif | |
5482 " call Dredir("ls!","s:NetrwBufRename (after rename)") | |
5483 " else " Decho | |
5484 " call Decho("oldbufname<".oldbufname."> == a:newname: did *not* rename",'~'.expand("<slnum>")) | |
5485 endif | |
5486 | |
5487 " call Dret("s:NetrwBufRename : buf#".bufnr("%").": oldname<".oldbufname."> newname<".a:newname."> expand(%)<".expand("%").">") | |
5488 endfun | |
5489 | |
5490 " --------------------------------------------------------------------- | |
6476 | 5491 " netrw#CheckIfRemote: returns 1 if current file looks like an url, 0 else {{{2 |
17433 | 5492 fun! netrw#CheckIfRemote(...) |
5493 " call Dfunc("netrw#CheckIfRemote() a:0=".a:0) | |
5494 if a:0 > 0 | |
5495 let curfile= a:1 | |
5496 else | |
5497 let curfile= expand("%") | |
5498 endif | |
5499 " call Decho("curfile<".curfile.">") | |
5500 if curfile =~ '^\a\{3,}://' | |
6476 | 5501 " call Dret("netrw#CheckIfRemote 1") |
5502 return 1 | |
5503 else | |
5504 " call Dret("netrw#CheckIfRemote 0") | |
5505 return 0 | |
5506 endif | |
1121 | 5507 endfun |
5508 | |
5509 " --------------------------------------------------------------------- | |
2034 | 5510 " s:NetrwChgPerm: (implements "gp") change file permission {{{2 |
5511 fun! s:NetrwChgPerm(islocal,curdir) | |
5512 " call Dfunc("s:NetrwChgPerm(islocal=".a:islocal." curdir<".a:curdir.">)") | |
3920 | 5513 let ykeep = @@ |
2034 | 5514 call inputsave() |
5515 let newperm= input("Enter new permission: ") | |
5516 call inputrestore() | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5517 let chgperm= substitute(g:netrw_chgperm,'\<FILENAME\>',s:ShellEscape(expand("<cfile>")),'') |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5518 let chgperm= substitute(chgperm,'\<PERM\>',s:ShellEscape(newperm),'') |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5519 " call Decho("chgperm<".chgperm.">",'~'.expand("<slnum>")) |
2034 | 5520 call system(chgperm) |
5521 if v:shell_error != 0 | |
6476 | 5522 NetrwKeepj call netrw#ErrorMsg(1,"changing permission on file<".expand("<cfile>")."> seems to have failed",75) |
2034 | 5523 endif |
5524 if a:islocal | |
6476 | 5525 NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) |
2034 | 5526 endif |
3920 | 5527 let @@= ykeep |
2034 | 5528 " call Dret("s:NetrwChgPerm") |
5529 endfun | |
5530 | |
5531 " --------------------------------------------------------------------- | |
6476 | 5532 " s:CheckIfKde: checks if kdeinit is running {{{2 |
5533 " Returns 0: kdeinit not running | |
5534 " 1: kdeinit is running | |
5535 fun! s:CheckIfKde() | |
5536 " call Dfunc("s:CheckIfKde()") | |
5537 " seems kde systems often have gnome-open due to dependencies, even though | |
5538 " gnome-open's subsidiary display tools are largely absent. Kde systems | |
5539 " usually have "kdeinit" running, though... (tnx Mikolaj Machowski) | |
5540 if !exists("s:haskdeinit") | |
5541 if has("unix") && executable("ps") && !has("win32unix") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5542 let s:haskdeinit= system("ps -e") =~ '\<kdeinit' |
6476 | 5543 if v:shell_error |
5544 let s:haskdeinit = 0 | |
5545 endif | |
5546 else | |
5547 let s:haskdeinit= 0 | |
5548 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5549 " call Decho("setting s:haskdeinit=".s:haskdeinit,'~'.expand("<slnum>")) |
6476 | 5550 endif |
5551 | |
5552 " call Dret("s:CheckIfKde ".s:haskdeinit) | |
5553 return s:haskdeinit | |
5554 endfun | |
5555 | |
5556 " --------------------------------------------------------------------- | |
2034 | 5557 " s:NetrwClearExplore: clear explore variables (if any) {{{2 |
5558 fun! s:NetrwClearExplore() | |
5559 " call Dfunc("s:NetrwClearExplore()") | |
5560 2match none | |
5561 if exists("s:explore_match") |unlet s:explore_match |endif | |
5562 if exists("s:explore_indx") |unlet s:explore_indx |endif | |
5563 if exists("s:netrw_explore_prvdir") |unlet s:netrw_explore_prvdir |endif | |
5564 if exists("s:dirstarstar") |unlet s:dirstarstar |endif | |
5565 if exists("s:explore_prvdir") |unlet s:explore_prvdir |endif | |
5566 if exists("w:netrw_explore_indx") |unlet w:netrw_explore_indx |endif | |
5567 if exists("w:netrw_explore_listlen")|unlet w:netrw_explore_listlen|endif | |
5568 if exists("w:netrw_explore_list") |unlet w:netrw_explore_list |endif | |
5569 if exists("w:netrw_explore_bufnr") |unlet w:netrw_explore_bufnr |endif | |
5570 " redraw! | |
5571 echo " " | |
5572 echo " " | |
5573 " call Dret("s:NetrwClearExplore") | |
5574 endfun | |
5575 | |
5576 " --------------------------------------------------------------------- | |
5577 " s:NetrwExploreListUniq: {{{2 | |
5578 fun! s:NetrwExploreListUniq(explist) | |
3153 | 5579 " call Dfunc("s:NetrwExploreListUniq(explist<".string(a:explist).">)") |
2034 | 5580 |
5581 " this assumes that the list is already sorted | |
5582 let newexplist= [] | |
5583 for member in a:explist | |
5584 if !exists("uniqmember") || member != uniqmember | |
5585 let uniqmember = member | |
5586 let newexplist = newexplist + [ member ] | |
5587 endif | |
5588 endfor | |
5589 | |
3153 | 5590 " call Dret("s:NetrwExploreListUniq newexplist<".string(newexplist).">") |
2034 | 5591 return newexplist |
5592 endfun | |
5593 | |
5594 " --------------------------------------------------------------------- | |
2751 | 5595 " s:NetrwForceChgDir: (gd support) Force treatment as a directory {{{2 |
5596 fun! s:NetrwForceChgDir(islocal,newdir) | |
5597 " call Dfunc("s:NetrwForceChgDir(islocal=".a:islocal." newdir<".a:newdir.">)") | |
3920 | 5598 let ykeep= @@ |
2751 | 5599 if a:newdir !~ '/$' |
5600 " ok, looks like force is needed to get directory-style treatment | |
5601 if a:newdir =~ '@$' | |
5602 let newdir= substitute(a:newdir,'@$','/','') | |
5603 elseif a:newdir =~ '[*=|\\]$' | |
5604 let newdir= substitute(a:newdir,'.$','/','') | |
5605 else | |
5606 let newdir= a:newdir.'/' | |
5607 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5608 " call Decho("adjusting newdir<".newdir."> due to gd",'~'.expand("<slnum>")) |
2751 | 5609 else |
5610 " should already be getting treatment as a directory | |
5611 let newdir= a:newdir | |
5612 endif | |
3920 | 5613 let newdir= s:NetrwBrowseChgDir(a:islocal,newdir) |
2751 | 5614 call s:NetrwBrowse(a:islocal,newdir) |
3920 | 5615 let @@= ykeep |
2751 | 5616 " call Dret("s:NetrwForceChgDir") |
5617 endfun | |
5618 | |
5619 " --------------------------------------------------------------------- | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5620 " s:NetrwGlob: does glob() if local, remote listing otherwise {{{2 |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5621 " direntry: this is the name of the directory. Will be fnameescape'd to prevent wildcard handling by glob() |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5622 " expr : this is the expression to follow the directory. Will use s:ComposePath() |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5623 " pare =1: remove the current directory from the resulting glob() filelist |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5624 " =0: leave the current directory in the resulting glob() filelist |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5625 fun! s:NetrwGlob(direntry,expr,pare) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5626 " call Dfunc("s:NetrwGlob(direntry<".a:direntry."> expr<".a:expr."> pare=".a:pare.")") |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5627 if netrw#CheckIfRemote() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5628 keepalt 1sp |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5629 keepalt enew |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5630 let keep_liststyle = w:netrw_liststyle |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5631 let w:netrw_liststyle = s:THINLIST |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5632 if s:NetrwRemoteListing() == 0 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5633 keepj keepalt %s@/@@ |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5634 let filelist= getline(1,$) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5635 q! |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5636 else |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5637 " remote listing error -- leave treedict unchanged |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5638 let filelist= w:netrw_treedict[a:direntry] |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5639 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5640 let w:netrw_liststyle= keep_liststyle |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5641 elseif v:version > 704 || (v:version == 704 && has("patch656")) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5642 let filelist= glob(s:ComposePath(fnameescape(a:direntry),a:expr),0,1,1) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5643 if a:pare |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5644 let filelist= map(filelist,'substitute(v:val, "^.*/", "", "")') |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5645 endif |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5646 else |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5647 let filelist= glob(s:ComposePath(fnameescape(a:direntry),a:expr),0,1) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5648 if a:pare |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5649 let filelist= map(filelist,'substitute(v:val, "^.*/", "", "")') |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
5650 endif |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5651 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5652 " call Dret("s:NetrwGlob ".string(filelist)) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5653 return filelist |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5654 endfun |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5655 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5656 " --------------------------------------------------------------------- |
2751 | 5657 " s:NetrwForceFile: (gf support) Force treatment as a file {{{2 |
5658 fun! s:NetrwForceFile(islocal,newfile) | |
4339 | 5659 " call Dfunc("s:NetrwForceFile(islocal=".a:islocal." newdir<".a:newfile.">)") |
2751 | 5660 if a:newfile =~ '[/@*=|\\]$' |
5661 let newfile= substitute(a:newfile,'.$','','') | |
5662 else | |
5663 let newfile= a:newfile | |
5664 endif | |
4339 | 5665 if a:islocal |
5666 call s:NetrwBrowseChgDir(a:islocal,newfile) | |
5667 else | |
5668 call s:NetrwBrowse(a:islocal,s:NetrwBrowseChgDir(a:islocal,newfile)) | |
5669 endif | |
2751 | 5670 " call Dret("s:NetrwForceFile") |
5671 endfun | |
5672 | |
5673 " --------------------------------------------------------------------- | |
1621 | 5674 " s:NetrwHide: this function is invoked by the "a" map for browsing {{{2 |
5675 " and switches the hiding mode. The actual hiding is done by | |
5676 " s:NetrwListHide(). | |
5677 " g:netrw_hide= 0: show all | |
5678 " 1: show not-hidden files | |
5679 " 2: show hidden files only | |
5680 fun! s:NetrwHide(islocal) | |
5681 " call Dfunc("NetrwHide(islocal=".a:islocal.") g:netrw_hide=".g:netrw_hide) | |
3920 | 5682 let ykeep= @@ |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5683 let svpos= winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5684 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
1621 | 5685 |
5686 if exists("s:netrwmarkfilelist_{bufnr('%')}") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5687 " call Decho("((g:netrw_hide == 1)? "unhide" : "hide")." files in markfilelist<".string(s:netrwmarkfilelist_{bufnr("%")}).">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5688 " call Decho("g:netrw_list_hide<".g:netrw_list_hide.">",'~'.expand("<slnum>")) |
1621 | 5689 |
5690 " hide the files in the markfile list | |
5691 for fname in s:netrwmarkfilelist_{bufnr("%")} | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5692 " call Decho("match(g:netrw_list_hide<".g:netrw_list_hide.'> fname<\<'.fname.'\>>)='.match(g:netrw_list_hide,'\<'.fname.'\>')." l:isk=".&l:isk,'~'.expand("<slnum>")) |
1621 | 5693 if match(g:netrw_list_hide,'\<'.fname.'\>') != -1 |
5694 " remove fname from hiding list | |
5695 let g:netrw_list_hide= substitute(g:netrw_list_hide,'..\<'.escape(fname,g:netrw_fname_escape).'\>..','','') | |
5696 let g:netrw_list_hide= substitute(g:netrw_list_hide,',,',',','g') | |
5697 let g:netrw_list_hide= substitute(g:netrw_list_hide,'^,\|,$','','') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5698 " call Decho("unhide: g:netrw_list_hide<".g:netrw_list_hide.">",'~'.expand("<slnum>")) |
1621 | 5699 else |
5700 " append fname to hiding list | |
5701 if exists("g:netrw_list_hide") && g:netrw_list_hide != "" | |
5702 let g:netrw_list_hide= g:netrw_list_hide.',\<'.escape(fname,g:netrw_fname_escape).'\>' | |
5703 else | |
5704 let g:netrw_list_hide= '\<'.escape(fname,g:netrw_fname_escape).'\>' | |
5705 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5706 " call Decho("hide: g:netrw_list_hide<".g:netrw_list_hide.">",'~'.expand("<slnum>")) |
1621 | 5707 endif |
5708 endfor | |
6476 | 5709 NetrwKeepj call s:NetrwUnmarkList(bufnr("%"),b:netrw_curdir) |
1621 | 5710 let g:netrw_hide= 1 |
5711 | |
5712 else | |
5713 | |
5714 " switch between show-all/show-not-hidden/show-hidden | |
5715 let g:netrw_hide=(g:netrw_hide+1)%3 | |
6476 | 5716 exe "NetrwKeepj norm! 0" |
1621 | 5717 if g:netrw_hide && g:netrw_list_hide == "" |
6476 | 5718 NetrwKeepj call netrw#ErrorMsg(s:WARNING,"your hiding list is empty!",49) |
3920 | 5719 let @@= ykeep |
1621 | 5720 " call Dret("NetrwHide") |
5721 return | |
5722 endif | |
5723 endif | |
5724 | |
6476 | 5725 NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5726 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5727 NetrwKeepj call winrestview(svpos) |
3920 | 5728 let @@= ykeep |
1621 | 5729 " call Dret("NetrwHide") |
5730 endfun | |
5731 | |
5732 " --------------------------------------------------------------------- | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5733 " s:NetrwHideEdit: allows user to edit the file/directory hiding list {{{2 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5734 fun! s:NetrwHideEdit(islocal) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5735 " call Dfunc("NetrwHideEdit(islocal=".a:islocal.")") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5736 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5737 let ykeep= @@ |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5738 " save current cursor position |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5739 let svpos= winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5740 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5741 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5742 " get new hiding list from user |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5743 call inputsave() |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5744 let newhide= input("Edit Hiding List: ",g:netrw_list_hide) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5745 call inputrestore() |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5746 let g:netrw_list_hide= newhide |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5747 " call Decho("new g:netrw_list_hide<".g:netrw_list_hide.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5748 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5749 " refresh the listing |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5750 sil NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,"./")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5751 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5752 " restore cursor position |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5753 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5754 call winrestview(svpos) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5755 let @@= ykeep |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5756 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5757 " call Dret("NetrwHideEdit") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5758 endfun |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5759 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5760 " --------------------------------------------------------------------- |
1621 | 5761 " s:NetrwHidden: invoked by "gh" {{{2 |
5762 fun! s:NetrwHidden(islocal) | |
5763 " call Dfunc("s:NetrwHidden()") | |
3920 | 5764 let ykeep= @@ |
1621 | 5765 " save current position |
17433 | 5766 let svpos = winsaveview() |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5767 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
1621 | 5768 |
5769 if g:netrw_list_hide =~ '\(^\|,\)\\(^\\|\\s\\s\\)\\zs\\.\\S\\+' | |
17433 | 5770 " remove .file pattern from hiding list |
5771 " call Decho("remove .file pattern from hiding list",'~'.expand("<slnum>")) | |
1621 | 5772 let g:netrw_list_hide= substitute(g:netrw_list_hide,'\(^\|,\)\\(^\\|\\s\\s\\)\\zs\\.\\S\\+','','') |
2034 | 5773 elseif s:Strlen(g:netrw_list_hide) >= 1 |
17433 | 5774 " call Decho("add .file pattern from hiding list",'~'.expand("<slnum>")) |
1621 | 5775 let g:netrw_list_hide= g:netrw_list_hide . ',\(^\|\s\s\)\zs\.\S\+' |
5776 else | |
17433 | 5777 " call Decho("set .file pattern as hiding list",'~'.expand("<slnum>")) |
1621 | 5778 let g:netrw_list_hide= '\(^\|\s\s\)\zs\.\S\+' |
5779 endif | |
17433 | 5780 if g:netrw_list_hide =~ '^,' |
5781 let g:netrw_list_hide= strpart(g:netrw_list_hide,1) | |
5782 endif | |
1621 | 5783 |
5784 " refresh screen and return to saved position | |
6476 | 5785 NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5786 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5787 NetrwKeepj call winrestview(svpos) |
3920 | 5788 let @@= ykeep |
1621 | 5789 " call Dret("s:NetrwHidden") |
5790 endfun | |
5791 | |
5792 " --------------------------------------------------------------------- | |
2034 | 5793 " s:NetrwHome: this function determines a "home" for saving bookmarks and history {{{2 |
5794 fun! s:NetrwHome() | |
5795 if exists("g:netrw_home") | |
17433 | 5796 let home= expand(g:netrw_home) |
2034 | 5797 else |
5798 " go to vim plugin home | |
5799 for home in split(&rtp,',') + [''] | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5800 if isdirectory(s:NetrwFile(home)) && filewritable(s:NetrwFile(home)) | break | endif |
2034 | 5801 let basehome= substitute(home,'[/\\]\.vim$','','') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5802 if isdirectory(s:NetrwFile(basehome)) && filewritable(s:NetrwFile(basehome)) |
2034 | 5803 let home= basehome."/.vim" |
5804 break | |
5805 endif | |
5806 endfor | |
5807 if home == "" | |
5808 " just pick the first directory | |
5809 let home= substitute(&rtp,',.*$','','') | |
5810 endif | |
5811 if (has("win32") || has("win95") || has("win64") || has("win16")) | |
5812 let home= substitute(home,'/','\\','g') | |
5813 endif | |
5814 endif | |
5815 " insure that the home directory exists | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5816 if g:netrw_dirhistmax > 0 && !isdirectory(s:NetrwFile(home)) |
17433 | 5817 " call Decho("insure that the home<".home."> directory exists") |
2034 | 5818 if exists("g:netrw_mkdir") |
17433 | 5819 " call Decho("call system(".g:netrw_mkdir." ".s:ShellEscape(s:NetrwFile(home)).")") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5820 call system(g:netrw_mkdir." ".s:ShellEscape(s:NetrwFile(home))) |
2034 | 5821 else |
17433 | 5822 " call Decho("mkdir(".home.")") |
2034 | 5823 call mkdir(home) |
5824 endif | |
5825 endif | |
5826 let g:netrw_home= home | |
5827 return home | |
5828 endfun | |
5829 | |
5830 " --------------------------------------------------------------------- | |
1621 | 5831 " s:NetrwLeftmouse: handles the <leftmouse> when in a netrw browsing window {{{2 |
5832 fun! s:NetrwLeftmouse(islocal) | |
4339 | 5833 if exists("s:netrwdrag") |
5834 return | |
5835 endif | |
17433 | 5836 if &ft != "netrw" |
5837 return | |
5838 endif | |
1621 | 5839 " call Dfunc("s:NetrwLeftmouse(islocal=".a:islocal.")") |
2152 | 5840 |
3920 | 5841 let ykeep= @@ |
2152 | 5842 " check if the status bar was clicked on instead of a file/directory name |
2751 | 5843 while getchar(0) != 0 |
5844 "clear the input stream | |
5845 endwhile | |
2152 | 5846 call feedkeys("\<LeftMouse>") |
2751 | 5847 let c = getchar() |
2152 | 5848 let mouse_lnum = v:mouse_lnum |
5849 let wlastline = line('w$') | |
5850 let lastline = line('$') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5851 " call Decho("v:mouse_lnum=".mouse_lnum." line(w$)=".wlastline." line($)=".lastline." v:mouse_win=".v:mouse_win." winnr#".winnr(),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5852 " call Decho("v:mouse_col =".v:mouse_col." col=".col(".")." wincol =".wincol()." winwidth =".winwidth(0),'~'.expand("<slnum>")) |
2152 | 5853 if mouse_lnum >= wlastline + 1 || v:mouse_win != winnr() |
5854 " appears to be a status bar leftmouse click | |
3920 | 5855 let @@= ykeep |
2152 | 5856 " call Dret("s:NetrwLeftmouse : detected a status bar leftmouse click") |
5857 return | |
5858 endif | |
6476 | 5859 " Dec 04, 2013: following test prevents leftmouse selection/deselection of directories and files in treelist mode |
5618 | 5860 " Windows are separated by vertical separator bars - but the mouse seems to be doing what it should when dragging that bar |
6476 | 5861 " without this test when its disabled. |
5862 " May 26, 2014: edit file, :Lex, resize window -- causes refresh. Reinstated a modified test. See if problems develop. | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5863 " call Decho("v:mouse_col=".v:mouse_col." col#".col('.')." virtcol#".virtcol('.')." col($)#".col("$")." virtcol($)#".virtcol("$"),'~'.expand("<slnum>")) |
6476 | 5864 if v:mouse_col > virtcol('.') |
5865 let @@= ykeep | |
5866 " call Dret("s:NetrwLeftmouse : detected a vertical separator bar leftmouse click") | |
5867 return | |
5868 endif | |
2152 | 5869 |
1621 | 5870 if a:islocal |
5871 if exists("b:netrw_curdir") | |
6476 | 5872 NetrwKeepj call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,s:NetrwGetWord())) |
1621 | 5873 endif |
5874 else | |
5875 if exists("b:netrw_curdir") | |
6476 | 5876 NetrwKeepj call s:NetrwBrowse(0,s:NetrwBrowseChgDir(0,s:NetrwGetWord())) |
1621 | 5877 endif |
5878 endif | |
3920 | 5879 let @@= ykeep |
1621 | 5880 " call Dret("s:NetrwLeftmouse") |
5881 endfun | |
5882 | |
5883 " --------------------------------------------------------------------- | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5884 " s:NetrwCLeftmouse: used to select a file/directory for a target {{{2 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5885 fun! s:NetrwCLeftmouse(islocal) |
17433 | 5886 if &ft != "netrw" |
5887 return | |
5888 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5889 " call Dfunc("s:NetrwCLeftmouse(islocal=".a:islocal.")") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5890 call s:NetrwMarkFileTgt(a:islocal) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5891 " call Dret("s:NetrwCLeftmouse") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5892 endfun |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5893 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5894 " --------------------------------------------------------------------- |
6476 | 5895 " s:NetrwServerEdit: edit file in a server gvim, usually NETRWSERVER (implements <c-r>){{{2 |
5896 " a:islocal=0 : <c-r> not used, remote | |
17433 | 5897 " a:islocal=1 : <c-r> not used, local |
6476 | 5898 " a:islocal=2 : <c-r> used, remote |
5899 " a:islocal=3 : <c-r> used, local | |
5900 fun! s:NetrwServerEdit(islocal,fname) | |
5901 " call Dfunc("s:NetrwServerEdit(islocal=".a:islocal.",fname<".a:fname.">)") | |
5902 let islocal = a:islocal%2 " =0: remote =1: local | |
5903 let ctrlr = a:islocal >= 2 " =0: <c-r> not used =1: <c-r> used | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5904 " call Decho("islocal=".islocal." ctrlr=".ctrlr,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5905 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5906 if (islocal && isdirectory(s:NetrwFile(a:fname))) || (!islocal && a:fname =~ '/$') |
6476 | 5907 " handle directories in the local window -- not in the remote vim server |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5908 " user must have closed the NETRWSERVER window. Treat as normal editing from netrw. |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5909 " call Decho("handling directory in client window",'~'.expand("<slnum>")) |
6476 | 5910 let g:netrw_browse_split= 0 |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
5911 if exists("s:netrw_browse_split") && exists("s:netrw_browse_split_".winnr()) |
6476 | 5912 let g:netrw_browse_split= s:netrw_browse_split_{winnr()} |
5913 unlet s:netrw_browse_split_{winnr()} | |
5914 endif | |
5915 call s:NetrwBrowse(islocal,s:NetrwBrowseChgDir(islocal,a:fname)) | |
5916 " call Dret("s:NetrwServerEdit") | |
5917 return | |
5918 endif | |
5919 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5920 " call Decho("handling file in server window",'~'.expand("<slnum>")) |
6476 | 5921 if has("clientserver") && executable("gvim") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5922 " call Decho("has clientserver and gvim",'~'.expand("<slnum>")) |
6476 | 5923 |
5924 if exists("g:netrw_browse_split") && type(g:netrw_browse_split) == 3 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5925 " call Decho("g:netrw_browse_split=".string(g:netrw_browse_split),'~'.expand("<slnum>")) |
6476 | 5926 let srvrname = g:netrw_browse_split[0] |
5927 let tabnum = g:netrw_browse_split[1] | |
5928 let winnum = g:netrw_browse_split[2] | |
5929 | |
5930 if serverlist() !~ '\<'.srvrname.'\>' | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5931 " call Decho("server not available; ctrlr=".ctrlr,'~'.expand("<slnum>")) |
6476 | 5932 |
5933 if !ctrlr | |
5934 " user must have closed the server window and the user did not use <c-r>, but | |
5935 " used something like <cr>. | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5936 " call Decho("user must have closed server AND did not use ctrl-r",'~'.expand("<slnum>")) |
6476 | 5937 if exists("g:netrw_browse_split") |
5938 unlet g:netrw_browse_split | |
5939 endif | |
5940 let g:netrw_browse_split= 0 | |
5941 if exists("s:netrw_browse_split_".winnr()) | |
5942 let g:netrw_browse_split= s:netrw_browse_split_{winnr()} | |
5943 endif | |
5944 call s:NetrwBrowseChgDir(islocal,a:fname) | |
5945 " call Dret("s:NetrwServerEdit") | |
5946 return | |
5947 | |
5948 elseif has("win32") && executable("start") | |
5949 " start up remote netrw server under windows | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5950 " call Decho("starting up gvim server<".srvrname."> for windows",'~'.expand("<slnum>")) |
6476 | 5951 call system("start gvim --servername ".srvrname) |
5952 | |
5953 else | |
5954 " start up remote netrw server under linux | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5955 " call Decho("starting up gvim server<".srvrname.">",'~'.expand("<slnum>")) |
6476 | 5956 call system("gvim --servername ".srvrname) |
5957 endif | |
5958 endif | |
5959 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5960 " call Decho("srvrname<".srvrname."> tabnum=".tabnum." winnum=".winnum." server-editing<".a:fname.">",'~'.expand("<slnum>")) |
6476 | 5961 call remote_send(srvrname,":tabn ".tabnum."\<cr>") |
5962 call remote_send(srvrname,":".winnum."wincmd w\<cr>") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5963 call remote_send(srvrname,":e ".fnameescape(s:NetrwFile(a:fname))."\<cr>") |
6476 | 5964 |
5965 else | |
5966 | |
5967 if serverlist() !~ '\<'.g:netrw_servername.'\>' | |
5968 | |
5969 if !ctrlr | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5970 " call Decho("server<".g:netrw_servername."> not available and ctrl-r not used",'~'.expand("<slnum>")) |
6476 | 5971 if exists("g:netrw_browse_split") |
5972 unlet g:netrw_browse_split | |
5973 endif | |
5974 let g:netrw_browse_split= 0 | |
5975 call s:NetrwBrowse(islocal,s:NetrwBrowseChgDir(islocal,a:fname)) | |
5976 " call Dret("s:NetrwServerEdit") | |
5977 return | |
5978 | |
5979 else | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5980 " call Decho("server<".g:netrw_servername."> not available but ctrl-r used",'~'.expand("<slnum>")) |
6476 | 5981 if has("win32") && executable("start") |
5982 " start up remote netrw server under windows | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5983 " call Decho("starting up gvim server<".g:netrw_servername."> for windows",'~'.expand("<slnum>")) |
6476 | 5984 call system("start gvim --servername ".g:netrw_servername) |
5985 else | |
5986 " start up remote netrw server under linux | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5987 " call Decho("starting up gvim server<".g:netrw_servername.">",'~'.expand("<slnum>")) |
6476 | 5988 call system("gvim --servername ".g:netrw_servername) |
5989 endif | |
5990 endif | |
5991 endif | |
5992 | |
5993 while 1 | |
5994 try | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5995 " call Decho("remote-send: e ".a:fname,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
5996 call remote_send(g:netrw_servername,":e ".fnameescape(s:NetrwFile(a:fname))."\<cr>") |
6476 | 5997 break |
5998 catch /^Vim\%((\a\+)\)\=:E241/ | |
5999 sleep 200m | |
6000 endtry | |
6001 endwhile | |
6002 | |
6003 if exists("g:netrw_browse_split") | |
6004 if type(g:netrw_browse_split) != 3 | |
6005 let s:netrw_browse_split_{winnr()}= g:netrw_browse_split | |
6006 endif | |
6007 unlet g:netrw_browse_split | |
6008 endif | |
6009 let g:netrw_browse_split= [g:netrw_servername,1,1] | |
6010 endif | |
6011 | |
6012 else | |
6013 call netrw#ErrorMsg(s:ERROR,"you need a gui-capable vim and client-server to use <ctrl-r>",98) | |
6014 endif | |
6015 | |
6016 " call Dret("s:NetrwServerEdit") | |
6017 endfun | |
6018 | |
6019 " --------------------------------------------------------------------- | |
5618 | 6020 " s:NetrwSLeftmouse: marks the file under the cursor. May be dragged to select additional files {{{2 |
6021 fun! s:NetrwSLeftmouse(islocal) | |
17433 | 6022 if &ft != "netrw" |
6023 return | |
6024 endif | |
5618 | 6025 " call Dfunc("s:NetrwSLeftmouse(islocal=".a:islocal.")") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6026 |
5618 | 6027 let s:ngw= s:NetrwGetWord() |
6028 call s:NetrwMarkFile(a:islocal,s:ngw) | |
6029 | |
6030 " call Dret("s:NetrwSLeftmouse") | |
6031 endfun | |
6032 | |
6033 " --------------------------------------------------------------------- | |
6034 " s:NetrwSLeftdrag: invoked via a shift-leftmouse and dragging {{{2 | |
6035 " Used to mark multiple files. | |
6036 fun! s:NetrwSLeftdrag(islocal) | |
6037 " call Dfunc("s:NetrwSLeftdrag(islocal=".a:islocal.")") | |
4339 | 6038 if !exists("s:netrwdrag") |
5618 | 6039 let s:netrwdrag = winnr() |
4339 | 6040 if a:islocal |
5618 | 6041 nno <silent> <s-leftrelease> <leftmouse>:<c-u>call <SID>NetrwSLeftrelease(1)<cr> |
4339 | 6042 else |
5618 | 6043 nno <silent> <s-leftrelease> <leftmouse>:<c-u>call <SID>NetrwSLeftrelease(0)<cr> |
6044 endif | |
6045 endif | |
6046 let ngw = s:NetrwGetWord() | |
6047 if !exists("s:ngw") || s:ngw != ngw | |
6048 call s:NetrwMarkFile(a:islocal,ngw) | |
6049 endif | |
6050 let s:ngw= ngw | |
6051 " call Dret("s:NetrwSLeftdrag : s:netrwdrag=".s:netrwdrag." buf#".bufnr("%")) | |
6052 endfun | |
6053 | |
6054 " --------------------------------------------------------------------- | |
6055 " s:NetrwSLeftrelease: terminates shift-leftmouse dragging {{{2 | |
6056 fun! s:NetrwSLeftrelease(islocal) | |
6057 " call Dfunc("s:NetrwSLeftrelease(islocal=".a:islocal.") s:netrwdrag=".s:netrwdrag." buf#".bufnr("%")) | |
4339 | 6058 if exists("s:netrwdrag") |
5618 | 6059 nunmap <s-leftrelease> |
6060 let ngw = s:NetrwGetWord() | |
6061 if !exists("s:ngw") || s:ngw != ngw | |
6062 call s:NetrwMarkFile(a:islocal,ngw) | |
6063 endif | |
6064 if exists("s:ngw") | |
6065 unlet s:ngw | |
6066 endif | |
4339 | 6067 unlet s:netrwdrag |
6068 endif | |
5618 | 6069 " call Dret("s:NetrwSLeftrelease") |
4339 | 6070 endfun |
6071 | |
6072 " --------------------------------------------------------------------- | |
1621 | 6073 " s:NetrwListHide: uses [range]g~...~d to delete files that match comma {{{2 |
6074 " separated patterns given in g:netrw_list_hide | |
6075 fun! s:NetrwListHide() | |
6476 | 6076 " call Dfunc("s:NetrwListHide() g:netrw_hide=".g:netrw_hide." g:netrw_list_hide<".g:netrw_list_hide.">") |
17433 | 6077 " call Decho("initial: ".string(getline(w:netrw_bannercnt,'$'))) |
3920 | 6078 let ykeep= @@ |
17433 | 6079 " call DechoBuf(bufnr("%"),"COMBAK#3") |
1621 | 6080 |
6081 " find a character not in the "hide" string to use as a separator for :g and :v commands | |
17433 | 6082 " How-it-works: take the hiding command, convert it into a range. |
6083 " Duplicate characters don't matter. | |
6084 " Remove all such characters from the '/~@#...890' string. | |
6085 " Use the first character left as a separator character. | |
6086 " call Decho("find a character not in the hide string to use as a separator") | |
1621 | 6087 let listhide= g:netrw_list_hide |
6088 let sep = strpart(substitute('/~@#$%^&*{};:,<.>?|1234567890','['.escape(listhide,'-]^\').']','','ge'),1,1) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6089 " call Decho("sep=".sep,'~'.expand("<slnum>")) |
1621 | 6090 |
6091 while listhide != "" | |
6092 if listhide =~ ',' | |
6093 let hide = substitute(listhide,',.*$','','e') | |
6094 let listhide = substitute(listhide,'^.\{-},\(.*\)$','\1','e') | |
6095 else | |
6096 let hide = listhide | |
6097 let listhide = "" | |
6098 endif | |
17433 | 6099 " call Decho("hide<".hide."> listhide<".listhide.'>','~'.expand("<slnum>")) |
1621 | 6100 |
6101 " Prune the list by hiding any files which match | |
17433 | 6102 " call Decho("prune the list by hiding any files which ",((g:netrw_hide == 1)? "" : "don't")." match hide<".hide.">") |
1621 | 6103 if g:netrw_hide == 1 |
17433 | 6104 " call Decho("..hiding<".hide.">",'~'.expand("<slnum>")) |
6476 | 6105 exe 'sil! NetrwKeepj '.w:netrw_bannercnt.',$g'.sep.hide.sep.'d' |
1621 | 6106 elseif g:netrw_hide == 2 |
17433 | 6107 " call Decho("..showing<".hide.">",'~'.expand("<slnum>")) |
6476 | 6108 exe 'sil! NetrwKeepj '.w:netrw_bannercnt.',$g'.sep.hide.sep.'s@^@ /-KEEP-/ @' |
1621 | 6109 endif |
17433 | 6110 " call Decho("..result: ".string(getline(w:netrw_bannercnt,'$')),'~'.expand("<slnum>")) |
1621 | 6111 endwhile |
17433 | 6112 |
1621 | 6113 if g:netrw_hide == 2 |
6476 | 6114 exe 'sil! NetrwKeepj '.w:netrw_bannercnt.',$v@^ /-KEEP-/ @d' |
17433 | 6115 " call Decho("..v KEEP: ".string(getline(w:netrw_bannercnt,'$')),'~'.expand("<slnum>")) |
6476 | 6116 exe 'sil! NetrwKeepj '.w:netrw_bannercnt.',$s@^\%( /-KEEP-/ \)\+@@e' |
17433 | 6117 " call Decho("..g KEEP: ".string(getline(w:netrw_bannercnt,'$')),'~'.expand("<slnum>")) |
1621 | 6118 endif |
6119 | |
2751 | 6120 " remove any blank lines that have somehow remained. |
6121 " This seems to happen under Windows. | |
6476 | 6122 exe 'sil! NetrwKeepj 1,$g@^\s*$@d' |
17433 | 6123 " call DechoBuf(bufnr("%"),"COMBAK#4") |
2751 | 6124 |
3920 | 6125 let @@= ykeep |
6476 | 6126 " call Dret("s:NetrwListHide") |
1621 | 6127 endfun |
6128 | |
6129 " --------------------------------------------------------------------- | |
6130 " s:NetrwMakeDir: this function makes a directory (both local and remote) {{{2 | |
6476 | 6131 " implements the "d" mapping. |
1621 | 6132 fun! s:NetrwMakeDir(usrhost) |
5734 | 6133 " call Dfunc("s:NetrwMakeDir(usrhost<".a:usrhost.">)") |
1621 | 6134 |
3920 | 6135 let ykeep= @@ |
1621 | 6136 " get name of new directory from user. A bare <CR> will skip. |
6137 " if its currently a directory, also request will be skipped, but with | |
6138 " a message. | |
6139 call inputsave() | |
6140 let newdirname= input("Please give directory name: ") | |
6141 call inputrestore() | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6142 " call Decho("newdirname<".newdirname.">",'~'.expand("<slnum>")) |
1621 | 6143 |
6144 if newdirname == "" | |
3920 | 6145 let @@= ykeep |
5734 | 6146 " call Dret("s:NetrwMakeDir : user aborted with bare <cr>") |
1621 | 6147 return |
6148 endif | |
6149 | |
6150 if a:usrhost == "" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6151 " call Decho("local mkdir",'~'.expand("<slnum>")) |
1621 | 6152 |
6153 " Local mkdir: | |
6154 " sanity checks | |
6155 let fullnewdir= b:netrw_curdir.'/'.newdirname | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6156 " call Decho("fullnewdir<".fullnewdir.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6157 if isdirectory(s:NetrwFile(fullnewdir)) |
1621 | 6158 if !exists("g:netrw_quiet") |
6476 | 6159 NetrwKeepj call netrw#ErrorMsg(s:WARNING,"<".newdirname."> is already a directory!",24) |
1621 | 6160 endif |
3920 | 6161 let @@= ykeep |
5734 | 6162 " call Dret("s:NetrwMakeDir : directory<".newdirname."> exists previously") |
1621 | 6163 return |
6164 endif | |
6165 if s:FileReadable(fullnewdir) | |
6166 if !exists("g:netrw_quiet") | |
6476 | 6167 NetrwKeepj call netrw#ErrorMsg(s:WARNING,"<".newdirname."> is already a file!",25) |
1621 | 6168 endif |
3920 | 6169 let @@= ykeep |
5734 | 6170 " call Dret("s:NetrwMakeDir : file<".newdirname."> exists previously") |
1621 | 6171 return |
6172 endif | |
6173 | |
6174 " requested new local directory is neither a pre-existing file or | |
6175 " directory, so make it! | |
6176 if exists("*mkdir") | |
5618 | 6177 if has("unix") |
6178 call mkdir(fullnewdir,"p",xor(0777, system("umask"))) | |
6179 else | |
6180 call mkdir(fullnewdir,"p") | |
6181 endif | |
1621 | 6182 else |
6183 let netrw_origdir= s:NetrwGetcwd(1) | |
17433 | 6184 if s:NetrwLcd(b:netrw_curdir) |
6185 " call Dret("s:NetrwMakeDir : lcd failure") | |
6186 return | |
6187 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6188 " call Decho("netrw_origdir<".netrw_origdir.">: lcd b:netrw_curdir<".fnameescape(b:netrw_curdir).">",'~'.expand("<slnum>")) |
17433 | 6189 call s:NetrwExe("sil! !".g:netrw_localmkdir.g:netrw_localmkdiropt.' '.s:ShellEscape(newdirname,1)) |
3920 | 6190 if v:shell_error != 0 |
6191 let @@= ykeep | |
6192 call netrw#ErrorMsg(s:ERROR,"consider setting g:netrw_localmkdir<".g:netrw_localmkdir."> to something that works",80) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6193 " call Dret("s:NetrwMakeDir : failed: sil! !".g:netrw_localmkdir.' '.s:ShellEscape(newdirname,1)) |
3920 | 6194 return |
6195 endif | |
1621 | 6196 if !g:netrw_keepdir |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6197 " call Decho("restoring netrw_origdir since g:netrw_keepdir=".g:netrw_keepdir,'~'.expand("<slnum>")) |
17433 | 6198 if s:NetrwLcd(netrw_origdir) |
6199 " call Dret("s:NetrwBrowse : lcd failure") | |
6200 return | |
6201 endif | |
1621 | 6202 endif |
6203 endif | |
6204 | |
6205 if v:shell_error == 0 | |
6206 " refresh listing | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6207 " call Decho("refresh listing",'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6208 let svpos= winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6209 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
1621 | 6210 call s:NetrwRefresh(1,s:NetrwBrowseChgDir(1,'./')) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6211 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6212 call winrestview(svpos) |
1621 | 6213 elseif !exists("g:netrw_quiet") |
6214 call netrw#ErrorMsg(s:ERROR,"unable to make directory<".newdirname.">",26) | |
6215 endif | |
6216 " redraw! | |
6217 | |
6218 elseif !exists("b:netrw_method") || b:netrw_method == 4 | |
5734 | 6219 " Remote mkdir: using ssh |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6220 " call Decho("remote mkdir",'~'.expand("<slnum>")) |
1621 | 6221 let mkdircmd = s:MakeSshCmd(g:netrw_mkdir_cmd) |
6222 let newdirname= substitute(b:netrw_curdir,'^\%(.\{-}/\)\{3}\(.*\)$','\1','').newdirname | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6223 call s:NetrwExe("sil! !".mkdircmd." ".s:ShellEscape(newdirname,1)) |
1621 | 6224 if v:shell_error == 0 |
6225 " refresh listing | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6226 let svpos= winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6227 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
6476 | 6228 NetrwKeepj call s:NetrwRefresh(0,s:NetrwBrowseChgDir(0,'./')) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6229 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6230 NetrwKeepj call winrestview(svpos) |
1621 | 6231 elseif !exists("g:netrw_quiet") |
6476 | 6232 NetrwKeepj call netrw#ErrorMsg(s:ERROR,"unable to make directory<".newdirname.">",27) |
1621 | 6233 endif |
6234 " redraw! | |
6235 | |
6236 elseif b:netrw_method == 2 | |
5734 | 6237 " Remote mkdir: using ftp+.netrc |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6238 let svpos= winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6239 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6240 " call Decho("b:netrw_curdir<".b:netrw_curdir.">",'~'.expand("<slnum>")) |
5734 | 6241 if exists("b:netrw_fname") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6242 " call Decho("b:netrw_fname<".b:netrw_fname.">",'~'.expand("<slnum>")) |
5734 | 6243 let remotepath= b:netrw_fname |
6244 else | |
6245 let remotepath= "" | |
6246 endif | |
6247 call s:NetrwRemoteFtpCmd(remotepath,g:netrw_remote_mkdir.' "'.newdirname.'"') | |
6476 | 6248 NetrwKeepj call s:NetrwRefresh(0,s:NetrwBrowseChgDir(0,'./')) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6249 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6250 NetrwKeepj call winrestview(svpos) |
5734 | 6251 |
1621 | 6252 elseif b:netrw_method == 3 |
5734 | 6253 " Remote mkdir: using ftp + machine, id, passwd, and fname (ie. no .netrc) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6254 let svpos= winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6255 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6256 " call Decho("b:netrw_curdir<".b:netrw_curdir.">",'~'.expand("<slnum>")) |
5734 | 6257 if exists("b:netrw_fname") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6258 " call Decho("b:netrw_fname<".b:netrw_fname.">",'~'.expand("<slnum>")) |
5734 | 6259 let remotepath= b:netrw_fname |
6260 else | |
6261 let remotepath= "" | |
6262 endif | |
6263 call s:NetrwRemoteFtpCmd(remotepath,g:netrw_remote_mkdir.' "'.newdirname.'"') | |
6476 | 6264 NetrwKeepj call s:NetrwRefresh(0,s:NetrwBrowseChgDir(0,'./')) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6265 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6266 NetrwKeepj call winrestview(svpos) |
1621 | 6267 endif |
6268 | |
3920 | 6269 let @@= ykeep |
5734 | 6270 " call Dret("s:NetrwMakeDir") |
6271 endfun | |
6272 | |
6273 " --------------------------------------------------------------------- | |
6274 " s:TreeSqueezeDir: allows a shift-cr (gvim only) to squeeze the current tree-listing directory {{{2 | |
6275 fun! s:TreeSqueezeDir(islocal) | |
6276 " call Dfunc("s:TreeSqueezeDir(islocal=".a:islocal.")") | |
6277 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") | |
6278 " its a tree-listing style | |
6279 let curdepth = substitute(getline('.'),'^\(\%('.s:treedepthstring.'\)*\)[^'.s:treedepthstring.'].\{-}$','\1','e') | |
6280 let stopline = (exists("w:netrw_bannercnt")? (w:netrw_bannercnt + 1) : 1) | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6281 let depth = strchars(substitute(curdepth,' ','','g')) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6282 let srch = -1 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6283 " call Decho("curdepth<".curdepth.'>','~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6284 " call Decho("depth =".depth,'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6285 " call Decho("stopline#".stopline,'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6286 " call Decho("curline#".line(".")."<".getline('.').'>','~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6287 if depth >= 2 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6288 NetrwKeepj norm! 0 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6289 let curdepthm1= substitute(curdepth,'^'.s:treedepthstring,'','') |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6290 let srch = search('^'.curdepthm1.'\%('.s:treedepthstring.'\)\@!','bW',stopline) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6291 " call Decho("curdepthm1<".curdepthm1.'>','~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6292 " call Decho("case depth>=2: srch<".srch.'>','~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6293 elseif depth == 1 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6294 NetrwKeepj norm! 0 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6295 let treedepthchr= substitute(s:treedepthstring,' ','','') |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6296 let srch = search('^[^'.treedepthchr.']','bW',stopline) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6297 " call Decho("case depth==1: srch<".srch.'>','~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6298 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6299 if srch > 0 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6300 " call Decho("squeezing at line#".line(".").": ".getline('.'),'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6301 call s:NetrwBrowse(a:islocal,s:NetrwBrowseChgDir(a:islocal,s:NetrwGetWord())) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6302 exe srch |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6303 endif |
5734 | 6304 endif |
6305 " call Dret("s:TreeSqueezeDir") | |
6306 endfun | |
6307 | |
6308 " --------------------------------------------------------------------- | |
6309 " s:NetrwMaps: {{{2 | |
6310 fun! s:NetrwMaps(islocal) | |
6311 " call Dfunc("s:NetrwMaps(islocal=".a:islocal.") b:netrw_curdir<".b:netrw_curdir.">") | |
6312 | |
17433 | 6313 " mouse <Plug> maps: {{{3 |
5734 | 6314 if g:netrw_mousemaps && g:netrw_retmap |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6315 " call Decho("set up Rexplore 2-leftmouse",'~'.expand("<slnum>")) |
5734 | 6316 if !hasmapto("<Plug>NetrwReturn") |
6317 if maparg("<2-leftmouse>","n") == "" || maparg("<2-leftmouse>","n") =~ '^-$' | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6318 " call Decho("making map for 2-leftmouse",'~'.expand("<slnum>")) |
5734 | 6319 nmap <unique> <silent> <2-leftmouse> <Plug>NetrwReturn |
6320 elseif maparg("<c-leftmouse>","n") == "" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6321 " call Decho("making map for c-leftmouse",'~'.expand("<slnum>")) |
5734 | 6322 nmap <unique> <silent> <c-leftmouse> <Plug>NetrwReturn |
6323 endif | |
6324 endif | |
6325 nno <silent> <Plug>NetrwReturn :Rexplore<cr> | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6326 " call Decho("made <Plug>NetrwReturn map",'~'.expand("<slnum>")) |
5734 | 6327 endif |
6328 | |
17433 | 6329 " generate default <Plug> maps {{{3 |
6330 if !hasmapto('<Plug>NetrwHide') |nmap <buffer> <silent> <nowait> a <Plug>NetrwHide_a|endif | |
6331 if !hasmapto('<Plug>NetrwBrowseUpDir') |nmap <buffer> <silent> <nowait> - <Plug>NetrwBrowseUpDir |endif | |
6332 if !hasmapto('<Plug>NetrwOpenFile') |nmap <buffer> <silent> <nowait> % <Plug>NetrwOpenFile|endif | |
6333 if !hasmapto('<Plug>NetrwBadd_cb') |nmap <buffer> <silent> <nowait> cb <Plug>NetrwBadd_cb|endif | |
6334 if !hasmapto('<Plug>NetrwBadd_cB') |nmap <buffer> <silent> <nowait> cB <Plug>NetrwBadd_cB|endif | |
6335 if !hasmapto('<Plug>NetrwLcd') |nmap <buffer> <silent> <nowait> cd <Plug>NetrwLcd|endif | |
6336 if !hasmapto('<Plug>NetrwSetChgwin') |nmap <buffer> <silent> <nowait> C <Plug>NetrwSetChgwin|endif | |
6337 if !hasmapto('<Plug>NetrwRefresh') |nmap <buffer> <silent> <nowait> <c-l> <Plug>NetrwRefresh|endif | |
6338 if !hasmapto('<Plug>NetrwLocalBrowseCheck') |nmap <buffer> <silent> <nowait> <cr> <Plug>NetrwLocalBrowseCheck|endif | |
6339 if !hasmapto('<Plug>NetrwServerEdit') |nmap <buffer> <silent> <nowait> <c-r> <Plug>NetrwServerEdit|endif | |
6340 if !hasmapto('<Plug>NetrwMakeDir') |nmap <buffer> <silent> <nowait> d <Plug>NetrwMakeDir|endif | |
6341 if !hasmapto('<Plug>NetrwBookHistHandler_gb')|nmap <buffer> <silent> <nowait> gb <Plug>NetrwBookHistHandler_gb|endif | |
6342 " --------------------------------------------------------------------- | |
6343 " if !hasmapto('<Plug>NetrwForceChgDir') |nmap <buffer> <silent> <nowait> gd <Plug>NetrwForceChgDir|endif | |
6344 " if !hasmapto('<Plug>NetrwForceFile') |nmap <buffer> <silent> <nowait> gf <Plug>NetrwForceFile|endif | |
6345 " if !hasmapto('<Plug>NetrwHidden') |nmap <buffer> <silent> <nowait> gh <Plug>NetrwHidden|endif | |
6346 " if !hasmapto('<Plug>NetrwSetTreetop') |nmap <buffer> <silent> <nowait> gn <Plug>NetrwSetTreetop|endif | |
6347 " if !hasmapto('<Plug>NetrwChgPerm') |nmap <buffer> <silent> <nowait> gp <Plug>NetrwChgPerm|endif | |
6348 " if !hasmapto('<Plug>NetrwBannerCtrl') |nmap <buffer> <silent> <nowait> I <Plug>NetrwBannerCtrl|endif | |
6349 " if !hasmapto('<Plug>NetrwListStyle') |nmap <buffer> <silent> <nowait> i <Plug>NetrwListStyle|endif | |
6350 " if !hasmapto('<Plug>NetrwMarkMoveMF2Arglist')|nmap <buffer> <silent> <nowait> ma <Plug>NetrwMarkMoveMF2Arglist|endif | |
6351 " if !hasmapto('<Plug>NetrwMarkMoveArglist2MF')|nmap <buffer> <silent> <nowait> mA <Plug>NetrwMarkMoveArglist2MF|endif | |
6352 " if !hasmapto('<Plug>NetrwBookHistHandler_mA')|nmap <buffer> <silent> <nowait> mb <Plug>NetrwBookHistHandler_mA|endif | |
6353 " if !hasmapto('<Plug>NetrwBookHistHandler_mB')|nmap <buffer> <silent> <nowait> mB <Plug>NetrwBookHistHandler_mB|endif | |
6354 " if !hasmapto('<Plug>NetrwMarkFileCopy') |nmap <buffer> <silent> <nowait> mc <Plug>NetrwMarkFileCopy|endif | |
6355 " if !hasmapto('<Plug>NetrwMarkFileDiff') |nmap <buffer> <silent> <nowait> md <Plug>NetrwMarkFileDiff|endif | |
6356 " if !hasmapto('<Plug>NetrwMarkFileEdit') |nmap <buffer> <silent> <nowait> me <Plug>NetrwMarkFileEdit|endif | |
6357 " if !hasmapto('<Plug>NetrwMarkFile') |nmap <buffer> <silent> <nowait> mf <Plug>NetrwMarkFile|endif | |
6358 " if !hasmapto('<Plug>NetrwUnmarkList') |nmap <buffer> <silent> <nowait> mF <Plug>NetrwUnmarkList|endif | |
6359 " if !hasmapto('<Plug>NetrwMarkFileGrep') |nmap <buffer> <silent> <nowait> mg <Plug>NetrwMarkFileGrep|endif | |
6360 " if !hasmapto('<Plug>NetrwMarkHideSfx') |nmap <buffer> <silent> <nowait> mh <Plug>NetrwMarkHideSfx|endif | |
6361 " if !hasmapto('<Plug>NetrwMarkFileMove') |nmap <buffer> <silent> <nowait> mm <Plug>NetrwMarkFileMove|endif | |
6362 " if !hasmapto('<Plug>NetrwMarkFilePrint') |nmap <buffer> <silent> <nowait> mp <Plug>NetrwMarkFilePrint|endif | |
6363 " if !hasmapto('<Plug>NetrwMarkFileRegexp') |nmap <buffer> <silent> <nowait> mr <Plug>NetrwMarkFileRegexp|endif | |
6364 " if !hasmapto('<Plug>NetrwMarkFileSource') |nmap <buffer> <silent> <nowait> ms <Plug>NetrwMarkFileSource|endif | |
6365 " if !hasmapto('<Plug>NetrwMarkFileTag') |nmap <buffer> <silent> <nowait> mT <Plug>NetrwMarkFileTag|endif | |
6366 " if !hasmapto('<Plug>NetrwMarkFileTgt') |nmap <buffer> <silent> <nowait> mt <Plug>NetrwMarkFileTgt|endif | |
6367 " if !hasmapto('<Plug>NetrwUnMarkFile') |nmap <buffer> <silent> <nowait> mu <Plug>NetrwUnMarkFile|endif | |
6368 " if !hasmapto('<Plug>NetrwMarkFileVimCmd') |nmap <buffer> <silent> <nowait> mv <Plug>NetrwMarkFileVimCmd|endif | |
6369 " if !hasmapto('<Plug>NetrwMarkFileExe_mx') |nmap <buffer> <silent> <nowait> mx <Plug>NetrwMarkFileExe_mx|endif | |
6370 " if !hasmapto('<Plug>NetrwMarkFileExe_mX') |nmap <buffer> <silent> <nowait> mX <Plug>NetrwMarkFileExe_mX|endif | |
6371 " if !hasmapto('<Plug>NetrwMarkFileCompress') |nmap <buffer> <silent> <nowait> mz <Plug>NetrwMarkFileCompress|endif | |
6372 " if !hasmapto('<Plug>NetrwObtain') |nmap <buffer> <silent> <nowait> O <Plug>NetrwObtain|endif | |
6373 " if !hasmapto('<Plug>NetrwSplit_o') |nmap <buffer> <silent> <nowait> o <Plug>NetrwSplit_o|endif | |
6374 " if !hasmapto('<Plug>NetrwPreview') |nmap <buffer> <silent> <nowait> p <Plug>NetrwPreview|endif | |
6375 " if !hasmapto('<Plug>NetrwPrevWinOpen') |nmap <buffer> <silent> <nowait> P <Plug>NetrwPrevWinOpen|endif | |
6376 " if !hasmapto('<Plug>NetrwBookHistHandler_qb')|nmap <buffer> <silent> <nowait> qb <Plug>NetrwBookHistHandler_qb|endif | |
6377 " if !hasmapto('<Plug>NetrwFileInfo') |nmap <buffer> <silent> <nowait> qf <Plug>NetrwFileInfo|endif | |
6378 " if !hasmapto('<Plug>NetrwMarkFileQFEL_qF') |nmap <buffer> <silent> <nowait> qF <Plug>NetrwMarkFileQFEL_qF|endif | |
6379 " if !hasmapto('<Plug>NetrwMarkFileQFEL_qL') |nmap <buffer> <silent> <nowait> qL <Plug>NetrwMarkFileQFEL_qL|endif | |
6380 " if !hasmapto('<Plug>NetrwSortStyle') |nmap <buffer> <silent> <nowait> s <Plug>NetrwSortStyle|endif | |
6381 " if !hasmapto('<Plug>NetSortSequence') |nmap <buffer> <silent> <nowait> S <Plug>NetSortSequence|endif | |
6382 " if !hasmapto('<Plug>NetrwSetTgt_Tb') |nmap <buffer> <silent> <nowait> Tb <Plug>NetrwSetTgt_Tb|endif | |
6383 " if !hasmapto('<Plug>NetrwSetTgt_Th') |nmap <buffer> <silent> <nowait> Th <Plug>NetrwSetTgt_Th|endif | |
6384 " if !hasmapto('<Plug>NetrwSplit_t') |nmap <buffer> <silent> <nowait> t <Plug>NetrwSplit_t|endif | |
6385 " if !hasmapto('<Plug>NetrwBookHistHandler_u') |nmap <buffer> <silent> <nowait> u <Plug>NetrwBookHistHandler_u|endif | |
6386 " if !hasmapto('<Plug>NetrwBookHistHandler_U') |nmap <buffer> <silent> <nowait> U <Plug>NetrwBookHistHandler_U|endif | |
6387 " if !hasmapto('<Plug>NetrwSplit_v') |nmap <buffer> <silent> <nowait> v <Plug>NetrwSplit_v|endif | |
6388 " if !hasmapto('<Plug>NetrwBrowseX') |nmap <buffer> <silent> <nowait> x <Plug>NetrwBrowseX|endif | |
6389 " if !hasmapto('<Plug>NetrwLocalExecute') |nmap <buffer> <silent> <nowait> X <Plug>NetrwLocalExecute|endif | |
6390 | |
5734 | 6391 if a:islocal |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6392 " call Decho("make local maps",'~'.expand("<slnum>")) |
17433 | 6393 " local normal-mode maps {{{3 |
6394 nnoremap <buffer> <silent> <Plug>NetrwHide_a :<c-u>call <SID>NetrwHide(1)<cr> | |
6395 nnoremap <buffer> <silent> <Plug>NetrwBrowseUpDir :<c-u>call <SID>NetrwBrowseUpDir(1)<cr> | |
6396 nnoremap <buffer> <silent> <Plug>NetrwOpenFile :<c-u>call <SID>NetrwOpenFile(1)<cr> | |
6397 nnoremap <buffer> <silent> <Plug>NetrwBadd_cb :<c-u>call <SID>NetrwBadd(1,0)<cr> | |
6398 nnoremap <buffer> <silent> <Plug>NetrwBadd_cB :<c-u>call <SID>NetrwBadd(1,1)<cr> | |
6399 nnoremap <buffer> <silent> <Plug>NetrwLcd :<c-u>call <SID>NetrwLcd(b:netrw_curdir)<cr> | |
6400 nnoremap <buffer> <silent> <Plug>NetrwSetChgwin :<c-u>call <SID>NetrwSetChgwin()<cr> | |
6401 nnoremap <buffer> <silent> <Plug>NetrwLocalBrowseCheck :<c-u>call netrw#LocalBrowseCheck(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord()))<cr> | |
6402 nnoremap <buffer> <silent> <Plug>NetrwServerEdit :<c-u>call <SID>NetrwServerEdit(3,<SID>NetrwGetWord())<cr> | |
6403 nnoremap <buffer> <silent> <Plug>NetrwMakeDir :<c-u>call <SID>NetrwMakeDir("")<cr> | |
6404 nnoremap <buffer> <silent> <Plug>NetrwBookHistHandler_gb :<c-u>call <SID>NetrwBookHistHandler(1,b:netrw_curdir)<cr> | |
6405 " --------------------------------------------------------------------- | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6406 nnoremap <buffer> <silent> <nowait> gd :<c-u>call <SID>NetrwForceChgDir(1,<SID>NetrwGetWord())<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6407 nnoremap <buffer> <silent> <nowait> gf :<c-u>call <SID>NetrwForceFile(1,<SID>NetrwGetWord())<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6408 nnoremap <buffer> <silent> <nowait> gh :<c-u>call <SID>NetrwHidden(1)<cr> |
17433 | 6409 nnoremap <buffer> <silent> <nowait> gn :<c-u>call netrw#SetTreetop(0,<SID>NetrwGetWord())<cr> |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6410 nnoremap <buffer> <silent> <nowait> gp :<c-u>call <SID>NetrwChgPerm(1,b:netrw_curdir)<cr> |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6411 nnoremap <buffer> <silent> <nowait> I :<c-u>call <SID>NetrwBannerCtrl(1)<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6412 nnoremap <buffer> <silent> <nowait> i :<c-u>call <SID>NetrwListStyle(1)<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6413 nnoremap <buffer> <silent> <nowait> ma :<c-u>call <SID>NetrwMarkFileArgList(1,0)<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6414 nnoremap <buffer> <silent> <nowait> mA :<c-u>call <SID>NetrwMarkFileArgList(1,1)<cr> |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6415 nnoremap <buffer> <silent> <nowait> mb :<c-u>call <SID>NetrwBookHistHandler(0,b:netrw_curdir)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6416 nnoremap <buffer> <silent> <nowait> mB :<c-u>call <SID>NetrwBookHistHandler(6,b:netrw_curdir)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6417 nnoremap <buffer> <silent> <nowait> mc :<c-u>call <SID>NetrwMarkFileCopy(1)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6418 nnoremap <buffer> <silent> <nowait> md :<c-u>call <SID>NetrwMarkFileDiff(1)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6419 nnoremap <buffer> <silent> <nowait> me :<c-u>call <SID>NetrwMarkFileEdit(1)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6420 nnoremap <buffer> <silent> <nowait> mf :<c-u>call <SID>NetrwMarkFile(1,<SID>NetrwGetWord())<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6421 nnoremap <buffer> <silent> <nowait> mF :<c-u>call <SID>NetrwUnmarkList(bufnr("%"),b:netrw_curdir)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6422 nnoremap <buffer> <silent> <nowait> mg :<c-u>call <SID>NetrwMarkFileGrep(1)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6423 nnoremap <buffer> <silent> <nowait> mh :<c-u>call <SID>NetrwMarkHideSfx(1)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6424 nnoremap <buffer> <silent> <nowait> mm :<c-u>call <SID>NetrwMarkFileMove(1)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6425 nnoremap <buffer> <silent> <nowait> mp :<c-u>call <SID>NetrwMarkFilePrint(1)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6426 nnoremap <buffer> <silent> <nowait> mr :<c-u>call <SID>NetrwMarkFileRegexp(1)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6427 nnoremap <buffer> <silent> <nowait> ms :<c-u>call <SID>NetrwMarkFileSource(1)<cr> |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6428 nnoremap <buffer> <silent> <nowait> mT :<c-u>call <SID>NetrwMarkFileTag(1)<cr> |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6429 nnoremap <buffer> <silent> <nowait> mt :<c-u>call <SID>NetrwMarkFileTgt(1)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6430 nnoremap <buffer> <silent> <nowait> mu :<c-u>call <SID>NetrwUnMarkFile(1)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6431 nnoremap <buffer> <silent> <nowait> mv :<c-u>call <SID>NetrwMarkFileVimCmd(1)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6432 nnoremap <buffer> <silent> <nowait> mx :<c-u>call <SID>NetrwMarkFileExe(1,0)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6433 nnoremap <buffer> <silent> <nowait> mX :<c-u>call <SID>NetrwMarkFileExe(1,1)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6434 nnoremap <buffer> <silent> <nowait> mz :<c-u>call <SID>NetrwMarkFileCompress(1)<cr> |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6435 nnoremap <buffer> <silent> <nowait> O :<c-u>call <SID>NetrwObtain(1)<cr> |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6436 nnoremap <buffer> <silent> <nowait> o :call <SID>NetrwSplit(3)<cr> |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6437 nnoremap <buffer> <silent> <nowait> p :<c-u>call <SID>NetrwPreview(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord(),1))<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6438 nnoremap <buffer> <silent> <nowait> P :<c-u>call <SID>NetrwPrevWinOpen(1)<cr> |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6439 nnoremap <buffer> <silent> <nowait> qb :<c-u>call <SID>NetrwBookHistHandler(2,b:netrw_curdir)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6440 nnoremap <buffer> <silent> <nowait> qf :<c-u>call <SID>NetrwFileInfo(1,<SID>NetrwGetWord())<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6441 nnoremap <buffer> <silent> <nowait> qF :<c-u>call <SID>NetrwMarkFileQFEL(1,getqflist())<cr> |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6442 nnoremap <buffer> <silent> <nowait> qL :<c-u>call <SID>NetrwMarkFileQFEL(1,getloclist(v:count))<cr> |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6443 nnoremap <buffer> <silent> <nowait> s :call <SID>NetrwSortStyle(1)<cr> |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6444 nnoremap <buffer> <silent> <nowait> S :<c-u>call <SID>NetSortSequence(1)<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6445 nnoremap <buffer> <silent> <nowait> Tb :<c-u>call <SID>NetrwSetTgt(1,'b',v:count1)<cr> |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6446 nnoremap <buffer> <silent> <nowait> t :call <SID>NetrwSplit(4)<cr> |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6447 nnoremap <buffer> <silent> <nowait> Th :<c-u>call <SID>NetrwSetTgt(1,'h',v:count)<cr> |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6448 nnoremap <buffer> <silent> <nowait> u :<c-u>call <SID>NetrwBookHistHandler(4,expand("%"))<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6449 nnoremap <buffer> <silent> <nowait> U :<c-u>call <SID>NetrwBookHistHandler(5,expand("%"))<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6450 nnoremap <buffer> <silent> <nowait> v :call <SID>NetrwSplit(5)<cr> |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6451 nnoremap <buffer> <silent> <nowait> x :<c-u>call netrw#BrowseX(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord(),0),0)"<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6452 nnoremap <buffer> <silent> <nowait> X :<c-u>call <SID>NetrwLocalExecute(expand("<cword>"))"<cr> |
17433 | 6453 |
6454 nnoremap <buffer> <silent> <nowait> r :<c-u>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> | |
5734 | 6455 if !hasmapto('<Plug>NetrwHideEdit') |
6456 nmap <buffer> <unique> <c-h> <Plug>NetrwHideEdit | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6457 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6458 nnoremap <buffer> <silent> <Plug>NetrwHideEdit :call <SID>NetrwHideEdit(1)<cr> |
5734 | 6459 if !hasmapto('<Plug>NetrwRefresh') |
6460 nmap <buffer> <unique> <c-l> <Plug>NetrwRefresh | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6461 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6462 nnoremap <buffer> <silent> <Plug>NetrwRefresh <c-l>:call <SID>NetrwRefresh(1,<SID>NetrwBrowseChgDir(1,(w:netrw_liststyle == 3)? w:netrw_treetop : './'))<cr> |
5734 | 6463 if s:didstarstar || !mapcheck("<s-down>","n") |
6464 nnoremap <buffer> <silent> <s-down> :Nexplore<cr> | |
6465 endif | |
6466 if s:didstarstar || !mapcheck("<s-up>","n") | |
6467 nnoremap <buffer> <silent> <s-up> :Pexplore<cr> | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6468 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6469 if !hasmapto('<Plug>NetrwTreeSqueeze') |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6470 nmap <buffer> <silent> <nowait> <s-cr> <Plug>NetrwTreeSqueeze |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6471 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6472 nnoremap <buffer> <silent> <Plug>NetrwTreeSqueeze :call <SID>TreeSqueezeDir(1)<cr> |
5734 | 6473 let mapsafecurdir = escape(b:netrw_curdir, s:netrw_map_escape) |
6474 if g:netrw_mousemaps == 1 | |
17433 | 6475 nmap <buffer> <leftmouse> <Plug>NetrwLeftmouse |
6476 nmap <buffer> <c-leftmouse> <Plug>NetrwCLeftmouse | |
6477 nmap <buffer> <middlemouse> <Plug>NetrwMiddlemouse | |
6478 nmap <buffer> <s-leftmouse> <Plug>NetrwSLeftmouse | |
6479 nmap <buffer> <s-leftdrag> <Plug>NetrwSLeftdrag | |
6480 nmap <buffer> <2-leftmouse> <Plug>Netrw2Leftmouse | |
6481 imap <buffer> <leftmouse> <Plug>ILeftmouse | |
6482 imap <buffer> <middlemouse> <Plug>IMiddlemouse | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6483 nno <buffer> <silent> <Plug>NetrwLeftmouse <leftmouse>:call <SID>NetrwLeftmouse(1)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6484 nno <buffer> <silent> <Plug>NetrwCLeftmouse <leftmouse>:call <SID>NetrwCLeftmouse(1)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6485 nno <buffer> <silent> <Plug>NetrwMiddlemouse <leftmouse>:call <SID>NetrwPrevWinOpen(1)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6486 nno <buffer> <silent> <Plug>NetrwSLeftmouse <leftmouse>:call <SID>NetrwSLeftmouse(1)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6487 nno <buffer> <silent> <Plug>NetrwSLeftdrag <leftmouse>:call <SID>NetrwSLeftdrag(1)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6488 nmap <buffer> <silent> <Plug>Netrw2Leftmouse - |
5734 | 6489 exe 'nnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' |
6490 exe 'vnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' | |
6491 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6492 exe 'nnoremap <buffer> <silent> <nowait> <del> :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6493 exe 'nnoremap <buffer> <silent> <nowait> D :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6494 exe 'nnoremap <buffer> <silent> <nowait> R :call <SID>NetrwLocalRename("'.mapsafecurdir.'")<cr>' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6495 exe 'nnoremap <buffer> <silent> <nowait> d :call <SID>NetrwMakeDir("")<cr>' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6496 exe 'vnoremap <buffer> <silent> <nowait> <del> :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6497 exe 'vnoremap <buffer> <silent> <nowait> D :call <SID>NetrwLocalRm("'.mapsafecurdir.'")<cr>' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6498 exe 'vnoremap <buffer> <silent> <nowait> R :call <SID>NetrwLocalRename("'.mapsafecurdir.'")<cr>' |
5734 | 6499 nnoremap <buffer> <F1> :he netrw-quickhelp<cr> |
6500 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6501 " support user-specified maps |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6502 call netrw#UserMaps(1) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6503 |
17433 | 6504 else |
6505 " remote normal-mode maps {{{3 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6506 " call Decho("make remote maps",'~'.expand("<slnum>")) |
5734 | 6507 call s:RemotePathAnalysis(b:netrw_curdir) |
17433 | 6508 nnoremap <buffer> <silent> <Plug>NetrwHide_a :<c-u>call <SID>NetrwHide(0)<cr> |
6509 nnoremap <buffer> <silent> <Plug>NetrwBrowseUpDir :<c-u>call <SID>NetrwBrowseUpDir(0)<cr> | |
6510 nnoremap <buffer> <silent> <Plug>NetrwOpenFile :<c-u>call <SID>NetrwOpenFile(0)<cr> | |
6511 nnoremap <buffer> <silent> <Plug>NetrwBadd_cb :<c-u>call <SID>NetrwBadd(0,0)<cr> | |
6512 nnoremap <buffer> <silent> <Plug>NetrwBadd_cB :<c-u>call <SID>NetrwBadd(0,1)<cr> | |
6513 nnoremap <buffer> <silent> <Plug>NetrwLcd :<c-u>call <SID>NetrwLcd(b:netrw_curdir)<cr> | |
6514 nnoremap <buffer> <silent> <Plug>NetrwSetChgwin :<c-u>call <SID>NetrwSetChgwin()<cr> | |
6515 nnoremap <buffer> <silent> <Plug>NetrwRefresh :<c-u>call <SID>NetrwRefresh(0,<SID>NetrwBrowseChgDir(0,'./'))<cr> | |
6516 nnoremap <buffer> <silent> <Plug>NetrwLocalBrowseCheck :<c-u>call <SID>NetrwBrowse(0,<SID>NetrwBrowseChgDir(0,<SID>NetrwGetWord()))<cr> | |
6517 nnoremap <buffer> <silent> <Plug>NetrwServerEdit :<c-u>call <SID>NetrwServerEdit(2,<SID>NetrwGetWord())<cr> | |
6518 nnoremap <buffer> <silent> <Plug>NetrwBookHistHandler_gb :<c-u>call <SID>NetrwBookHistHandler(1,b:netrw_curdir)<cr> | |
6519 " --------------------------------------------------------------------- | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6520 nnoremap <buffer> <silent> <nowait> gd :<c-u>call <SID>NetrwForceChgDir(0,<SID>NetrwGetWord())<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6521 nnoremap <buffer> <silent> <nowait> gf :<c-u>call <SID>NetrwForceFile(0,<SID>NetrwGetWord())<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6522 nnoremap <buffer> <silent> <nowait> gh :<c-u>call <SID>NetrwHidden(0)<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6523 nnoremap <buffer> <silent> <nowait> gp :<c-u>call <SID>NetrwChgPerm(0,b:netrw_curdir)<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6524 nnoremap <buffer> <silent> <nowait> I :<c-u>call <SID>NetrwBannerCtrl(1)<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6525 nnoremap <buffer> <silent> <nowait> i :<c-u>call <SID>NetrwListStyle(0)<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6526 nnoremap <buffer> <silent> <nowait> ma :<c-u>call <SID>NetrwMarkFileArgList(0,0)<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6527 nnoremap <buffer> <silent> <nowait> mA :<c-u>call <SID>NetrwMarkFileArgList(0,1)<cr> |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6528 nnoremap <buffer> <silent> <nowait> mb :<c-u>call <SID>NetrwBookHistHandler(0,b:netrw_curdir)<cr> |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6529 nnoremap <buffer> <silent> <nowait> mB :<c-u>call <SID>NetrwBookHistHandler(6,b:netrw_curdir)<cr> |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6530 nnoremap <buffer> <silent> <nowait> mc :<c-u>call <SID>NetrwMarkFileCopy(0)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6531 nnoremap <buffer> <silent> <nowait> md :<c-u>call <SID>NetrwMarkFileDiff(0)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6532 nnoremap <buffer> <silent> <nowait> me :<c-u>call <SID>NetrwMarkFileEdit(0)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6533 nnoremap <buffer> <silent> <nowait> mf :<c-u>call <SID>NetrwMarkFile(0,<SID>NetrwGetWord())<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6534 nnoremap <buffer> <silent> <nowait> mF :<c-u>call <SID>NetrwUnmarkList(bufnr("%"),b:netrw_curdir)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6535 nnoremap <buffer> <silent> <nowait> mg :<c-u>call <SID>NetrwMarkFileGrep(0)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6536 nnoremap <buffer> <silent> <nowait> mh :<c-u>call <SID>NetrwMarkHideSfx(0)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6537 nnoremap <buffer> <silent> <nowait> mm :<c-u>call <SID>NetrwMarkFileMove(0)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6538 nnoremap <buffer> <silent> <nowait> mp :<c-u>call <SID>NetrwMarkFilePrint(0)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6539 nnoremap <buffer> <silent> <nowait> mr :<c-u>call <SID>NetrwMarkFileRegexp(0)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6540 nnoremap <buffer> <silent> <nowait> ms :<c-u>call <SID>NetrwMarkFileSource(0)<cr> |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6541 nnoremap <buffer> <silent> <nowait> mT :<c-u>call <SID>NetrwMarkFileTag(0)<cr> |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6542 nnoremap <buffer> <silent> <nowait> mt :<c-u>call <SID>NetrwMarkFileTgt(0)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6543 nnoremap <buffer> <silent> <nowait> mu :<c-u>call <SID>NetrwUnMarkFile(0)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6544 nnoremap <buffer> <silent> <nowait> mv :<c-u>call <SID>NetrwMarkFileVimCmd(0)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6545 nnoremap <buffer> <silent> <nowait> mx :<c-u>call <SID>NetrwMarkFileExe(0,0)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6546 nnoremap <buffer> <silent> <nowait> mX :<c-u>call <SID>NetrwMarkFileExe(0,1)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6547 nnoremap <buffer> <silent> <nowait> mz :<c-u>call <SID>NetrwMarkFileCompress(0)<cr> |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6548 nnoremap <buffer> <silent> <nowait> O :<c-u>call <SID>NetrwObtain(0)<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6549 nnoremap <buffer> <silent> <nowait> o :call <SID>NetrwSplit(0)<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6550 nnoremap <buffer> <silent> <nowait> p :<c-u>call <SID>NetrwPreview(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord(),1))<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6551 nnoremap <buffer> <silent> <nowait> P :<c-u>call <SID>NetrwPrevWinOpen(0)<cr> |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6552 nnoremap <buffer> <silent> <nowait> qb :<c-u>call <SID>NetrwBookHistHandler(2,b:netrw_curdir)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6553 nnoremap <buffer> <silent> <nowait> qf :<c-u>call <SID>NetrwFileInfo(0,<SID>NetrwGetWord())<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6554 nnoremap <buffer> <silent> <nowait> qF :<c-u>call <SID>NetrwMarkFileQFEL(0,getqflist())<cr> |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6555 nnoremap <buffer> <silent> <nowait> qL :<c-u>call <SID>NetrwMarkFileQFEL(0,getloclist(v:count))<cr> |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
6556 nnoremap <buffer> <silent> <nowait> r :<c-u>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> |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6557 nnoremap <buffer> <silent> <nowait> s :call <SID>NetrwSortStyle(0)<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6558 nnoremap <buffer> <silent> <nowait> S :<c-u>call <SID>NetSortSequence(0)<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6559 nnoremap <buffer> <silent> <nowait> Tb :<c-u>call <SID>NetrwSetTgt(0,'b',v:count1)<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6560 nnoremap <buffer> <silent> <nowait> t :call <SID>NetrwSplit(1)<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6561 nnoremap <buffer> <silent> <nowait> Th :<c-u>call <SID>NetrwSetTgt(0,'h',v:count)<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6562 nnoremap <buffer> <silent> <nowait> u :<c-u>call <SID>NetrwBookHistHandler(4,b:netrw_curdir)<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6563 nnoremap <buffer> <silent> <nowait> U :<c-u>call <SID>NetrwBookHistHandler(5,b:netrw_curdir)<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6564 nnoremap <buffer> <silent> <nowait> v :call <SID>NetrwSplit(2)<cr> |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6565 nnoremap <buffer> <silent> <nowait> x :<c-u>call netrw#BrowseX(<SID>NetrwBrowseChgDir(0,<SID>NetrwGetWord()),1)<cr> |
5734 | 6566 if !hasmapto('<Plug>NetrwHideEdit') |
6567 nmap <buffer> <c-h> <Plug>NetrwHideEdit | |
6568 endif | |
6569 nnoremap <buffer> <silent> <Plug>NetrwHideEdit :call <SID>NetrwHideEdit(0)<cr> | |
6570 if !hasmapto('<Plug>NetrwRefresh') | |
6571 nmap <buffer> <c-l> <Plug>NetrwRefresh | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6572 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6573 if !hasmapto('<Plug>NetrwTreeSqueeze') |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6574 nmap <buffer> <silent> <nowait> <s-cr> <Plug>NetrwTreeSqueeze |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6575 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6576 nnoremap <buffer> <silent> <Plug>NetrwTreeSqueeze :call <SID>TreeSqueezeDir(0)<cr> |
5734 | 6577 |
6578 let mapsafepath = escape(s:path, s:netrw_map_escape) | |
6476 | 6579 let mapsafeusermach = escape(((s:user == "")? "" : s:user."@").s:machine, s:netrw_map_escape) |
5734 | 6580 |
6581 nnoremap <buffer> <silent> <Plug>NetrwRefresh :call <SID>NetrwRefresh(0,<SID>NetrwBrowseChgDir(0,'./'))<cr> | |
6582 if g:netrw_mousemaps == 1 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6583 nmap <buffer> <leftmouse> <Plug>NetrwLeftmouse |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6584 nno <buffer> <silent> <Plug>NetrwLeftmouse <leftmouse>:call <SID>NetrwLeftmouse(0)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6585 nmap <buffer> <c-leftmouse> <Plug>NetrwCLeftmouse |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6586 nno <buffer> <silent> <Plug>NetrwCLeftmouse <leftmouse>:call <SID>NetrwCLeftmouse(0)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6587 nmap <buffer> <s-leftmouse> <Plug>NetrwSLeftmouse |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6588 nno <buffer> <silent> <Plug>NetrwSLeftmouse <leftmouse>:call <SID>NetrwSLeftmouse(0)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6589 nmap <buffer> <s-leftdrag> <Plug>NetrwSLeftdrag |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6590 nno <buffer> <silent> <Plug>NetrwSLeftdrag <leftmouse>:call <SID>NetrwSLeftdrag(0)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6591 nmap <middlemouse> <Plug>NetrwMiddlemouse |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6592 nno <buffer> <silent> <middlemouse> <Plug>NetrwMiddlemouse <leftmouse>:call <SID>NetrwPrevWinOpen(0)<cr> |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6593 nmap <buffer> <2-leftmouse> <Plug>Netrw2Leftmouse |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6594 nmap <buffer> <silent> <Plug>Netrw2Leftmouse - |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6595 imap <buffer> <leftmouse> <Plug>ILeftmouse |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6596 imap <buffer> <middlemouse> <Plug>IMiddlemouse |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6597 imap <buffer> <s-leftmouse> <Plug>ISLeftmouse |
5734 | 6598 exe 'nnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>' |
6599 exe 'vnoremap <buffer> <silent> <rightmouse> <leftmouse>:call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>' | |
6600 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6601 exe 'nnoremap <buffer> <silent> <nowait> <del> :call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6602 exe 'nnoremap <buffer> <silent> <nowait> d :call <SID>NetrwMakeDir("'.mapsafeusermach.'")<cr>' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6603 exe 'nnoremap <buffer> <silent> <nowait> D :call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6604 exe 'nnoremap <buffer> <silent> <nowait> R :call <SID>NetrwRemoteRename("'.mapsafeusermach.'","'.mapsafepath.'")<cr>' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6605 exe 'vnoremap <buffer> <silent> <nowait> <del> :call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6606 exe 'vnoremap <buffer> <silent> <nowait> D :call <SID>NetrwRemoteRm("'.mapsafeusermach.'","'.mapsafepath.'")<cr>' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6607 exe 'vnoremap <buffer> <silent> <nowait> R :call <SID>NetrwRemoteRename("'.mapsafeusermach.'","'.mapsafepath.'")<cr>' |
5734 | 6608 nnoremap <buffer> <F1> :he netrw-quickhelp<cr> |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6609 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6610 " support user-specified maps |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6611 call netrw#UserMaps(0) |
17433 | 6612 endif " }}}3 |
5734 | 6613 |
6614 " call Dret("s:NetrwMaps") | |
6615 endfun | |
6616 | |
6617 " --------------------------------------------------------------------- | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6618 " s:NetrwCommands: set up commands {{{2 |
6476 | 6619 " If -buffer, the command is only available from within netrw buffers |
6620 " Otherwise, the command is available from any window, so long as netrw | |
6621 " has been used at least once in the session. | |
5734 | 6622 fun! s:NetrwCommands(islocal) |
6623 " call Dfunc("s:NetrwCommands(islocal=".a:islocal.")") | |
6624 | |
6476 | 6625 com! -nargs=* -complete=file -bang NetrwMB call s:NetrwBookmark(<bang>0,<f-args>) |
6626 com! -nargs=* NetrwC call s:NetrwSetChgwin(<q-args>) | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6627 com! Rexplore if exists("w:netrw_rexlocal")|call s:NetrwRexplore(w:netrw_rexlocal,exists("w:netrw_rexdir")? w:netrw_rexdir : ".")|else|call netrw#ErrorMsg(s:WARNING,"win#".winnr()." not a former netrw window",79)|endif |
5734 | 6628 if a:islocal |
6476 | 6629 com! -buffer -nargs=+ -complete=file MF call s:NetrwMarkFiles(1,<f-args>) |
6630 else | |
6631 com! -buffer -nargs=+ -complete=file MF call s:NetrwMarkFiles(0,<f-args>) | |
6632 endif | |
6633 com! -buffer -nargs=? -complete=file MT call s:NetrwMarkTarget(<q-args>) | |
5734 | 6634 |
6635 " call Dret("s:NetrwCommands") | |
6636 endfun | |
6637 | |
6638 " --------------------------------------------------------------------- | |
6639 " s:NetrwMarkFiles: apply s:NetrwMarkFile() to named file(s) {{{2 | |
6640 " glob()ing only works with local files | |
6641 fun! s:NetrwMarkFiles(islocal,...) | |
6642 " call Dfunc("s:NetrwMarkFiles(islocal=".a:islocal."...) a:0=".a:0) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6643 let curdir = s:NetrwGetCurdir(a:islocal) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6644 let i = 1 |
5734 | 6645 while i <= a:0 |
6646 if a:islocal | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
6647 if v:version > 704 || (v:version == 704 && has("patch656")) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
6648 let mffiles= glob(fnameescape(a:{i}),0,1,1) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
6649 else |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
6650 let mffiles= glob(fnameescape(a:{i}),0,1) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6651 endif |
5734 | 6652 else |
6653 let mffiles= [a:{i}] | |
6654 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6655 " call Decho("mffiles".string(mffiles),'~'.expand("<slnum>")) |
5734 | 6656 for mffile in mffiles |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6657 " call Decho("mffile<".mffile.">",'~'.expand("<slnum>")) |
5734 | 6658 call s:NetrwMarkFile(a:islocal,mffile) |
6659 endfor | |
6660 let i= i + 1 | |
6661 endwhile | |
6662 " call Dret("s:NetrwMarkFiles") | |
6663 endfun | |
6664 | |
6665 " --------------------------------------------------------------------- | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6666 " s:NetrwMarkTarget: implements :MT (mark target) {{{2 |
5734 | 6667 fun! s:NetrwMarkTarget(...) |
6668 " call Dfunc("s:NetrwMarkTarget() a:0=".a:0) | |
6669 if a:0 == 0 || (a:0 == 1 && a:1 == "") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6670 let curdir = s:NetrwGetCurdir(1) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6671 let tgt = b:netrw_curdir |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6672 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6673 let curdir = s:NetrwGetCurdir((a:1 =~ '^\a\{3,}://')? 0 : 1) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6674 let tgt = a:1 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6675 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6676 " call Decho("tgt<".tgt.">",'~'.expand("<slnum>")) |
5734 | 6677 let s:netrwmftgt = tgt |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6678 let s:netrwmftgt_islocal = tgt !~ '^\a\{3,}://' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6679 let curislocal = b:netrw_curdir !~ '^\a\{3,}://' |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6680 let svpos = winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6681 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
5734 | 6682 call s:NetrwRefresh(curislocal,s:NetrwBrowseChgDir(curislocal,'./')) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6683 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6684 call winrestview(svpos) |
5734 | 6685 " call Dret("s:NetrwMarkTarget") |
1621 | 6686 endfun |
6687 | |
6688 " --------------------------------------------------------------------- | |
6689 " s:NetrwMarkFile: (invoked by mf) This function is used to both {{{2 | |
6690 " mark and unmark files. If a markfile list exists, | |
6691 " then the rename and delete functions will use it instead | |
6692 " of whatever may happen to be under the cursor at that | |
6693 " moment. When the mouse and gui are available, | |
6694 " shift-leftmouse may also be used to mark files. | |
1698 | 6695 " |
6696 " Creates two lists | |
6697 " s:netrwmarkfilelist -- holds complete paths to all marked files | |
6698 " s:netrwmarkfilelist_# -- holds list of marked files in current-buffer's directory (#==bufnr()) | |
6699 " | |
6700 " Creates a marked file match string | |
6701 " s:netrwmarfilemtch_# -- used with 2match to display marked files | |
6702 " | |
1702 | 6703 " Creates a buffer version of islocal |
6704 " b:netrw_islocal | |
1621 | 6705 fun! s:NetrwMarkFile(islocal,fname) |
6706 " call Dfunc("s:NetrwMarkFile(islocal=".a:islocal." fname<".a:fname.">)") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6707 " call Decho("bufnr(%)=".bufnr("%").": ".bufname("%"),'~'.expand("<slnum>")) |
4339 | 6708 |
6709 " sanity check | |
6710 if empty(a:fname) | |
6711 " call Dret("s:NetrwMarkFile : emtpy fname") | |
6712 return | |
6713 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6714 let curdir = s:NetrwGetCurdir(a:islocal) |
4339 | 6715 |
3920 | 6716 let ykeep = @@ |
1621 | 6717 let curbufnr= bufnr("%") |
5734 | 6718 if a:fname =~ '^\a' |
6719 let leader= '\<' | |
6720 else | |
6721 let leader= '' | |
6722 endif | |
6723 if a:fname =~ '\a$' | |
6724 let trailer = '\>[@=|\/\*]\=\ze\%( \|\t\|$\)' | |
6725 else | |
6726 let trailer = '[@=|\/\*]\=\ze\%( \|\t\|$\)' | |
6727 endif | |
2751 | 6728 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6729 if exists("s:netrwmarkfilelist_".curbufnr) |
2751 | 6730 " markfile list pre-exists |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6731 " call Decho("case s:netrwmarkfilelist_".curbufnr." already exists",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6732 " call Decho("starting s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr}).">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6733 " call Decho("starting s:netrwmarkfilemtch_".curbufnr."<".s:netrwmarkfilemtch_{curbufnr}.">",'~'.expand("<slnum>")) |
1702 | 6734 let b:netrw_islocal= a:islocal |
1621 | 6735 |
6736 if index(s:netrwmarkfilelist_{curbufnr},a:fname) == -1 | |
1702 | 6737 " append filename to buffer's markfilelist |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6738 " call Decho("append filename<".a:fname."> to local markfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr}).">",'~'.expand("<slnum>")) |
1621 | 6739 call add(s:netrwmarkfilelist_{curbufnr},a:fname) |
5734 | 6740 let s:netrwmarkfilemtch_{curbufnr}= s:netrwmarkfilemtch_{curbufnr}.'\|'.leader.escape(a:fname,g:netrw_markfileesc).trailer |
1621 | 6741 |
6742 else | |
1702 | 6743 " remove filename from buffer's markfilelist |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6744 " call Decho("remove filename<".a:fname."> from local markfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr}).">",'~'.expand("<slnum>")) |
1621 | 6745 call filter(s:netrwmarkfilelist_{curbufnr},'v:val != a:fname') |
6746 if s:netrwmarkfilelist_{curbufnr} == [] | |
6747 " local markfilelist is empty; remove it entirely | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6748 " call Decho("markfile list now empty",'~'.expand("<slnum>")) |
1621 | 6749 call s:NetrwUnmarkList(curbufnr,curdir) |
6750 else | |
6751 " rebuild match list to display markings correctly | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6752 " call Decho("rebuild s:netrwmarkfilemtch_".curbufnr,'~'.expand("<slnum>")) |
1621 | 6753 let s:netrwmarkfilemtch_{curbufnr}= "" |
5734 | 6754 let first = 1 |
1621 | 6755 for fname in s:netrwmarkfilelist_{curbufnr} |
6756 if first | |
5734 | 6757 let s:netrwmarkfilemtch_{curbufnr}= s:netrwmarkfilemtch_{curbufnr}.leader.escape(fname,g:netrw_markfileesc).trailer |
1621 | 6758 else |
5734 | 6759 let s:netrwmarkfilemtch_{curbufnr}= s:netrwmarkfilemtch_{curbufnr}.'\|'.leader.escape(fname,g:netrw_markfileesc).trailer |
1621 | 6760 endif |
6761 let first= 0 | |
6762 endfor | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6763 " call Decho("ending s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr}).">",'~'.expand("<slnum>")) |
1621 | 6764 endif |
6765 endif | |
6766 | |
6767 else | |
6768 " initialize new markfilelist | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6769 " call Decho("case: initialize new markfilelist",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6770 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6771 " call Decho("add fname<".a:fname."> to new markfilelist_".curbufnr,'~'.expand("<slnum>")) |
1621 | 6772 let s:netrwmarkfilelist_{curbufnr}= [] |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6773 call add(s:netrwmarkfilelist_{curbufnr},substitute(a:fname,'[|@]$','','')) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6774 " call Decho("ending s:netrwmarkfilelist_{curbufnr}<".string(s:netrwmarkfilelist_{curbufnr}).">",'~'.expand("<slnum>")) |
1621 | 6775 |
6776 " build initial markfile matching pattern | |
6777 if a:fname =~ '/$' | |
5734 | 6778 let s:netrwmarkfilemtch_{curbufnr}= leader.escape(a:fname,g:netrw_markfileesc) |
6779 else | |
6780 let s:netrwmarkfilemtch_{curbufnr}= leader.escape(a:fname,g:netrw_markfileesc).trailer | |
1621 | 6781 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6782 " call Decho("ending s:netrwmarkfilemtch_".curbufnr."<".s:netrwmarkfilemtch_{curbufnr}.">",'~'.expand("<slnum>")) |
1621 | 6783 endif |
6784 | |
6785 " handle global markfilelist | |
6786 if exists("s:netrwmarkfilelist") | |
6787 let dname= s:ComposePath(b:netrw_curdir,a:fname) | |
6788 if index(s:netrwmarkfilelist,dname) == -1 | |
6789 " append new filename to global markfilelist | |
6790 call add(s:netrwmarkfilelist,s:ComposePath(b:netrw_curdir,a:fname)) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6791 " call Decho("append filename<".a:fname."> to global markfilelist<".string(s:netrwmarkfilelist).">",'~'.expand("<slnum>")) |
1621 | 6792 else |
6793 " remove new filename from global markfilelist | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6794 " call Decho("filter(".string(s:netrwmarkfilelist).",'v:val != '.".dname.")",'~'.expand("<slnum>")) |
1621 | 6795 call filter(s:netrwmarkfilelist,'v:val != "'.dname.'"') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6796 " call Decho("ending s:netrwmarkfilelist <".string(s:netrwmarkfilelist).">",'~'.expand("<slnum>")) |
1621 | 6797 if s:netrwmarkfilelist == [] |
6798 unlet s:netrwmarkfilelist | |
6799 endif | |
6800 endif | |
6801 else | |
6802 " initialize new global-directory markfilelist | |
6803 let s:netrwmarkfilelist= [] | |
6804 call add(s:netrwmarkfilelist,s:ComposePath(b:netrw_curdir,a:fname)) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6805 " call Decho("init s:netrwmarkfilelist<".string(s:netrwmarkfilelist).">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6806 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6807 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6808 " set up 2match'ing to netrwmarkfilemtch_# list |
17433 | 6809 if has("syntax") && exists("g:syntax_on") && g:syntax_on |
6810 if exists("s:netrwmarkfilemtch_{curbufnr}") && s:netrwmarkfilemtch_{curbufnr} != "" | |
6811 " " call Decho("exe 2match netrwMarkFile /".s:netrwmarkfilemtch_{curbufnr}."/",'~'.expand("<slnum>")) | |
6812 if exists("g:did_drchip_netrwlist_syntax") | |
6813 exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{curbufnr}."/" | |
6814 endif | |
6815 else | |
6816 " " call Decho("2match none",'~'.expand("<slnum>")) | |
6817 2match none | |
6818 endif | |
1621 | 6819 endif |
3920 | 6820 let @@= ykeep |
2751 | 6821 " call Dret("s:NetrwMarkFile : s:netrwmarkfilelist_".curbufnr."<".(exists("s:netrwmarkfilelist_{curbufnr}")? string(s:netrwmarkfilelist_{curbufnr}) : " doesn't exist").">") |
1621 | 6822 endfun |
6823 | |
6824 " --------------------------------------------------------------------- | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6825 " s:NetrwMarkFileArgList: ma: move the marked file list to the argument list (tomflist=0) {{{2 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6826 " mA: move the argument list to marked file list (tomflist=1) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6827 " Uses the global marked file list |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6828 fun! s:NetrwMarkFileArgList(islocal,tomflist) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6829 " call Dfunc("s:NetrwMarkFileArgList(islocal=".a:islocal.",tomflist=".a:tomflist.")") |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6830 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6831 let svpos = winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6832 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6833 let curdir = s:NetrwGetCurdir(a:islocal) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6834 let curbufnr = bufnr("%") |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6835 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6836 if a:tomflist |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6837 " mA: move argument list to marked file list |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6838 while argc() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6839 let fname= argv(0) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6840 " call Decho("exe argdel ".fname,'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6841 exe "argdel ".fnameescape(fname) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6842 call s:NetrwMarkFile(a:islocal,fname) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6843 endwhile |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6844 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6845 else |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6846 " ma: move marked file list to argument list |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6847 if exists("s:netrwmarkfilelist") |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6848 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6849 " for every filename in the marked list |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6850 for fname in s:netrwmarkfilelist |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6851 " call Decho("exe argadd ".fname,'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6852 exe "argadd ".fnameescape(fname) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6853 endfor " for every file in the marked list |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6854 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6855 " unmark list and refresh |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6856 call s:NetrwUnmarkList(curbufnr,curdir) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6857 NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6858 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6859 NetrwKeepj call winrestview(svpos) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6860 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6861 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6862 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6863 " call Dret("s:NetrwMarkFileArgList") |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6864 endfun |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6865 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6866 " --------------------------------------------------------------------- |
1621 | 6867 " s:NetrwMarkFileCompress: (invoked by mz) This function is used to {{{2 |
6868 " compress/decompress files using the programs | |
6869 " in g:netrw_compress and g:netrw_uncompress, | |
6870 " using g:netrw_compress_suffix to know which to | |
6871 " do. By default: | |
6872 " g:netrw_compress = "gzip" | |
2420
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
6873 " g:netrw_decompress = { ".gz" : "gunzip" , ".bz2" : "bunzip2" , ".zip" : "unzip" , ".tar" : "tar -xf", ".xz" : "unxz"} |
1621 | 6874 fun! s:NetrwMarkFileCompress(islocal) |
6875 " call Dfunc("s:NetrwMarkFileCompress(islocal=".a:islocal.")") | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6876 let svpos = winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6877 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6878 let curdir = s:NetrwGetCurdir(a:islocal) |
1621 | 6879 let curbufnr = bufnr("%") |
6880 | |
4339 | 6881 " sanity check |
6882 if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr}) | |
6476 | 6883 NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) |
4339 | 6884 " call Dret("s:NetrwMarkFileCompress") |
6885 return | |
6886 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6887 " call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr}),'~'.expand("<slnum>")) |
4339 | 6888 |
1621 | 6889 if exists("s:netrwmarkfilelist_{curbufnr}") && exists("g:netrw_compress") && exists("g:netrw_decompress") |
4339 | 6890 |
6891 " for every filename in the marked list | |
1621 | 6892 for fname in s:netrwmarkfilelist_{curbufnr} |
4339 | 6893 let sfx= substitute(fname,'^.\{-}\(\.\a\+\)$','\1','') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6894 " call Decho("extracted sfx<".sfx.">",'~'.expand("<slnum>")) |
4339 | 6895 if exists("g:netrw_decompress['".sfx."']") |
6896 " fname has a suffix indicating that its compressed; apply associated decompression routine | |
6897 let exe= g:netrw_decompress[sfx] | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6898 " call Decho("fname<".fname."> is compressed so decompress with <".exe.">",'~'.expand("<slnum>")) |
4339 | 6899 let exe= netrw#WinPath(exe) |
6900 if a:islocal | |
6901 if g:netrw_keepdir | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6902 let fname= s:ShellEscape(s:ComposePath(curdir,fname)) |
4339 | 6903 endif |
17433 | 6904 call system(exe." ".fname) |
6905 if v:shell_error | |
6906 NetrwKeepj call netrw#ErrorMsg(s:WARNING,"unable to apply<".exe."> to file<".fname.">",50) | |
6907 endif | |
13030
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
6908 else |
92a0a33f8296
move netrw back to the previous version
Christian Brabandt <cb@256bit.org>
parents:
12785
diff
changeset
|
6909 let fname= s:ShellEscape(b:netrw_curdir.fname,1) |
17433 | 6910 NetrwKeepj call s:RemoteSystem(exe." ".fname) |
6911 endif | |
6912 | |
4339 | 6913 endif |
6914 unlet sfx | |
6915 | |
1621 | 6916 if exists("exe") |
6917 unlet exe | |
6918 elseif a:islocal | |
6919 " fname not a compressed file, so compress it | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6920 call system(netrw#WinPath(g:netrw_compress)." ".s:ShellEscape(s:ComposePath(b:netrw_curdir,fname))) |
17433 | 6921 if v:shell_error |
6922 call netrw#ErrorMsg(s:WARNING,"consider setting g:netrw_compress<".g:netrw_compress."> to something that works",104) | |
6923 endif | |
1621 | 6924 else |
6925 " fname not a compressed file, so compress it | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6926 NetrwKeepj call s:RemoteSystem(netrw#WinPath(g:netrw_compress)." ".s:ShellEscape(fname)) |
1621 | 6927 endif |
4339 | 6928 endfor " for every file in the marked list |
6929 | |
1621 | 6930 call s:NetrwUnmarkList(curbufnr,curdir) |
6476 | 6931 NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6932 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6933 NetrwKeepj call winrestview(svpos) |
1621 | 6934 endif |
6935 " call Dret("s:NetrwMarkFileCompress") | |
6936 endfun | |
6937 | |
6938 " --------------------------------------------------------------------- | |
6939 " s:NetrwMarkFileCopy: (invoked by mc) copy marked files to target {{{2 | |
6940 " If no marked files, then set up directory as the | |
6941 " target. Currently does not support copying entire | |
6942 " directories. Uses the local-buffer marked file list. | |
6943 " Returns 1=success (used by NetrwMarkFileMove()) | |
6944 " 0=failure | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
6945 fun! s:NetrwMarkFileCopy(islocal,...) |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
6946 " call Dfunc("s:NetrwMarkFileCopy(islocal=".a:islocal.") target<".(exists("s:netrwmftgt")? s:netrwmftgt : '---')."> a:0=".a:0) |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
6947 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6948 let curdir = s:NetrwGetCurdir(a:islocal) |
4339 | 6949 let curbufnr = bufnr("%") |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6950 if b:netrw_curdir !~ '/$' |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6951 if !exists("b:netrw_curdir") |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6952 let b:netrw_curdir= curdir |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6953 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6954 let b:netrw_curdir= b:netrw_curdir."/" |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6955 endif |
4339 | 6956 |
6957 " sanity check | |
6958 if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr}) | |
6476 | 6959 NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) |
4339 | 6960 " call Dret("s:NetrwMarkFileCopy") |
6961 return | |
6962 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6963 " call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr}),'~'.expand("<slnum>")) |
4339 | 6964 |
1621 | 6965 if !exists("s:netrwmftgt") |
6476 | 6966 NetrwKeepj call netrw#ErrorMsg(s:ERROR,"your marked file target is empty! (:help netrw-mt)",67) |
1621 | 6967 " call Dret("s:NetrwMarkFileCopy 0") |
6968 return 0 | |
6969 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6970 " call Decho("sanity chk passed: s:netrwmftgt<".s:netrwmftgt.">",'~'.expand("<slnum>")) |
1621 | 6971 |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6972 if a:islocal && s:netrwmftgt_islocal |
1621 | 6973 " Copy marked files, local directory to local directory |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6974 " call Decho("copy from local to local",'~'.expand("<slnum>")) |
17433 | 6975 if !executable(g:netrw_localcopycmd) |
3920 | 6976 call netrw#ErrorMsg(s:ERROR,"g:netrw_localcopycmd<".g:netrw_localcopycmd."> not executable on your system, aborting",91) |
6977 " call Dfunc("s:NetrwMarkFileMove : g:netrw_localcopycmd<".g:netrw_localcopycmd."> n/a!") | |
6978 return | |
6979 endif | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
6980 |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
6981 " copy marked files while within the same directory (ie. allow renaming) |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
6982 if simplify(s:netrwmftgt) == simplify(b:netrw_curdir) |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
6983 if len(s:netrwmarkfilelist_{bufnr('%')}) == 1 |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
6984 " only one marked file |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6985 " call Decho("case: only one marked file",'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6986 let args = s:ShellEscape(b:netrw_curdir.s:netrwmarkfilelist_{bufnr('%')}[0]) |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
6987 let oldname = s:netrwmarkfilelist_{bufnr('%')}[0] |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
6988 elseif a:0 == 1 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6989 " call Decho("case: handling one input argument",'~'.expand("<slnum>")) |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
6990 " this happens when the next case was used to recursively call s:NetrwMarkFileCopy() |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
6991 let args = s:ShellEscape(b:netrw_curdir.a:1) |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
6992 let oldname = a:1 |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
6993 else |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
6994 " copy multiple marked files inside the same directory |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
6995 " call Decho("case: handling a multiple marked files",'~'.expand("<slnum>")) |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
6996 let s:recursive= 1 |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
6997 for oldname in s:netrwmarkfilelist_{bufnr("%")} |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
6998 let ret= s:NetrwMarkFileCopy(a:islocal,oldname) |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
6999 if ret == 0 |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
7000 break |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
7001 endif |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
7002 endfor |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
7003 unlet s:recursive |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
7004 call s:NetrwUnmarkList(curbufnr,curdir) |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
7005 " call Dret("s:NetrwMarkFileCopy ".ret) |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
7006 return ret |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
7007 endif |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
7008 |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
7009 call inputsave() |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
7010 let newname= input("Copy ".oldname." to : ",oldname,"file") |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
7011 call inputrestore() |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
7012 if newname == "" |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
7013 " call Dret("s:NetrwMarkFileCopy 0") |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
7014 return 0 |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
7015 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7016 let args= s:ShellEscape(oldname) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7017 let tgt = s:ShellEscape(s:netrwmftgt.'/'.newname) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7018 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7019 let args= join(map(deepcopy(s:netrwmarkfilelist_{bufnr('%')}),"s:ShellEscape(b:netrw_curdir.\"/\".v:val)")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7020 let tgt = s:ShellEscape(s:netrwmftgt) |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
7021 endif |
4339 | 7022 if !g:netrw_cygwin && (has("win32") || has("win95") || has("win64") || has("win16")) |
7023 let args= substitute(args,'/','\\','g') | |
7024 let tgt = substitute(tgt, '/','\\','g') | |
7025 endif | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7026 if args =~ "'" |let args= substitute(args,"'\\(.*\\)'",'\1','')|endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7027 if tgt =~ "'" |let tgt = substitute(tgt ,"'\\(.*\\)'",'\1','')|endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7028 if args =~ '//'|let args= substitute(args,'//','/','g')|endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7029 if tgt =~ '//'|let tgt = substitute(tgt ,'//','/','g')|endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7030 " call Decho("args <".args.">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7031 " call Decho("tgt <".tgt.">",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7032 if isdirectory(s:NetrwFile(args)) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7033 " call Decho("args<".args."> is a directory",'~'.expand("<slnum>")) |
6476 | 7034 let copycmd= g:netrw_localcopydircmd |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7035 " call Decho("using copydircmd<".copycmd.">",'~'.expand("<slnum>")) |
6476 | 7036 if !g:netrw_cygwin && (has("win32") || has("win95") || has("win64") || has("win16")) |
7037 " window's xcopy doesn't copy a directory to a target properly. Instead, it copies a directory's | |
7038 " contents to a target. One must append the source directory name to the target to get xcopy to | |
7039 " do the right thing. | |
7040 let tgt= tgt.'\'.substitute(a:1,'^.*[\\/]','','') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7041 " call Decho("modified tgt for xcopy",'~'.expand("<slnum>")) |
6476 | 7042 endif |
7043 else | |
7044 let copycmd= g:netrw_localcopycmd | |
7045 endif | |
4339 | 7046 if g:netrw_localcopycmd =~ '\s' |
6476 | 7047 let copycmd = substitute(copycmd,'\s.*$','','') |
7048 let copycmdargs = substitute(copycmd,'^.\{-}\(\s.*\)$','\1','') | |
4339 | 7049 let copycmd = netrw#WinPath(copycmd).copycmdargs |
7050 else | |
6476 | 7051 let copycmd = netrw#WinPath(copycmd) |
4339 | 7052 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7053 " call Decho("args <".args.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7054 " call Decho("tgt <".tgt.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7055 " call Decho("copycmd<".copycmd.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7056 " call Decho("system(".copycmd." '".args."' '".tgt."')",'~'.expand("<slnum>")) |
17433 | 7057 call system(copycmd.g:netrw_localcopycmdopt." '".args."' '".tgt."'") |
3920 | 7058 if v:shell_error != 0 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7059 if exists("b:netrw_curdir") && b:netrw_curdir != getcwd() && !g:netrw_keepdir |
17433 | 7060 call netrw#ErrorMsg(s:ERROR,"copy failed; perhaps due to vim's current directory<".getcwd()."> not matching netrw's (".b:netrw_curdir.") (see :help netrw-cd)",101) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7061 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7062 call netrw#ErrorMsg(s:ERROR,"tried using g:netrw_localcopycmd<".g:netrw_localcopycmd.">; it doesn't work!",80) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7063 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7064 " call Dret("s:NetrwMarkFileCopy 0 : failed: system(".g:netrw_localcopycmd." ".args." ".s:ShellEscape(s:netrwmftgt)) |
3920 | 7065 return 0 |
7066 endif | |
1621 | 7067 |
7068 elseif a:islocal && !s:netrwmftgt_islocal | |
7069 " Copy marked files, local directory to remote directory | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7070 " call Decho("copy from local to remote",'~'.expand("<slnum>")) |
6476 | 7071 NetrwKeepj call s:NetrwUpload(s:netrwmarkfilelist_{bufnr('%')},s:netrwmftgt) |
1621 | 7072 |
7073 elseif !a:islocal && s:netrwmftgt_islocal | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
7074 " Copy marked files, remote directory to local directory |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7075 " call Decho("copy from remote to local",'~'.expand("<slnum>")) |
6476 | 7076 NetrwKeepj call netrw#Obtain(a:islocal,s:netrwmarkfilelist_{bufnr('%')},s:netrwmftgt) |
1621 | 7077 |
7078 elseif !a:islocal && !s:netrwmftgt_islocal | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
7079 " Copy marked files, remote directory to remote directory |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7080 " call Decho("copy from remote to remote",'~'.expand("<slnum>")) |
1621 | 7081 let curdir = getcwd() |
7082 let tmpdir = s:GetTempfile("") | |
7083 if tmpdir !~ '/' | |
7084 let tmpdir= curdir."/".tmpdir | |
7085 endif | |
7086 if exists("*mkdir") | |
7087 call mkdir(tmpdir) | |
7088 else | |
17433 | 7089 call s:NetrwExe("sil! !".g:netrw_localmkdir.g:netrw_localmkdiropt.' '.s:ShellEscape(tmpdir,1)) |
3920 | 7090 if v:shell_error != 0 |
7091 call netrw#ErrorMsg(s:WARNING,"consider setting g:netrw_localmkdir<".g:netrw_localmkdir."> to something that works",80) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7092 " call Dret("s:NetrwMarkFileCopy : failed: sil! !".g:netrw_localmkdir.' '.s:ShellEscape(tmpdir,1) ) |
3920 | 7093 return |
7094 endif | |
1621 | 7095 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7096 if isdirectory(s:NetrwFile(tmpdir)) |
17433 | 7097 if s:NetrwLcd(tmpdir) |
7098 " call Dret("s:NetrwMarkFileCopy : lcd failure") | |
7099 return | |
7100 endif | |
6476 | 7101 NetrwKeepj call netrw#Obtain(a:islocal,s:netrwmarkfilelist_{bufnr('%')},tmpdir) |
1698 | 7102 let localfiles= map(deepcopy(s:netrwmarkfilelist_{bufnr('%')}),'substitute(v:val,"^.*/","","")') |
6476 | 7103 NetrwKeepj call s:NetrwUpload(localfiles,s:netrwmftgt) |
1621 | 7104 if getcwd() == tmpdir |
7105 for fname in s:netrwmarkfilelist_{bufnr('%')} | |
6476 | 7106 NetrwKeepj call s:NetrwDelete(fname) |
1621 | 7107 endfor |
17433 | 7108 if s:NetrwLcd(curdir) |
7109 " call Dret("s:NetrwMarkFileCopy : lcd failure") | |
7110 return | |
7111 endif | |
7112 if v:version < 704 || (v:version == 704 && !has("patch1107")) | |
7113 call s:NetrwExe("sil !".g:netrw_localrmdir.g:netrw_localrmdiropt." ".s:ShellEscape(tmpdir,1)) | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7114 if v:shell_error != 0 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7115 call netrw#ErrorMsg(s:WARNING,"consider setting g:netrw_localrmdir<".g:netrw_localrmdir."> to something that works",80) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7116 " " call Dret("s:NetrwMarkFileCopy : failed: sil !".g:netrw_localrmdir." ".s:ShellEscape(tmpdir,1) ) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7117 return |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7118 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7119 else |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7120 if delete(tmpdir,"d") |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7121 call netrw#ErrorMsg(s:ERROR,"unable to delete directory <".tmpdir.">!",103) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7122 endif |
3920 | 7123 endif |
1621 | 7124 else |
17433 | 7125 if s:NetrwLcd(curdir) |
7126 " call Dret("s:NetrwMarkFileCopy : lcd failure") | |
7127 return | |
7128 endif | |
1621 | 7129 endif |
7130 endif | |
7131 endif | |
7132 | |
7133 " ------- | |
7134 " cleanup | |
7135 " ------- | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7136 " call Decho("cleanup",'~'.expand("<slnum>")) |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
7137 " remove markings from local buffer |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
7138 call s:NetrwUnmarkList(curbufnr,curdir) " remove markings from local buffer |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7139 " call Decho(" g:netrw_fastbrowse =".g:netrw_fastbrowse,'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7140 " call Decho(" s:netrwmftgt =".s:netrwmftgt,'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7141 " call Decho(" s:netrwmftgt_islocal=".s:netrwmftgt_islocal,'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7142 " call Decho(" curdir =".curdir,'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7143 " call Decho(" a:islocal =".a:islocal,'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7144 " call Decho(" curbufnr =".curbufnr,'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7145 if exists("s:recursive") |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7146 " call Decho(" s:recursive =".s:recursive,'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7147 else |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7148 " call Decho(" s:recursive =n/a",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7149 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7150 " see s:LocalFastBrowser() for g:netrw_fastbrowse interpretation (refreshing done for both slow and medium) |
2034 | 7151 if g:netrw_fastbrowse <= 1 |
6476 | 7152 NetrwKeepj call s:LocalBrowseRefresh() |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7153 else |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7154 " refresh local and targets for fast browsing |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7155 if !exists("s:recursive") |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7156 " remove markings from local buffer |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7157 " call Decho(" remove markings from local buffer",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7158 NetrwKeepj call s:NetrwUnmarkList(curbufnr,curdir) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7159 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7160 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7161 " refresh buffers |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7162 if s:netrwmftgt_islocal |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7163 " call Decho(" refresh s:netrwmftgt=".s:netrwmftgt,'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7164 NetrwKeepj call s:NetrwRefreshDir(s:netrwmftgt_islocal,s:netrwmftgt) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7165 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7166 if a:islocal && s:netrwmftgt != curdir |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7167 " call Decho(" refresh curdir=".curdir,'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7168 NetrwKeepj call s:NetrwRefreshDir(a:islocal,curdir) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7169 endif |
2034 | 7170 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7171 |
1621 | 7172 " call Dret("s:NetrwMarkFileCopy 1") |
7173 return 1 | |
7174 endfun | |
7175 | |
7176 " --------------------------------------------------------------------- | |
7177 " s:NetrwMarkFileDiff: (invoked by md) This function is used to {{{2 | |
7178 " invoke vim's diff mode on the marked files. | |
7179 " Either two or three files can be so handled. | |
7180 " Uses the global marked file list. | |
7181 fun! s:NetrwMarkFileDiff(islocal) | |
7182 " call Dfunc("s:NetrwMarkFileDiff(islocal=".a:islocal.") b:netrw_curdir<".b:netrw_curdir.">") | |
7183 let curbufnr= bufnr("%") | |
1698 | 7184 |
4339 | 7185 " sanity check |
7186 if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr}) | |
6476 | 7187 NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) |
4339 | 7188 " call Dret("s:NetrwMarkFileDiff") |
7189 return | |
7190 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7191 let curdir= s:NetrwGetCurdir(a:islocal) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7192 " call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr}),'~'.expand("<slnum>")) |
4339 | 7193 |
5734 | 7194 if exists("s:netrwmarkfilelist_{".curbufnr."}") |
1621 | 7195 let cnt = 0 |
7196 for fname in s:netrwmarkfilelist | |
7197 let cnt= cnt + 1 | |
7198 if cnt == 1 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7199 " call Decho("diffthis: fname<".fname.">",'~'.expand("<slnum>")) |
6476 | 7200 exe "NetrwKeepj e ".fnameescape(fname) |
1621 | 7201 diffthis |
7202 elseif cnt == 2 || cnt == 3 | |
7203 vsplit | |
7204 wincmd l | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7205 " call Decho("diffthis: ".fname,'~'.expand("<slnum>")) |
6476 | 7206 exe "NetrwKeepj e ".fnameescape(fname) |
1621 | 7207 diffthis |
7208 else | |
7209 break | |
7210 endif | |
7211 endfor | |
7212 call s:NetrwUnmarkList(curbufnr,curdir) | |
7213 endif | |
1698 | 7214 |
1621 | 7215 " call Dret("s:NetrwMarkFileDiff") |
7216 endfun | |
7217 | |
7218 " --------------------------------------------------------------------- | |
7219 " s:NetrwMarkFileEdit: (invoked by me) put marked files on arg list and start editing them {{{2 | |
7220 " Uses global markfilelist | |
7221 fun! s:NetrwMarkFileEdit(islocal) | |
7222 " call Dfunc("s:NetrwMarkFileEdit(islocal=".a:islocal.")") | |
7223 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7224 let curdir = s:NetrwGetCurdir(a:islocal) |
1621 | 7225 let curbufnr = bufnr("%") |
4339 | 7226 |
7227 " sanity check | |
7228 if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr}) | |
6476 | 7229 NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) |
4339 | 7230 " call Dret("s:NetrwMarkFileEdit") |
7231 return | |
7232 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7233 " call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr}),'~'.expand("<slnum>")) |
4339 | 7234 |
1621 | 7235 if exists("s:netrwmarkfilelist_{curbufnr}") |
7236 call s:SetRexDir(a:islocal,curdir) | |
1698 | 7237 let flist= join(map(deepcopy(s:netrwmarkfilelist), "fnameescape(v:val)")) |
1621 | 7238 " unmark markedfile list |
7239 " call s:NetrwUnmarkList(curbufnr,curdir) | |
7240 call s:NetrwUnmarkAll() | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7241 " call Decho("exe sil args ".flist,'~'.expand("<slnum>")) |
2751 | 7242 exe "sil args ".flist |
1621 | 7243 endif |
4339 | 7244 echo "(use :bn, :bp to navigate files; :Rex to return)" |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7245 |
1621 | 7246 " call Dret("s:NetrwMarkFileEdit") |
7247 endfun | |
7248 | |
7249 " --------------------------------------------------------------------- | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7250 " s:NetrwMarkFileQFEL: convert a quickfix-error or location list into a marked file list {{{2 |
4339 | 7251 fun! s:NetrwMarkFileQFEL(islocal,qfel) |
7252 " call Dfunc("s:NetrwMarkFileQFEL(islocal=".a:islocal.",qfel)") | |
7253 call s:NetrwUnmarkAll() | |
7254 let curbufnr= bufnr("%") | |
7255 | |
7256 if !empty(a:qfel) | |
7257 for entry in a:qfel | |
7258 let bufnmbr= entry["bufnr"] | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7259 " call Decho("bufname(".bufnmbr.")<".bufname(bufnmbr)."> line#".entry["lnum"]." text=".entry["text"],'~'.expand("<slnum>")) |
4339 | 7260 if !exists("s:netrwmarkfilelist_{curbufnr}") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7261 " call Decho("case: no marked file list",'~'.expand("<slnum>")) |
4339 | 7262 call s:NetrwMarkFile(a:islocal,bufname(bufnmbr)) |
7263 elseif index(s:netrwmarkfilelist_{curbufnr},bufname(bufnmbr)) == -1 | |
7264 " s:NetrwMarkFile will remove duplicate entries from the marked file list. | |
7265 " So, this test lets two or more hits on the same pattern to be ignored. | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7266 " call Decho("case: ".bufname(bufnmbr)." not currently in marked file list",'~'.expand("<slnum>")) |
4339 | 7267 call s:NetrwMarkFile(a:islocal,bufname(bufnmbr)) |
7268 else | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7269 " call Decho("case: ".bufname(bufnmbr)." already in marked file list",'~'.expand("<slnum>")) |
4339 | 7270 endif |
7271 endfor | |
7272 echo "(use me to edit marked files)" | |
7273 else | |
7274 call netrw#ErrorMsg(s:WARNING,"can't convert quickfix error list; its empty!",92) | |
7275 endif | |
7276 | |
7277 " call Dret("s:NetrwMarkFileQFEL") | |
7278 endfun | |
7279 | |
7280 " --------------------------------------------------------------------- | |
6476 | 7281 " s:NetrwMarkFileExe: (invoked by mx and mX) execute arbitrary system command on marked files {{{2 |
7282 " mx enbloc=0: Uses the local marked-file list, applies command to each file individually | |
7283 " mX enbloc=1: Uses the global marked-file list, applies command to entire list | |
7284 fun! s:NetrwMarkFileExe(islocal,enbloc) | |
7285 " call Dfunc("s:NetrwMarkFileExe(islocal=".a:islocal.",enbloc=".a:enbloc.")") | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7286 let svpos = winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7287 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7288 let curdir = s:NetrwGetCurdir(a:islocal) |
1621 | 7289 let curbufnr = bufnr("%") |
7290 | |
6476 | 7291 if a:enbloc == 0 |
7292 " individually apply command to files, one at a time | |
7293 " sanity check | |
7294 if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr}) | |
7295 NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) | |
7296 " call Dret("s:NetrwMarkFileExe") | |
7297 return | |
7298 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7299 " call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr}),'~'.expand("<slnum>")) |
6476 | 7300 |
7301 if exists("s:netrwmarkfilelist_{curbufnr}") | |
7302 " get the command | |
7303 call inputsave() | |
7304 let cmd= input("Enter command: ","","file") | |
7305 call inputrestore() | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7306 " call Decho("cmd<".cmd.">",'~'.expand("<slnum>")) |
6476 | 7307 if cmd == "" |
7308 " call Dret("s:NetrwMarkFileExe : early exit, empty command") | |
7309 return | |
7310 endif | |
7311 | |
7312 " apply command to marked files, individually. Substitute: filename -> % | |
7313 " If no %, then append a space and the filename to the command | |
7314 for fname in s:netrwmarkfilelist_{curbufnr} | |
7315 if a:islocal | |
7316 if g:netrw_keepdir | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7317 let fname= s:ShellEscape(netrw#WinPath(s:ComposePath(curdir,fname))) |
6476 | 7318 endif |
7319 else | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7320 let fname= s:ShellEscape(netrw#WinPath(b:netrw_curdir.fname)) |
6476 | 7321 endif |
7322 if cmd =~ '%' | |
7323 let xcmd= substitute(cmd,'%',fname,'g') | |
7324 else | |
7325 let xcmd= cmd.' '.fname | |
7326 endif | |
7327 if a:islocal | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7328 " call Decho("local: xcmd<".xcmd.">",'~'.expand("<slnum>")) |
6476 | 7329 let ret= system(xcmd) |
7330 else | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7331 " call Decho("remote: xcmd<".xcmd.">",'~'.expand("<slnum>")) |
6476 | 7332 let ret= s:RemoteSystem(xcmd) |
7333 endif | |
7334 if v:shell_error < 0 | |
7335 NetrwKeepj call netrw#ErrorMsg(s:ERROR,"command<".xcmd."> failed, aborting",54) | |
7336 break | |
7337 else | |
7338 echo ret | |
7339 endif | |
7340 endfor | |
1621 | 7341 |
7342 " unmark marked file list | |
7343 call s:NetrwUnmarkList(curbufnr,curdir) | |
7344 | |
7345 " refresh the listing | |
6476 | 7346 NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7347 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7348 NetrwKeepj call winrestview(svpos) |
6476 | 7349 else |
7350 NetrwKeepj call netrw#ErrorMsg(s:ERROR,"no files marked!",59) | |
7351 endif | |
7352 | |
7353 else " apply command to global list of files, en bloc | |
7354 | |
7355 call inputsave() | |
7356 let cmd= input("Enter command: ","","file") | |
7357 call inputrestore() | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7358 " call Decho("cmd<".cmd.">",'~'.expand("<slnum>")) |
6476 | 7359 if cmd == "" |
7360 " call Dret("s:NetrwMarkFileExe : early exit, empty command") | |
7361 return | |
7362 endif | |
7363 if cmd =~ '%' | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7364 let cmd= substitute(cmd,'%',join(map(s:netrwmarkfilelist,'s:ShellEscape(v:val)'),' '),'g') |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7365 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7366 let cmd= cmd.' '.join(map(s:netrwmarkfilelist,'s:ShellEscape(v:val)'),' ') |
6476 | 7367 endif |
7368 if a:islocal | |
7369 call system(cmd) | |
7370 if v:shell_error < 0 | |
7371 NetrwKeepj call netrw#ErrorMsg(s:ERROR,"command<".xcmd."> failed, aborting",54) | |
7372 endif | |
7373 else | |
7374 let ret= s:RemoteSystem(cmd) | |
7375 endif | |
7376 call s:NetrwUnmarkAll() | |
7377 | |
7378 " refresh the listing | |
7379 NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7380 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7381 NetrwKeepj call winrestview(svpos) |
6476 | 7382 |
7383 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7384 |
1621 | 7385 " call Dret("s:NetrwMarkFileExe") |
7386 endfun | |
7387 | |
7388 " --------------------------------------------------------------------- | |
7389 " s:NetrwMarkHideSfx: (invoked by mh) (un)hide files having same suffix | |
7390 " as the marked file(s) (toggles suffix presence) | |
7391 " Uses the local marked file list. | |
7392 fun! s:NetrwMarkHideSfx(islocal) | |
7393 " call Dfunc("s:NetrwMarkHideSfx(islocal=".a:islocal.")") | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7394 let svpos = winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7395 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
1621 | 7396 let curbufnr = bufnr("%") |
7397 | |
7398 " s:netrwmarkfilelist_{curbufnr}: the List of marked files | |
7399 if exists("s:netrwmarkfilelist_{curbufnr}") | |
7400 | |
7401 for fname in s:netrwmarkfilelist_{curbufnr} | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7402 " call Decho("s:NetrwMarkFileCopy: fname<".fname.">",'~'.expand("<slnum>")) |
1621 | 7403 " construct suffix pattern |
7404 if fname =~ '\.' | |
7405 let sfxpat= "^.*".substitute(fname,'^.*\(\.[^. ]\+\)$','\1','') | |
7406 else | |
7407 let sfxpat= '^\%(\%(\.\)\@!.\)*$' | |
7408 endif | |
7409 " determine if its in the hiding list or not | |
7410 let inhidelist= 0 | |
7411 if g:netrw_list_hide != "" | |
7412 let itemnum = 0 | |
7413 let hidelist= split(g:netrw_list_hide,',') | |
7414 for hidepat in hidelist | |
7415 if sfxpat == hidepat | |
7416 let inhidelist= 1 | |
7417 break | |
7418 endif | |
7419 let itemnum= itemnum + 1 | |
7420 endfor | |
7421 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7422 " call Decho("fname<".fname."> inhidelist=".inhidelist." sfxpat<".sfxpat.">",'~'.expand("<slnum>")) |
1621 | 7423 if inhidelist |
7424 " remove sfxpat from list | |
7425 call remove(hidelist,itemnum) | |
7426 let g:netrw_list_hide= join(hidelist,",") | |
7427 elseif g:netrw_list_hide != "" | |
7428 " append sfxpat to non-empty list | |
7429 let g:netrw_list_hide= g:netrw_list_hide.",".sfxpat | |
7430 else | |
7431 " set hiding list to sfxpat | |
7432 let g:netrw_list_hide= sfxpat | |
7433 endif | |
7434 endfor | |
7435 | |
7436 " refresh the listing | |
6476 | 7437 NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7438 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7439 NetrwKeepj call winrestview(svpos) |
6476 | 7440 else |
7441 NetrwKeepj call netrw#ErrorMsg(s:ERROR,"no files marked!",59) | |
1621 | 7442 endif |
7443 | |
7444 " call Dret("s:NetrwMarkHideSfx") | |
7445 endfun | |
7446 | |
7447 " --------------------------------------------------------------------- | |
6476 | 7448 " s:NetrwMarkFileVimCmd: (invoked by mv) execute arbitrary vim command on marked files, one at a time {{{2 |
3153 | 7449 " Uses the local marked-file list. |
7450 fun! s:NetrwMarkFileVimCmd(islocal) | |
7451 " call Dfunc("s:NetrwMarkFileVimCmd(islocal=".a:islocal.")") | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7452 let svpos = winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7453 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7454 let curdir = s:NetrwGetCurdir(a:islocal) |
3153 | 7455 let curbufnr = bufnr("%") |
7456 | |
4339 | 7457 " sanity check |
7458 if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr}) | |
6476 | 7459 NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) |
4339 | 7460 " call Dret("s:NetrwMarkFileVimCmd") |
7461 return | |
7462 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7463 " call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr}),'~'.expand("<slnum>")) |
4339 | 7464 |
3153 | 7465 if exists("s:netrwmarkfilelist_{curbufnr}") |
7466 " get the command | |
7467 call inputsave() | |
7468 let cmd= input("Enter vim command: ","","file") | |
7469 call inputrestore() | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7470 " call Decho("cmd<".cmd.">",'~'.expand("<slnum>")) |
3153 | 7471 if cmd == "" |
7472 " " call Dret("s:NetrwMarkFileVimCmd : early exit, empty command") | |
7473 return | |
7474 endif | |
7475 | |
7476 " apply command to marked files. Substitute: filename -> % | |
7477 " If no %, then append a space and the filename to the command | |
7478 for fname in s:netrwmarkfilelist_{curbufnr} | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7479 " call Decho("fname<".fname.">",'~'.expand("<slnum>")) |
3153 | 7480 if a:islocal |
7481 1split | |
6476 | 7482 exe "sil! NetrwKeepj keepalt e ".fnameescape(fname) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7483 " call Decho("local<".fname.">: exe ".cmd,'~'.expand("<slnum>")) |
3153 | 7484 exe cmd |
7485 exe "sil! keepalt wq!" | |
7486 else | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7487 " call Decho("remote<".fname.">: exe ".cmd." : NOT SUPPORTED YET",'~'.expand("<slnum>")) |
6476 | 7488 echo "sorry, \"mv\" not supported yet for remote files" |
3153 | 7489 endif |
7490 endfor | |
7491 | |
7492 " unmark marked file list | |
7493 call s:NetrwUnmarkList(curbufnr,curdir) | |
7494 | |
7495 " refresh the listing | |
6476 | 7496 NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7497 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7498 NetrwKeepj call winrestview(svpos) |
6476 | 7499 else |
7500 NetrwKeepj call netrw#ErrorMsg(s:ERROR,"no files marked!",59) | |
3153 | 7501 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7502 |
3153 | 7503 " call Dret("s:NetrwMarkFileVimCmd") |
7504 endfun | |
7505 | |
7506 " --------------------------------------------------------------------- | |
7507 " s:NetrwMarkHideSfx: (invoked by mh) (un)hide files having same suffix | |
7508 " as the marked file(s) (toggles suffix presence) | |
7509 " Uses the local marked file list. | |
7510 fun! s:NetrwMarkHideSfx(islocal) | |
7511 " call Dfunc("s:NetrwMarkHideSfx(islocal=".a:islocal.")") | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7512 let svpos = winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7513 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
3153 | 7514 let curbufnr = bufnr("%") |
7515 | |
7516 " s:netrwmarkfilelist_{curbufnr}: the List of marked files | |
7517 if exists("s:netrwmarkfilelist_{curbufnr}") | |
7518 | |
7519 for fname in s:netrwmarkfilelist_{curbufnr} | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7520 " call Decho("s:NetrwMarkFileCopy: fname<".fname.">",'~'.expand("<slnum>")) |
3153 | 7521 " construct suffix pattern |
7522 if fname =~ '\.' | |
7523 let sfxpat= "^.*".substitute(fname,'^.*\(\.[^. ]\+\)$','\1','') | |
7524 else | |
7525 let sfxpat= '^\%(\%(\.\)\@!.\)*$' | |
7526 endif | |
7527 " determine if its in the hiding list or not | |
7528 let inhidelist= 0 | |
7529 if g:netrw_list_hide != "" | |
7530 let itemnum = 0 | |
7531 let hidelist= split(g:netrw_list_hide,',') | |
7532 for hidepat in hidelist | |
7533 if sfxpat == hidepat | |
7534 let inhidelist= 1 | |
7535 break | |
7536 endif | |
7537 let itemnum= itemnum + 1 | |
7538 endfor | |
7539 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7540 " call Decho("fname<".fname."> inhidelist=".inhidelist." sfxpat<".sfxpat.">",'~'.expand("<slnum>")) |
3153 | 7541 if inhidelist |
7542 " remove sfxpat from list | |
7543 call remove(hidelist,itemnum) | |
7544 let g:netrw_list_hide= join(hidelist,",") | |
7545 elseif g:netrw_list_hide != "" | |
7546 " append sfxpat to non-empty list | |
7547 let g:netrw_list_hide= g:netrw_list_hide.",".sfxpat | |
7548 else | |
7549 " set hiding list to sfxpat | |
7550 let g:netrw_list_hide= sfxpat | |
7551 endif | |
7552 endfor | |
7553 | |
7554 " refresh the listing | |
6476 | 7555 NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7556 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7557 NetrwKeepj call winrestview(svpos) |
6476 | 7558 else |
7559 NetrwKeepj call netrw#ErrorMsg(s:ERROR,"no files marked!",59) | |
3153 | 7560 endif |
7561 | |
7562 " call Dret("s:NetrwMarkHideSfx") | |
7563 endfun | |
7564 | |
7565 " --------------------------------------------------------------------- | |
1621 | 7566 " s:NetrwMarkFileGrep: (invoked by mg) This function applies vimgrep to marked files {{{2 |
7567 " Uses the global markfilelist | |
7568 fun! s:NetrwMarkFileGrep(islocal) | |
7569 " call Dfunc("s:NetrwMarkFileGrep(islocal=".a:islocal.")") | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7570 let svpos = winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7571 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
1621 | 7572 let curbufnr = bufnr("%") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7573 let curdir = s:NetrwGetCurdir(a:islocal) |
1621 | 7574 |
7575 if exists("s:netrwmarkfilelist") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7576 " call Decho("s:netrwmarkfilelist".string(s:netrwmarkfilelist).">",'~'.expand("<slnum>")) |
1698 | 7577 let netrwmarkfilelist= join(map(deepcopy(s:netrwmarkfilelist), "fnameescape(v:val)")) |
1621 | 7578 call s:NetrwUnmarkAll() |
4339 | 7579 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7580 " call Decho('no marked files, using "*"','~'.expand("<slnum>")) |
4339 | 7581 let netrwmarkfilelist= "*" |
7582 endif | |
7583 | |
7584 " ask user for pattern | |
7585 call inputsave() | |
7586 let pat= input("Enter pattern: ","") | |
7587 call inputrestore() | |
7588 let patbang = "" | |
7589 if pat =~ '^!' | |
7590 let patbang = "!" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7591 let pat = strpart(pat,2) |
4339 | 7592 endif |
7593 if pat =~ '^\i' | |
7594 let pat = escape(pat,'/') | |
7595 let pat = '/'.pat.'/' | |
7596 else | |
7597 let nonisi = pat[0] | |
7598 endif | |
7599 | |
7600 " use vimgrep for both local and remote | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7601 " call Decho("exe vimgrep".patbang." ".pat." ".netrwmarkfilelist,'~'.expand("<slnum>")) |
4339 | 7602 try |
6476 | 7603 exe "NetrwKeepj noautocmd vimgrep".patbang." ".pat." ".netrwmarkfilelist |
4339 | 7604 catch /^Vim\%((\a\+)\)\=:E480/ |
6476 | 7605 NetrwKeepj call netrw#ErrorMsg(s:WARNING,"no match with pattern<".pat.">",76) |
4339 | 7606 " call Dret("s:NetrwMarkFileGrep : unable to find pattern<".pat.">") |
7607 return | |
7608 endtry | |
7609 echo "(use :cn, :cp to navigate, :Rex to return)" | |
7610 | |
7611 2match none | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7612 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7613 NetrwKeepj call winrestview(svpos) |
4339 | 7614 |
7615 if exists("nonisi") | |
7616 " original, user-supplied pattern did not begin with a character from isident | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7617 " call Decho("looking for trailing nonisi<".nonisi."> followed by a j, gj, or jg",'~'.expand("<slnum>")) |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
7618 if pat =~# nonisi.'j$\|'.nonisi.'gj$\|'.nonisi.'jg$' |
4339 | 7619 call s:NetrwMarkFileQFEL(a:islocal,getqflist()) |
7620 endif | |
1621 | 7621 endif |
7622 | |
7623 " call Dret("s:NetrwMarkFileGrep") | |
7624 endfun | |
7625 | |
7626 " --------------------------------------------------------------------- | |
7627 " s:NetrwMarkFileMove: (invoked by mm) execute arbitrary command on marked files, one at a time {{{2 | |
7628 " uses the global marked file list | |
7629 " s:netrwmfloc= 0: target directory is remote | |
7630 " = 1: target directory is local | |
7631 fun! s:NetrwMarkFileMove(islocal) | |
7632 " call Dfunc("s:NetrwMarkFileMove(islocal=".a:islocal.")") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7633 let curdir = s:NetrwGetCurdir(a:islocal) |
1621 | 7634 let curbufnr = bufnr("%") |
7635 | |
7636 " sanity check | |
4339 | 7637 if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr}) |
6476 | 7638 NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) |
1621 | 7639 " call Dret("s:NetrwMarkFileMove") |
7640 return | |
7641 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7642 " call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr}),'~'.expand("<slnum>")) |
4339 | 7643 |
1621 | 7644 if !exists("s:netrwmftgt") |
6476 | 7645 NetrwKeepj call netrw#ErrorMsg(2,"your marked file target is empty! (:help netrw-mt)",67) |
1621 | 7646 " call Dret("s:NetrwMarkFileCopy 0") |
7647 return 0 | |
7648 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7649 " call Decho("sanity chk passed: s:netrwmftgt<".s:netrwmftgt.">",'~'.expand("<slnum>")) |
1621 | 7650 |
7651 if a:islocal && s:netrwmftgt_islocal | |
7652 " move: local -> local | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7653 " call Decho("move from local to local",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7654 " call Decho("local to local move",'~'.expand("<slnum>")) |
17433 | 7655 if !executable(g:netrw_localmovecmd) |
3920 | 7656 call netrw#ErrorMsg(s:ERROR,"g:netrw_localmovecmd<".g:netrw_localmovecmd."> not executable on your system, aborting",90) |
7657 " call Dfunc("s:NetrwMarkFileMove : g:netrw_localmovecmd<".g:netrw_localmovecmd."> n/a!") | |
7658 return | |
7659 endif | |
17433 | 7660 let tgt = s:ShellEscape(s:netrwmftgt) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7661 " call Decho("tgt<".tgt.">",'~'.expand("<slnum>")) |
4339 | 7662 if !g:netrw_cygwin && (has("win32") || has("win95") || has("win64") || has("win16")) |
17433 | 7663 let tgt= substitute(tgt, '/','\\','g') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7664 " call Decho("windows exception: tgt<".tgt.">",'~'.expand("<slnum>")) |
4339 | 7665 if g:netrw_localmovecmd =~ '\s' |
7666 let movecmd = substitute(g:netrw_localmovecmd,'\s.*$','','') | |
7667 let movecmdargs = substitute(g:netrw_localmovecmd,'^.\{-}\(\s.*\)$','\1','') | |
7668 let movecmd = netrw#WinPath(movecmd).movecmdargs | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7669 " call Decho("windows exception: movecmd<".movecmd."> (#1: had a space)",'~'.expand("<slnum>")) |
4339 | 7670 else |
7671 let movecmd = netrw#WinPath(movecmd) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7672 " call Decho("windows exception: movecmd<".movecmd."> (#2: no space)",'~'.expand("<slnum>")) |
4339 | 7673 endif |
7674 else | |
7675 let movecmd = netrw#WinPath(g:netrw_localmovecmd) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7676 " call Decho("movecmd<".movecmd."> (#3 linux or cygwin)",'~'.expand("<slnum>")) |
4339 | 7677 endif |
3920 | 7678 for fname in s:netrwmarkfilelist_{bufnr("%")} |
4339 | 7679 if !g:netrw_cygwin && (has("win32") || has("win95") || has("win64") || has("win16")) |
7680 let fname= substitute(fname,'/','\\','g') | |
7681 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7682 " call Decho("system(".movecmd." ".s:ShellEscape(fname)." ".tgt.")",'~'.expand("<slnum>")) |
17433 | 7683 let ret= system(movecmd.g:netrw_localmovecmdopt." ".s:ShellEscape(fname)." ".tgt) |
4339 | 7684 if v:shell_error != 0 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7685 if exists("b:netrw_curdir") && b:netrw_curdir != getcwd() && !g:netrw_keepdir |
17433 | 7686 call netrw#ErrorMsg(s:ERROR,"move failed; perhaps due to vim's current directory<".getcwd()."> not matching netrw's (".b:netrw_curdir.") (see :help netrw-cd)",100) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7687 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7688 call netrw#ErrorMsg(s:ERROR,"tried using g:netrw_localmovecmd<".g:netrw_localmovecmd.">; it doesn't work!",54) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7689 endif |
3920 | 7690 break |
7691 endif | |
7692 endfor | |
1621 | 7693 |
7694 elseif a:islocal && !s:netrwmftgt_islocal | |
7695 " move: local -> remote | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7696 " call Decho("move from local to remote",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7697 " call Decho("copy",'~'.expand("<slnum>")) |
1621 | 7698 let mflist= s:netrwmarkfilelist_{bufnr("%")} |
6476 | 7699 NetrwKeepj call s:NetrwMarkFileCopy(a:islocal) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7700 " call Decho("remove",'~'.expand("<slnum>")) |
1621 | 7701 for fname in mflist |
7702 let barefname = substitute(fname,'^\(.*/\)\(.\{-}\)$','\2','') | |
7703 let ok = s:NetrwLocalRmFile(b:netrw_curdir,barefname,1) | |
7704 endfor | |
7705 unlet mflist | |
7706 | |
7707 elseif !a:islocal && s:netrwmftgt_islocal | |
7708 " move: remote -> local | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7709 " call Decho("move from remote to local",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7710 " call Decho("copy",'~'.expand("<slnum>")) |
1621 | 7711 let mflist= s:netrwmarkfilelist_{bufnr("%")} |
6476 | 7712 NetrwKeepj call s:NetrwMarkFileCopy(a:islocal) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7713 " call Decho("remove",'~'.expand("<slnum>")) |
1621 | 7714 for fname in mflist |
7715 let barefname = substitute(fname,'^\(.*/\)\(.\{-}\)$','\2','') | |
7716 let ok = s:NetrwRemoteRmFile(b:netrw_curdir,barefname,1) | |
7717 endfor | |
7718 unlet mflist | |
7719 | |
7720 elseif !a:islocal && !s:netrwmftgt_islocal | |
7721 " move: remote -> remote | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7722 " call Decho("move from remote to remote",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7723 " call Decho("copy",'~'.expand("<slnum>")) |
1621 | 7724 let mflist= s:netrwmarkfilelist_{bufnr("%")} |
6476 | 7725 NetrwKeepj call s:NetrwMarkFileCopy(a:islocal) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7726 " call Decho("remove",'~'.expand("<slnum>")) |
1621 | 7727 for fname in mflist |
7728 let barefname = substitute(fname,'^\(.*/\)\(.\{-}\)$','\2','') | |
7729 let ok = s:NetrwRemoteRmFile(b:netrw_curdir,barefname,1) | |
7730 endfor | |
7731 unlet mflist | |
7732 endif | |
7733 | |
7734 " ------- | |
7735 " cleanup | |
7736 " ------- | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7737 " call Decho("cleanup",'~'.expand("<slnum>")) |
1621 | 7738 |
7739 " remove markings from local buffer | |
7740 call s:NetrwUnmarkList(curbufnr,curdir) " remove markings from local buffer | |
7741 | |
7742 " refresh buffers | |
7743 if !s:netrwmftgt_islocal | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7744 " call Decho("refresh netrwmftgt<".s:netrwmftgt.">",'~'.expand("<slnum>")) |
6476 | 7745 NetrwKeepj call s:NetrwRefreshDir(s:netrwmftgt_islocal,s:netrwmftgt) |
1621 | 7746 endif |
7747 if a:islocal | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7748 " call Decho("refresh b:netrw_curdir<".b:netrw_curdir.">",'~'.expand("<slnum>")) |
6476 | 7749 NetrwKeepj call s:NetrwRefreshDir(a:islocal,b:netrw_curdir) |
1621 | 7750 endif |
2034 | 7751 if g:netrw_fastbrowse <= 1 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7752 " call Decho("since g:netrw_fastbrowse=".g:netrw_fastbrowse.", perform shell cmd refresh",'~'.expand("<slnum>")) |
6476 | 7753 NetrwKeepj call s:LocalBrowseRefresh() |
2034 | 7754 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7755 |
1621 | 7756 " call Dret("s:NetrwMarkFileMove") |
7757 endfun | |
7758 | |
7759 " --------------------------------------------------------------------- | |
7760 " s:NetrwMarkFilePrint: (invoked by mp) This function prints marked files {{{2 | |
7761 " using the hardcopy command. Local marked-file list only. | |
7762 fun! s:NetrwMarkFilePrint(islocal) | |
7763 " call Dfunc("s:NetrwMarkFilePrint(islocal=".a:islocal.")") | |
7764 let curbufnr= bufnr("%") | |
4339 | 7765 |
7766 " sanity check | |
7767 if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr}) | |
6476 | 7768 NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) |
4339 | 7769 " call Dret("s:NetrwMarkFilePrint") |
7770 return | |
7771 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7772 " call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr}),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7773 let curdir= s:NetrwGetCurdir(a:islocal) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7774 |
1621 | 7775 if exists("s:netrwmarkfilelist_{curbufnr}") |
7776 let netrwmarkfilelist = s:netrwmarkfilelist_{curbufnr} | |
7777 call s:NetrwUnmarkList(curbufnr,curdir) | |
7778 for fname in netrwmarkfilelist | |
7779 if a:islocal | |
7780 if g:netrw_keepdir | |
7781 let fname= s:ComposePath(curdir,fname) | |
7782 endif | |
7783 else | |
7784 let fname= curdir.fname | |
7785 endif | |
7786 1split | |
7787 " the autocmds will handle both local and remote files | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7788 " call Decho("exe sil e ".escape(fname,' '),'~'.expand("<slnum>")) |
6476 | 7789 exe "sil NetrwKeepj e ".fnameescape(fname) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7790 " call Decho("hardcopy",'~'.expand("<slnum>")) |
1621 | 7791 hardcopy |
7792 q | |
7793 endfor | |
7794 2match none | |
7795 endif | |
7796 " call Dret("s:NetrwMarkFilePrint") | |
7797 endfun | |
7798 | |
7799 " --------------------------------------------------------------------- | |
7800 " s:NetrwMarkFileRegexp: (invoked by mr) This function is used to mark {{{2 | |
7801 " files when given a regexp (for which a prompt is | |
4339 | 7802 " issued) (matches to name of files). |
1621 | 7803 fun! s:NetrwMarkFileRegexp(islocal) |
7804 " call Dfunc("s:NetrwMarkFileRegexp(islocal=".a:islocal.")") | |
7805 | |
7806 " get the regular expression | |
7807 call inputsave() | |
7808 let regexp= input("Enter regexp: ","","file") | |
7809 call inputrestore() | |
7810 | |
7811 if a:islocal | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7812 let curdir= s:NetrwGetCurdir(a:islocal) |
17433 | 7813 " call Decho("curdir<".fnameescape(curdir).">") |
1621 | 7814 " get the matching list of files using local glob() |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7815 " call Decho("handle local regexp",'~'.expand("<slnum>")) |
4339 | 7816 let dirname = escape(b:netrw_curdir,g:netrw_glob_escape) |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
7817 if v:version > 704 || (v:version == 704 && has("patch656")) |
17433 | 7818 let filelist= glob(s:ComposePath(dirname,regexp),0,1,1) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7819 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7820 let files = glob(s:ComposePath(dirname,regexp),0,0) |
17433 | 7821 let filelist= split(files,"\n") |
7822 endif | |
7823 " call Decho("files<".string(filelist).">",'~'.expand("<slnum>")) | |
1621 | 7824 |
7825 " mark the list of files | |
2034 | 7826 for fname in filelist |
17433 | 7827 if fname =~ '^'.fnameescape(curdir) |
7828 " call Decho("fname<".substitute(fname,'^'.fnameescape(curdir).'/','','').">",'~'.expand("<slnum>")) | |
7829 NetrwKeepj call s:NetrwMarkFile(a:islocal,substitute(fname,'^'.fnameescape(curdir).'/','','')) | |
7830 else | |
7831 " call Decho("fname<".fname.">",'~'.expand("<slnum>")) | |
7832 NetrwKeepj call s:NetrwMarkFile(a:islocal,substitute(fname,'^.*/','','')) | |
7833 endif | |
2034 | 7834 endfor |
1621 | 7835 |
7836 else | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7837 " call Decho("handle remote regexp",'~'.expand("<slnum>")) |
1621 | 7838 |
7839 " convert displayed listing into a filelist | |
7840 let eikeep = &ei | |
7841 let areg = @a | |
6476 | 7842 sil NetrwKeepj %y a |
5734 | 7843 setl ei=all ma |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7844 " call Decho("setl ei=all ma",'~'.expand("<slnum>")) |
1621 | 7845 1split |
6476 | 7846 NetrwKeepj call s:NetrwEnew() |
17433 | 7847 NetrwKeepj call s:NetrwOptionsSafe(a:islocal) |
6476 | 7848 sil NetrwKeepj norm! "ap |
7849 NetrwKeepj 2 | |
1621 | 7850 let bannercnt= search('^" =====','W') |
6476 | 7851 exe "sil NetrwKeepj 1,".bannercnt."d" |
5734 | 7852 setl bt=nofile |
1621 | 7853 if g:netrw_liststyle == s:LONGLIST |
6476 | 7854 sil NetrwKeepj %s/\s\{2,}\S.*$//e |
2034 | 7855 call histdel("/",-1) |
1621 | 7856 elseif g:netrw_liststyle == s:WIDELIST |
6476 | 7857 sil NetrwKeepj %s/\s\{2,}/\r/ge |
2034 | 7858 call histdel("/",-1) |
1621 | 7859 elseif g:netrw_liststyle == s:TREELIST |
6476 | 7860 exe 'sil NetrwKeepj %s/^'.s:treedepthstring.' //e' |
7861 sil! NetrwKeepj g/^ .*$/d | |
2034 | 7862 call histdel("/",-1) |
7863 call histdel("/",-1) | |
1621 | 7864 endif |
7865 " convert regexp into the more usual glob-style format | |
7866 let regexp= substitute(regexp,'\*','.*','g') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7867 " call Decho("regexp<".regexp.">",'~'.expand("<slnum>")) |
6476 | 7868 exe "sil! NetrwKeepj v/".escape(regexp,'/')."/d" |
2034 | 7869 call histdel("/",-1) |
1621 | 7870 let filelist= getline(1,line("$")) |
7871 q! | |
7872 for filename in filelist | |
6476 | 7873 NetrwKeepj call s:NetrwMarkFile(a:islocal,substitute(filename,'^.*/','','')) |
1621 | 7874 endfor |
7875 unlet filelist | |
7876 let @a = areg | |
7877 let &ei = eikeep | |
7878 endif | |
4339 | 7879 echo " (use me to edit marked files)" |
1621 | 7880 |
7881 " call Dret("s:NetrwMarkFileRegexp") | |
7882 endfun | |
7883 | |
7884 " --------------------------------------------------------------------- | |
7885 " s:NetrwMarkFileSource: (invoked by ms) This function sources marked files {{{2 | |
7886 " Uses the local marked file list. | |
7887 fun! s:NetrwMarkFileSource(islocal) | |
7888 " call Dfunc("s:NetrwMarkFileSource(islocal=".a:islocal.")") | |
7889 let curbufnr= bufnr("%") | |
4339 | 7890 |
7891 " sanity check | |
7892 if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr}) | |
6476 | 7893 NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) |
4339 | 7894 " call Dret("s:NetrwMarkFileSource") |
7895 return | |
7896 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7897 " call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr}),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7898 let curdir= s:NetrwGetCurdir(a:islocal) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7899 |
1621 | 7900 if exists("s:netrwmarkfilelist_{curbufnr}") |
7901 let netrwmarkfilelist = s:netrwmarkfilelist_{bufnr("%")} | |
7902 call s:NetrwUnmarkList(curbufnr,curdir) | |
7903 for fname in netrwmarkfilelist | |
7904 if a:islocal | |
7905 if g:netrw_keepdir | |
7906 let fname= s:ComposePath(curdir,fname) | |
7907 endif | |
7908 else | |
7909 let fname= curdir.fname | |
7910 endif | |
7911 " the autocmds will handle sourcing both local and remote files | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7912 " call Decho("exe so ".fnameescape(fname),'~'.expand("<slnum>")) |
1668 | 7913 exe "so ".fnameescape(fname) |
1621 | 7914 endfor |
7915 2match none | |
7916 endif | |
7917 " call Dret("s:NetrwMarkFileSource") | |
7918 endfun | |
7919 | |
7920 " --------------------------------------------------------------------- | |
7921 " s:NetrwMarkFileTag: (invoked by mT) This function applies g:netrw_ctags to marked files {{{2 | |
7922 " Uses the global markfilelist | |
7923 fun! s:NetrwMarkFileTag(islocal) | |
7924 " call Dfunc("s:NetrwMarkFileTag(islocal=".a:islocal.")") | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7925 let svpos = winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7926 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7927 let curdir = s:NetrwGetCurdir(a:islocal) |
1621 | 7928 let curbufnr = bufnr("%") |
7929 | |
4339 | 7930 " sanity check |
7931 if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr}) | |
6476 | 7932 NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66) |
4339 | 7933 " call Dret("s:NetrwMarkFileTag") |
7934 return | |
7935 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7936 " call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr}),'~'.expand("<slnum>")) |
4339 | 7937 |
1621 | 7938 if exists("s:netrwmarkfilelist") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7939 " call Decho("s:netrwmarkfilelist".string(s:netrwmarkfilelist).">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7940 let netrwmarkfilelist= join(map(deepcopy(s:netrwmarkfilelist), "s:ShellEscape(v:val,".!a:islocal.")")) |
1621 | 7941 call s:NetrwUnmarkAll() |
7942 | |
7943 if a:islocal | |
17433 | 7944 |
7945 " call Decho("call system(".g:netrw_ctags." ".netrwmarkfilelist.")",'~'.expand("<slnum>")) | |
7946 call system(g:netrw_ctags." ".netrwmarkfilelist) | |
7947 if v:shell_error | |
1621 | 7948 call netrw#ErrorMsg(s:ERROR,"g:netrw_ctags<".g:netrw_ctags."> is not executable!",51) |
7949 endif | |
17433 | 7950 |
1621 | 7951 else |
1668 | 7952 let cmd = s:RemoteSystem(g:netrw_ctags." ".netrwmarkfilelist) |
5734 | 7953 call netrw#Obtain(a:islocal,"tags") |
1621 | 7954 let curdir= b:netrw_curdir |
7955 1split | |
6476 | 7956 NetrwKeepj e tags |
1621 | 7957 let path= substitute(curdir,'^\(.*\)/[^/]*$','\1/','') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7958 " call Decho("curdir<".curdir."> path<".path.">",'~'.expand("<slnum>")) |
6476 | 7959 exe 'NetrwKeepj %s/\t\(\S\+\)\t/\t'.escape(path,"/\n\r\\").'\1\t/e' |
2034 | 7960 call histdel("/",-1) |
1621 | 7961 wq! |
7962 endif | |
7963 2match none | |
7964 call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7965 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7966 call winrestview(svpos) |
1621 | 7967 endif |
7968 | |
7969 " call Dret("s:NetrwMarkFileTag") | |
7970 endfun | |
7971 | |
7972 " --------------------------------------------------------------------- | |
7973 " s:NetrwMarkFileTgt: (invoked by mt) This function sets up a marked file target {{{2 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7974 " Sets up two variables, |
4339 | 7975 " s:netrwmftgt : holds the target directory |
1621 | 7976 " s:netrwmftgt_islocal : 0=target directory is remote |
4339 | 7977 " 1=target directory is local |
1621 | 7978 fun! s:NetrwMarkFileTgt(islocal) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7979 " call Dfunc("s:NetrwMarkFileTgt(islocal=".a:islocal.")") |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7980 let svpos = winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7981 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7982 let curdir = s:NetrwGetCurdir(a:islocal) |
1621 | 7983 let hadtgt = exists("s:netrwmftgt") |
7984 if !exists("w:netrw_bannercnt") | |
7985 let w:netrw_bannercnt= b:netrw_bannercnt | |
7986 endif | |
7987 | |
7988 " set up target | |
7989 if line(".") < w:netrw_bannercnt | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7990 " call Decho("set up target: line(.) < w:netrw_bannercnt=".w:netrw_bannercnt,'~'.expand("<slnum>")) |
4339 | 7991 " if cursor in banner region, use b:netrw_curdir for the target unless its already the target |
7992 if exists("s:netrwmftgt") && exists("s:netrwmftgt_islocal") && s:netrwmftgt == b:netrw_curdir | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
7993 " call Decho("cursor in banner region, and target already is <".b:netrw_curdir.">: removing target",'~'.expand("<slnum>")) |
4339 | 7994 unlet s:netrwmftgt s:netrwmftgt_islocal |
7995 if g:netrw_fastbrowse <= 1 | |
5734 | 7996 call s:LocalBrowseRefresh() |
4339 | 7997 endif |
7998 call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
7999 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8000 call winrestview(svpos) |
4339 | 8001 " call Dret("s:NetrwMarkFileTgt : removed target") |
8002 return | |
8003 else | |
8004 let s:netrwmftgt= b:netrw_curdir | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8005 " call Decho("inbanner: s:netrwmftgt<".s:netrwmftgt.">",'~'.expand("<slnum>")) |
4339 | 8006 endif |
1621 | 8007 |
8008 else | |
8009 " get word under cursor. | |
8010 " * If directory, use it for the target. | |
8011 " * If file, use b:netrw_curdir for the target | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8012 " call Decho("get word under cursor",'~'.expand("<slnum>")) |
1621 | 8013 let curword= s:NetrwGetWord() |
8014 let tgtdir = s:ComposePath(curdir,curword) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8015 if a:islocal && isdirectory(s:NetrwFile(tgtdir)) |
1621 | 8016 let s:netrwmftgt = tgtdir |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8017 " call Decho("local isdir: s:netrwmftgt<".s:netrwmftgt.">",'~'.expand("<slnum>")) |
1621 | 8018 elseif !a:islocal && tgtdir =~ '/$' |
8019 let s:netrwmftgt = tgtdir | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8020 " call Decho("remote isdir: s:netrwmftgt<".s:netrwmftgt.">",'~'.expand("<slnum>")) |
1621 | 8021 else |
8022 let s:netrwmftgt = curdir | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8023 " call Decho("isfile: s:netrwmftgt<".s:netrwmftgt.">",'~'.expand("<slnum>")) |
1621 | 8024 endif |
8025 endif | |
8026 if a:islocal | |
8027 " simplify the target (eg. /abc/def/../ghi -> /abc/ghi) | |
8028 let s:netrwmftgt= simplify(s:netrwmftgt) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8029 " call Decho("simplify: s:netrwmftgt<".s:netrwmftgt.">",'~'.expand("<slnum>")) |
1621 | 8030 endif |
8031 if g:netrw_cygwin | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8032 let s:netrwmftgt= substitute(system("cygpath ".s:ShellEscape(s:netrwmftgt)),'\n$','','') |
1621 | 8033 let s:netrwmftgt= substitute(s:netrwmftgt,'\n$','','') |
8034 endif | |
8035 let s:netrwmftgt_islocal= a:islocal | |
8036 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8037 " need to do refresh so that the banner will be updated |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8038 " s:LocalBrowseRefresh handles all local-browsing buffers when not fast browsing |
2034 | 8039 if g:netrw_fastbrowse <= 1 |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
8040 " call Decho("g:netrw_fastbrowse=".g:netrw_fastbrowse.", so refreshing all local netrw buffers",'~'.expand("<slnum>")) |
5734 | 8041 call s:LocalBrowseRefresh() |
1621 | 8042 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8043 " call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8044 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8045 call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,w:netrw_treetop)) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8046 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8047 call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8048 endif |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8049 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8050 call winrestview(svpos) |
1621 | 8051 if !hadtgt |
6476 | 8052 sil! NetrwKeepj norm! j |
1621 | 8053 endif |
8054 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8055 " call Decho("getmatches=".string(getmatches()),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8056 " call Decho("s:netrwmarkfilelist=".(exists("s:netrwmarkfilelist")? string(s:netrwmarkfilelist) : 'n/a'),'~'.expand("<slnum>")) |
1621 | 8057 " call Dret("s:NetrwMarkFileTgt : netrwmftgt<".(exists("s:netrwmftgt")? s:netrwmftgt : "").">") |
8058 endfun | |
8059 | |
8060 " --------------------------------------------------------------------- | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8061 " s:NetrwGetCurdir: gets current directory and sets up b:netrw_curdir if necessary {{{2 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8062 fun! s:NetrwGetCurdir(islocal) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8063 " call Dfunc("s:NetrwGetCurdir(islocal=".a:islocal.")") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8064 |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8065 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8066 let b:netrw_curdir = s:NetrwTreePath(w:netrw_treetop) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8067 " call Decho("set b:netrw_curdir<".b:netrw_curdir."> (used s:NetrwTreeDir)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8068 elseif !exists("b:netrw_curdir") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8069 let b:netrw_curdir= getcwd() |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8070 " call Decho("set b:netrw_curdir<".b:netrw_curdir."> (used getcwd)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8071 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8072 |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
8073 " call Decho("b:netrw_curdir<".b:netrw_curdir."> ".((b:netrw_curdir !~ '\<\a\{3,}://')? "does not match" : "matches")." url pattern",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8074 if b:netrw_curdir !~ '\<\a\{3,}://' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8075 let curdir= b:netrw_curdir |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
8076 " call Decho("g:netrw_keepdir=".g:netrw_keepdir,'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8077 if g:netrw_keepdir == 0 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8078 call s:NetrwLcd(curdir) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8079 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8080 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8081 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8082 " call Dret("s:NetrwGetCurdir <".curdir.">") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8083 return b:netrw_curdir |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8084 endfun |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8085 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8086 " --------------------------------------------------------------------- |
1668 | 8087 " s:NetrwOpenFile: query user for a filename and open it {{{2 |
8088 fun! s:NetrwOpenFile(islocal) | |
8089 " call Dfunc("s:NetrwOpenFile(islocal=".a:islocal.")") | |
3920 | 8090 let ykeep= @@ |
1668 | 8091 call inputsave() |
8092 let fname= input("Enter filename: ") | |
8093 call inputrestore() | |
8094 if fname !~ '[/\\]' | |
8095 if exists("b:netrw_curdir") | |
8096 if exists("g:netrw_quiet") | |
8097 let netrw_quiet_keep = g:netrw_quiet | |
8098 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8099 let g:netrw_quiet = 1 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8100 " save position for benefit of Rexplore |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8101 let s:rexposn_{bufnr("%")}= winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8102 " call Decho("saving posn to s:rexposn_".bufnr("%")."<".string(s:rexposn_{bufnr("%")}).">",'~'.expand("<slnum>")) |
1668 | 8103 if b:netrw_curdir =~ '/$' |
6476 | 8104 exe "NetrwKeepj e ".fnameescape(b:netrw_curdir.fname) |
1668 | 8105 else |
8106 exe "e ".fnameescape(b:netrw_curdir."/".fname) | |
8107 endif | |
8108 if exists("netrw_quiet_keep") | |
8109 let g:netrw_quiet= netrw_quiet_keep | |
8110 else | |
8111 unlet g:netrw_quiet | |
8112 endif | |
8113 endif | |
8114 else | |
6476 | 8115 exe "NetrwKeepj e ".fnameescape(fname) |
1668 | 8116 endif |
3920 | 8117 let @@= ykeep |
1668 | 8118 " call Dret("s:NetrwOpenFile") |
8119 endfun | |
8120 | |
8121 " --------------------------------------------------------------------- | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8122 " netrw#Shrink: shrinks/expands a netrw or Lexplorer window {{{2 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8123 " For the mapping to this function be made via |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8124 " netrwPlugin, you'll need to have had |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8125 " g:netrw_usetab set to non-zero. |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8126 fun! netrw#Shrink() |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8127 " call Dfunc("netrw#Shrink() ft<".&ft."> winwidth=".winwidth(0)." lexbuf#".((exists("t:netrw_lexbufnr"))? t:netrw_lexbufnr : 'n/a')) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8128 let curwin = winnr() |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8129 let wiwkeep = &wiw |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8130 set wiw=1 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8131 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8132 if &ft == "netrw" |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8133 if winwidth(0) > g:netrw_wiw |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8134 let t:netrw_winwidth= winwidth(0) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8135 exe "vert resize ".g:netrw_wiw |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8136 wincmd l |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8137 if winnr() == curwin |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8138 wincmd h |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8139 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8140 " call Decho("vert resize 0",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8141 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8142 exe "vert resize ".t:netrw_winwidth |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8143 " call Decho("vert resize ".t:netrw_winwidth,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8144 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8145 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8146 elseif exists("t:netrw_lexbufnr") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8147 exe bufwinnr(t:netrw_lexbufnr)."wincmd w" |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8148 if winwidth(bufwinnr(t:netrw_lexbufnr)) > g:netrw_wiw |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8149 let t:netrw_winwidth= winwidth(0) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8150 exe "vert resize ".g:netrw_wiw |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8151 wincmd l |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8152 if winnr() == curwin |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8153 wincmd h |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8154 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8155 " call Decho("vert resize 0",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8156 elseif winwidth(bufwinnr(t:netrw_lexbufnr)) >= 0 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8157 exe "vert resize ".t:netrw_winwidth |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8158 " call Decho("vert resize ".t:netrw_winwidth,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8159 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8160 call netrw#Lexplore(0,0) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8161 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8162 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8163 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8164 call netrw#Lexplore(0,0) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8165 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8166 let wiw= wiwkeep |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8167 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8168 " call Dret("netrw#Shrink") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8169 endfun |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8170 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8171 " --------------------------------------------------------------------- |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8172 " s:NetSortSequence: allows user to edit the sorting sequence {{{2 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8173 fun! s:NetSortSequence(islocal) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8174 " call Dfunc("NetSortSequence(islocal=".a:islocal.")") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8175 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8176 let ykeep= @@ |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8177 let svpos= winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8178 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8179 call inputsave() |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8180 let newsortseq= input("Edit Sorting Sequence: ",g:netrw_sort_sequence) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8181 call inputrestore() |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8182 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8183 " refresh the listing |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8184 let g:netrw_sort_sequence= newsortseq |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8185 NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8186 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8187 NetrwKeepj call winrestview(svpos) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8188 let @@= ykeep |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8189 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8190 " call Dret("NetSortSequence") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8191 endfun |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8192 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8193 " --------------------------------------------------------------------- |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8194 " s:NetrwUnmarkList: delete local marked file list and remove their contents from the global marked-file list {{{2 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8195 " User access provided by the <mF> mapping. (see :help netrw-mF) |
4339 | 8196 " Used by many MarkFile functions. |
1621 | 8197 fun! s:NetrwUnmarkList(curbufnr,curdir) |
8198 " call Dfunc("s:NetrwUnmarkList(curbufnr=".a:curbufnr." curdir<".a:curdir.">)") | |
8199 | |
8200 " remove all files in local marked-file list from global list | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8201 if exists("s:netrwmarkfilelist") |
1621 | 8202 for mfile in s:netrwmarkfilelist_{a:curbufnr} |
8203 let dfile = s:ComposePath(a:curdir,mfile) " prepend directory to mfile | |
8204 let idx = index(s:netrwmarkfilelist,dfile) " get index in list of dfile | |
8205 call remove(s:netrwmarkfilelist,idx) " remove from global list | |
8206 endfor | |
8207 if s:netrwmarkfilelist == [] | |
8208 unlet s:netrwmarkfilelist | |
8209 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8210 |
1621 | 8211 " getting rid of the local marked-file lists is easy |
8212 unlet s:netrwmarkfilelist_{a:curbufnr} | |
8213 endif | |
8214 if exists("s:netrwmarkfilemtch_{a:curbufnr}") | |
8215 unlet s:netrwmarkfilemtch_{a:curbufnr} | |
8216 endif | |
8217 2match none | |
8218 " call Dret("s:NetrwUnmarkList") | |
8219 endfun | |
8220 | |
8221 " --------------------------------------------------------------------- | |
8222 " s:NetrwUnmarkAll: remove the global marked file list and all local ones {{{2 | |
8223 fun! s:NetrwUnmarkAll() | |
8224 " call Dfunc("s:NetrwUnmarkAll()") | |
8225 if exists("s:netrwmarkfilelist") | |
8226 unlet s:netrwmarkfilelist | |
8227 endif | |
2751 | 8228 sil call s:NetrwUnmarkAll2() |
1621 | 8229 2match none |
8230 " call Dret("s:NetrwUnmarkAll") | |
8231 endfun | |
8232 | |
8233 " --------------------------------------------------------------------- | |
4339 | 8234 " s:NetrwUnmarkAll2: unmark all files from all buffers {{{2 |
1621 | 8235 fun! s:NetrwUnmarkAll2() |
8236 " call Dfunc("s:NetrwUnmarkAll2()") | |
8237 redir => netrwmarkfilelist_let | |
8238 let | |
8239 redir END | |
8240 let netrwmarkfilelist_list= split(netrwmarkfilelist_let,'\n') " convert let string into a let list | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8241 call filter(netrwmarkfilelist_list,"v:val =~ '^s:netrwmarkfilelist_'") " retain only those vars that start as s:netrwmarkfilelist_ |
1621 | 8242 call map(netrwmarkfilelist_list,"substitute(v:val,'\\s.*$','','')") " remove what the entries are equal to |
8243 for flist in netrwmarkfilelist_list | |
8244 let curbufnr= substitute(flist,'s:netrwmarkfilelist_','','') | |
8245 unlet s:netrwmarkfilelist_{curbufnr} | |
8246 unlet s:netrwmarkfilemtch_{curbufnr} | |
8247 endfor | |
8248 " call Dret("s:NetrwUnmarkAll2") | |
8249 endfun | |
8250 | |
8251 " --------------------------------------------------------------------- | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8252 " s:NetrwUnMarkFile: called via mu map; unmarks *all* marked files, both global and buffer-local {{{2 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8253 " |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8254 " Marked files are in two types of lists: |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8255 " s:netrwmarkfilelist -- holds complete paths to all marked files |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8256 " s:netrwmarkfilelist_# -- holds list of marked files in current-buffer's directory (#==bufnr()) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8257 " |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8258 " Marked files suitable for use with 2match are in: |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8259 " s:netrwmarkfilemtch_# -- used with 2match to display marked files |
1621 | 8260 fun! s:NetrwUnMarkFile(islocal) |
8261 " call Dfunc("s:NetrwUnMarkFile(islocal=".a:islocal.")") | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8262 let svpos = winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8263 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
1621 | 8264 let curbufnr = bufnr("%") |
8265 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8266 " unmark marked file list |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8267 " (although I expect s:NetrwUpload() to do it, I'm just making sure) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8268 if exists("s:netrwmarkfilelist") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8269 " " call Decho("unlet'ing: s:netrwmarkfilelist",'~'.expand("<slnum>")) |
1621 | 8270 unlet s:netrwmarkfilelist |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8271 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8272 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8273 let ibuf= 1 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8274 while ibuf < bufnr("$") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8275 if exists("s:netrwmarkfilelist_".ibuf) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8276 unlet s:netrwmarkfilelist_{ibuf} |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8277 unlet s:netrwmarkfilemtch_{ibuf} |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8278 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8279 let ibuf = ibuf + 1 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8280 endwhile |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8281 2match none |
1621 | 8282 |
8283 " call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8284 "call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8285 call winrestview(svpos) |
1621 | 8286 " call Dret("s:NetrwUnMarkFile") |
1121 | 8287 endfun |
8288 | |
8289 " --------------------------------------------------------------------- | |
1621 | 8290 " s:NetrwMenu: generates the menu for gvim and netrw {{{2 |
8291 fun! s:NetrwMenu(domenu) | |
8292 | |
8293 if !exists("g:NetrwMenuPriority") | |
8294 let g:NetrwMenuPriority= 80 | |
8295 endif | |
8296 | |
2751 | 8297 if has("menu") && has("gui_running") && &go =~# 'm' && g:netrw_menu |
1621 | 8298 " call Dfunc("NetrwMenu(domenu=".a:domenu.")") |
8299 | |
8300 if !exists("s:netrw_menu_enabled") && a:domenu | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8301 " call Decho("initialize menu",'~'.expand("<slnum>")) |
1621 | 8302 let s:netrw_menu_enabled= 1 |
4339 | 8303 exe 'sil! menu '.g:NetrwMenuPriority.'.1 '.g:NetrwTopLvlMenu.'Help<tab><F1> <F1>' |
8304 exe 'sil! menu '.g:NetrwMenuPriority.'.5 '.g:NetrwTopLvlMenu.'-Sep1- :' | |
8305 exe 'sil! menu '.g:NetrwMenuPriority.'.6 '.g:NetrwTopLvlMenu.'Go\ Up\ Directory<tab>- -' | |
8306 exe 'sil! menu '.g:NetrwMenuPriority.'.7 '.g:NetrwTopLvlMenu.'Apply\ Special\ Viewer<tab>x x' | |
8307 if g:netrw_dirhistmax > 0 | |
8308 exe 'sil! menu '.g:NetrwMenuPriority.'.8.1 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Bookmark\ Current\ Directory<tab>mb mb' | |
8309 exe 'sil! menu '.g:NetrwMenuPriority.'.8.4 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Goto\ Prev\ Dir\ (History)<tab>u u' | |
8310 exe 'sil! menu '.g:NetrwMenuPriority.'.8.5 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.Goto\ Next\ Dir\ (History)<tab>U U' | |
8311 exe 'sil! menu '.g:NetrwMenuPriority.'.8.6 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History.List<tab>qb qb' | |
8312 else | |
8313 exe 'sil! menu '.g:NetrwMenuPriority.'.8 '.g:NetrwTopLvlMenu.'Bookmarks\ and\ History :echo "(disabled)"'."\<cr>" | |
8314 endif | |
8315 exe 'sil! menu '.g:NetrwMenuPriority.'.9.1 '.g:NetrwTopLvlMenu.'Browsing\ Control.Horizontal\ Split<tab>o o' | |
8316 exe 'sil! menu '.g:NetrwMenuPriority.'.9.2 '.g:NetrwTopLvlMenu.'Browsing\ Control.Vertical\ Split<tab>v v' | |
8317 exe 'sil! menu '.g:NetrwMenuPriority.'.9.3 '.g:NetrwTopLvlMenu.'Browsing\ Control.New\ Tab<tab>t t' | |
8318 exe 'sil! menu '.g:NetrwMenuPriority.'.9.4 '.g:NetrwTopLvlMenu.'Browsing\ Control.Preview<tab>p p' | |
8319 exe 'sil! menu '.g:NetrwMenuPriority.'.9.5 '.g:NetrwTopLvlMenu.'Browsing\ Control.Edit\ File\ Hiding\ List<tab><ctrl-h>'." \<c-h>'" | |
8320 exe 'sil! menu '.g:NetrwMenuPriority.'.9.6 '.g:NetrwTopLvlMenu.'Browsing\ Control.Edit\ Sorting\ Sequence<tab>S S' | |
8321 exe 'sil! menu '.g:NetrwMenuPriority.'.9.7 '.g:NetrwTopLvlMenu.'Browsing\ Control.Quick\ Hide/Unhide\ Dot\ Files<tab>'."gh gh" | |
8322 exe 'sil! menu '.g:NetrwMenuPriority.'.9.8 '.g:NetrwTopLvlMenu.'Browsing\ Control.Refresh\ Listing<tab>'."<ctrl-l> \<c-l>" | |
8323 exe 'sil! menu '.g:NetrwMenuPriority.'.9.9 '.g:NetrwTopLvlMenu.'Browsing\ Control.Settings/Options<tab>:NetrwSettings '.":NetrwSettings\<cr>" | |
8324 exe 'sil! menu '.g:NetrwMenuPriority.'.10 '.g:NetrwTopLvlMenu.'Delete\ File/Directory<tab>D D' | |
8325 exe 'sil! menu '.g:NetrwMenuPriority.'.11.1 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.Create\ New\ File<tab>% %' | |
8326 exe 'sil! menu '.g:NetrwMenuPriority.'.11.1 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ Current\ Window<tab><cr> '."\<cr>" | |
8327 exe 'sil! menu '.g:NetrwMenuPriority.'.11.2 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.Preview\ File/Directory<tab>p p' | |
8328 exe 'sil! menu '.g:NetrwMenuPriority.'.11.3 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ Previous\ Window<tab>P P' | |
8329 exe 'sil! menu '.g:NetrwMenuPriority.'.11.4 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ New\ Window<tab>o o' | |
6476 | 8330 exe 'sil! menu '.g:NetrwMenuPriority.'.11.5 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ New\ Tab<tab>t t' |
4339 | 8331 exe 'sil! menu '.g:NetrwMenuPriority.'.11.5 '.g:NetrwTopLvlMenu.'Edit\ File/Dir.In\ New\ Vertical\ Window<tab>v v' |
8332 exe 'sil! menu '.g:NetrwMenuPriority.'.12.1 '.g:NetrwTopLvlMenu.'Explore.Directory\ Name :Explore ' | |
8333 exe 'sil! menu '.g:NetrwMenuPriority.'.12.2 '.g:NetrwTopLvlMenu.'Explore.Filenames\ Matching\ Pattern\ (curdir\ only)<tab>:Explore\ */ :Explore */' | |
8334 exe 'sil! menu '.g:NetrwMenuPriority.'.12.2 '.g:NetrwTopLvlMenu.'Explore.Filenames\ Matching\ Pattern\ (+subdirs)<tab>:Explore\ **/ :Explore **/' | |
8335 exe 'sil! menu '.g:NetrwMenuPriority.'.12.3 '.g:NetrwTopLvlMenu.'Explore.Files\ Containing\ String\ Pattern\ (curdir\ only)<tab>:Explore\ *// :Explore *//' | |
8336 exe 'sil! menu '.g:NetrwMenuPriority.'.12.4 '.g:NetrwTopLvlMenu.'Explore.Files\ Containing\ String\ Pattern\ (+subdirs)<tab>:Explore\ **// :Explore **//' | |
8337 exe 'sil! menu '.g:NetrwMenuPriority.'.12.4 '.g:NetrwTopLvlMenu.'Explore.Next\ Match<tab>:Nexplore :Nexplore<cr>' | |
8338 exe 'sil! menu '.g:NetrwMenuPriority.'.12.4 '.g:NetrwTopLvlMenu.'Explore.Prev\ Match<tab>:Pexplore :Pexplore<cr>' | |
8339 exe 'sil! menu '.g:NetrwMenuPriority.'.13 '.g:NetrwTopLvlMenu.'Make\ Subdirectory<tab>d d' | |
8340 exe 'sil! menu '.g:NetrwMenuPriority.'.14.1 '.g:NetrwTopLvlMenu.'Marked\ Files.Mark\ File<tab>mf mf' | |
8341 exe 'sil! menu '.g:NetrwMenuPriority.'.14.2 '.g:NetrwTopLvlMenu.'Marked\ Files.Mark\ Files\ by\ Regexp<tab>mr mr' | |
8342 exe 'sil! menu '.g:NetrwMenuPriority.'.14.3 '.g:NetrwTopLvlMenu.'Marked\ Files.Hide-Show-List\ Control<tab>a a' | |
8343 exe 'sil! menu '.g:NetrwMenuPriority.'.14.4 '.g:NetrwTopLvlMenu.'Marked\ Files.Copy\ To\ Target<tab>mc mc' | |
8344 exe 'sil! menu '.g:NetrwMenuPriority.'.14.5 '.g:NetrwTopLvlMenu.'Marked\ Files.Delete<tab>D D' | |
8345 exe 'sil! menu '.g:NetrwMenuPriority.'.14.6 '.g:NetrwTopLvlMenu.'Marked\ Files.Diff<tab>md md' | |
8346 exe 'sil! menu '.g:NetrwMenuPriority.'.14.7 '.g:NetrwTopLvlMenu.'Marked\ Files.Edit<tab>me me' | |
8347 exe 'sil! menu '.g:NetrwMenuPriority.'.14.8 '.g:NetrwTopLvlMenu.'Marked\ Files.Exe\ Cmd<tab>mx mx' | |
8348 exe 'sil! menu '.g:NetrwMenuPriority.'.14.9 '.g:NetrwTopLvlMenu.'Marked\ Files.Move\ To\ Target<tab>mm mm' | |
8349 exe 'sil! menu '.g:NetrwMenuPriority.'.14.10 '.g:NetrwTopLvlMenu.'Marked\ Files.Obtain<tab>O O' | |
8350 exe 'sil! menu '.g:NetrwMenuPriority.'.14.11 '.g:NetrwTopLvlMenu.'Marked\ Files.Print<tab>mp mp' | |
8351 exe 'sil! menu '.g:NetrwMenuPriority.'.14.12 '.g:NetrwTopLvlMenu.'Marked\ Files.Replace<tab>R R' | |
8352 exe 'sil! menu '.g:NetrwMenuPriority.'.14.13 '.g:NetrwTopLvlMenu.'Marked\ Files.Set\ Target<tab>mt mt' | |
8353 exe 'sil! menu '.g:NetrwMenuPriority.'.14.14 '.g:NetrwTopLvlMenu.'Marked\ Files.Tag<tab>mT mT' | |
8354 exe 'sil! menu '.g:NetrwMenuPriority.'.14.15 '.g:NetrwTopLvlMenu.'Marked\ Files.Zip/Unzip/Compress/Uncompress<tab>mz mz' | |
8355 exe 'sil! menu '.g:NetrwMenuPriority.'.15 '.g:NetrwTopLvlMenu.'Obtain\ File<tab>O O' | |
8356 exe 'sil! menu '.g:NetrwMenuPriority.'.16.1.1 '.g:NetrwTopLvlMenu.'Style.Listing.thin<tab>i :let w:netrw_liststyle=0<cr><c-L>' | |
8357 exe 'sil! menu '.g:NetrwMenuPriority.'.16.1.1 '.g:NetrwTopLvlMenu.'Style.Listing.long<tab>i :let w:netrw_liststyle=1<cr><c-L>' | |
8358 exe 'sil! menu '.g:NetrwMenuPriority.'.16.1.1 '.g:NetrwTopLvlMenu.'Style.Listing.wide<tab>i :let w:netrw_liststyle=2<cr><c-L>' | |
8359 exe 'sil! menu '.g:NetrwMenuPriority.'.16.1.1 '.g:NetrwTopLvlMenu.'Style.Listing.tree<tab>i :let w:netrw_liststyle=3<cr><c-L>' | |
8360 exe 'sil! menu '.g:NetrwMenuPriority.'.16.2.1 '.g:NetrwTopLvlMenu.'Style.Normal-Hide-Show.Show\ All<tab>a :let g:netrw_hide=0<cr><c-L>' | |
8361 exe 'sil! menu '.g:NetrwMenuPriority.'.16.2.3 '.g:NetrwTopLvlMenu.'Style.Normal-Hide-Show.Normal<tab>a :let g:netrw_hide=1<cr><c-L>' | |
8362 exe 'sil! menu '.g:NetrwMenuPriority.'.16.2.2 '.g:NetrwTopLvlMenu.'Style.Normal-Hide-Show.Hidden\ Only<tab>a :let g:netrw_hide=2<cr><c-L>' | |
8363 exe 'sil! menu '.g:NetrwMenuPriority.'.16.3 '.g:NetrwTopLvlMenu.'Style.Reverse\ Sorting\ Order<tab>'."r r" | |
8364 exe 'sil! menu '.g:NetrwMenuPriority.'.16.4.1 '.g:NetrwTopLvlMenu.'Style.Sorting\ Method.Name<tab>s :let g:netrw_sort_by="name"<cr><c-L>' | |
8365 exe 'sil! menu '.g:NetrwMenuPriority.'.16.4.2 '.g:NetrwTopLvlMenu.'Style.Sorting\ Method.Time<tab>s :let g:netrw_sort_by="time"<cr><c-L>' | |
8366 exe 'sil! menu '.g:NetrwMenuPriority.'.16.4.3 '.g:NetrwTopLvlMenu.'Style.Sorting\ Method.Size<tab>s :let g:netrw_sort_by="size"<cr><c-L>' | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8367 exe 'sil! menu '.g:NetrwMenuPriority.'.16.4.3 '.g:NetrwTopLvlMenu.'Style.Sorting\ Method.Exten<tab>s :let g:netrw_sort_by="exten"<cr><c-L>' |
4339 | 8368 exe 'sil! menu '.g:NetrwMenuPriority.'.17 '.g:NetrwTopLvlMenu.'Rename\ File/Directory<tab>R R' |
8369 exe 'sil! menu '.g:NetrwMenuPriority.'.18 '.g:NetrwTopLvlMenu.'Set\ Current\ Directory<tab>c c' | |
8370 let s:netrw_menucnt= 28 | |
2034 | 8371 call s:NetrwBookmarkMenu() " provide some history! uses priorities 2,3, reserves 4, 8.2.x |
4339 | 8372 call s:NetrwTgtMenu() " let bookmarks and history be easy targets |
1621 | 8373 |
8374 elseif !a:domenu | |
8375 let s:netrwcnt = 0 | |
8376 let curwin = winnr() | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
8377 windo if getline(2) =~# "Netrw" | let s:netrwcnt= s:netrwcnt + 1 | endif |
1621 | 8378 exe curwin."wincmd w" |
8379 | |
8380 if s:netrwcnt <= 1 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8381 " call Decho("clear menus",'~'.expand("<slnum>")) |
2152 | 8382 exe 'sil! unmenu '.g:NetrwTopLvlMenu |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8383 " call Decho('exe sil! unmenu '.g:NetrwTopLvlMenu.'*','~'.expand("<slnum>")) |
2152 | 8384 sil! unlet s:netrw_menu_enabled |
1621 | 8385 endif |
8386 endif | |
8387 " call Dret("NetrwMenu") | |
3456 | 8388 return |
1621 | 8389 endif |
8390 | |
8391 endfun | |
8392 | |
8393 " --------------------------------------------------------------------- | |
8394 " s:NetrwObtain: obtain file under cursor or from markfile list {{{2 | |
8395 " Used by the O maps (as <SID>NetrwObtain()) | |
8396 fun! s:NetrwObtain(islocal) | |
8397 " call Dfunc("NetrwObtain(islocal=".a:islocal.")") | |
8398 | |
3920 | 8399 let ykeep= @@ |
1621 | 8400 if exists("s:netrwmarkfilelist_{bufnr('%')}") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8401 let islocal= s:netrwmarkfilelist_{bufnr('%')}[1] !~ '^\a\{3,}://' |
5734 | 8402 call netrw#Obtain(islocal,s:netrwmarkfilelist_{bufnr('%')}) |
1621 | 8403 call s:NetrwUnmarkList(bufnr('%'),b:netrw_curdir) |
8404 else | |
17433 | 8405 call netrw#Obtain(a:islocal,s:NetrwGetWord()) |
1621 | 8406 endif |
3920 | 8407 let @@= ykeep |
1621 | 8408 |
8409 " call Dret("NetrwObtain") | |
8410 endfun | |
8411 | |
8412 " --------------------------------------------------------------------- | |
8413 " s:NetrwPrevWinOpen: open file/directory in previous window. {{{2 | |
8414 " If there's only one window, then the window will first be split. | |
8415 " Returns: | |
8416 " choice = 0 : didn't have to choose | |
8417 " choice = 1 : saved modified file in window first | |
8418 " choice = 2 : didn't save modified file, opened window | |
8419 " choice = 3 : cancel open | |
8420 fun! s:NetrwPrevWinOpen(islocal) | |
5618 | 8421 " call Dfunc("s:NetrwPrevWinOpen(islocal=".a:islocal.")") |
1621 | 8422 |
3920 | 8423 let ykeep= @@ |
1621 | 8424 " grab a copy of the b:netrw_curdir to pass it along to newly split windows |
5734 | 8425 let curdir = b:netrw_curdir |
1621 | 8426 |
8427 " get last window number and the word currently under the cursor | |
5618 | 8428 let origwin = winnr() |
1621 | 8429 let lastwinnr = winnr("$") |
8430 let curword = s:NetrwGetWord() | |
8431 let choice = 0 | |
6476 | 8432 let s:treedir = s:NetrwTreeDir(a:islocal) |
5734 | 8433 let curdir = s:treedir |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8434 " call Decho("winnr($)#".lastwinnr." curword<".curword.">",'~'.expand("<slnum>")) |
5618 | 8435 |
8436 let didsplit = 0 | |
1621 | 8437 if lastwinnr == 1 |
8438 " if only one window, open a new one first | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8439 " call Decho("only one window, so open a new one (g:netrw_alto=".g:netrw_alto.")",'~'.expand("<slnum>")) |
17433 | 8440 " g:netrw_preview=0: preview window shown in a horizontally split window |
8441 " g:netrw_preview=1: preview window shown in a vertically split window | |
1621 | 8442 if g:netrw_preview |
6476 | 8443 " vertically split preview window |
17433 | 8444 let winsz= (g:netrw_winsize > 0)? (g:netrw_winsize*winwidth(0))/100 : -g:netrw_winsize |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8445 " call Decho("exe ".(g:netrw_alto? "top " : "bot ")."vert ".winsz."wincmd s",'~'.expand("<slnum>")) |
3153 | 8446 exe (g:netrw_alto? "top " : "bot ")."vert ".winsz."wincmd s" |
1621 | 8447 else |
6476 | 8448 " horizontally split preview window |
17433 | 8449 let winsz= (g:netrw_winsize > 0)? (g:netrw_winsize*winheight(0))/100 : -g:netrw_winsize |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8450 " call Decho("exe ".(g:netrw_alto? "bel " : "abo ").winsz."wincmd s",'~'.expand("<slnum>")) |
3153 | 8451 exe (g:netrw_alto? "bel " : "abo ").winsz."wincmd s" |
1621 | 8452 endif |
5618 | 8453 let didsplit = 1 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8454 " call Decho("did split",'~'.expand("<slnum>")) |
1621 | 8455 |
8456 else | |
6476 | 8457 NetrwKeepj call s:SaveBufVars() |
5618 | 8458 let eikeep= &ei |
5734 | 8459 setl ei=all |
1621 | 8460 wincmd p |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8461 " call Decho("wincmd p (now in win#".winnr().") curdir<".curdir.">",'~'.expand("<slnum>")) |
5618 | 8462 |
8463 " prevwinnr: the window number of the "prev" window | |
8464 " prevbufnr: the buffer number of the buffer in the "prev" window | |
8465 " bnrcnt : the qty of windows open on the "prev" buffer | |
8466 let prevwinnr = winnr() | |
8467 let prevbufnr = bufnr("%") | |
8468 let prevbufname = bufname("%") | |
8469 let prevmod = &mod | |
8470 let bnrcnt = 0 | |
6476 | 8471 NetrwKeepj call s:RestoreBufVars() |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8472 " call Decho("after wincmd p: win#".winnr()." win($)#".winnr("$")." origwin#".origwin." &mod=".&mod." bufname(%)<".bufname("%")."> prevbufnr=".prevbufnr,'~'.expand("<slnum>")) |
5618 | 8473 |
8474 " if the previous window's buffer has been changed (ie. its modified flag is set), | |
1621 | 8475 " and it doesn't appear in any other extant window, then ask the |
8476 " user if s/he wants to abandon modifications therein. | |
5618 | 8477 if prevmod |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8478 " call Decho("detected that prev window's buffer has been modified: prevbufnr=".prevbufnr." winnr()#".winnr(),'~'.expand("<slnum>")) |
5618 | 8479 windo if winbufnr(0) == prevbufnr | let bnrcnt=bnrcnt+1 | endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8480 " call Decho("prevbufnr=".prevbufnr." bnrcnt=".bnrcnt." buftype=".&bt." winnr()=".winnr()." prevwinnr#".prevwinnr,'~'.expand("<slnum>")) |
5618 | 8481 exe prevwinnr."wincmd w" |
8482 | |
8483 if bnrcnt == 1 && &hidden == 0 | |
8484 " only one copy of the modified buffer in a window, and | |
8485 " hidden not set, so overwriting will lose the modified file. Ask first... | |
8486 let choice = confirm("Save modified buffer<".prevbufname."> first?","&Yes\n&No\n&Cancel") | |
17433 | 8487 " call Decho("prevbufname<".prevbufname."> choice=".choice." current-winnr#".winnr(),'~'.expand("<slnum>")) |
5618 | 8488 let &ei= eikeep |
1621 | 8489 |
8490 if choice == 1 | |
8491 " Yes -- write file & then browse | |
8492 let v:errmsg= "" | |
2751 | 8493 sil w |
1621 | 8494 if v:errmsg != "" |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8495 call netrw#ErrorMsg(s:ERROR,"unable to write <".(exists("prevbufname")? prevbufname : 'n/a').">!",30) |
5618 | 8496 exe origwin."wincmd w" |
8497 let &ei = eikeep | |
8498 let @@ = ykeep | |
8499 " call Dret("s:NetrwPrevWinOpen ".choice." : unable to write <".prevbufname.">") | |
1621 | 8500 return choice |
8501 endif | |
8502 | |
8503 elseif choice == 2 | |
8504 " No -- don't worry about changed file, just browse anyway | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8505 " call Decho("don't worry about chgd file, just browse anyway (winnr($)#".winnr("$").")",'~'.expand("<slnum>")) |
5618 | 8506 echomsg "**note** changes to ".prevbufname." abandoned" |
1621 | 8507 |
8508 else | |
8509 " Cancel -- don't do this | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8510 " call Decho("cancel, don't browse, switch to win#".origwin,'~'.expand("<slnum>")) |
5618 | 8511 exe origwin."wincmd w" |
8512 let &ei= eikeep | |
8513 let @@ = ykeep | |
8514 " call Dret("s:NetrwPrevWinOpen ".choice." : cancelled") | |
1621 | 8515 return choice |
8516 endif | |
8517 endif | |
8518 endif | |
5618 | 8519 let &ei= eikeep |
1621 | 8520 endif |
8521 | |
8522 " restore b:netrw_curdir (window split/enew may have lost it) | |
8523 let b:netrw_curdir= curdir | |
8524 if a:islocal < 2 | |
8525 if a:islocal | |
8526 call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(a:islocal,curword)) | |
8527 else | |
8528 call s:NetrwBrowse(a:islocal,s:NetrwBrowseChgDir(a:islocal,curword)) | |
8529 endif | |
8530 endif | |
3920 | 8531 let @@= ykeep |
5618 | 8532 " call Dret("s:NetrwPrevWinOpen ".choice) |
1621 | 8533 return choice |
8534 endfun | |
8535 | |
8536 " --------------------------------------------------------------------- | |
8537 " s:NetrwUpload: load fname to tgt (used by NetrwMarkFileCopy()) {{{2 | |
8538 " Always assumed to be local -> remote | |
8539 " call s:NetrwUpload(filename, target) | |
8540 " call s:NetrwUpload(filename, target, fromdirectory) | |
8541 fun! s:NetrwUpload(fname,tgt,...) | |
8542 " call Dfunc("s:NetrwUpload(fname<".((type(a:fname) == 1)? a:fname : string(a:fname))."> tgt<".a:tgt.">) a:0=".a:0) | |
8543 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8544 if a:tgt =~ '^\a\{3,}://' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8545 let tgtdir= substitute(a:tgt,'^\a\{3,}://[^/]\+/\(.\{-}\)$','\1','') |
1621 | 8546 else |
8547 let tgtdir= substitute(a:tgt,'^\(.*\)/[^/]*$','\1','') | |
8548 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8549 " call Decho("tgtdir<".tgtdir.">",'~'.expand("<slnum>")) |
1621 | 8550 |
8551 if a:0 > 0 | |
8552 let fromdir= a:1 | |
8553 else | |
8554 let fromdir= getcwd() | |
8555 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8556 " call Decho("fromdir<".fromdir.">",'~'.expand("<slnum>")) |
1621 | 8557 |
8558 if type(a:fname) == 1 | |
8559 " handle uploading a single file using NetWrite | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8560 " call Decho("handle uploading a single file via NetWrite",'~'.expand("<slnum>")) |
1621 | 8561 1split |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8562 " call Decho("exe e ".fnameescape(s:NetrwFile(a:fname)),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8563 exe "NetrwKeepj e ".fnameescape(s:NetrwFile(a:fname)) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8564 " call Decho("now locally editing<".expand("%").">, has ".line("$")." lines",'~'.expand("<slnum>")) |
1621 | 8565 if a:tgt =~ '/$' |
8566 let wfname= substitute(a:fname,'^.*/','','') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8567 " call Decho("exe w! ".fnameescape(wfname),'~'.expand("<slnum>")) |
1698 | 8568 exe "w! ".fnameescape(a:tgt.wfname) |
1621 | 8569 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8570 " call Decho("writing local->remote: exe w ".fnameescape(a:tgt),'~'.expand("<slnum>")) |
1668 | 8571 exe "w ".fnameescape(a:tgt) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8572 " call Decho("done writing local->remote",'~'.expand("<slnum>")) |
1621 | 8573 endif |
8574 q! | |
8575 | |
8576 elseif type(a:fname) == 3 | |
8577 " handle uploading a list of files via scp | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8578 " call Decho("handle uploading a list of files via scp",'~'.expand("<slnum>")) |
1621 | 8579 let curdir= getcwd() |
8580 if a:tgt =~ '^scp:' | |
17433 | 8581 if s:NetrwLcd(fromdir) |
8582 " call Dret("s:NetrwUpload : lcd failure") | |
8583 return | |
8584 endif | |
1698 | 8585 let filelist= deepcopy(s:netrwmarkfilelist_{bufnr('%')}) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8586 let args = join(map(filelist,"s:ShellEscape(v:val, 1)")) |
1621 | 8587 if exists("g:netrw_port") && g:netrw_port != "" |
8588 let useport= " ".g:netrw_scpport." ".g:netrw_port | |
8589 else | |
8590 let useport= "" | |
8591 endif | |
8592 let machine = substitute(a:tgt,'^scp://\([^/:]\+\).*$','\1','') | |
8593 let tgt = substitute(a:tgt,'^scp://[^/]\+/\(.*\)$','\1','') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8594 call s:NetrwExe(s:netrw_silentxfer."!".g:netrw_scp_cmd.s:ShellEscape(useport,1)." ".args." ".s:ShellEscape(machine.":".tgt,1)) |
17433 | 8595 if s:NetrwLcd(curdir) |
8596 " call Dret("s:NetrwUpload : lcd failure") | |
8597 return | |
8598 endif | |
1621 | 8599 |
8600 elseif a:tgt =~ '^ftp:' | |
8601 call s:NetrwMethod(a:tgt) | |
8602 | |
8603 if b:netrw_method == 2 | |
8604 " handle uploading a list of files via ftp+.netrc | |
8605 let netrw_fname = b:netrw_fname | |
6476 | 8606 sil NetrwKeepj new |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8607 " call Decho("filter input window#".winnr(),'~'.expand("<slnum>")) |
1621 | 8608 |
6476 | 8609 NetrwKeepj put =g:netrw_ftpmode |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8610 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
1621 | 8611 |
8612 if exists("g:netrw_ftpextracmd") | |
6476 | 8613 NetrwKeepj put =g:netrw_ftpextracmd |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8614 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
1621 | 8615 endif |
8616 | |
6476 | 8617 NetrwKeepj call setline(line("$")+1,'lcd "'.fromdir.'"') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8618 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
1621 | 8619 |
2751 | 8620 if tgtdir == "" |
8621 let tgtdir= '/' | |
8622 endif | |
6476 | 8623 NetrwKeepj call setline(line("$")+1,'cd "'.tgtdir.'"') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8624 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
1621 | 8625 |
8626 for fname in a:fname | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8627 NetrwKeepj call setline(line("$")+1,'put "'.s:NetrwFile(fname).'"') |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8628 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
1621 | 8629 endfor |
8630 | |
8631 if exists("g:netrw_port") && g:netrw_port != "" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8632 call s:NetrwExe(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".s:ShellEscape(g:netrw_machine,1)." ".s:ShellEscape(g:netrw_port,1)) |
1621 | 8633 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8634 " call Decho("filter input window#".winnr(),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8635 call s:NetrwExe(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." -i ".s:ShellEscape(g:netrw_machine,1)) |
1621 | 8636 endif |
8637 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) | |
6476 | 8638 sil NetrwKeepj g/Local directory now/d |
2034 | 8639 call histdel("/",-1) |
1621 | 8640 if getline(1) !~ "^$" && !exists("g:netrw_quiet") && getline(1) !~ '^Trying ' |
8641 call netrw#ErrorMsg(s:ERROR,getline(1),14) | |
8642 else | |
8643 bw!|q | |
8644 endif | |
8645 | |
8646 elseif b:netrw_method == 3 | |
8647 " upload with ftp + machine, id, passwd, and fname (ie. no .netrc) | |
8648 let netrw_fname= b:netrw_fname | |
6476 | 8649 NetrwKeepj call s:SaveBufVars()|sil NetrwKeepj new|NetrwKeepj call s:RestoreBufVars() |
1621 | 8650 let tmpbufnr= bufnr("%") |
4339 | 8651 setl ff=unix |
1621 | 8652 |
8653 if exists("g:netrw_port") && g:netrw_port != "" | |
6476 | 8654 NetrwKeepj put ='open '.g:netrw_machine.' '.g:netrw_port |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8655 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
1621 | 8656 else |
6476 | 8657 NetrwKeepj put ='open '.g:netrw_machine |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8658 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
1621 | 8659 endif |
8660 | |
3456 | 8661 if exists("g:netrw_uid") && g:netrw_uid != "" |
8662 if exists("g:netrw_ftp") && g:netrw_ftp == 1 | |
6476 | 8663 NetrwKeepj put =g:netrw_uid |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8664 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
3456 | 8665 if exists("s:netrw_passwd") |
6476 | 8666 NetrwKeepj call setline(line("$")+1,'"'.s:netrw_passwd.'"') |
3456 | 8667 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8668 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
3456 | 8669 elseif exists("s:netrw_passwd") |
6476 | 8670 NetrwKeepj put ='user \"'.g:netrw_uid.'\" \"'.s:netrw_passwd.'\"' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8671 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
3456 | 8672 endif |
1621 | 8673 endif |
8674 | |
6476 | 8675 NetrwKeepj call setline(line("$")+1,'lcd "'.fromdir.'"') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8676 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
1621 | 8677 |
8678 if exists("b:netrw_fname") && b:netrw_fname != "" | |
6476 | 8679 NetrwKeepj call setline(line("$")+1,'cd "'.b:netrw_fname.'"') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8680 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
1621 | 8681 endif |
8682 | |
8683 if exists("g:netrw_ftpextracmd") | |
6476 | 8684 NetrwKeepj put =g:netrw_ftpextracmd |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8685 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
1621 | 8686 endif |
8687 | |
8688 for fname in a:fname | |
6476 | 8689 NetrwKeepj call setline(line("$")+1,'put "'.fname.'"') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8690 " call Decho("filter input: ".getline('$'),'~'.expand("<slnum>")) |
1621 | 8691 endfor |
8692 | |
8693 " perform ftp: | |
8694 " -i : turns off interactive prompting from ftp | |
8695 " -n unix : DON'T use <.netrc>, even though it exists | |
8696 " -n win32: quit being obnoxious about password | |
6476 | 8697 NetrwKeepj norm! 1Gdd |
8698 call s:NetrwExe(s:netrw_silentxfer."%!".s:netrw_ftp_cmd." ".g:netrw_ftp_options) | |
1621 | 8699 " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) |
6476 | 8700 sil NetrwKeepj g/Local directory now/d |
2034 | 8701 call histdel("/",-1) |
1621 | 8702 if getline(1) !~ "^$" && !exists("g:netrw_quiet") && getline(1) !~ '^Trying ' |
8703 let debugkeep= &debug | |
4339 | 8704 setl debug=msg |
1621 | 8705 call netrw#ErrorMsg(s:ERROR,getline(1),15) |
8706 let &debug = debugkeep | |
8707 let mod = 1 | |
8708 else | |
8709 bw!|q | |
8710 endif | |
2034 | 8711 elseif !exists("b:netrw_method") || b:netrw_method < 0 |
17433 | 8712 " call Dret("s:#NetrwUpload : unsupported method") |
2034 | 8713 return |
1621 | 8714 endif |
8715 else | |
8716 call netrw#ErrorMsg(s:ERROR,"can't obtain files with protocol from<".a:tgt.">",63) | |
8717 endif | |
8718 endif | |
8719 | |
8720 " call Dret("s:NetrwUpload") | |
8721 endfun | |
8722 | |
8723 " --------------------------------------------------------------------- | |
17433 | 8724 " s:NetrwPreview: supports netrw's "p" map {{{2 |
1621 | 8725 fun! s:NetrwPreview(path) range |
8726 " call Dfunc("NetrwPreview(path<".a:path.">)") | |
17433 | 8727 " call Decho("g:netrw_alto =".(exists("g:netrw_alto")? g:netrw_alto : 'n/a'),'~'.expand("<slnum>")) |
8728 " call Decho("g:netrw_preview=".(exists("g:netrw_preview")? g:netrw_preview : 'n/a'),'~'.expand("<slnum>")) | |
3920 | 8729 let ykeep= @@ |
17433 | 8730 NetrwKeepj call s:NetrwOptionsSave("s:") |
8731 if a:path !~ '^\*\{1,2}/' && a:path !~ '^\a\{3,}://' | |
8732 NetrwKeepj call s:NetrwOptionsSafe(1) | |
8733 else | |
8734 NetrwKeepj call s:NetrwOptionsSafe(0) | |
8735 endif | |
1621 | 8736 if has("quickfix") |
17433 | 8737 " call Decho("has quickfix",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8738 if !isdirectory(s:NetrwFile(a:path)) |
17433 | 8739 " call Decho("good; not previewing a directory",'~'.expand("<slnum>")) |
8740 if g:netrw_preview | |
8741 " vertical split | |
3153 | 8742 let pvhkeep = &pvh |
8743 let winsz = (g:netrw_winsize > 0)? (g:netrw_winsize*winwidth(0))/100 : -g:netrw_winsize | |
8744 let &pvh = winwidth(0) - winsz | |
17433 | 8745 " call Decho("g:netrw_preview: winsz=".winsz." &pvh=".&pvh." (temporarily) g:netrw_winsize=".g:netrw_winsize,'~'.expand("<slnum>")) |
8746 else | |
8747 " horizontal split | |
8748 let pvhkeep = &pvh | |
8749 let winsz = (g:netrw_winsize > 0)? (g:netrw_winsize*winheight(0))/100 : -g:netrw_winsize | |
8750 let &pvh = winheight(0) - winsz | |
8751 " call Decho("!g:netrw_preview: winsz=".winsz." &pvh=".&pvh." (temporarily) g:netrw_winsize=".g:netrw_winsize,'~'.expand("<slnum>")) | |
8752 endif | |
8753 " g:netrw_preview g:netrw_alto | |
8754 " 1 : vert 1: top -- preview window is vertically split off and on the left | |
8755 " 1 : vert 0: bot -- preview window is vertically split off and on the right | |
8756 " 0 : 1: top -- preview window is horizontally split off and on the top | |
8757 " 0 : 0: bot -- preview window is horizontally split off and on the bottom | |
8758 " | |
8759 " Note that the file being previewed is already known to not be a directory, hence we can avoid doing a LocalBrowse() check via | |
8760 " the BufEnter event set up in netrwPlugin.vim | |
8761 " call Decho("exe ".(g:netrw_alto? "top " : "bot ").(g:netrw_preview? "vert " : "")."pedit ".fnameescape(a:path),'~'.expand("<slnum>")) | |
8762 let eikeep = &ei | |
8763 set ei=BufEnter | |
2152 | 8764 exe (g:netrw_alto? "top " : "bot ").(g:netrw_preview? "vert " : "")."pedit ".fnameescape(a:path) |
17433 | 8765 let &ei= eikeep |
8766 " call Decho("winnr($)=".winnr("$"),'~'.expand("<slnum>")) | |
2152 | 8767 if exists("pvhkeep") |
8768 let &pvh= pvhkeep | |
8769 endif | |
1621 | 8770 elseif !exists("g:netrw_quiet") |
6476 | 8771 NetrwKeepj call netrw#ErrorMsg(s:WARNING,"sorry, cannot preview a directory such as <".a:path.">",38) |
1621 | 8772 endif |
8773 elseif !exists("g:netrw_quiet") | |
6476 | 8774 NetrwKeepj call netrw#ErrorMsg(s:WARNING,"sorry, to preview your vim needs the quickfix feature compiled in",39) |
8775 endif | |
17433 | 8776 NetrwKeepj call s:NetrwOptionsRestore("s:") |
3920 | 8777 let @@= ykeep |
1621 | 8778 " call Dret("NetrwPreview") |
8779 endfun | |
8780 | |
8781 " --------------------------------------------------------------------- | |
8782 " s:NetrwRefresh: {{{2 | |
8783 fun! s:NetrwRefresh(islocal,dirname) | |
17433 | 8784 " call Dfunc("s:NetrwRefresh(islocal<".a:islocal.">,dirname=".a:dirname.") g:netrw_hide=".g:netrw_hide." g:netrw_sort_direction=".g:netrw_sort_direction) |
1621 | 8785 " at the current time (Mar 19, 2007) all calls to NetrwRefresh() call NetrwBrowseChgDir() first. |
4339 | 8786 setl ma noro |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8787 " call Decho("setl ma noro",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8788 " call Decho("clear buffer<".expand("%")."> with :%d",'~'.expand("<slnum>")) |
3920 | 8789 let ykeep = @@ |
17433 | 8790 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST |
8791 if !exists("w:netrw_treetop") | |
8792 if exists("b:netrw_curdir") | |
8793 let w:netrw_treetop= b:netrw_curdir | |
8794 else | |
8795 let w:netrw_treetop= getcwd() | |
8796 endif | |
8797 endif | |
8798 NetrwKeepj call s:NetrwRefreshTreeDict(w:netrw_treetop) | |
8799 endif | |
5929 | 8800 |
8801 " save the cursor position before refresh. | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8802 let screenposn = winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8803 " call Decho("saving posn to screenposn<".string(screenposn).">",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8804 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8805 " call Decho("win#".winnr().": ".winheight(0)."x".winwidth(0)." curfile<".expand("%").">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8806 " call Decho("clearing buffer prior to refresh",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8807 sil! NetrwKeepj %d _ |
1621 | 8808 if a:islocal |
6476 | 8809 NetrwKeepj call netrw#LocalBrowseCheck(a:dirname) |
8810 else | |
8811 NetrwKeepj call s:NetrwBrowse(a:islocal,a:dirname) | |
2751 | 8812 endif |
5929 | 8813 |
8814 " restore position | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8815 " call Decho("restoring posn to screenposn<".string(screenposn).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8816 NetrwKeepj call winrestview(screenposn) |
1621 | 8817 |
8818 " restore file marks | |
17433 | 8819 if has("syntax") && exists("g:syntax_on") && g:syntax_on |
8820 if exists("s:netrwmarkfilemtch_{bufnr('%')}") && s:netrwmarkfilemtch_{bufnr("%")} != "" | |
8821 " " call Decho("exe 2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/",'~'.expand("<slnum>")) | |
8822 exe "2match netrwMarkFile /".s:netrwmarkfilemtch_{bufnr("%")}."/" | |
8823 else | |
8824 " " call Decho("2match none (bufnr(%)=".bufnr("%")."<".bufname("%").">)",'~'.expand("<slnum>")) | |
8825 2match none | |
8826 endif | |
8827 endif | |
1621 | 8828 |
3920 | 8829 " restore |
8830 let @@= ykeep | |
6476 | 8831 " call Dret("s:NetrwRefresh") |
1621 | 8832 endfun |
8833 | |
8834 " --------------------------------------------------------------------- | |
8835 " s:NetrwRefreshDir: refreshes a directory by name {{{2 | |
8836 " Called by NetrwMarkFileCopy() | |
5734 | 8837 " Interfaces to s:NetrwRefresh() and s:LocalBrowseRefresh() |
1621 | 8838 fun! s:NetrwRefreshDir(islocal,dirname) |
3920 | 8839 " call Dfunc("s:NetrwRefreshDir(islocal=".a:islocal." dirname<".a:dirname.">) g:netrw_fastbrowse=".g:netrw_fastbrowse) |
1621 | 8840 if g:netrw_fastbrowse == 0 |
8841 " slowest mode (keep buffers refreshed, local or remote) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8842 " call Decho("slowest mode: keep buffers refreshed, local or remote",'~'.expand("<slnum>")) |
1621 | 8843 let tgtwin= bufwinnr(a:dirname) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8844 " call Decho("tgtwin= bufwinnr(".a:dirname.")=".tgtwin,'~'.expand("<slnum>")) |
1621 | 8845 |
8846 if tgtwin > 0 | |
8847 " tgtwin is being displayed, so refresh it | |
8848 let curwin= winnr() | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8849 " call Decho("refresh tgtwin#".tgtwin." (curwin#".curwin.")",'~'.expand("<slnum>")) |
1621 | 8850 exe tgtwin."wincmd w" |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8851 NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) |
1621 | 8852 exe curwin."wincmd w" |
8853 | |
8854 elseif bufnr(a:dirname) > 0 | |
8855 let bn= bufnr(a:dirname) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8856 " call Decho("bd bufnr(".a:dirname.")=".bn,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8857 exe "sil keepj bd ".bn |
1621 | 8858 endif |
8859 | |
8860 elseif g:netrw_fastbrowse <= 1 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8861 " call Decho("medium-speed mode: refresh local buffers only",'~'.expand("<slnum>")) |
6476 | 8862 NetrwKeepj call s:LocalBrowseRefresh() |
1621 | 8863 endif |
8864 " call Dret("s:NetrwRefreshDir") | |
8865 endfun | |
8866 | |
8867 " --------------------------------------------------------------------- | |
5929 | 8868 " s:NetrwSetChgwin: set g:netrw_chgwin; a <cr> will use the specified |
8869 " window number to do its editing in. | |
8870 " Supports [count]C where the count, if present, is used to specify | |
8871 " a window to use for editing via the <cr> mapping. | |
6476 | 8872 fun! s:NetrwSetChgwin(...) |
5929 | 8873 " call Dfunc("s:NetrwSetChgwin() v:count=".v:count) |
6476 | 8874 if a:0 > 0 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8875 " call Decho("a:1<".a:1.">",'~'.expand("<slnum>")) |
6476 | 8876 if a:1 == "" " :NetrwC win# |
8877 let g:netrw_chgwin= winnr() | |
8878 else " :NetrwC | |
8879 let g:netrw_chgwin= a:1 | |
8880 endif | |
8881 elseif v:count > 0 " [count]C | |
5929 | 8882 let g:netrw_chgwin= v:count |
6476 | 8883 else " C |
5929 | 8884 let g:netrw_chgwin= winnr() |
8885 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8886 echo "editing window now set to window#".g:netrw_chgwin |
6476 | 8887 " call Dret("s:NetrwSetChgwin : g:netrw_chgwin=".g:netrw_chgwin) |
5929 | 8888 endfun |
8889 | |
8890 " --------------------------------------------------------------------- | |
1621 | 8891 " s:NetrwSetSort: sets up the sort based on the g:netrw_sort_sequence {{{2 |
8892 " What this function does is to compute a priority for the patterns | |
8893 " in the g:netrw_sort_sequence. It applies a substitute to any | |
8894 " "files" that satisfy each pattern, putting the priority / in | |
8895 " front. An "*" pattern handles the default priority. | |
8896 fun! s:NetrwSetSort() | |
8897 " call Dfunc("SetSort() bannercnt=".w:netrw_bannercnt) | |
3920 | 8898 let ykeep= @@ |
1621 | 8899 if w:netrw_liststyle == s:LONGLIST |
8900 let seqlist = substitute(g:netrw_sort_sequence,'\$','\\%(\t\\|\$\\)','ge') | |
8901 else | |
8902 let seqlist = g:netrw_sort_sequence | |
8903 endif | |
8904 " sanity check -- insure that * appears somewhere | |
8905 if seqlist == "" | |
8906 let seqlist= '*' | |
8907 elseif seqlist !~ '\*' | |
8908 let seqlist= seqlist.',*' | |
8909 endif | |
8910 let priority = 1 | |
8911 while seqlist != "" | |
8912 if seqlist =~ ',' | |
8913 let seq = substitute(seqlist,',.*$','','e') | |
8914 let seqlist = substitute(seqlist,'^.\{-},\(.*\)$','\1','e') | |
8915 else | |
8916 let seq = seqlist | |
8917 let seqlist = "" | |
8918 endif | |
8919 if priority < 10 | |
2034 | 8920 let spriority= "00".priority.g:netrw_sepchr |
1621 | 8921 elseif priority < 100 |
2034 | 8922 let spriority= "0".priority.g:netrw_sepchr |
1621 | 8923 else |
2034 | 8924 let spriority= priority.g:netrw_sepchr |
1621 | 8925 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
8926 " call Decho("priority=".priority." spriority<".spriority."> seq<".seq."> seqlist<".seqlist.">",'~'.expand("<slnum>")) |
1621 | 8927 |
8928 " sanity check | |
8929 if w:netrw_bannercnt > line("$") | |
8930 " apparently no files were left after a Hiding pattern was used | |
8931 " call Dret("SetSort : no files left after hiding") | |
8932 return | |
8933 endif | |
8934 if seq == '*' | |
8935 let starpriority= spriority | |
8936 else | |
6476 | 8937 exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$g/'.seq.'/s/^/'.spriority.'/' |
2034 | 8938 call histdel("/",-1) |
1621 | 8939 " sometimes multiple sorting patterns will match the same file or directory. |
8940 " The following substitute is intended to remove the excess matches. | |
6476 | 8941 exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$g/^\d\{3}'.g:netrw_sepchr.'\d\{3}\//s/^\d\{3}'.g:netrw_sepchr.'\(\d\{3}\/\).\@=/\1/e' |
8942 NetrwKeepj call histdel("/",-1) | |
1621 | 8943 endif |
8944 let priority = priority + 1 | |
8945 endwhile | |
8946 if exists("starpriority") | |
6476 | 8947 exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$v/^\d\{3}'.g:netrw_sepchr.'/s/^/'.starpriority.'/e' |
8948 NetrwKeepj call histdel("/",-1) | |
1621 | 8949 endif |
8950 | |
8951 " Following line associated with priority -- items that satisfy a priority | |
8952 " pattern get prefixed by ###/ which permits easy sorting by priority. | |
8953 " Sometimes files can satisfy multiple priority patterns -- only the latest | |
8954 " priority pattern needs to be retained. So, at this point, these excess | |
8955 " priority prefixes need to be removed, but not directories that happen to | |
8956 " be just digits themselves. | |
6476 | 8957 exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$s/^\(\d\{3}'.g:netrw_sepchr.'\)\%(\d\{3}'.g:netrw_sepchr.'\)\+\ze./\1/e' |
8958 NetrwKeepj call histdel("/",-1) | |
3920 | 8959 let @@= ykeep |
1621 | 8960 |
8961 " call Dret("SetSort") | |
8962 endfun | |
8963 | |
4339 | 8964 " --------------------------------------------------------------------- |
8965 " s:NetrwSetTgt: sets the target to the specified choice index {{{2 | |
8966 " Implements [count]Tb (bookhist<b>) | |
8967 " [count]Th (bookhist<h>) | |
8968 " See :help netrw-qb for how to make the choice. | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8969 fun! s:NetrwSetTgt(islocal,bookhist,choice) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8970 " call Dfunc("s:NetrwSetTgt(islocal=".a:islocal." bookhist<".a:bookhist."> choice#".a:choice.")") |
4339 | 8971 |
8972 if a:bookhist == 'b' | |
8973 " supports choosing a bookmark as a target using a qb-generated list | |
8974 let choice= a:choice - 1 | |
8975 if exists("g:netrw_bookmarklist[".choice."]") | |
5734 | 8976 call netrw#MakeTgt(g:netrw_bookmarklist[choice]) |
4339 | 8977 else |
8978 echomsg "Sorry, bookmark#".a:choice." doesn't exist!" | |
8979 endif | |
8980 | |
8981 elseif a:bookhist == 'h' | |
8982 " supports choosing a history stack entry as a target using a qb-generated list | |
8983 let choice= (a:choice % g:netrw_dirhistmax) + 1 | |
8984 if exists("g:netrw_dirhist_".choice) | |
8985 let histentry = g:netrw_dirhist_{choice} | |
5734 | 8986 call netrw#MakeTgt(histentry) |
4339 | 8987 else |
8988 echomsg "Sorry, history#".a:choice." not available!" | |
8989 endif | |
8990 endif | |
8991 | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8992 " refresh the display |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8993 if !exists("b:netrw_curdir") |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8994 let b:netrw_curdir= getcwd() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8995 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8996 call s:NetrwRefresh(a:islocal,b:netrw_curdir) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
8997 |
4339 | 8998 " call Dret("s:NetrwSetTgt") |
8999 endfun | |
9000 | |
1621 | 9001 " ===================================================================== |
17433 | 9002 " s:NetrwSortStyle: change sorting style (name - time - size - exten) and refresh display {{{2 |
1621 | 9003 fun! s:NetrwSortStyle(islocal) |
9004 " call Dfunc("s:NetrwSortStyle(islocal=".a:islocal.") netrw_sort_by<".g:netrw_sort_by.">") | |
6476 | 9005 NetrwKeepj call s:NetrwSaveWordPosn() |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9006 let svpos= winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9007 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
1621 | 9008 |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
9009 let g:netrw_sort_by= (g:netrw_sort_by =~# '^n')? 'time' : (g:netrw_sort_by =~# '^t')? 'size' : (g:netrw_sort_by =~# '^siz')? 'exten' : 'name' |
6476 | 9010 NetrwKeepj norm! 0 |
9011 NetrwKeepj call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9012 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9013 NetrwKeepj call winrestview(svpos) |
1621 | 9014 |
9015 " call Dret("s:NetrwSortStyle : netrw_sort_by<".g:netrw_sort_by.">") | |
9016 endfun | |
9017 | |
9018 " --------------------------------------------------------------------- | |
9019 " s:NetrwSplit: mode {{{2 | |
9020 " =0 : net and o | |
9021 " =1 : net and t | |
9022 " =2 : net and v | |
9023 " =3 : local and o | |
9024 " =4 : local and t | |
9025 " =5 : local and v | |
9026 fun! s:NetrwSplit(mode) | |
9027 " call Dfunc("s:NetrwSplit(mode=".a:mode.") alto=".g:netrw_alto." altv=".g:netrw_altv) | |
9028 | |
3920 | 9029 let ykeep= @@ |
1621 | 9030 call s:SaveWinVars() |
9031 | |
9032 if a:mode == 0 | |
9033 " remote and o | |
3153 | 9034 let winsz= (g:netrw_winsize > 0)? (g:netrw_winsize*winheight(0))/100 : -g:netrw_winsize |
5929 | 9035 if winsz == 0|let winsz= ""|endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9036 " call Decho("exe ".(g:netrw_alto? "bel " : "abo ").winsz."wincmd s",'~'.expand("<slnum>")) |
2908 | 9037 exe (g:netrw_alto? "bel " : "abo ").winsz."wincmd s" |
1621 | 9038 let s:didsplit= 1 |
6476 | 9039 NetrwKeepj call s:RestoreWinVars() |
9040 NetrwKeepj call s:NetrwBrowse(0,s:NetrwBrowseChgDir(0,s:NetrwGetWord())) | |
1621 | 9041 unlet s:didsplit |
9042 | |
9043 elseif a:mode == 1 | |
9044 " remote and t | |
2034 | 9045 let newdir = s:NetrwBrowseChgDir(0,s:NetrwGetWord()) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9046 " call Decho("tabnew",'~'.expand("<slnum>")) |
1621 | 9047 tabnew |
9048 let s:didsplit= 1 | |
6476 | 9049 NetrwKeepj call s:RestoreWinVars() |
9050 NetrwKeepj call s:NetrwBrowse(0,newdir) | |
1621 | 9051 unlet s:didsplit |
9052 | |
9053 elseif a:mode == 2 | |
9054 " remote and v | |
3153 | 9055 let winsz= (g:netrw_winsize > 0)? (g:netrw_winsize*winwidth(0))/100 : -g:netrw_winsize |
5929 | 9056 if winsz == 0|let winsz= ""|endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9057 " call Decho("exe ".(g:netrw_altv? "rightb " : "lefta ").winsz."wincmd v",'~'.expand("<slnum>")) |
2908 | 9058 exe (g:netrw_altv? "rightb " : "lefta ").winsz."wincmd v" |
1621 | 9059 let s:didsplit= 1 |
6476 | 9060 NetrwKeepj call s:RestoreWinVars() |
9061 NetrwKeepj call s:NetrwBrowse(0,s:NetrwBrowseChgDir(0,s:NetrwGetWord())) | |
1621 | 9062 unlet s:didsplit |
9063 | |
9064 elseif a:mode == 3 | |
9065 " local and o | |
3153 | 9066 let winsz= (g:netrw_winsize > 0)? (g:netrw_winsize*winheight(0))/100 : -g:netrw_winsize |
5929 | 9067 if winsz == 0|let winsz= ""|endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9068 " call Decho("exe ".(g:netrw_alto? "bel " : "abo ").winsz."wincmd s",'~'.expand("<slnum>")) |
2908 | 9069 exe (g:netrw_alto? "bel " : "abo ").winsz."wincmd s" |
1621 | 9070 let s:didsplit= 1 |
6476 | 9071 NetrwKeepj call s:RestoreWinVars() |
9072 NetrwKeepj call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,s:NetrwGetWord())) | |
1621 | 9073 unlet s:didsplit |
9074 | |
9075 elseif a:mode == 4 | |
9076 " local and t | |
9077 let cursorword = s:NetrwGetWord() | |
5618 | 9078 let eikeep = &ei |
9079 let netrw_winnr = winnr() | |
9080 let netrw_line = line(".") | |
9081 let netrw_col = virtcol(".") | |
6476 | 9082 NetrwKeepj norm! H0 |
5618 | 9083 let netrw_hline = line(".") |
5734 | 9084 setl ei=all |
6476 | 9085 exe "NetrwKeepj norm! ".netrw_hline."G0z\<CR>" |
9086 exe "NetrwKeepj norm! ".netrw_line."G0".netrw_col."\<bar>" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9087 let &ei = eikeep |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9088 let netrw_curdir = s:NetrwTreeDir(0) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9089 " call Decho("tabnew",'~'.expand("<slnum>")) |
1621 | 9090 tabnew |
5618 | 9091 let b:netrw_curdir = netrw_curdir |
9092 let s:didsplit = 1 | |
6476 | 9093 NetrwKeepj call s:RestoreWinVars() |
9094 NetrwKeepj call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,cursorword)) | |
5618 | 9095 if &ft == "netrw" |
5734 | 9096 setl ei=all |
6476 | 9097 exe "NetrwKeepj norm! ".netrw_hline."G0z\<CR>" |
9098 exe "NetrwKeepj norm! ".netrw_line."G0".netrw_col."\<bar>" | |
5618 | 9099 let &ei= eikeep |
9100 endif | |
1621 | 9101 unlet s:didsplit |
9102 | |
9103 elseif a:mode == 5 | |
9104 " local and v | |
3153 | 9105 let winsz= (g:netrw_winsize > 0)? (g:netrw_winsize*winwidth(0))/100 : -g:netrw_winsize |
5929 | 9106 if winsz == 0|let winsz= ""|endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9107 " call Decho("exe ".(g:netrw_altv? "rightb " : "lefta ").winsz."wincmd v",'~'.expand("<slnum>")) |
2908 | 9108 exe (g:netrw_altv? "rightb " : "lefta ").winsz."wincmd v" |
1621 | 9109 let s:didsplit= 1 |
6476 | 9110 NetrwKeepj call s:RestoreWinVars() |
9111 NetrwKeepj call netrw#LocalBrowseCheck(s:NetrwBrowseChgDir(1,s:NetrwGetWord())) | |
1621 | 9112 unlet s:didsplit |
9113 | |
9114 else | |
6476 | 9115 NetrwKeepj call netrw#ErrorMsg(s:ERROR,"(NetrwSplit) unsupported mode=".a:mode,45) |
1621 | 9116 endif |
9117 | |
3920 | 9118 let @@= ykeep |
1621 | 9119 " call Dret("s:NetrwSplit") |
9120 endfun | |
9121 | |
9122 " --------------------------------------------------------------------- | |
4339 | 9123 " s:NetrwTgtMenu: {{{2 |
9124 fun! s:NetrwTgtMenu() | |
9125 if !exists("s:netrw_menucnt") | |
9126 return | |
9127 endif | |
9128 " call Dfunc("s:NetrwTgtMenu()") | |
9129 | |
9130 " the following test assures that gvim is running, has menus available, and has menus enabled. | |
9131 if has("gui") && has("menu") && has("gui_running") && &go =~# 'm' && g:netrw_menu | |
9132 if exists("g:NetrwTopLvlMenu") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9133 " call Decho("removing ".g:NetrwTopLvlMenu."Bookmarks menu item(s)",'~'.expand("<slnum>")) |
4339 | 9134 exe 'sil! unmenu '.g:NetrwTopLvlMenu.'Targets' |
9135 endif | |
9136 if !exists("s:netrw_initbookhist") | |
9137 call s:NetrwBookHistRead() | |
9138 endif | |
9139 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9140 " try to cull duplicate entries |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9141 let tgtdict={} |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9142 |
4339 | 9143 " target bookmarked places |
9144 if exists("g:netrw_bookmarklist") && g:netrw_bookmarklist != [] && g:netrw_dirhistmax > 0 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9145 " call Decho("installing bookmarks as easy targets",'~'.expand("<slnum>")) |
4339 | 9146 let cnt= 1 |
9147 for bmd in g:netrw_bookmarklist | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9148 if has_key(tgtdict,bmd) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9149 let cnt= cnt + 1 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9150 continue |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9151 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9152 let tgtdict[bmd]= cnt |
4339 | 9153 let ebmd= escape(bmd,g:netrw_menu_escape) |
9154 " show bookmarks for goto menu | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9155 " call Decho("menu: Targets: ".bmd,'~'.expand("<slnum>")) |
5734 | 9156 exe 'sil! menu <silent> '.g:NetrwMenuPriority.".19.1.".cnt." ".g:NetrwTopLvlMenu.'Targets.'.ebmd." :call netrw#MakeTgt('".bmd."')\<cr>" |
4339 | 9157 let cnt= cnt + 1 |
9158 endfor | |
9159 endif | |
9160 | |
9161 " target directory browsing history | |
9162 if exists("g:netrw_dirhistmax") && g:netrw_dirhistmax > 0 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9163 " call Decho("installing history as easy targets (histmax=".g:netrw_dirhistmax.")",'~'.expand("<slnum>")) |
4339 | 9164 let histcnt = 1 |
9165 while histcnt <= g:netrw_dirhistmax | |
17433 | 9166 let priority = g:netrw_dirhistcnt + histcnt |
4339 | 9167 if exists("g:netrw_dirhist_{histcnt}") |
9168 let histentry = g:netrw_dirhist_{histcnt} | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9169 if has_key(tgtdict,histentry) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9170 let histcnt = histcnt + 1 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9171 continue |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9172 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9173 let tgtdict[histentry] = histcnt |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9174 let ehistentry = escape(histentry,g:netrw_menu_escape) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9175 " call Decho("menu: Targets: ".histentry,'~'.expand("<slnum>")) |
5734 | 9176 exe 'sil! menu <silent> '.g:NetrwMenuPriority.".19.2.".priority." ".g:NetrwTopLvlMenu.'Targets.'.ehistentry." :call netrw#MakeTgt('".histentry."')\<cr>" |
4339 | 9177 endif |
9178 let histcnt = histcnt + 1 | |
9179 endwhile | |
9180 endif | |
9181 endif | |
9182 " call Dret("s:NetrwTgtMenu") | |
1621 | 9183 endfun |
9184 | |
9185 " --------------------------------------------------------------------- | |
9186 " s:NetrwTreeDir: determine tree directory given current cursor position {{{2 | |
9187 " (full path directory with trailing slash returned) | |
6476 | 9188 fun! s:NetrwTreeDir(islocal) |
9189 " call Dfunc("s:NetrwTreeDir(islocal=".a:islocal.") getline(".line(".").")"."<".getline('.')."> b:netrw_curdir<".b:netrw_curdir."> tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> ft=".&ft) | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
9190 " call Decho("g:netrw_keepdir =".(exists("g:netrw_keepdir")? g:netrw_keepdir : 'n/a'),'~'.expand("<slnum>")) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
9191 " call Decho("w:netrw_liststyle=".(exists("w:netrw_liststyle")? w:netrw_liststyle : 'n/a'),'~'.expand("<slnum>")) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
9192 " call Decho("w:netrw_treetop =".(exists("w:netrw_treetop")? w:netrw_treetop : 'n/a'),'~'.expand("<slnum>")) |
5618 | 9193 |
9194 if exists("s:treedir") | |
9195 " s:NetrwPrevWinOpen opens a "previous" window -- and thus needs to and does call s:NetrwTreeDir early | |
9196 let treedir= s:treedir | |
9197 unlet s:treedir | |
9198 " call Dret("s:NetrwTreeDir ".treedir) | |
9199 return treedir | |
9200 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9201 |
5618 | 9202 if !exists("b:netrw_curdir") || b:netrw_curdir == "" |
9203 let b:netrw_curdir= getcwd() | |
9204 endif | |
9205 let treedir = b:netrw_curdir | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9206 " call Decho("set initial treedir<".treedir.">",'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9207 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9208 let s:treecurpos= winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9209 " call Decho("saving posn to s:treecurpos<".string(s:treecurpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9210 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9211 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9212 " call Decho("w:netrw_liststyle is TREELIST:",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9213 " call Decho("line#".line(".")." getline(.)<".getline('.')."> treecurpos<".string(s:treecurpos).">",'~'.expand("<slnum>")) |
2034 | 9214 |
9215 " extract tree directory if on a line specifying a subdirectory (ie. ends with "/") | |
6476 | 9216 let curline= substitute(getline('.'),"\t -->.*$",'','') |
9217 if curline =~ '/$' | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9218 " call Decho("extract tree subdirectory from current line",'~'.expand("<slnum>")) |
5618 | 9219 let treedir= substitute(getline('.'),'^\%('.s:treedepthstring.'\)*\([^'.s:treedepthstring.'].\{-}\)$','\1','e') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9220 " call Decho("treedir<".treedir.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9221 elseif curline =~ '@$' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9222 " call Decho("handle symbolic link from current line",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9223 let treedir= resolve(substitute(substitute(getline('.'),'@.*$','','e'),'^|*\s*','','e')) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9224 " call Decho("treedir<".treedir.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9225 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9226 " call Decho("do not extract tree subdirectory from current line and set treedir to empty",'~'.expand("<slnum>")) |
1621 | 9227 let treedir= "" |
9228 endif | |
9229 | |
9230 " detect user attempting to close treeroot | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9231 " call Decho("check if user is attempting to close treeroot",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9232 " call Decho(".win#".winnr()." buf#".bufnr("%")."<".bufname("%").">",'~'.expand("<slnum>")) |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
9233 " call Decho(".getline(".line(".").")<".getline('.').'> '.((getline('.') =~# '^'.s:treedepthstring)? '=~#' : '!~').' ^'.s:treedepthstring,'~'.expand("<slnum>")) |
6476 | 9234 if curline !~ '^'.s:treedepthstring && getline('.') != '..' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9235 " call Decho(".user may have attempted to close treeroot",'~'.expand("<slnum>")) |
1621 | 9236 " now force a refresh |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9237 " call Decho(".force refresh: clear buffer<".expand("%")."> with :%d",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9238 sil! NetrwKeepj %d _ |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9239 " call Dret("s:NetrwTreeDir <".treedir."> : (side effect) s:treecurpos<".(exists("s:treecurpos")? string(s:treecurpos) : 'n/a').">") |
1621 | 9240 return b:netrw_curdir |
5618 | 9241 " else " Decho |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9242 " call Decho(".user not attempting to close treeroot",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9243 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9244 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9245 " call Decho("islocal=".a:islocal." curline<".curline.">",'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9246 let potentialdir= s:NetrwFile(substitute(curline,'^'.s:treedepthstring.'\+ \(.*\)@$','\1','')) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9247 " call Decho("potentialdir<".potentialdir."> isdir=".isdirectory(potentialdir),'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9248 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9249 " COMBAK: a symbolic link may point anywhere -- so it will be used to start a new treetop |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9250 " if a:islocal && curline =~ '@$' && isdirectory(s:NetrwFile(potentialdir)) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9251 " let newdir = w:netrw_treetop.'/'.potentialdir |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9252 " " call Decho("apply NetrwTreePath to newdir<".newdir.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9253 " let treedir = s:NetrwTreePath(newdir) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9254 " let w:netrw_treetop = newdir |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9255 " " call Decho("newdir <".newdir.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9256 " else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9257 " call Decho("apply NetrwTreePath to treetop<".w:netrw_treetop.">",'~'.expand("<slnum>")) |
6476 | 9258 let treedir = s:NetrwTreePath(w:netrw_treetop) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9259 " endif |
5618 | 9260 endif |
9261 | |
9262 " sanity maintenance: keep those //s away... | |
1621 | 9263 let treedir= substitute(treedir,'//$','/','') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9264 " call Decho("treedir<".treedir.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9265 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9266 " call Dret("s:NetrwTreeDir <".treedir."> : (side effect) s:treecurpos<".(exists("s:treecurpos")? string(s:treecurpos) : 'n/a').">") |
1621 | 9267 return treedir |
9268 endfun | |
9269 | |
9270 " --------------------------------------------------------------------- | |
9271 " s:NetrwTreeDisplay: recursive tree display {{{2 | |
9272 fun! s:NetrwTreeDisplay(dir,depth) | |
9273 " call Dfunc("NetrwTreeDisplay(dir<".a:dir."> depth<".a:depth.">)") | |
9274 | |
9275 " insure that there are no folds | |
4339 | 9276 setl nofen |
1621 | 9277 |
9278 " install ../ and shortdir | |
9279 if a:depth == "" | |
9280 call setline(line("$")+1,'../') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9281 " call Decho("setline#".line("$")." ../ (depth is zero)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9282 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9283 if a:dir =~ '^\a\{3,}://' |
1621 | 9284 if a:dir == w:netrw_treetop |
9285 let shortdir= a:dir | |
9286 else | |
9287 let shortdir= substitute(a:dir,'^.*/\([^/]\+\)/$','\1/','e') | |
9288 endif | |
9289 call setline(line("$")+1,a:depth.shortdir) | |
9290 else | |
9291 let shortdir= substitute(a:dir,'^.*/','','e') | |
9292 call setline(line("$")+1,a:depth.shortdir.'/') | |
9293 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9294 " call Decho("setline#".line("$")." shortdir<".a:depth.shortdir.">",'~'.expand("<slnum>")) |
1621 | 9295 |
9296 " append a / to dir if its missing one | |
9297 let dir= a:dir | |
9298 | |
9299 " display subtrees (if any) | |
5618 | 9300 let depth= s:treedepthstring.a:depth |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9301 " call Decho("display subtrees with depth<".depth."> and current leaves",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9302 |
17433 | 9303 " implement g:netrw_hide for tree listings (uses g:netrw_list_hide) |
9304 if g:netrw_hide == 1 | |
9305 " hide given patterns | |
9306 let listhide= split(g:netrw_list_hide,',') | |
9307 " call Decho("listhide=".string(listhide)) | |
9308 for pat in listhide | |
9309 call filter(w:netrw_treedict[dir],'v:val !~ "'.pat.'"') | |
9310 endfor | |
9311 | |
9312 elseif g:netrw_hide == 2 | |
9313 " show given patterns (only) | |
9314 let listhide= split(g:netrw_list_hide,',') | |
9315 " call Decho("listhide=".string(listhide)) | |
9316 let entries=[] | |
9317 for entry in w:netrw_treedict[dir] | |
9318 for pat in listhide | |
9319 if entry =~ pat | |
9320 call add(entries,entry) | |
9321 break | |
9322 endif | |
9323 endfor | |
9324 endfor | |
9325 let w:netrw_treedict[dir]= entries | |
9326 endif | |
9327 if depth != "" | |
9328 " always remove "." and ".." entries when there's depth | |
9329 call filter(w:netrw_treedict[dir],'v:val !~ "\\.\\.$"') | |
9330 call filter(w:netrw_treedict[dir],'v:val !~ "\\.$"') | |
9331 endif | |
9332 | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9333 " call Decho("for every entry in w:netrw_treedict[".dir."]=".string(w:netrw_treedict[dir]),'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9334 for entry in w:netrw_treedict[dir] |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9335 if dir =~ '/$' |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9336 let direntry= substitute(dir.entry,'[@/]$','','e') |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9337 else |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9338 let direntry= substitute(dir.'/'.entry,'[@/]$','','e') |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9339 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9340 " call Decho("dir<".dir."> entry<".entry."> direntry<".direntry.">",'~'.expand("<slnum>")) |
1621 | 9341 if entry =~ '/$' && has_key(w:netrw_treedict,direntry) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9342 " call Decho("<".direntry."> is a key in treedict - display subtree for it",'~'.expand("<slnum>")) |
6476 | 9343 NetrwKeepj call s:NetrwTreeDisplay(direntry,depth) |
1621 | 9344 elseif entry =~ '/$' && has_key(w:netrw_treedict,direntry.'/') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9345 " call Decho("<".direntry."/> is a key in treedict - display subtree for it",'~'.expand("<slnum>")) |
6476 | 9346 NetrwKeepj call s:NetrwTreeDisplay(direntry.'/',depth) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9347 elseif entry =~ '@$' && has_key(w:netrw_treedict,direntry.'@') |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9348 " call Decho("<".direntry."/> is a key in treedict - display subtree for it",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9349 NetrwKeepj call s:NetrwTreeDisplay(direntry.'/',depth) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9350 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9351 " call Decho("<".entry."> is not a key in treedict (no subtree)",'~'.expand("<slnum>")) |
6476 | 9352 sil! NetrwKeepj call setline(line("$")+1,depth.entry) |
1621 | 9353 endif |
9354 endfor | |
17433 | 9355 " call Decho("displaying: ".string(getline(w:netrw_bannercnt,'$'))) |
5618 | 9356 |
1621 | 9357 " call Dret("NetrwTreeDisplay") |
9358 endfun | |
9359 | |
9360 " --------------------------------------------------------------------- | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9361 " s:NetrwRefreshTreeDict: updates the contents information for a tree (w:netrw_treedict) {{{2 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9362 fun! s:NetrwRefreshTreeDict(dir) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9363 " call Dfunc("s:NetrwRefreshTreeDict(dir<".a:dir.">)") |
17433 | 9364 if !exists("w:netrw_treedict") |
9365 " call Dret("s:NetrwRefreshTreeDict : w:netrw_treedict doesn't exist") | |
9366 return | |
9367 endif | |
9368 | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9369 for entry in w:netrw_treedict[a:dir] |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9370 let direntry= substitute(a:dir.'/'.entry,'[@/]$','','e') |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9371 " call Decho("a:dir<".a:dir."> entry<".entry."> direntry<".direntry.">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9372 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9373 if entry =~ '/$' && has_key(w:netrw_treedict,direntry) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9374 " call Decho("<".direntry."> is a key in treedict - display subtree for it",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9375 NetrwKeepj call s:NetrwRefreshTreeDict(direntry) |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
9376 let liststar = s:NetrwGlob(direntry,'*',1) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
9377 let listdotstar = s:NetrwGlob(direntry,'.*',1) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9378 let w:netrw_treedict[direntry] = liststar + listdotstar |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9379 " call Decho("updating w:netrw_treedict[".direntry.']='.string(w:netrw_treedict[direntry]),'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9380 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9381 elseif entry =~ '/$' && has_key(w:netrw_treedict,direntry.'/') |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9382 " call Decho("<".direntry."/> is a key in treedict - display subtree for it",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9383 NetrwKeepj call s:NetrwRefreshTreeDict(direntry.'/') |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
9384 let liststar = s:NetrwGlob(direntry.'/','*',1) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
9385 let listdotstar= s:NetrwGlob(direntry.'/','.*',1) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9386 let w:netrw_treedict[direntry]= liststar + listdotstar |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9387 " call Decho("updating w:netrw_treedict[".direntry.']='.string(w:netrw_treedict[direntry]),'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9388 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9389 elseif entry =~ '@$' && has_key(w:netrw_treedict,direntry.'@') |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9390 " call Decho("<".direntry."/> is a key in treedict - display subtree for it",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9391 NetrwKeepj call s:NetrwRefreshTreeDict(direntry.'/') |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
9392 let liststar = s:NetrwGlob(direntry.'/','*',1) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
9393 let listdotstar= s:NetrwGlob(direntry.'/','.*',1) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9394 " call Decho("updating w:netrw_treedict[".direntry.']='.string(w:netrw_treedict[direntry]),'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9395 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9396 else |
17433 | 9397 " call Decho('not updating w:netrw_treedict['.string(direntry).'] with entry<'.string(entry).'> (no subtree)','~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9398 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9399 endfor |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9400 " call Dret("s:NetrwRefreshTreeDict") |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9401 endfun |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9402 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9403 " --------------------------------------------------------------------- |
1621 | 9404 " s:NetrwTreeListing: displays tree listing from treetop on down, using NetrwTreeDisplay() {{{2 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9405 " Called by s:PerformListing() |
1621 | 9406 fun! s:NetrwTreeListing(dirname) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9407 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST |
1621 | 9408 " call Dfunc("NetrwTreeListing() bufname<".expand("%").">") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9409 " call Decho("curdir<".a:dirname.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9410 " call Decho("win#".winnr().": w:netrw_treetop ".(exists("w:netrw_treetop")? "exists" : "doesn't exist")." w:netrw_treedict ".(exists("w:netrw_treedict")? "exists" : "doesn't exit"),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9411 " call Decho("g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")",'~'.expand("<slnum>")) |
1621 | 9412 |
9413 " update the treetop | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9414 " call Decho("update the treetop",'~'.expand("<slnum>")) |
1621 | 9415 if !exists("w:netrw_treetop") |
9416 let w:netrw_treetop= a:dirname | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9417 " call Decho("w:netrw_treetop<".w:netrw_treetop."> (reusing)",'~'.expand("<slnum>")) |
1621 | 9418 elseif (w:netrw_treetop =~ ('^'.a:dirname) && s:Strlen(a:dirname) < s:Strlen(w:netrw_treetop)) || a:dirname !~ ('^'.w:netrw_treetop) |
9419 let w:netrw_treetop= a:dirname | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9420 " call Decho("w:netrw_treetop<".w:netrw_treetop."> (went up)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9421 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9422 |
1621 | 9423 if !exists("w:netrw_treedict") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9424 " insure that we have a treedict, albeit empty |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9425 " call Decho("initializing w:netrw_treedict to empty",'~'.expand("<slnum>")) |
1621 | 9426 let w:netrw_treedict= {} |
9427 endif | |
9428 | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9429 " update the dictionary for the current directory |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9430 " call Decho("updating: w:netrw_treedict[".a:dirname.'] -> [directory listing]','~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9431 " call Decho("w:netrw_bannercnt=".w:netrw_bannercnt." line($)=".line("$"),'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9432 exe "sil! NetrwKeepj ".w:netrw_bannercnt.',$g@^\.\.\=/$@d _' |
1621 | 9433 let w:netrw_treedict[a:dirname]= getline(w:netrw_bannercnt,line("$")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9434 " call Decho("w:treedict[".a:dirname."]= ".string(w:netrw_treedict[a:dirname]),'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9435 exe "sil! NetrwKeepj ".w:netrw_bannercnt.",$d _" |
1621 | 9436 |
9437 " if past banner, record word | |
9438 if exists("w:netrw_bannercnt") && line(".") > w:netrw_bannercnt | |
9439 let fname= expand("<cword>") | |
9440 else | |
9441 let fname= "" | |
9442 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9443 " call Decho("fname<".fname.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9444 " call Decho("g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")",'~'.expand("<slnum>")) |
1621 | 9445 |
9446 " display from treetop on down | |
6476 | 9447 NetrwKeepj call s:NetrwTreeDisplay(w:netrw_treetop,"") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9448 " call Decho("s:NetrwTreeDisplay) setl noma nomod ro",'~'.expand("<slnum>")) |
5618 | 9449 |
9450 " remove any blank line remaining as line#1 (happens in treelisting mode with banner suppressed) | |
9451 while getline(1) =~ '^\s*$' && byte2line(1) > 0 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9452 " call Decho("deleting blank line",'~'.expand("<slnum>")) |
5618 | 9453 1d |
9454 endwhile | |
9455 | |
5929 | 9456 exe "setl ".g:netrw_bufsettings |
1621 | 9457 |
9458 " call Dret("NetrwTreeListing : bufname<".expand("%").">") | |
3456 | 9459 return |
1621 | 9460 endif |
9461 endfun | |
9462 | |
9463 " --------------------------------------------------------------------- | |
17433 | 9464 " s:NetrwTreePath: returns path to current file/directory in tree listing {{{2 |
5734 | 9465 " Normally, treetop is w:netrw_treetop, but a |
9466 " user of the function ( netrw#SetTreetop() ) | |
9467 " wipes that out prior to calling this function | |
9468 fun! s:NetrwTreePath(treetop) | |
17433 | 9469 " call Dfunc("s:NetrwTreePath(treetop<".a:treetop.">) line#".line(".")."<".getline(".").">") |
9470 if line(".") < w:netrw_bannercnt + 2 | |
9471 let treedir= a:treetop | |
9472 if treedir !~ '/$' | |
9473 let treedir= treedir.'/' | |
9474 endif | |
9475 " call Dret("s:NetrwTreePath ".treedir." : line#".line(".")." ≤ ".(w:netrw_bannercnt+2)) | |
9476 return treedir | |
9477 endif | |
9478 | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9479 let svpos = winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9480 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
5734 | 9481 let depth = substitute(getline('.'),'^\(\%('.s:treedepthstring.'\)*\)[^'.s:treedepthstring.'].\{-}$','\1','e') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9482 " call Decho("depth<".depth."> 1st subst",'~'.expand("<slnum>")) |
5734 | 9483 let depth = substitute(depth,'^'.s:treedepthstring,'','') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9484 " call Decho("depth<".depth."> 2nd subst (first depth removed)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9485 let curline= getline('.') |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9486 " call Decho("curline<".curline.'>','~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9487 if curline =~ '/$' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9488 " call Decho("extract tree directory from current line",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9489 let treedir= substitute(curline,'^\%('.s:treedepthstring.'\)*\([^'.s:treedepthstring.'].\{-}\)$','\1','e') |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9490 " call Decho("treedir<".treedir.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9491 elseif curline =~ '@\s\+-->' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9492 " call Decho("extract tree directory using symbolic link",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9493 let treedir= substitute(curline,'^\%('.s:treedepthstring.'\)*\([^'.s:treedepthstring.'].\{-}\)$','\1','e') |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9494 let treedir= substitute(treedir,'@\s\+-->.*$','','e') |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9495 " call Decho("treedir<".treedir.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9496 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9497 " call Decho("do not extract tree directory from current line and set treedir to empty",'~'.expand("<slnum>")) |
5734 | 9498 let treedir= "" |
9499 endif | |
9500 " construct treedir by searching backwards at correct depth | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9501 " call Decho("construct treedir by searching backwards for correct depth",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9502 " call Decho("initial treedir<".treedir."> depth<".depth.">",'~'.expand("<slnum>")) |
5734 | 9503 while depth != "" && search('^'.depth.'[^'.s:treedepthstring.'].\{-}/$','bW') |
9504 let dirname= substitute(getline('.'),'^\('.s:treedepthstring.'\)*','','e') | |
9505 let treedir= dirname.treedir | |
9506 let depth = substitute(depth,'^'.s:treedepthstring,'','') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9507 " call Decho("constructing treedir<".treedir.">: dirname<".dirname."> while depth<".depth.">",'~'.expand("<slnum>")) |
5734 | 9508 endwhile |
17433 | 9509 " call Decho("treedir#1<".treedir.">",'~'.expand("<slnum>")) |
5734 | 9510 if a:treetop =~ '/$' |
9511 let treedir= a:treetop.treedir | |
9512 else | |
9513 let treedir= a:treetop.'/'.treedir | |
9514 endif | |
17433 | 9515 " call Decho("treedir#2<".treedir.">",'~'.expand("<slnum>")) |
5734 | 9516 let treedir= substitute(treedir,'//$','/','') |
17433 | 9517 " call Decho("treedir#3<".treedir.">",'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9518 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>"))" |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9519 call winrestview(svpos) |
5734 | 9520 " call Dret("s:NetrwTreePath <".treedir.">") |
9521 return treedir | |
9522 endfun | |
9523 | |
9524 " --------------------------------------------------------------------- | |
1621 | 9525 " s:NetrwWideListing: {{{2 |
9526 fun! s:NetrwWideListing() | |
9527 | |
9528 if w:netrw_liststyle == s:WIDELIST | |
9529 " call Dfunc("NetrwWideListing() w:netrw_liststyle=".w:netrw_liststyle.' fo='.&fo.' l:fo='.&l:fo) | |
9530 " look for longest filename (cpf=characters per filename) | |
2034 | 9531 " cpf: characters per filename |
9532 " fpl: filenames per line | |
9533 " fpc: filenames per column | |
4339 | 9534 setl ma noro |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9535 " call Decho("setl ma noro",'~'.expand("<slnum>")) |
1621 | 9536 let b:netrw_cpf= 0 |
9537 if line("$") >= w:netrw_bannercnt | |
6476 | 9538 exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$g/^./if virtcol("$") > b:netrw_cpf|let b:netrw_cpf= virtcol("$")|endif' |
9539 NetrwKeepj call histdel("/",-1) | |
1621 | 9540 else |
9541 " call Dret("NetrwWideListing") | |
9542 return | |
9543 endif | |
2034 | 9544 let b:netrw_cpf= b:netrw_cpf + 2 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9545 " call Decho("b:netrw_cpf=max_filename_length+2=".b:netrw_cpf,'~'.expand("<slnum>")) |
1621 | 9546 |
9547 " determine qty files per line (fpl) | |
9548 let w:netrw_fpl= winwidth(0)/b:netrw_cpf | |
9549 if w:netrw_fpl <= 0 | |
9550 let w:netrw_fpl= 1 | |
9551 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9552 " call Decho("fpl= [winwidth=".winwidth(0)."]/[b:netrw_cpf=".b:netrw_cpf.']='.w:netrw_fpl,'~'.expand("<slnum>")) |
1621 | 9553 |
9554 " make wide display | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9555 " fpc: files per column of wide listing |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9556 exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$s/^.*$/\=escape(printf("%-'.b:netrw_cpf.'S",submatch(0)),"\\")/' |
6476 | 9557 NetrwKeepj call histdel("/",-1) |
1621 | 9558 let fpc = (line("$") - w:netrw_bannercnt + w:netrw_fpl)/w:netrw_fpl |
9559 let newcolstart = w:netrw_bannercnt + fpc | |
9560 let newcolend = newcolstart + fpc - 1 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9561 " call Decho("bannercnt=".w:netrw_bannercnt." fpl=".w:netrw_fpl." fpc=".fpc." newcol[".newcolstart.",".newcolend."]",'~'.expand("<slnum>")) |
5734 | 9562 if has("clipboard") |
9563 sil! let keepregstar = @* | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9564 sil! let keepregplus = @+ |
5734 | 9565 endif |
1621 | 9566 while line("$") >= newcolstart |
9567 if newcolend > line("$") | let newcolend= line("$") | endif | |
9568 let newcolqty= newcolend - newcolstart | |
9569 exe newcolstart | |
9570 if newcolqty == 0 | |
6476 | 9571 exe "sil! NetrwKeepj norm! 0\<c-v>$hx".w:netrw_bannercnt."G$p" |
1621 | 9572 else |
6476 | 9573 exe "sil! NetrwKeepj norm! 0\<c-v>".newcolqty.'j$hx'.w:netrw_bannercnt.'G$p' |
9574 endif | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9575 exe "sil! NetrwKeepj ".newcolstart.','.newcolend.'d _' |
6476 | 9576 exe 'sil! NetrwKeepj '.w:netrw_bannercnt |
1621 | 9577 endwhile |
5734 | 9578 if has("clipboard") |
9579 sil! let @*= keepregstar | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9580 sil! let @+= keepregplus |
5734 | 9581 endif |
6476 | 9582 exe "sil! NetrwKeepj ".w:netrw_bannercnt.',$s/\s\+$//e' |
9583 NetrwKeepj call histdel("/",-1) | |
9584 exe 'nno <buffer> <silent> w :call search(''^.\\|\s\s\zs\S'',''W'')'."\<cr>" | |
9585 exe 'nno <buffer> <silent> b :call search(''^.\\|\s\s\zs\S'',''bW'')'."\<cr>" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9586 " call Decho("NetrwWideListing) setl noma nomod ro",'~'.expand("<slnum>")) |
5929 | 9587 exe "setl ".g:netrw_bufsettings |
17433 | 9588 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
1621 | 9589 " call Dret("NetrwWideListing") |
3456 | 9590 return |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
9591 else |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
9592 if hasmapto("w","n") |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
9593 sil! nunmap <buffer> w |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
9594 endif |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
9595 if hasmapto("b","n") |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
9596 sil! nunmap <buffer> b |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
9597 endif |
1621 | 9598 endif |
9599 | |
9600 endfun | |
9601 | |
9602 " --------------------------------------------------------------------- | |
9603 " s:PerformListing: {{{2 | |
9604 fun! s:PerformListing(islocal) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9605 " call Dfunc("s:PerformListing(islocal=".a:islocal.")") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9606 " call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol()." line($)=".line("$"),'~'.expand("<slnum>")) |
17433 | 9607 " call Decho("settings: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (enter)"." ei<".&ei.">",'~'.expand("<slnum>")) |
9608 sil! NetrwKeepj %d _ | |
9609 " call DechoBuf(bufnr("%")) | |
1621 | 9610 |
3153 | 9611 " set up syntax highlighting {{{3 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9612 " call Decho("--set up syntax highlighting (ie. setl ft=netrw)",'~'.expand("<slnum>")) |
6476 | 9613 sil! setl ft=netrw |
9614 | |
17433 | 9615 NetrwKeepj call s:NetrwOptionsSafe(a:islocal) |
5734 | 9616 setl noro ma |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9617 " call Decho("setl noro ma bh=".&bh,'~'.expand("<slnum>")) |
1621 | 9618 |
9619 " if exists("g:netrw_silent") && g:netrw_silent == 0 && &ch >= 1 " Decho | |
17433 | 9620 " call Decho("Processing your browsing request...",'~'.expand("<slnum>")) |
1621 | 9621 " endif " Decho |
9622 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9623 " call Decho('w:netrw_liststyle='.(exists("w:netrw_liststyle")? w:netrw_liststyle : 'n/a'),'~'.expand("<slnum>")) |
1621 | 9624 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST && exists("w:netrw_treedict") |
9625 " force a refresh for tree listings | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9626 " call Decho("force refresh for treelisting: clear buffer<".expand("%")."> with :%d",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9627 sil! NetrwKeepj %d _ |
1621 | 9628 endif |
9629 | |
9630 " save current directory on directory history list | |
6476 | 9631 NetrwKeepj call s:NetrwBookHistHandler(3,b:netrw_curdir) |
1621 | 9632 |
9633 " Set up the banner {{{3 | |
2034 | 9634 if g:netrw_banner |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9635 " call Decho("--set up banner",'~'.expand("<slnum>")) |
6476 | 9636 NetrwKeepj call setline(1,'" ============================================================================') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9637 if exists("g:netrw_pchk") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9638 " this undocumented option allows pchk to run with different versions of netrw without causing spurious |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9639 " failure detections. |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9640 NetrwKeepj call setline(2,'" Netrw Directory Listing') |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9641 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9642 NetrwKeepj call setline(2,'" Netrw Directory Listing (netrw '.g:loaded_netrw.')') |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9643 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9644 if exists("g:netrw_pchk") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9645 let curdir= substitute(b:netrw_curdir,expand("$HOME"),'~','') |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9646 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9647 let curdir= b:netrw_curdir |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9648 endif |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
9649 if exists("g:netrw_bannerbackslash") && g:netrw_bannerbackslash |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9650 NetrwKeepj call setline(3,'" '.substitute(curdir,'/','\\','g')) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9651 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9652 NetrwKeepj call setline(3,'" '.curdir) |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
9653 endif |
2034 | 9654 let w:netrw_bannercnt= 3 |
6476 | 9655 NetrwKeepj exe "sil! NetrwKeepj ".w:netrw_bannercnt |
9656 else | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9657 " call Decho("--no banner",'~'.expand("<slnum>")) |
6476 | 9658 NetrwKeepj 1 |
2034 | 9659 let w:netrw_bannercnt= 1 |
9660 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9661 " call Decho("w:netrw_bannercnt=".w:netrw_bannercnt." win#".winnr(),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9662 " call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol()." line($)=".line("$"),'~'.expand("<slnum>")) |
1621 | 9663 |
17433 | 9664 " construct sortby string: [name|time|size|exten] [reversed] |
1621 | 9665 let sortby= g:netrw_sort_by |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
9666 if g:netrw_sort_direction =~# "^r" |
1621 | 9667 let sortby= sortby." reversed" |
9668 endif | |
9669 | |
9670 " Sorted by... {{{3 | |
2034 | 9671 if g:netrw_banner |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9672 " call Decho("--handle specified sorting: g:netrw_sort_by<".g:netrw_sort_by.">",'~'.expand("<slnum>")) |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
9673 if g:netrw_sort_by =~# "^n" |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9674 " call Decho("directories will be sorted by name",'~'.expand("<slnum>")) |
17433 | 9675 " sorted by name (also includes the sorting sequence in the banner) |
6476 | 9676 NetrwKeepj put ='\" Sorted by '.sortby |
9677 NetrwKeepj put ='\" Sort sequence: '.g:netrw_sort_sequence | |
2034 | 9678 let w:netrw_bannercnt= w:netrw_bannercnt + 2 |
9679 else | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9680 " call Decho("directories will be sorted by size or time",'~'.expand("<slnum>")) |
17433 | 9681 " sorted by time, size, exten |
6476 | 9682 NetrwKeepj put ='\" Sorted by '.sortby |
2034 | 9683 let w:netrw_bannercnt= w:netrw_bannercnt + 1 |
9684 endif | |
6476 | 9685 exe "sil! NetrwKeepj ".w:netrw_bannercnt |
5618 | 9686 " else " Decho |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9687 " call Decho("g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")",'~'.expand("<slnum>")) |
2034 | 9688 endif |
1621 | 9689 |
17433 | 9690 " show copy/move target, if any {{{3 |
2034 | 9691 if g:netrw_banner |
9692 if exists("s:netrwmftgt") && exists("s:netrwmftgt_islocal") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9693 " call Decho("--show copy/move target<".s:netrwmftgt.">",'~'.expand("<slnum>")) |
6476 | 9694 NetrwKeepj put ='' |
2034 | 9695 if s:netrwmftgt_islocal |
6476 | 9696 sil! NetrwKeepj call setline(line("."),'" Copy/Move Tgt: '.s:netrwmftgt.' (local)') |
2034 | 9697 else |
6476 | 9698 sil! NetrwKeepj call setline(line("."),'" Copy/Move Tgt: '.s:netrwmftgt.' (remote)') |
2034 | 9699 endif |
9700 let w:netrw_bannercnt= w:netrw_bannercnt + 1 | |
1621 | 9701 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9702 " call Decho("s:netrwmftgt does not exist, don't make Copy/Move Tgt",'~'.expand("<slnum>")) |
2034 | 9703 endif |
6476 | 9704 exe "sil! NetrwKeepj ".w:netrw_bannercnt |
2034 | 9705 endif |
1621 | 9706 |
9707 " Hiding... -or- Showing... {{{3 | |
2034 | 9708 if g:netrw_banner |
17433 | 9709 " call Decho("--handle hiding/showing (g:netrw_hide=".g:netrw_hide." g:netrw_list_hide<".g:netrw_list_hide.">)",'~'.expand("<slnum>")) |
2034 | 9710 if g:netrw_list_hide != "" && g:netrw_hide |
9711 if g:netrw_hide == 1 | |
6476 | 9712 NetrwKeepj put ='\" Hiding: '.g:netrw_list_hide |
2034 | 9713 else |
6476 | 9714 NetrwKeepj put ='\" Showing: '.g:netrw_list_hide |
2034 | 9715 endif |
9716 let w:netrw_bannercnt= w:netrw_bannercnt + 1 | |
9717 endif | |
6476 | 9718 exe "NetrwKeepj ".w:netrw_bannercnt |
5734 | 9719 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9720 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
5734 | 9721 let quickhelp = g:netrw_quickhelp%len(s:QuickHelp) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9722 " call Decho("quickhelp =".quickhelp,'~'.expand("<slnum>")) |
6476 | 9723 NetrwKeepj put ='\" Quick Help: <F1>:help '.s:QuickHelp[quickhelp] |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9724 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
6476 | 9725 NetrwKeepj put ='\" ==============================================================================' |
2034 | 9726 let w:netrw_bannercnt= w:netrw_bannercnt + 2 |
5618 | 9727 " else " Decho |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9728 " call Decho("g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")",'~'.expand("<slnum>")) |
2034 | 9729 endif |
1621 | 9730 |
9731 " bannercnt should index the line just after the banner | |
2034 | 9732 if g:netrw_banner |
9733 let w:netrw_bannercnt= w:netrw_bannercnt + 1 | |
6476 | 9734 exe "sil! NetrwKeepj ".w:netrw_bannercnt |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9735 " call Decho("--w:netrw_bannercnt=".w:netrw_bannercnt." (should index line just after banner) line($)=".line("$"),'~'.expand("<slnum>")) |
5618 | 9736 " else " Decho |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9737 " call Decho("g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")",'~'.expand("<slnum>")) |
2034 | 9738 endif |
1621 | 9739 |
9740 " get list of files | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9741 " call Decho("--Get list of files - islocal=".a:islocal,'~'.expand("<slnum>")) |
1621 | 9742 if a:islocal |
6476 | 9743 NetrwKeepj call s:LocalListing() |
1621 | 9744 else " remote |
6476 | 9745 NetrwKeepj let badresult= s:NetrwRemoteListing() |
5734 | 9746 if badresult |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9747 " call Decho("w:netrw_bannercnt=".(exists("w:netrw_bannercnt")? w:netrw_bannercnt : 'n/a')." win#".winnr()." buf#".bufnr("%")."<".bufname("%").">",'~'.expand("<slnum>")) |
5734 | 9748 " call Dret("s:PerformListing : error detected by NetrwRemoteListing") |
9749 return | |
9750 endif | |
9751 endif | |
1621 | 9752 |
9753 " manipulate the directory listing (hide, sort) {{{3 | |
3456 | 9754 if !exists("w:netrw_bannercnt") |
9755 let w:netrw_bannercnt= 0 | |
9756 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9757 " call Decho("--manipulate directory listing (hide, sort)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9758 " call Decho("g:netrw_banner=".g:netrw_banner." w:netrw_bannercnt=".w:netrw_bannercnt." (banner complete)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9759 " call Decho("g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")",'~'.expand("<slnum>")) |
5734 | 9760 |
2034 | 9761 if !g:netrw_banner || line("$") >= w:netrw_bannercnt |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9762 " call Decho("manipulate directory listing (hide)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9763 " call Decho("g:netrw_hide=".g:netrw_hide." g:netrw_list_hide<".g:netrw_list_hide.">",'~'.expand("<slnum>")) |
1621 | 9764 if g:netrw_hide && g:netrw_list_hide != "" |
6476 | 9765 NetrwKeepj call s:NetrwListHide() |
1621 | 9766 endif |
2034 | 9767 if !g:netrw_banner || line("$") >= w:netrw_bannercnt |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9768 " call Decho("manipulate directory listing (sort) : g:netrw_sort_by<".g:netrw_sort_by.">",'~'.expand("<slnum>")) |
1621 | 9769 |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
9770 if g:netrw_sort_by =~# "^n" |
1621 | 9771 " sort by name |
17433 | 9772 " call Decho("sort by name",'~'.expand("<slnum>")) |
6476 | 9773 NetrwKeepj call s:NetrwSetSort() |
1621 | 9774 |
2034 | 9775 if !g:netrw_banner || w:netrw_bannercnt < line("$") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9776 " call Decho("g:netrw_sort_direction=".g:netrw_sort_direction." (bannercnt=".w:netrw_bannercnt.")",'~'.expand("<slnum>")) |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
9777 if g:netrw_sort_direction =~# 'n' |
17433 | 9778 " name: sort by name of file |
6476 | 9779 exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$sort'.' '.g:netrw_sort_options |
1621 | 9780 else |
9781 " reverse direction sorting | |
6476 | 9782 exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$sort!'.' '.g:netrw_sort_options |
1621 | 9783 endif |
9784 endif | |
9785 " remove priority pattern prefix | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9786 " call Decho("remove priority pattern prefix",'~'.expand("<slnum>")) |
6476 | 9787 exe 'sil! NetrwKeepj '.w:netrw_bannercnt.',$s/^\d\{3}'.g:netrw_sepchr.'//e' |
9788 NetrwKeepj call histdel("/",-1) | |
1621 | 9789 |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
9790 elseif g:netrw_sort_by =~# "^ext" |
17433 | 9791 " exten: sort by extension |
9792 " The histdel(...,-1) calls remove the last search from the search history | |
9793 " call Decho("sort by extension",'~'.expand("<slnum>")) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9794 exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$g+/+s/^/001'.g:netrw_sepchr.'/' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9795 NetrwKeepj call histdel("/",-1) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9796 exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$v+[./]+s/^/002'.g:netrw_sepchr.'/' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9797 NetrwKeepj call histdel("/",-1) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9798 exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$v+['.g:netrw_sepchr.'/]+s/^\(.*\.\)\(.\{-\}\)$/\2'.g:netrw_sepchr.'&/e' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9799 NetrwKeepj call histdel("/",-1) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9800 if !g:netrw_banner || w:netrw_bannercnt < line("$") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9801 " call Decho("g:netrw_sort_direction=".g:netrw_sort_direction." (bannercnt=".w:netrw_bannercnt.")",'~'.expand("<slnum>")) |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
9802 if g:netrw_sort_direction =~# 'n' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9803 " normal direction sorting |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9804 exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$sort'.' '.g:netrw_sort_options |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9805 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9806 " reverse direction sorting |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9807 exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$sort!'.' '.g:netrw_sort_options |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9808 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9809 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9810 exe 'sil! NetrwKeepj '.w:netrw_bannercnt.',$s/^.\{-}'.g:netrw_sepchr.'//e' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9811 NetrwKeepj call histdel("/",-1) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9812 |
1621 | 9813 elseif a:islocal |
2034 | 9814 if !g:netrw_banner || w:netrw_bannercnt < line("$") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9815 " call Decho("g:netrw_sort_direction=".g:netrw_sort_direction,'~'.expand("<slnum>")) |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
9816 if g:netrw_sort_direction =~# 'n' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9817 " call Decho('exe sil NetrwKeepj '.w:netrw_bannercnt.',$sort','~'.expand("<slnum>")) |
6476 | 9818 exe 'sil! NetrwKeepj '.w:netrw_bannercnt.',$sort'.' '.g:netrw_sort_options |
1621 | 9819 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9820 " call Decho('exe sil NetrwKeepj '.w:netrw_bannercnt.',$sort!','~'.expand("<slnum>")) |
6476 | 9821 exe 'sil! NetrwKeepj '.w:netrw_bannercnt.',$sort!'.' '.g:netrw_sort_options |
1621 | 9822 endif |
6476 | 9823 exe 'sil! NetrwKeepj '.w:netrw_bannercnt.',$s/^\d\{-}\///e' |
9824 NetrwKeepj call histdel("/",-1) | |
1621 | 9825 endif |
9826 endif | |
9827 | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
9828 elseif g:netrw_sort_direction =~# 'r' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9829 " call Decho('(s:PerformListing) reverse the sorted listing','~'.expand("<slnum>")) |
2034 | 9830 if !g:netrw_banner || w:netrw_bannercnt < line('$') |
6476 | 9831 exe 'sil! NetrwKeepj '.w:netrw_bannercnt.',$g/^/m '.w:netrw_bannercnt |
2034 | 9832 call histdel("/",-1) |
9833 endif | |
1621 | 9834 endif |
9835 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9836 " call Decho("g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")",'~'.expand("<slnum>")) |
1621 | 9837 |
9838 " convert to wide/tree listing {{{3 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9839 " call Decho("--modify display if wide/tree listing style",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9840 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#1)",'~'.expand("<slnum>")) |
6476 | 9841 NetrwKeepj call s:NetrwWideListing() |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9842 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#2)",'~'.expand("<slnum>")) |
6476 | 9843 NetrwKeepj call s:NetrwTreeListing(b:netrw_curdir) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9844 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#3)",'~'.expand("<slnum>")) |
1621 | 9845 |
6476 | 9846 " resolve symbolic links if local and (thin or tree) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9847 if a:islocal && (w:netrw_liststyle == s:THINLIST || (exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST)) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9848 " call Decho("--resolve symbolic links if local and thin|tree",'~'.expand("<slnum>")) |
17433 | 9849 sil! g/@$/call s:ShowLink() |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9850 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9851 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9852 if exists("w:netrw_bannercnt") && (line("$") >= w:netrw_bannercnt || !g:netrw_banner) |
1621 | 9853 " place cursor on the top-left corner of the file listing |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9854 " call Decho("--place cursor on top-left corner of file listing",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9855 exe 'sil! '.w:netrw_bannercnt |
6476 | 9856 sil! NetrwKeepj norm! 0 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9857 " call Decho(" tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol()." line($)=".line("$"),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9858 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9859 " call Decho("--did NOT place cursor on top-left corner",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9860 " call Decho(" w:netrw_bannercnt=".(exists("w:netrw_bannercnt")? w:netrw_bannercnt : 'n/a'),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9861 " call Decho(" line($)=".line("$"),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9862 " call Decho(" g:netrw_banner=".(exists("g:netrw_banner")? g:netrw_banner : 'n/a'),'~'.expand("<slnum>")) |
1621 | 9863 endif |
9864 | |
9865 " record previous current directory | |
9866 let w:netrw_prvdir= b:netrw_curdir | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9867 " call Decho("--record netrw_prvdir<".w:netrw_prvdir.">",'~'.expand("<slnum>")) |
1621 | 9868 |
9869 " save certain window-oriented variables into buffer-oriented variables {{{3 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9870 " call Decho("--save some window-oriented variables into buffer oriented variables",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9871 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#4)",'~'.expand("<slnum>")) |
6476 | 9872 NetrwKeepj call s:SetBufWinVars() |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9873 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#5)",'~'.expand("<slnum>")) |
17433 | 9874 NetrwKeepj call s:NetrwOptionsRestore("w:") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9875 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#6)",'~'.expand("<slnum>")) |
1621 | 9876 |
9877 " set display to netrw display settings | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9878 " call Decho("--set display to netrw display settings (".g:netrw_bufsettings.")",'~'.expand("<slnum>")) |
2420
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
9879 exe "setl ".g:netrw_bufsettings |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9880 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#7)",'~'.expand("<slnum>")) |
3920 | 9881 if g:netrw_liststyle == s:LONGLIST |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9882 " call Decho("exe setl ts=".(g:netrw_maxfilenamelen+1),'~'.expand("<slnum>")) |
3920 | 9883 exe "setl ts=".(g:netrw_maxfilenamelen+1) |
9884 endif | |
17433 | 9885 " call DechoBuf(bufnr("%")) |
5618 | 9886 |
1621 | 9887 if exists("s:treecurpos") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9888 " call Decho("s:treecurpos exists; restore posn",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9889 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (internal#8)",'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9890 " call Decho("restoring posn to s:treecurpos<".string(s:treecurpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9891 NetrwKeepj call winrestview(s:treecurpos) |
1621 | 9892 unlet s:treecurpos |
9893 endif | |
9894 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9895 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo. " (return)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9896 " call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol()." line($)=".line("$"),'~'.expand("<slnum>")) |
1621 | 9897 " call Dret("s:PerformListing : curpos<".string(getpos(".")).">") |
9898 endfun | |
9899 | |
9900 " --------------------------------------------------------------------- | |
9901 " s:SetupNetrwStatusLine: {{{2 | |
1121 | 9902 fun! s:SetupNetrwStatusLine(statline) |
9903 " call Dfunc("SetupNetrwStatusLine(statline<".a:statline.">)") | |
9904 | |
9905 if !exists("s:netrw_setup_statline") | |
9906 let s:netrw_setup_statline= 1 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9907 " call Decho("do first-time status line setup",'~'.expand("<slnum>")) |
1121 | 9908 |
9909 if !exists("s:netrw_users_stl") | |
9910 let s:netrw_users_stl= &stl | |
9911 endif | |
9912 if !exists("s:netrw_users_ls") | |
9913 let s:netrw_users_ls= &laststatus | |
9914 endif | |
9915 | |
9916 " set up User9 highlighting as needed | |
9917 let keepa= @a | |
9918 redir @a | |
9919 try | |
9920 hi User9 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9921 catch /^Vim\%((\a\{3,})\)\=:E411/ |
1121 | 9922 if &bg == "dark" |
9923 hi User9 ctermfg=yellow ctermbg=blue guifg=yellow guibg=blue | |
9924 else | |
9925 hi User9 ctermbg=yellow ctermfg=blue guibg=yellow guifg=blue | |
9926 endif | |
9927 endtry | |
9928 redir END | |
9929 let @a= keepa | |
9930 endif | |
9931 | |
9932 " set up status line (may use User9 highlighting) | |
9933 " insure that windows have a statusline | |
9934 " make sure statusline is displayed | |
9935 let &stl=a:statline | |
4339 | 9936 setl laststatus=2 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9937 " call Decho("stl=".&stl,'~'.expand("<slnum>")) |
1621 | 9938 redraw |
1121 | 9939 |
9940 " call Dret("SetupNetrwStatusLine : stl=".&stl) | |
9941 endfun | |
9942 | |
17433 | 9943 " ========================================= |
9944 " Remote Directory Browsing Support: {{{1 | |
9945 " ========================================= | |
1621 | 9946 |
9947 " --------------------------------------------------------------------- | |
5734 | 9948 " s:NetrwRemoteFtpCmd: unfortunately, not all ftp servers honor options for ls {{{2 |
9949 " This function assumes that a long listing will be received. Size, time, | |
9950 " and reverse sorts will be requested of the server but not otherwise | |
9951 " enforced here. | |
9952 fun! s:NetrwRemoteFtpCmd(path,listcmd) | |
9953 " call Dfunc("NetrwRemoteFtpCmd(path<".a:path."> listcmd<".a:listcmd.">) w:netrw_method=".(exists("w:netrw_method")? w:netrw_method : (exists("b:netrw_method")? b:netrw_method : "???"))) | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9954 " call Decho("line($)=".line("$")." win#".winnr()." w:netrw_bannercnt=".w:netrw_bannercnt,'~'.expand("<slnum>")) |
5734 | 9955 " sanity check: {{{3 |
9956 if !exists("w:netrw_method") | |
9957 if exists("b:netrw_method") | |
9958 let w:netrw_method= b:netrw_method | |
9959 else | |
9960 call netrw#ErrorMsg(2,"(s:NetrwRemoteFtpCmd) internal netrw error",93) | |
9961 " call Dret("NetrwRemoteFtpCmd") | |
9962 return | |
9963 endif | |
9964 endif | |
9965 | |
9966 " WinXX ftp uses unix style input, so set ff to unix " {{{3 | |
9967 let ffkeep= &ff | |
9968 setl ma ff=unix noro | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9969 " call Decho("setl ma ff=unix noro",'~'.expand("<slnum>")) |
5734 | 9970 |
9971 " clear off any older non-banner lines " {{{3 | |
9972 " note that w:netrw_bannercnt indexes the line after the banner | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9973 " call Decho('exe sil! NetrwKeepj '.w:netrw_bannercnt.",$d _ (clear off old non-banner lines)",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
9974 exe "sil! NetrwKeepj ".w:netrw_bannercnt.",$d _" |
5734 | 9975 |
9976 "......................................... | |
9977 if w:netrw_method == 2 || w:netrw_method == 5 " {{{3 | |
9978 " ftp + <.netrc>: Method #2 | |
9979 if a:path != "" | |
6476 | 9980 NetrwKeepj put ='cd \"'.a:path.'\"' |
5734 | 9981 endif |
9982 if exists("g:netrw_ftpextracmd") | |
6476 | 9983 NetrwKeepj put =g:netrw_ftpextracmd |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9984 " call Decho("filter input: ".getline('.'),'~'.expand("<slnum>")) |
5734 | 9985 endif |
6476 | 9986 NetrwKeepj call setline(line("$")+1,a:listcmd) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9987 " exe "NetrwKeepj ".w:netrw_bannercnt.',$g/^./call Decho("ftp#".line(".").": ".getline("."),''~''.expand("<slnum>"))' |
5734 | 9988 if exists("g:netrw_port") && g:netrw_port != "" |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9989 " call Decho("exe ".s:netrw_silentxfer.w:netrw_bannercnt.",$!".s:netrw_ftp_cmd." -i ".s:ShellEscape(g:netrw_machine,1)." ".s:ShellEscape(g:netrw_port,1),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9990 exe s:netrw_silentxfer." NetrwKeepj ".w:netrw_bannercnt.",$!".s:netrw_ftp_cmd." -i ".s:ShellEscape(g:netrw_machine,1)." ".s:ShellEscape(g:netrw_port,1) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9991 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9992 " call Decho("exe ".s:netrw_silentxfer.w:netrw_bannercnt.",$!".s:netrw_ftp_cmd." -i ".s:ShellEscape(g:netrw_machine,1),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
9993 exe s:netrw_silentxfer." NetrwKeepj ".w:netrw_bannercnt.",$!".s:netrw_ftp_cmd." -i ".s:ShellEscape(g:netrw_machine,1) |
5734 | 9994 endif |
9995 | |
9996 "......................................... | |
9997 elseif w:netrw_method == 3 " {{{3 | |
9998 " ftp + machine,id,passwd,filename: Method #3 | |
9999 setl ff=unix | |
10000 if exists("g:netrw_port") && g:netrw_port != "" | |
6476 | 10001 NetrwKeepj put ='open '.g:netrw_machine.' '.g:netrw_port |
5734 | 10002 else |
6476 | 10003 NetrwKeepj put ='open '.g:netrw_machine |
5734 | 10004 endif |
10005 | |
10006 " handle userid and password | |
10007 let host= substitute(g:netrw_machine,'\..*$','','') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10008 " call Decho("host<".host.">",'~'.expand("<slnum>")) |
5734 | 10009 if exists("s:netrw_hup") && exists("s:netrw_hup[host]") |
10010 call NetUserPass("ftp:".host) | |
10011 endif | |
10012 if exists("g:netrw_uid") && g:netrw_uid != "" | |
10013 if exists("g:netrw_ftp") && g:netrw_ftp == 1 | |
6476 | 10014 NetrwKeepj put =g:netrw_uid |
5734 | 10015 if exists("s:netrw_passwd") && s:netrw_passwd != "" |
6476 | 10016 NetrwKeepj put ='\"'.s:netrw_passwd.'\"' |
5734 | 10017 endif |
10018 elseif exists("s:netrw_passwd") | |
6476 | 10019 NetrwKeepj put ='user \"'.g:netrw_uid.'\" \"'.s:netrw_passwd.'\"' |
5734 | 10020 endif |
10021 endif | |
10022 | |
10023 if a:path != "" | |
6476 | 10024 NetrwKeepj put ='cd \"'.a:path.'\"' |
5734 | 10025 endif |
10026 if exists("g:netrw_ftpextracmd") | |
6476 | 10027 NetrwKeepj put =g:netrw_ftpextracmd |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10028 " call Decho("filter input: ".getline('.'),'~'.expand("<slnum>")) |
5734 | 10029 endif |
6476 | 10030 NetrwKeepj call setline(line("$")+1,a:listcmd) |
5734 | 10031 |
10032 " perform ftp: | |
10033 " -i : turns off interactive prompting from ftp | |
10034 " -n unix : DON'T use <.netrc>, even though it exists | |
10035 " -n win32: quit being obnoxious about password | |
10036 if exists("w:netrw_bannercnt") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10037 " exe w:netrw_bannercnt.',$g/^./call Decho("ftp#".line(".").": ".getline("."),''~''.expand("<slnum>"))' |
6476 | 10038 call s:NetrwExe(s:netrw_silentxfer.w:netrw_bannercnt.",$!".s:netrw_ftp_cmd." ".g:netrw_ftp_options) |
5734 | 10039 " else " Decho |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10040 " call Decho("WARNING: w:netrw_bannercnt doesn't exist!",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10041 " g/^./call Decho("SKIPPING ftp#".line(".").": ".getline("."),'~'.expand("<slnum>")) |
5734 | 10042 endif |
10043 | |
10044 "......................................... | |
10045 elseif w:netrw_method == 9 " {{{3 | |
10046 " sftp username@machine: Method #9 | |
10047 " s:netrw_sftp_cmd | |
10048 setl ff=unix | |
10049 | |
10050 " restore settings | |
10051 let &ff= ffkeep | |
10052 " call Dret("NetrwRemoteFtpCmd") | |
10053 return | |
10054 | |
10055 "......................................... | |
10056 else " {{{3 | |
6476 | 10057 NetrwKeepj call netrw#ErrorMsg(s:WARNING,"unable to comply with your request<" . bufname("%") . ">",23) |
5734 | 10058 endif |
10059 | |
10060 " cleanup for Windows " {{{3 | |
10061 if has("win32") || has("win95") || has("win64") || has("win16") | |
6476 | 10062 sil! NetrwKeepj %s/\r$//e |
10063 NetrwKeepj call histdel("/",-1) | |
5734 | 10064 endif |
10065 if a:listcmd == "dir" | |
10066 " infer directory/link based on the file permission string | |
6476 | 10067 sil! NetrwKeepj g/d\%([-r][-w][-x]\)\{3}/NetrwKeepj s@$@/@e |
10068 sil! NetrwKeepj g/l\%([-r][-w][-x]\)\{3}/NetrwKeepj s/$/@/e | |
10069 NetrwKeepj call histdel("/",-1) | |
10070 NetrwKeepj call histdel("/",-1) | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10071 if w:netrw_liststyle == s:THINLIST || w:netrw_liststyle == s:WIDELIST || (exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST) |
6476 | 10072 exe "sil! NetrwKeepj ".w:netrw_bannercnt.',$s/^\%(\S\+\s\+\)\{8}//e' |
10073 NetrwKeepj call histdel("/",-1) | |
5734 | 10074 endif |
10075 endif | |
10076 | |
10077 " ftp's listing doesn't seem to include ./ or ../ " {{{3 | |
10078 if !search('^\.\/$\|\s\.\/$','wn') | |
6476 | 10079 exe 'NetrwKeepj '.w:netrw_bannercnt |
10080 NetrwKeepj put ='./' | |
5734 | 10081 endif |
10082 if !search('^\.\.\/$\|\s\.\.\/$','wn') | |
6476 | 10083 exe 'NetrwKeepj '.w:netrw_bannercnt |
10084 NetrwKeepj put ='../' | |
5734 | 10085 endif |
10086 | |
10087 " restore settings " {{{3 | |
10088 let &ff= ffkeep | |
10089 " call Dret("NetrwRemoteFtpCmd") | |
10090 endfun | |
10091 | |
10092 " --------------------------------------------------------------------- | |
1621 | 10093 " s:NetrwRemoteListing: {{{2 |
10094 fun! s:NetrwRemoteListing() | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10095 " call Dfunc("s:NetrwRemoteListing() b:netrw_curdir<".b:netrw_curdir.">) win#".winnr()) |
1621 | 10096 |
5734 | 10097 if !exists("w:netrw_bannercnt") && exists("s:bannercnt") |
10098 let w:netrw_bannercnt= s:bannercnt | |
10099 endif | |
10100 if !exists("w:netrw_bannercnt") && exists("b:bannercnt") | |
10101 let w:netrw_bannercnt= s:bannercnt | |
10102 endif | |
10103 | |
1621 | 10104 call s:RemotePathAnalysis(b:netrw_curdir) |
10105 | |
10106 " sanity check: | |
10107 if exists("b:netrw_method") && b:netrw_method =~ '[235]' | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10108 " call Decho("b:netrw_method=".b:netrw_method,'~'.expand("<slnum>")) |
1621 | 10109 if !executable("ftp") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10110 " call Decho("ftp is not executable",'~'.expand("<slnum>")) |
1621 | 10111 if !exists("g:netrw_quiet") |
10112 call netrw#ErrorMsg(s:ERROR,"this system doesn't support remote directory listing via ftp",18) | |
10113 endif | |
17433 | 10114 call s:NetrwOptionsRestore("w:") |
5734 | 10115 " call Dret("s:NetrwRemoteListing -1") |
10116 return -1 | |
1621 | 10117 endif |
10118 | |
5618 | 10119 elseif !exists("g:netrw_list_cmd") || g:netrw_list_cmd == '' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10120 " call Decho("g:netrw_list_cmd<",(exists("g:netrw_list_cmd")? 'n/a' : "-empty-").">",'~'.expand("<slnum>")) |
1621 | 10121 if !exists("g:netrw_quiet") |
5618 | 10122 if g:netrw_list_cmd == "" |
6476 | 10123 NetrwKeepj call netrw#ErrorMsg(s:ERROR,"your g:netrw_list_cmd is empty; perhaps ".g:netrw_ssh_cmd." is not executable on your system",47) |
1621 | 10124 else |
6476 | 10125 NetrwKeepj call netrw#ErrorMsg(s:ERROR,"this system doesn't support remote directory listing via ".g:netrw_list_cmd,19) |
10126 endif | |
10127 endif | |
10128 | |
17433 | 10129 NetrwKeepj call s:NetrwOptionsRestore("w:") |
5734 | 10130 " call Dret("s:NetrwRemoteListing -1") |
10131 return -1 | |
1621 | 10132 endif " (remote handling sanity check) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10133 " call Decho("passed remote listing sanity checks",'~'.expand("<slnum>")) |
1621 | 10134 |
10135 if exists("b:netrw_method") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10136 " call Decho("setting w:netrw_method to b:netrw_method<".b:netrw_method.">",'~'.expand("<slnum>")) |
1621 | 10137 let w:netrw_method= b:netrw_method |
10138 endif | |
10139 | |
5929 | 10140 if s:method == "ftp" |
2751 | 10141 " use ftp to get remote file listing {{{3 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10142 " call Decho("use ftp to get remote file listing",'~'.expand("<slnum>")) |
5618 | 10143 let s:method = "ftp" |
10144 let listcmd = g:netrw_ftp_list_cmd | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10145 if g:netrw_sort_by =~# '^t' |
1621 | 10146 let listcmd= g:netrw_ftp_timelist_cmd |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10147 elseif g:netrw_sort_by =~# '^s' |
1621 | 10148 let listcmd= g:netrw_ftp_sizelist_cmd |
10149 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10150 " call Decho("listcmd<".listcmd."> (using g:netrw_ftp_list_cmd)",'~'.expand("<slnum>")) |
1621 | 10151 call s:NetrwRemoteFtpCmd(s:path,listcmd) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10152 " exe "sil! keepalt NetrwKeepj ".w:netrw_bannercnt.',$g/^./call Decho("raw listing: ".getline("."),''~''.expand("<slnum>"))' |
1621 | 10153 |
5734 | 10154 " report on missing file or directory messages |
10155 if search('[Nn]o such file or directory\|Failed to change directory') | |
10156 let mesg= getline(".") | |
10157 if exists("w:netrw_bannercnt") | |
10158 setl ma | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10159 exe w:netrw_bannercnt.",$d _" |
5734 | 10160 setl noma |
10161 endif | |
17433 | 10162 NetrwKeepj call s:NetrwOptionsRestore("w:") |
5734 | 10163 call netrw#ErrorMsg(s:WARNING,mesg,96) |
10164 " call Dret("s:NetrwRemoteListing : -1") | |
10165 return -1 | |
10166 endif | |
10167 | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10168 if w:netrw_liststyle == s:THINLIST || w:netrw_liststyle == s:WIDELIST || (exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST) |
1621 | 10169 " shorten the listing |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10170 " call Decho("generate short listing",'~'.expand("<slnum>")) |
6476 | 10171 exe "sil! keepalt NetrwKeepj ".w:netrw_bannercnt |
1621 | 10172 |
10173 " cleanup | |
10174 if g:netrw_ftp_browse_reject != "" | |
6476 | 10175 exe "sil! keepalt NetrwKeepj g/".g:netrw_ftp_browse_reject."/NetrwKeepj d" |
10176 NetrwKeepj call histdel("/",-1) | |
10177 endif | |
10178 sil! NetrwKeepj %s/\r$//e | |
10179 NetrwKeepj call histdel("/",-1) | |
1621 | 10180 |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
10181 " if there's no ../ listed, then put ../ in |
1621 | 10182 let line1= line(".") |
6476 | 10183 exe "sil! NetrwKeepj ".w:netrw_bannercnt |
3920 | 10184 let line2= search('\.\.\/\%(\s\|$\)','cnW') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10185 " call Decho("search(".'\.\.\/\%(\s\|$\)'."','cnW')=".line2." w:netrw_bannercnt=".w:netrw_bannercnt,'~'.expand("<slnum>")) |
1621 | 10186 if line2 == 0 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10187 " call Decho("netrw is putting ../ into listing",'~'.expand("<slnum>")) |
6476 | 10188 sil! NetrwKeepj put='../' |
10189 endif | |
10190 exe "sil! NetrwKeepj ".line1 | |
10191 sil! NetrwKeepj norm! 0 | |
1621 | 10192 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10193 " call Decho("line1=".line1." line2=".line2." line(.)=".line("."),'~'.expand("<slnum>")) |
1621 | 10194 if search('^\d\{2}-\d\{2}-\d\{2}\s','n') " M$ ftp site cleanup |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10195 " call Decho("M$ ftp cleanup",'~'.expand("<slnum>")) |
6476 | 10196 exe 'sil! NetrwKeepj '.w:netrw_bannercnt.',$s/^\d\{2}-\d\{2}-\d\{2}\s\+\d\+:\d\+[AaPp][Mm]\s\+\%(<DIR>\|\d\+\)\s\+//' |
10197 NetrwKeepj call histdel("/",-1) | |
1621 | 10198 else " normal ftp cleanup |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10199 " call Decho("normal ftp cleanup",'~'.expand("<slnum>")) |
6476 | 10200 exe 'sil! NetrwKeepj '.w:netrw_bannercnt.',$s/^\(\%(\S\+\s\+\)\{7}\S\+\)\s\+\(\S.*\)$/\2/e' |
10201 exe "sil! NetrwKeepj ".w:netrw_bannercnt.',$g/ -> /s# -> .*/$#/#e' | |
10202 exe "sil! NetrwKeepj ".w:netrw_bannercnt.',$g/ -> /s# -> .*$#/#e' | |
10203 NetrwKeepj call histdel("/",-1) | |
10204 NetrwKeepj call histdel("/",-1) | |
10205 NetrwKeepj call histdel("/",-1) | |
1621 | 10206 endif |
10207 endif | |
10208 | |
5929 | 10209 else |
1621 | 10210 " use ssh to get remote file listing {{{3 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10211 " call Decho("use ssh to get remote file listing: s:path<".s:path.">",'~'.expand("<slnum>")) |
1621 | 10212 let listcmd= s:MakeSshCmd(g:netrw_list_cmd) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10213 " call Decho("listcmd<".listcmd."> (using g:netrw_list_cmd)",'~'.expand("<slnum>")) |
1621 | 10214 if g:netrw_scp_cmd =~ '^pscp' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10215 " call Decho("1: exe r! ".s:ShellEscape(listcmd.s:path, 1),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10216 exe "NetrwKeepj r! ".listcmd.s:ShellEscape(s:path, 1) |
1621 | 10217 " remove rubbish and adjust listing format of 'pscp' to 'ssh ls -FLa' like |
6476 | 10218 sil! NetrwKeepj g/^Listing directory/NetrwKeepj d |
10219 sil! NetrwKeepj g/^d[-rwx][-rwx][-rwx]/NetrwKeepj s+$+/+e | |
10220 sil! NetrwKeepj g/^l[-rwx][-rwx][-rwx]/NetrwKeepj s+$+@+e | |
10221 NetrwKeepj call histdel("/",-1) | |
10222 NetrwKeepj call histdel("/",-1) | |
10223 NetrwKeepj call histdel("/",-1) | |
1621 | 10224 if g:netrw_liststyle != s:LONGLIST |
6476 | 10225 sil! NetrwKeepj g/^[dlsp-][-rwx][-rwx][-rwx]/NetrwKeepj s/^.*\s\(\S\+\)$/\1/e |
10226 NetrwKeepj call histdel("/",-1) | |
1621 | 10227 endif |
10228 else | |
10229 if s:path == "" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10230 " call Decho("2: exe r! ".listcmd,'~'.expand("<slnum>")) |
6476 | 10231 exe "NetrwKeepj keepalt r! ".listcmd |
1621 | 10232 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10233 " call Decho("3: exe r! ".listcmd.' '.s:ShellEscape(fnameescape(s:path),1),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10234 exe "NetrwKeepj keepalt r! ".listcmd.' '.s:ShellEscape(fnameescape(s:path),1) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10235 " call Decho("listcmd<".listcmd."> path<".s:path.">",'~'.expand("<slnum>")) |
1621 | 10236 endif |
10237 endif | |
10238 | |
10239 " cleanup | |
5734 | 10240 if g:netrw_ssh_browse_reject != "" |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10241 " call Decho("cleanup: exe sil! g/".g:netrw_ssh_browse_reject."/NetrwKeepj d",'~'.expand("<slnum>")) |
6476 | 10242 exe "sil! g/".g:netrw_ssh_browse_reject."/NetrwKeepj d" |
10243 NetrwKeepj call histdel("/",-1) | |
1621 | 10244 endif |
10245 endif | |
10246 | |
10247 if w:netrw_liststyle == s:LONGLIST | |
10248 " do a long listing; these substitutions need to be done prior to sorting {{{3 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10249 " call Decho("fix long listing:",'~'.expand("<slnum>")) |
1621 | 10250 |
10251 if s:method == "ftp" | |
10252 " cleanup | |
6476 | 10253 exe "sil! NetrwKeepj ".w:netrw_bannercnt |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10254 while getline('.') =~# g:netrw_ftp_browse_reject |
6476 | 10255 sil! NetrwKeepj d |
1621 | 10256 endwhile |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
10257 " if there's no ../ listed, then put ../ in |
1621 | 10258 let line1= line(".") |
6476 | 10259 sil! NetrwKeepj 1 |
10260 sil! NetrwKeepj call search('^\.\.\/\%(\s\|$\)','W') | |
1621 | 10261 let line2= line(".") |
10262 if line2 == 0 | |
10263 if b:netrw_curdir != '/' | |
6476 | 10264 exe 'sil! NetrwKeepj '.w:netrw_bannercnt."put='../'" |
10265 endif | |
10266 endif | |
10267 exe "sil! NetrwKeepj ".line1 | |
10268 sil! NetrwKeepj norm! 0 | |
1621 | 10269 endif |
10270 | |
10271 if search('^\d\{2}-\d\{2}-\d\{2}\s','n') " M$ ftp site cleanup | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10272 " call Decho("M$ ftp site listing cleanup",'~'.expand("<slnum>")) |
6476 | 10273 exe 'sil! NetrwKeepj '.w:netrw_bannercnt.',$s/^\(\d\{2}-\d\{2}-\d\{2}\s\+\d\+:\d\+[AaPp][Mm]\s\+\%(<DIR>\|\d\+\)\s\+\)\(\w.*\)$/\2\t\1/' |
1621 | 10274 elseif exists("w:netrw_bannercnt") && w:netrw_bannercnt <= line("$") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10275 " call Decho("normal ftp site listing cleanup: bannercnt=".w:netrw_bannercnt." line($)=".line("$"),'~'.expand("<slnum>")) |
6476 | 10276 exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$s/ -> .*$//e' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10277 exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$s/^\(\%(\S\+\s\+\)\{7}\S\+\)\s\+\(\S.*\)$/\2 \t\1/e' |
6476 | 10278 exe 'sil NetrwKeepj '.w:netrw_bannercnt |
10279 NetrwKeepj call histdel("/",-1) | |
10280 NetrwKeepj call histdel("/",-1) | |
10281 NetrwKeepj call histdel("/",-1) | |
1621 | 10282 endif |
10283 endif | |
10284 | |
10285 " if exists("w:netrw_bannercnt") && w:netrw_bannercnt <= line("$") " Decho | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10286 " exe "NetrwKeepj ".w:netrw_bannercnt.',$g/^./call Decho("listing: ".getline("."),''~''.expand("<slnum>"))' |
1621 | 10287 " endif " Decho |
5734 | 10288 |
10289 " call Dret("s:NetrwRemoteListing 0") | |
10290 return 0 | |
1621 | 10291 endfun |
10292 | |
10293 " --------------------------------------------------------------------- | |
10294 " s:NetrwRemoteRm: remove/delete a remote file or directory {{{2 | |
10295 fun! s:NetrwRemoteRm(usrhost,path) range | |
10296 " call Dfunc("s:NetrwRemoteRm(usrhost<".a:usrhost."> path<".a:path.">) virtcol=".virtcol(".")) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10297 " call Decho("firstline=".a:firstline." lastline=".a:lastline,'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10298 let svpos= winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10299 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
1621 | 10300 |
10301 let all= 0 | |
10302 if exists("s:netrwmarkfilelist_{bufnr('%')}") | |
10303 " remove all marked files | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10304 " call Decho("remove all marked files with bufnr#".bufnr("%"),'~'.expand("<slnum>")) |
1621 | 10305 for fname in s:netrwmarkfilelist_{bufnr("%")} |
10306 let ok= s:NetrwRemoteRmFile(a:path,fname,all) | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10307 if ok =~# 'q\%[uit]' |
1621 | 10308 break |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10309 elseif ok =~# 'a\%[ll]' |
1621 | 10310 let all= 1 |
10311 endif | |
10312 endfor | |
2034 | 10313 call s:NetrwUnmarkList(bufnr("%"),b:netrw_curdir) |
1621 | 10314 |
10315 else | |
10316 " remove files specified by range | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10317 " call Decho("remove files specified by range",'~'.expand("<slnum>")) |
1621 | 10318 |
10319 " preparation for removing multiple files/directories | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10320 let keepsol = &l:sol |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10321 setl nosol |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10322 let ctr = a:firstline |
1621 | 10323 |
10324 " remove multiple files and directories | |
10325 while ctr <= a:lastline | |
6476 | 10326 exe "NetrwKeepj ".ctr |
1621 | 10327 let ok= s:NetrwRemoteRmFile(a:path,s:NetrwGetWord(),all) |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10328 if ok =~# 'q\%[uit]' |
1621 | 10329 break |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10330 elseif ok =~# 'a\%[ll]' |
1621 | 10331 let all= 1 |
10332 endif | |
10333 let ctr= ctr + 1 | |
10334 endwhile | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10335 let &l:sol = keepsol |
1621 | 10336 endif |
10337 | |
10338 " refresh the (remote) directory listing | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10339 " call Decho("refresh remote directory listing",'~'.expand("<slnum>")) |
6476 | 10340 NetrwKeepj call s:NetrwRefresh(0,s:NetrwBrowseChgDir(0,'./')) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10341 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10342 NetrwKeepj call winrestview(svpos) |
1621 | 10343 |
10344 " call Dret("s:NetrwRemoteRm") | |
1121 | 10345 endfun |
10346 | |
10347 " --------------------------------------------------------------------- | |
1621 | 10348 " s:NetrwRemoteRmFile: {{{2 |
10349 fun! s:NetrwRemoteRmFile(path,rmfile,all) | |
10350 " call Dfunc("s:NetrwRemoteRmFile(path<".a:path."> rmfile<".a:rmfile.">) all=".a:all) | |
10351 | |
10352 let all= a:all | |
10353 let ok = "" | |
10354 | |
10355 if a:rmfile !~ '^"' && (a:rmfile =~ '@$' || a:rmfile !~ '[\/]$') | |
10356 " attempt to remove file | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10357 " call Decho("attempt to remove file (all=".all.")",'~'.expand("<slnum>")) |
1621 | 10358 if !all |
10359 echohl Statement | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10360 " call Decho("case all=0:",'~'.expand("<slnum>")) |
1621 | 10361 call inputsave() |
10362 let ok= input("Confirm deletion of file<".a:rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ") | |
10363 call inputrestore() | |
10364 echohl NONE | |
10365 if ok == "" | |
10366 let ok="no" | |
10367 endif | |
10368 let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e') | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10369 if ok =~# 'a\%[ll]' |
1621 | 10370 let all= 1 |
10371 endif | |
10372 endif | |
10373 | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10374 if all || ok =~# 'y\%[es]' || ok == "" |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10375 " call Decho("case all=".all." or ok<".ok.">".(exists("w:netrw_method")? ': netrw_method='.w:netrw_method : ""),'~'.expand("<slnum>")) |
1621 | 10376 if exists("w:netrw_method") && (w:netrw_method == 2 || w:netrw_method == 3) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10377 " call Decho("case ftp:",'~'.expand("<slnum>")) |
1621 | 10378 let path= a:path |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10379 if path =~ '^\a\{3,}://' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10380 let path= substitute(path,'^\a\{3,}://[^/]\+/','','') |
1621 | 10381 endif |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10382 sil! NetrwKeepj .,$d _ |
1621 | 10383 call s:NetrwRemoteFtpCmd(path,"delete ".'"'.a:rmfile.'"') |
10384 else | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10385 " call Decho("case ssh: g:netrw_rm_cmd<".g:netrw_rm_cmd.">",'~'.expand("<slnum>")) |
1621 | 10386 let netrw_rm_cmd= s:MakeSshCmd(g:netrw_rm_cmd) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10387 " call Decho("netrw_rm_cmd<".netrw_rm_cmd.">",'~'.expand("<slnum>")) |
1621 | 10388 if !exists("b:netrw_curdir") |
6476 | 10389 NetrwKeepj call netrw#ErrorMsg(s:ERROR,"for some reason b:netrw_curdir doesn't exist!",53) |
1621 | 10390 let ok="q" |
10391 else | |
10392 let remotedir= substitute(b:netrw_curdir,'^.*//[^/]\+/\(.*\)$','\1','') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10393 " call Decho("netrw_rm_cmd<".netrw_rm_cmd.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10394 " call Decho("remotedir<".remotedir.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10395 " call Decho("rmfile<".a:rmfile.">",'~'.expand("<slnum>")) |
1621 | 10396 if remotedir != "" |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10397 let netrw_rm_cmd= netrw_rm_cmd." ".s:ShellEscape(fnameescape(remotedir.a:rmfile)) |
1621 | 10398 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10399 let netrw_rm_cmd= netrw_rm_cmd." ".s:ShellEscape(fnameescape(a:rmfile)) |
1621 | 10400 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10401 " call Decho("call system(".netrw_rm_cmd.")",'~'.expand("<slnum>")) |
1621 | 10402 let ret= system(netrw_rm_cmd) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10403 if v:shell_error != 0 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10404 if exists("b:netrw_curdir") && b:netrw_curdir != getcwd() && !g:netrw_keepdir |
17433 | 10405 call netrw#ErrorMsg(s:ERROR,"remove failed; perhaps due to vim's current directory<".getcwd()."> not matching netrw's (".b:netrw_curdir.") (see :help netrw-cd)",102) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10406 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10407 call netrw#ErrorMsg(s:WARNING,"cmd<".netrw_rm_cmd."> failed",60) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10408 endif |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10409 elseif ret != 0 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10410 call netrw#ErrorMsg(s:WARNING,"cmd<".netrw_rm_cmd."> failed",60) |
1621 | 10411 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10412 " call Decho("returned=".ret." errcode=".v:shell_error,'~'.expand("<slnum>")) |
1621 | 10413 endif |
10414 endif | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10415 elseif ok =~# 'q\%[uit]' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10416 " call Decho("ok==".ok,'~'.expand("<slnum>")) |
1621 | 10417 endif |
10418 | |
10419 else | |
10420 " attempt to remove directory | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10421 " call Decho("attempt to remove directory",'~'.expand("<slnum>")) |
1621 | 10422 if !all |
10423 call inputsave() | |
10424 let ok= input("Confirm deletion of directory<".a:rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ") | |
10425 call inputrestore() | |
10426 if ok == "" | |
10427 let ok="no" | |
10428 endif | |
10429 let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e') | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10430 if ok =~# 'a\%[ll]' |
1621 | 10431 let all= 1 |
10432 endif | |
10433 endif | |
10434 | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10435 if all || ok =~# 'y\%[es]' || ok == "" |
1621 | 10436 if exists("w:netrw_method") && (w:netrw_method == 2 || w:netrw_method == 3) |
6476 | 10437 NetrwKeepj call s:NetrwRemoteFtpCmd(a:path,"rmdir ".a:rmfile) |
1621 | 10438 else |
10439 let rmfile = substitute(a:path.a:rmfile,'/$','','') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10440 let netrw_rmdir_cmd = s:MakeSshCmd(netrw#WinPath(g:netrw_rmdir_cmd)).' '.s:ShellEscape(netrw#WinPath(rmfile)) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10441 " call Decho("attempt to remove dir: system(".netrw_rmdir_cmd.")",'~'.expand("<slnum>")) |
1668 | 10442 let ret= system(netrw_rmdir_cmd) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10443 " call Decho("returned=".ret." errcode=".v:shell_error,'~'.expand("<slnum>")) |
1621 | 10444 |
10445 if v:shell_error != 0 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10446 " call Decho("v:shell_error not 0",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10447 let netrw_rmf_cmd= s:MakeSshCmd(netrw#WinPath(g:netrw_rmf_cmd)).' '.s:ShellEscape(netrw#WinPath(substitute(rmfile,'[\/]$','','e'))) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10448 " call Decho("2nd attempt to remove dir: system(".netrw_rmf_cmd.")",'~'.expand("<slnum>")) |
1668 | 10449 let ret= system(netrw_rmf_cmd) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10450 " call Decho("returned=".ret." errcode=".v:shell_error,'~'.expand("<slnum>")) |
1621 | 10451 |
10452 if v:shell_error != 0 && !exists("g:netrw_quiet") | |
6476 | 10453 NetrwKeepj call netrw#ErrorMsg(s:ERROR,"unable to remove directory<".rmfile."> -- is it empty?",22) |
1621 | 10454 endif |
10455 endif | |
10456 endif | |
10457 | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10458 elseif ok =~# 'q\%[uit]' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10459 " call Decho("ok==".ok,'~'.expand("<slnum>")) |
1621 | 10460 endif |
10461 endif | |
10462 | |
10463 " call Dret("s:NetrwRemoteRmFile ".ok) | |
10464 return ok | |
10465 endfun | |
10466 | |
10467 " --------------------------------------------------------------------- | |
10468 " s:NetrwRemoteRename: rename a remote file or directory {{{2 | |
10469 fun! s:NetrwRemoteRename(usrhost,path) range | |
10470 " call Dfunc("NetrwRemoteRename(usrhost<".a:usrhost."> path<".a:path.">)") | |
10471 | |
10472 " preparation for removing multiple files/directories | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10473 let svpos = winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10474 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
1621 | 10475 let ctr = a:firstline |
10476 let rename_cmd = s:MakeSshCmd(g:netrw_rename_cmd) | |
10477 | |
10478 " rename files given by the markfilelist | |
10479 if exists("s:netrwmarkfilelist_{bufnr('%')}") | |
10480 for oldname in s:netrwmarkfilelist_{bufnr("%")} | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10481 " call Decho("oldname<".oldname.">",'~'.expand("<slnum>")) |
1621 | 10482 if exists("subfrom") |
10483 let newname= substitute(oldname,subfrom,subto,'') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10484 " call Decho("subfrom<".subfrom."> subto<".subto."> newname<".newname.">",'~'.expand("<slnum>")) |
1621 | 10485 else |
10486 call inputsave() | |
10487 let newname= input("Moving ".oldname." to : ",oldname) | |
10488 call inputrestore() | |
10489 if newname =~ '^s/' | |
10490 let subfrom = substitute(newname,'^s/\([^/]*\)/.*/$','\1','') | |
10491 let subto = substitute(newname,'^s/[^/]*/\(.*\)/$','\1','') | |
10492 let newname = substitute(oldname,subfrom,subto,'') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10493 " call Decho("subfrom<".subfrom."> subto<".subto."> newname<".newname.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10494 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10495 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10496 |
1621 | 10497 if exists("w:netrw_method") && (w:netrw_method == 2 || w:netrw_method == 3) |
6476 | 10498 NetrwKeepj call s:NetrwRemoteFtpCmd(a:path,"rename ".oldname." ".newname) |
1621 | 10499 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10500 let oldname= s:ShellEscape(a:path.oldname) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10501 let newname= s:ShellEscape(a:path.newname) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10502 " call Decho("system(netrw#WinPath(".rename_cmd.") ".oldname.' '.newname.")",'~'.expand("<slnum>")) |
2034 | 10503 let ret = system(netrw#WinPath(rename_cmd).' '.oldname.' '.newname) |
1621 | 10504 endif |
10505 | |
10506 endfor | |
10507 call s:NetrwUnMarkFile(1) | |
10508 | |
10509 else | |
10510 | |
10511 " attempt to rename files/directories | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10512 let keepsol= &l:sol |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10513 setl nosol |
1621 | 10514 while ctr <= a:lastline |
6476 | 10515 exe "NetrwKeepj ".ctr |
1621 | 10516 |
10517 let oldname= s:NetrwGetWord() | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10518 " call Decho("oldname<".oldname.">",'~'.expand("<slnum>")) |
1621 | 10519 |
10520 call inputsave() | |
10521 let newname= input("Moving ".oldname." to : ",oldname) | |
10522 call inputrestore() | |
10523 | |
10524 if exists("w:netrw_method") && (w:netrw_method == 2 || w:netrw_method == 3) | |
10525 call s:NetrwRemoteFtpCmd(a:path,"rename ".oldname." ".newname) | |
10526 else | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10527 let oldname= s:ShellEscape(a:path.oldname) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10528 let newname= s:ShellEscape(a:path.newname) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10529 " call Decho("system(netrw#WinPath(".rename_cmd.") ".oldname.' '.newname.")",'~'.expand("<slnum>")) |
2034 | 10530 let ret = system(netrw#WinPath(rename_cmd).' '.oldname.' '.newname) |
1621 | 10531 endif |
10532 | |
10533 let ctr= ctr + 1 | |
10534 endwhile | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10535 let &l:sol= keepsol |
1621 | 10536 endif |
10537 | |
10538 " refresh the directory | |
6476 | 10539 NetrwKeepj call s:NetrwRefresh(0,s:NetrwBrowseChgDir(0,'./')) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10540 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10541 NetrwKeepj call winrestview(svpos) |
1621 | 10542 |
10543 " call Dret("NetrwRemoteRename") | |
10544 endfun | |
10545 | |
17433 | 10546 " ========================================== |
1621 | 10547 " Local Directory Browsing Support: {{{1 |
10548 " ========================================== | |
10549 | |
10550 " --------------------------------------------------------------------- | |
17433 | 10551 " netrw#FileUrlEdit: handles editing file://* files {{{2 |
3920 | 10552 " Should accept: file://localhost/etc/fstab |
10553 " file:///etc/fstab | |
10554 " file:///c:/WINDOWS/clock.avi | |
10555 " file:///c|/WINDOWS/clock.avi | |
10556 " file://localhost/c:/WINDOWS/clock.avi | |
10557 " file://localhost/c|/WINDOWS/clock.avi | |
10558 " file://c:/foo.txt | |
10559 " file:///c:/foo.txt | |
10560 " and %XX (where X is [0-9a-fA-F] is converted into a character with the given hexadecimal value | |
17433 | 10561 fun! netrw#FileUrlEdit(fname) |
10562 " call Dfunc("netrw#FileUrlEdit(fname<".a:fname.">)") | |
3920 | 10563 let fname = a:fname |
10564 if fname =~ '^file://localhost/' | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10565 " call Decho('converting file://localhost/ -to- file:///','~'.expand("<slnum>")) |
3920 | 10566 let fname= substitute(fname,'^file://localhost/','file:///','') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10567 " call Decho("fname<".fname.">",'~'.expand("<slnum>")) |
3920 | 10568 endif |
10569 if (has("win32") || has("win95") || has("win64") || has("win16")) | |
10570 if fname =~ '^file:///\=\a[|:]/' | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10571 " call Decho('converting file:///\a|/ -to- file://\a:/','~'.expand("<slnum>")) |
3920 | 10572 let fname = substitute(fname,'^file:///\=\(\a\)[|:]/','file://\1:/','') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10573 " call Decho("fname<".fname.">",'~'.expand("<slnum>")) |
3920 | 10574 endif |
10575 endif | |
10576 let fname2396 = netrw#RFC2396(fname) | |
10577 let fname2396e= fnameescape(fname2396) | |
10578 let plainfname= substitute(fname2396,'file://\(.*\)','\1',"") | |
10579 if (has("win32") || has("win95") || has("win64") || has("win16")) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10580 " call Decho("windows exception for plainfname",'~'.expand("<slnum>")) |
3920 | 10581 if plainfname =~ '^/\+\a:' |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10582 " call Decho('removing leading "/"s','~'.expand("<slnum>")) |
3920 | 10583 let plainfname= substitute(plainfname,'^/\+\(\a:\)','\1','') |
10584 endif | |
10585 endif | |
17433 | 10586 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10587 " call Decho("fname2396<".fname2396.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10588 " call Decho("plainfname<".plainfname.">",'~'.expand("<slnum>")) |
3920 | 10589 exe "sil doau BufReadPre ".fname2396e |
17433 | 10590 exe 'NetrwKeepj keepalt edit '.plainfname |
10591 exe 'sil! NetrwKeepj keepalt bdelete '.fnameescape(a:fname) | |
10592 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10593 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
17433 | 10594 " call Dret("netrw#FileUrlEdit") |
3920 | 10595 exe "sil doau BufReadPost ".fname2396e |
10596 endfun | |
10597 | |
10598 " --------------------------------------------------------------------- | |
1621 | 10599 " netrw#LocalBrowseCheck: {{{2 |
10600 fun! netrw#LocalBrowseCheck(dirname) | |
17433 | 10601 " This function is called by netrwPlugin.vim's s:LocalBrowse(), s:NetrwRexplore(), |
10602 " and by <cr> when atop a listed file/directory (via a buffer-local map) | |
10603 " | |
10604 " unfortunate interaction -- split window debugging can't be used here, must use | |
10605 " D-echoRemOn or D-echoTabOn as the BufEnter event triggers | |
10606 " another call to LocalBrowseCheck() when attempts to write | |
10607 " to the DBG buffer are made. | |
10608 " | |
1621 | 10609 " The &ft == "netrw" test was installed because the BufEnter event |
10610 " would hit when re-entering netrw windows, creating unexpected | |
10611 " refreshes (and would do so in the middle of NetrwSaveOptions(), too) | |
17433 | 10612 " call Dfunc("netrw#LocalBrowseCheck(dirname<".a:dirname.">)") |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10613 " call Decho("isdir<".a:dirname."> =".isdirectory(s:NetrwFile(a:dirname)).((exists("s:treeforceredraw")? " treeforceredraw" : "")).'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10614 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("<slnum>")) |
17433 | 10615 " call Dredir("ls!","netrw#LocalBrowseCheck") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10616 " call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10617 " call Decho("current buffer#".bufnr("%")."<".bufname("%")."> ft=".&ft,'~'.expand("<slnum>")) |
5734 | 10618 |
3920 | 10619 let ykeep= @@ |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10620 if isdirectory(s:NetrwFile(a:dirname)) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10621 " call Decho("is-directory ft<".&ft."> b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : " doesn't exist")."> dirname<".a:dirname.">"." line($)=".line("$")." ft<".&ft."> g:netrw_fastbrowse=".g:netrw_fastbrowse,'~'.expand("<slnum>")) |
6476 | 10622 |
3920 | 10623 if &ft != "netrw" || (exists("b:netrw_curdir") && b:netrw_curdir != a:dirname) || g:netrw_fastbrowse <= 1 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10624 " call Decho("case 1 : ft=".&ft,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10625 " call Decho("s:rexposn_".bufnr("%")."<".bufname("%")."> ".(exists("s:rexposn_".bufnr("%"))? "exists" : "does not exist"),'~'.expand("<slnum>")) |
6476 | 10626 sil! NetrwKeepj keepalt call s:NetrwBrowse(1,a:dirname) |
5618 | 10627 |
1621 | 10628 elseif &ft == "netrw" && line("$") == 1 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10629 " call Decho("case 2 (ft≡netrw && line($)≡1)",'~'.expand("<slnum>")) |
6476 | 10630 sil! NetrwKeepj keepalt call s:NetrwBrowse(1,a:dirname) |
5618 | 10631 |
2034 | 10632 elseif exists("s:treeforceredraw") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10633 " call Decho("case 3 (treeforceredraw)",'~'.expand("<slnum>")) |
2034 | 10634 unlet s:treeforceredraw |
6476 | 10635 sil! NetrwKeepj keepalt call s:NetrwBrowse(1,a:dirname) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10636 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10637 " call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>")) |
5734 | 10638 " call Dret("netrw#LocalBrowseCheck") |
10639 return | |
5618 | 10640 endif |
10641 | |
17433 | 10642 " The following code wipes out currently unused netrw buffers |
3920 | 10643 " IF g:netrw_fastbrowse is zero (ie. slow browsing selected) |
10644 " AND IF the listing style is not a tree listing | |
10645 if exists("g:netrw_fastbrowse") && g:netrw_fastbrowse == 0 && g:netrw_liststyle != s:TREELIST | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10646 " call Decho("wiping out currently unused netrw buffers",'~'.expand("<slnum>")) |
3920 | 10647 let ibuf = 1 |
10648 let buflast = bufnr("$") | |
10649 while ibuf <= buflast | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10650 if bufwinnr(ibuf) == -1 && isdirectory(s:NetrwFile(bufname(ibuf))) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10651 exe "sil! keepj keepalt ".ibuf."bw!" |
3920 | 10652 endif |
10653 let ibuf= ibuf + 1 | |
10654 endwhile | |
10655 endif | |
10656 let @@= ykeep | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10657 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10658 " call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>")) |
1621 | 10659 " not a directory, ignore it |
5734 | 10660 " call Dret("netrw#LocalBrowseCheck : not a directory, ignoring it; dirname<".a:dirname.">") |
10661 endfun | |
10662 | |
10663 " --------------------------------------------------------------------- | |
10664 " s:LocalBrowseRefresh: this function is called after a user has {{{2 | |
1621 | 10665 " performed any shell command. The idea is to cause all local-browsing |
10666 " buffers to be refreshed after a user has executed some shell command, | |
10667 " on the chance that s/he removed/created a file/directory with it. | |
5734 | 10668 fun! s:LocalBrowseRefresh() |
10669 " call Dfunc("s:LocalBrowseRefresh() tabpagenr($)=".tabpagenr("$")) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10670 " call Decho("s:netrw_browselist =".(exists("s:netrw_browselist")? string(s:netrw_browselist) : '<n/a>'),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10671 " call Decho("w:netrw_bannercnt =".(exists("w:netrw_bannercnt")? string(w:netrw_bannercnt) : '<n/a>'),'~'.expand("<slnum>")) |
5734 | 10672 |
1621 | 10673 " determine which buffers currently reside in a tab |
10674 if !exists("s:netrw_browselist") | |
5734 | 10675 " call Dret("s:LocalBrowseRefresh : browselist is empty") |
1621 | 10676 return |
10677 endif | |
10678 if !exists("w:netrw_bannercnt") | |
5734 | 10679 " call Dret("s:LocalBrowseRefresh : don't refresh when focus not on netrw window") |
1621 | 10680 return |
10681 endif | |
5734 | 10682 if exists("s:netrw_events") && s:netrw_events == 1 |
10683 " s:LocalFastBrowser gets called (indirectly) from a | |
10684 let s:netrw_events= 2 | |
10685 " call Dret("s:LocalBrowseRefresh : avoid initial double refresh") | |
10686 return | |
2034 | 10687 endif |
1621 | 10688 let itab = 1 |
10689 let buftablist = [] | |
3920 | 10690 let ykeep = @@ |
1621 | 10691 while itab <= tabpagenr("$") |
10692 let buftablist = buftablist + tabpagebuflist() | |
10693 let itab = itab + 1 | |
17433 | 10694 sil! tabn |
482 | 10695 endwhile |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10696 " call Decho("buftablist".string(buftablist),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10697 " call Decho("s:netrw_browselist<".(exists("s:netrw_browselist")? string(s:netrw_browselist) : "").">",'~'.expand("<slnum>")) |
1621 | 10698 " GO through all buffers on netrw_browselist (ie. just local-netrw buffers): |
10699 " | refresh any netrw window | |
10700 " | wipe out any non-displaying netrw buffer | |
17433 | 10701 let curwinid = win_getid(winnr()) |
1621 | 10702 let ibl = 0 |
10703 for ibuf in s:netrw_browselist | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10704 " call Decho("bufwinnr(".ibuf.") index(buftablist,".ibuf.")=".index(buftablist,ibuf),'~'.expand("<slnum>")) |
1621 | 10705 if bufwinnr(ibuf) == -1 && index(buftablist,ibuf) == -1 |
10706 " wipe out any non-displaying netrw buffer | |
17433 | 10707 " (ibuf not shown in a current window AND |
10708 " ibuf not in any tab) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10709 " call Decho("wiping buf#".ibuf,"<".bufname(ibuf).">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10710 exe "sil! keepj bd ".fnameescape(ibuf) |
1621 | 10711 call remove(s:netrw_browselist,ibl) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10712 " call Decho("browselist=".string(s:netrw_browselist),'~'.expand("<slnum>")) |
1621 | 10713 continue |
10714 elseif index(tabpagebuflist(),ibuf) != -1 | |
10715 " refresh any netrw buffer | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10716 " call Decho("refresh buf#".ibuf.'-> win#'.bufwinnr(ibuf),'~'.expand("<slnum>")) |
1621 | 10717 exe bufwinnr(ibuf)."wincmd w" |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10718 if getline(".") =~# 'Quick Help' |
5734 | 10719 " decrement g:netrw_quickhelp to prevent refresh from changing g:netrw_quickhelp |
10720 " (counteracts s:NetrwBrowseChgDir()'s incrementing) | |
10721 let g:netrw_quickhelp= g:netrw_quickhelp - 1 | |
10722 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10723 " call Decho("#3: quickhelp=".g:netrw_quickhelp,'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10724 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10725 NetrwKeepj call s:NetrwRefreshTreeDict(w:netrw_treetop) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10726 endif |
6476 | 10727 NetrwKeepj call s:NetrwRefresh(1,s:NetrwBrowseChgDir(1,'./')) |
1621 | 10728 endif |
10729 let ibl= ibl + 1 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10730 " call Decho("bottom of s:netrw_browselist for loop: ibl=".ibl,'~'.expand("<slnum>")) |
1621 | 10731 endfor |
17433 | 10732 " call Decho("restore window: win_gotoid(".curwinid.")") |
10733 call win_gotoid(curwinid) | |
3920 | 10734 let @@= ykeep |
1621 | 10735 |
5734 | 10736 " call Dret("s:LocalBrowseRefresh") |
1621 | 10737 endfun |
10738 | |
10739 " --------------------------------------------------------------------- | |
3920 | 10740 " s:LocalFastBrowser: handles setting up/taking down fast browsing for the local browser {{{2 |
10741 " | |
10742 " g:netrw_ Directory Is | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10743 " fastbrowse Local Remote |
3920 | 10744 " slow 0 D D D=Deleting a buffer implies it will not be re-used (slow) |
10745 " med 1 D H H=Hiding a buffer implies it may be re-used (fast) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10746 " fast 2 H H |
3920 | 10747 " |
10748 " Deleting a buffer means that it will be re-loaded when examined, hence "slow". | |
10749 " Hiding a buffer means that it will be re-used when examined, hence "fast". | |
5734 | 10750 " (re-using a buffer may not be as accurate) |
10751 " | |
10752 " s:netrw_events : doesn't exist, s:LocalFastBrowser() will install autocmds whena med or fast browsing | |
10753 " =1: autocmds installed, but ignore next FocusGained event to avoid initial double-refresh of listing. | |
10754 " BufEnter may be first event, then a FocusGained event. Ignore the first FocusGained event. | |
10755 " If :Explore used: it sets s:netrw_events to 2, so no FocusGained events are ignored. | |
10756 " =2: autocmds installed (doesn't ignore any FocusGained events) | |
3920 | 10757 fun! s:LocalFastBrowser() |
17433 | 10758 " call Dfunc("s:LocalFastBrowser() g:netrw_fastbrowse=".g:netrw_fastbrowse) |
10759 " call Decho("s:netrw_events ".(exists("s:netrw_events")? "exists" : 'n/a'),'~'.expand("<slnum>")) | |
10760 " call Decho("autocmd: ShellCmdPost ".(exists("#ShellCmdPost")? "already installed" : "not installed"),'~'.expand("<slnum>")) | |
10761 " call Decho("autocmd: FocusGained ".(exists("#FocusGained")? "already installed" : "not installed"),'~'.expand("<slnum>")) | |
3920 | 10762 |
10763 " initialize browselist, a list of buffer numbers that the local browser has used | |
10764 if !exists("s:netrw_browselist") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10765 " call Decho("initialize s:netrw_browselist",'~'.expand("<slnum>")) |
3920 | 10766 let s:netrw_browselist= [] |
10767 endif | |
10768 | |
10769 " append current buffer to fastbrowse list | |
10770 if empty(s:netrw_browselist) || bufnr("%") > s:netrw_browselist[-1] | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10771 " call Decho("appendng current buffer to browselist",'~'.expand("<slnum>")) |
3920 | 10772 call add(s:netrw_browselist,bufnr("%")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10773 " call Decho("browselist=".string(s:netrw_browselist),'~'.expand("<slnum>")) |
3920 | 10774 endif |
10775 | |
10776 " enable autocmd events to handle refreshing/removing local browser buffers | |
10777 " If local browse buffer is currently showing: refresh it | |
10778 " If local browse buffer is currently hidden : wipe it | |
10779 " g:netrw_fastbrowse=0 : slow speed, never re-use directory listing | |
10780 " =1 : medium speed, re-use directory listing for remote only | |
10781 " =2 : fast speed, always re-use directory listing when possible | |
5734 | 10782 if g:netrw_fastbrowse <= 1 && !exists("#ShellCmdPost") && !exists("s:netrw_events") |
10783 let s:netrw_events= 1 | |
10784 augroup AuNetrwEvent | |
3920 | 10785 au! |
10786 if (has("win32") || has("win95") || has("win64") || has("win16")) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10787 " call Decho("installing autocmd: ShellCmdPost",'~'.expand("<slnum>")) |
5734 | 10788 au ShellCmdPost * call s:LocalBrowseRefresh() |
3920 | 10789 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10790 " call Decho("installing autocmds: ShellCmdPost FocusGained",'~'.expand("<slnum>")) |
5734 | 10791 au ShellCmdPost,FocusGained * call s:LocalBrowseRefresh() |
3920 | 10792 endif |
10793 augroup END | |
10794 | |
10795 " user must have changed fastbrowse to its fast setting, so remove | |
10796 " the associated autocmd events | |
5734 | 10797 elseif g:netrw_fastbrowse > 1 && exists("#ShellCmdPost") && exists("s:netrw_events") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10798 " call Decho("remove AuNetrwEvent autcmd group",'~'.expand("<slnum>")) |
5734 | 10799 unlet s:netrw_events |
10800 augroup AuNetrwEvent | |
3920 | 10801 au! |
10802 augroup END | |
5734 | 10803 augroup! AuNetrwEvent |
3920 | 10804 endif |
10805 | |
17433 | 10806 " call Dret("s:LocalFastBrowser : browselist<".string(s:netrw_browselist).">") |
3920 | 10807 endfun |
10808 | |
10809 " --------------------------------------------------------------------- | |
5734 | 10810 " s:LocalListing: does the job of "ls" for local directories {{{2 |
10811 fun! s:LocalListing() | |
10812 " call Dfunc("s:LocalListing()") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10813 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10814 " call Decho("modified=".&modified." modifiable=".&modifiable." readonly=".&readonly,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10815 " call Decho("tab#".tabpagenr()." win#".winnr()." buf#".bufnr("%")."<".bufname("%")."> line#".line(".")." col#".col(".")." winline#".winline()." wincol#".wincol(),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10816 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10817 " if exists("b:netrw_curdir") |call Decho('b:netrw_curdir<'.b:netrw_curdir.">") |else|call Decho("b:netrw_curdir doesn't exist",'~'.expand("<slnum>")) |endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10818 " 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",'~'.expand("<slnum>"))|endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10819 " call Decho("g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")",'~'.expand("<slnum>")) |
5734 | 10820 |
10821 " get the list of files contained in the current directory | |
10822 let dirname = b:netrw_curdir | |
10823 let dirnamelen = strlen(b:netrw_curdir) | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10824 let filelist = s:NetrwGlob(dirname,"*",0) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10825 let filelist = filelist + s:NetrwGlob(dirname,".*",0) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10826 " call Decho("filelist=".string(filelist),'~'.expand("<slnum>")) |
5734 | 10827 |
10828 if g:netrw_cygwin == 0 && (has("win32") || has("win95") || has("win64") || has("win16")) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10829 " call Decho("filelist=".string(filelist),'~'.expand("<slnum>")) |
5734 | 10830 elseif index(filelist,'..') == -1 && b:netrw_curdir !~ '/' |
10831 " include ../ in the glob() entry if its missing | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10832 " call Decho("forcibly including on \"..\"",'~'.expand("<slnum>")) |
5734 | 10833 let filelist= filelist+[s:ComposePath(b:netrw_curdir,"../")] |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10834 " call Decho("filelist=".string(filelist),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10835 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10836 |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10837 " call Decho("before while: dirname <".dirname.">",'~'.expand("<slnum>")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10838 " call Decho("before while: dirnamelen<".dirnamelen.">",'~'.expand("<slnum>")) |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10839 " call Decho("before while: filelist =".string(filelist),'~'.expand("<slnum>")) |
5734 | 10840 |
10841 if get(g:, 'netrw_dynamic_maxfilenamelen', 0) | |
10842 let filelistcopy = map(deepcopy(filelist),'fnamemodify(v:val, ":t")') | |
10843 let g:netrw_maxfilenamelen = max(map(filelistcopy,'len(v:val)')) + 1 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10844 " call Decho("dynamic_maxfilenamelen: filenames =".string(filelistcopy),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10845 " call Decho("dynamic_maxfilenamelen: g:netrw_maxfilenamelen=".g:netrw_maxfilenamelen,'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10846 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10847 " call Decho("g:netrw_banner=".g:netrw_banner.": banner ".(g:netrw_banner? "enabled" : "suppressed").": (line($)=".line("$")." byte2line(1)=".byte2line(1)." bannercnt=".w:netrw_bannercnt.")",'~'.expand("<slnum>")) |
5734 | 10848 |
10849 for filename in filelist | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10850 " call Decho(" ",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10851 " call Decho("for filename in filelist: filename<".filename.">",'~'.expand("<slnum>")) |
17433 | 10852 " call DechoBuf(bufnr("%"),"COMBAK#1") |
5734 | 10853 |
10854 if getftype(filename) == "link" | |
10855 " indicate a symbolic link | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10856 " call Decho("indicate <".filename."> is a symbolic link with trailing @",'~'.expand("<slnum>")) |
5734 | 10857 let pfile= filename."@" |
10858 | |
10859 elseif getftype(filename) == "socket" | |
10860 " indicate a socket | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10861 " call Decho("indicate <".filename."> is a socket with trailing =",'~'.expand("<slnum>")) |
5734 | 10862 let pfile= filename."=" |
10863 | |
10864 elseif getftype(filename) == "fifo" | |
10865 " indicate a fifo | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10866 " call Decho("indicate <".filename."> is a fifo with trailing |",'~'.expand("<slnum>")) |
5734 | 10867 let pfile= filename."|" |
10868 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10869 elseif isdirectory(s:NetrwFile(filename)) |
5734 | 10870 " indicate a directory |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10871 " call Decho("indicate <".filename."> is a directory with trailing /",'~'.expand("<slnum>")) |
5734 | 10872 let pfile= filename."/" |
10873 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10874 elseif exists("b:netrw_curdir") && b:netrw_curdir !~ '^.*://' && !isdirectory(s:NetrwFile(filename)) |
5734 | 10875 if (has("win32") || has("win95") || has("win64") || has("win16")) |
10876 if filename =~ '\.[eE][xX][eE]$' || filename =~ '\.[cC][oO][mM]$' || filename =~ '\.[bB][aA][tT]$' | |
10877 " indicate an executable | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10878 " call Decho("indicate <".filename."> is executable with trailing *",'~'.expand("<slnum>")) |
5734 | 10879 let pfile= filename."*" |
10880 else | |
10881 " normal file | |
10882 let pfile= filename | |
10883 endif | |
10884 elseif executable(filename) | |
10885 " indicate an executable | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10886 " call Decho("indicate <".filename."> is executable with trailing *",'~'.expand("<slnum>")) |
5734 | 10887 let pfile= filename."*" |
10888 else | |
10889 " normal file | |
10890 let pfile= filename | |
10891 endif | |
10892 | |
10893 else | |
10894 " normal file | |
10895 let pfile= filename | |
10896 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10897 " call Decho("pfile<".pfile."> (after *@/ appending)",'~'.expand("<slnum>")) |
5734 | 10898 |
10899 if pfile =~ '//$' | |
10900 let pfile= substitute(pfile,'//$','/','e') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10901 " call Decho("change // to /: pfile<".pfile.">",'~'.expand("<slnum>")) |
5734 | 10902 endif |
10903 let pfile= strpart(pfile,dirnamelen) | |
10904 let pfile= substitute(pfile,'^[/\\]','','e') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10905 " call Decho("filename<".filename.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10906 " call Decho("pfile <".pfile.">",'~'.expand("<slnum>")) |
5734 | 10907 |
10908 if w:netrw_liststyle == s:LONGLIST | |
10909 let sz = getfsize(filename) | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10910 if g:netrw_sizestyle =~# "[hH]" |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10911 let sz= s:NetrwHumanReadable(sz) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10912 endif |
17433 | 10913 let fsz = strpart(" ",1,15-strlen(sz)).sz |
10914 let longfile= printf("%-".(g:netrw_maxfilenamelen+1)."s",pfile) | |
10915 let pfile = longfile.fsz." ".strftime(g:netrw_timefmt,getftime(filename)) | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10916 " call Decho("longlist support: sz=".sz." fsz=".fsz,'~'.expand("<slnum>")) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10917 endif |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10918 |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10919 if g:netrw_sort_by =~# "^t" |
5734 | 10920 " sort by time (handles time up to 1 quintillion seconds, US) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10921 " call Decho("getftime(".filename.")=".getftime(filename),'~'.expand("<slnum>")) |
5734 | 10922 let t = getftime(filename) |
10923 let ft = strpart("000000000000000000",1,18-strlen(t)).t | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10924 " call Decho("exe NetrwKeepj put ='".ft.'/'.filename."'",'~'.expand("<slnum>")) |
5734 | 10925 let ftpfile= ft.'/'.pfile |
6476 | 10926 sil! NetrwKeepj put=ftpfile |
5734 | 10927 |
10928 elseif g:netrw_sort_by =~ "^s" | |
10929 " sort by size (handles file sizes up to 1 quintillion bytes, US) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10930 " call Decho("getfsize(".filename.")=".getfsize(filename),'~'.expand("<slnum>")) |
5734 | 10931 let sz = getfsize(filename) |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
10932 if g:netrw_sizestyle =~# "[hH]" |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10933 let sz= s:NetrwHumanReadable(sz) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10934 endif |
5734 | 10935 let fsz = strpart("000000000000000000",1,18-strlen(sz)).sz |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10936 " call Decho("exe NetrwKeepj put ='".fsz.'/'.filename."'",'~'.expand("<slnum>")) |
5734 | 10937 let fszpfile= fsz.'/'.pfile |
6476 | 10938 sil! NetrwKeepj put =fszpfile |
5734 | 10939 |
10940 else | |
10941 " sort by name | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10942 " call Decho("exe NetrwKeepj put ='".pfile."'",'~'.expand("<slnum>")) |
6476 | 10943 sil! NetrwKeepj put=pfile |
5734 | 10944 endif |
17433 | 10945 " call DechoBuf(bufnr("%"),"COMBAK#2") |
5734 | 10946 endfor |
10947 | |
10948 " cleanup any windows mess at end-of-line | |
6476 | 10949 sil! NetrwKeepj g/^$/d |
10950 sil! NetrwKeepj %s/\r$//e | |
5734 | 10951 call histdel("/",-1) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10952 " call Decho("exe setl ts=".(g:netrw_maxfilenamelen+1),'~'.expand("<slnum>")) |
5734 | 10953 exe "setl ts=".(g:netrw_maxfilenamelen+1) |
10954 | |
10955 " call Dret("s:LocalListing") | |
10956 endfun | |
10957 | |
10958 " --------------------------------------------------------------------- | |
3920 | 10959 " s:NetrwLocalExecute: uses system() to execute command under cursor ("X" command support) {{{2 |
10960 fun! s:NetrwLocalExecute(cmd) | |
10961 " call Dfunc("s:NetrwLocalExecute(cmd<".a:cmd.">)") | |
10962 let ykeep= @@ | |
10963 " sanity check | |
10964 if !executable(a:cmd) | |
10965 call netrw#ErrorMsg(s:ERROR,"the file<".a:cmd."> is not executable!",89) | |
10966 let @@= ykeep | |
10967 " call Dret("s:NetrwLocalExecute") | |
10968 return | |
10969 endif | |
10970 | |
10971 let optargs= input(":!".a:cmd,"","file") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10972 " call Decho("optargs<".optargs.">",'~'.expand("<slnum>")) |
3920 | 10973 let result= system(a:cmd.optargs) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10974 " call Decho("result,'~'.expand("<slnum>")) |
3920 | 10975 |
10976 " strip any ansi escape sequences off | |
10977 let result = substitute(result,"\e\\[[0-9;]*m","","g") | |
10978 | |
10979 " show user the result(s) | |
10980 echomsg result | |
10981 let @@= ykeep | |
10982 | |
10983 " call Dret("s:NetrwLocalExecute") | |
10984 endfun | |
10985 | |
10986 " --------------------------------------------------------------------- | |
6476 | 10987 " s:NetrwLocalRename: rename a local file or directory {{{2 |
3920 | 10988 fun! s:NetrwLocalRename(path) range |
10989 " call Dfunc("NetrwLocalRename(path<".a:path.">)") | |
10990 | |
10991 " preparation for removing multiple files/directories | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10992 let ykeep = @@ |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
10993 let ctr = a:firstline |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10994 let svpos = winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
10995 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
3920 | 10996 |
10997 " rename files given by the markfilelist | |
10998 if exists("s:netrwmarkfilelist_{bufnr('%')}") | |
10999 for oldname in s:netrwmarkfilelist_{bufnr("%")} | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11000 " call Decho("oldname<".oldname.">",'~'.expand("<slnum>")) |
3920 | 11001 if exists("subfrom") |
11002 let newname= substitute(oldname,subfrom,subto,'') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11003 " call Decho("subfrom<".subfrom."> subto<".subto."> newname<".newname.">",'~'.expand("<slnum>")) |
3920 | 11004 else |
11005 call inputsave() | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11006 let newname= input("Moving ".oldname." to : ",oldname,"file") |
3920 | 11007 call inputrestore() |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11008 if newname =~ '' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11009 " two ctrl-x's : ignore all of string preceding the ctrl-x's |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11010 let newname = substitute(newname,'^.*','','') |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11011 elseif newname =~ '' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11012 " one ctrl-x : ignore portion of string preceding ctrl-x but after last / |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11013 let newname = substitute(newname,'[^/]*','','') |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11014 endif |
3920 | 11015 if newname =~ '^s/' |
11016 let subfrom = substitute(newname,'^s/\([^/]*\)/.*/$','\1','') | |
11017 let subto = substitute(newname,'^s/[^/]*/\(.*\)/$','\1','') | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11018 " call Decho("subfrom<".subfrom."> subto<".subto."> newname<".newname.">",'~'.expand("<slnum>")) |
3920 | 11019 let newname = substitute(oldname,subfrom,subto,'') |
11020 endif | |
11021 endif | |
11022 call rename(oldname,newname) | |
11023 endfor | |
11024 call s:NetrwUnmarkList(bufnr("%"),b:netrw_curdir) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11025 |
3920 | 11026 else |
11027 | |
11028 " attempt to rename files/directories | |
11029 while ctr <= a:lastline | |
6476 | 11030 exe "NetrwKeepj ".ctr |
3920 | 11031 |
11032 " sanity checks | |
11033 if line(".") < w:netrw_bannercnt | |
11034 let ctr= ctr + 1 | |
11035 continue | |
11036 endif | |
11037 let curword= s:NetrwGetWord() | |
11038 if curword == "./" || curword == "../" | |
11039 let ctr= ctr + 1 | |
11040 continue | |
11041 endif | |
11042 | |
6476 | 11043 NetrwKeepj norm! 0 |
3920 | 11044 let oldname= s:ComposePath(a:path,curword) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11045 " call Decho("oldname<".oldname.">",'~'.expand("<slnum>")) |
3920 | 11046 |
11047 call inputsave() | |
11048 let newname= input("Moving ".oldname." to : ",substitute(oldname,'/*$','','e')) | |
11049 call inputrestore() | |
11050 | |
11051 call rename(oldname,newname) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11052 " call Decho("renaming <".oldname."> to <".newname.">",'~'.expand("<slnum>")) |
3920 | 11053 |
11054 let ctr= ctr + 1 | |
11055 endwhile | |
11056 endif | |
11057 | |
11058 " refresh the directory | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11059 " call Decho("refresh the directory listing",'~'.expand("<slnum>")) |
6476 | 11060 NetrwKeepj call s:NetrwRefresh(1,s:NetrwBrowseChgDir(1,'./')) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11061 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11062 NetrwKeepj call winrestview(svpos) |
3920 | 11063 let @@= ykeep |
11064 | |
11065 " call Dret("NetrwLocalRename") | |
11066 endfun | |
11067 | |
11068 " --------------------------------------------------------------------- | |
1621 | 11069 " s:NetrwLocalRm: {{{2 |
11070 fun! s:NetrwLocalRm(path) range | |
11071 " call Dfunc("s:NetrwLocalRm(path<".a:path.">)") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11072 " call Decho("firstline=".a:firstline." lastline=".a:lastline,'~'.expand("<slnum>")) |
1621 | 11073 |
11074 " preparation for removing multiple files/directories | |
3920 | 11075 let ykeep = @@ |
1621 | 11076 let ret = 0 |
11077 let all = 0 | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11078 let svpos = winsaveview() |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11079 " call Decho("saving posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
1621 | 11080 |
11081 if exists("s:netrwmarkfilelist_{bufnr('%')}") | |
11082 " remove all marked files | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11083 " call Decho("remove all marked files",'~'.expand("<slnum>")) |
1621 | 11084 for fname in s:netrwmarkfilelist_{bufnr("%")} |
11085 let ok= s:NetrwLocalRmFile(a:path,fname,all) | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11086 if ok =~# 'q\%[uit]' || ok == "no" |
1621 | 11087 break |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11088 elseif ok =~# 'a\%[ll]' |
1621 | 11089 let all= 1 |
11090 endif | |
11091 endfor | |
11092 call s:NetrwUnMarkFile(1) | |
11093 | |
11094 else | |
11095 " remove (multiple) files and directories | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11096 " call Decho("remove files in range [".a:firstline.",".a:lastline."]",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11097 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11098 let keepsol= &l:sol |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11099 setl nosol |
1621 | 11100 let ctr = a:firstline |
11101 while ctr <= a:lastline | |
6476 | 11102 exe "NetrwKeepj ".ctr |
1621 | 11103 |
11104 " sanity checks | |
11105 if line(".") < w:netrw_bannercnt | |
11106 let ctr= ctr + 1 | |
11107 continue | |
11108 endif | |
11109 let curword= s:NetrwGetWord() | |
11110 if curword == "./" || curword == "../" | |
11111 let ctr= ctr + 1 | |
11112 continue | |
11113 endif | |
11114 let ok= s:NetrwLocalRmFile(a:path,curword,all) | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11115 if ok =~# 'q\%[uit]' || ok == "no" |
1621 | 11116 break |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11117 elseif ok =~# 'a\%[ll]' |
1621 | 11118 let all= 1 |
11119 endif | |
11120 let ctr= ctr + 1 | |
11121 endwhile | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11122 let &l:sol= keepsol |
1621 | 11123 endif |
11124 | |
11125 " refresh the directory | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11126 " call Decho("bufname<".bufname("%").">",'~'.expand("<slnum>")) |
1621 | 11127 if bufname("%") != "NetrwMessage" |
6476 | 11128 NetrwKeepj call s:NetrwRefresh(1,s:NetrwBrowseChgDir(1,'./')) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11129 " call Decho("restoring posn to svpos<".string(svpos).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11130 NetrwKeepj call winrestview(svpos) |
1621 | 11131 endif |
3920 | 11132 let @@= ykeep |
1621 | 11133 |
11134 " call Dret("s:NetrwLocalRm") | |
482 | 11135 endfun |
11136 | |
1621 | 11137 " --------------------------------------------------------------------- |
11138 " s:NetrwLocalRmFile: remove file fname given the path {{{2 | |
11139 " Give confirmation prompt unless all==1 | |
11140 fun! s:NetrwLocalRmFile(path,fname,all) | |
11141 " call Dfunc("s:NetrwLocalRmFile(path<".a:path."> fname<".a:fname."> all=".a:all) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11142 |
1621 | 11143 let all= a:all |
11144 let ok = "" | |
6476 | 11145 NetrwKeepj norm! 0 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11146 let rmfile= s:NetrwFile(s:ComposePath(a:path,a:fname)) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11147 " call Decho("rmfile<".rmfile.">",'~'.expand("<slnum>")) |
1621 | 11148 |
11149 if rmfile !~ '^"' && (rmfile =~ '@$' || rmfile !~ '[\/]$') | |
11150 " attempt to remove file | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11151 " call Decho("attempt to remove file<".rmfile.">",'~'.expand("<slnum>")) |
1621 | 11152 if !all |
11153 echohl Statement | |
11154 call inputsave() | |
11155 let ok= input("Confirm deletion of file<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ") | |
11156 call inputrestore() | |
11157 echohl NONE | |
11158 if ok == "" | |
11159 let ok="no" | |
11160 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11161 " call Decho("response: ok<".ok.">",'~'.expand("<slnum>")) |
1621 | 11162 let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11163 " call Decho("response: ok<".ok."> (after sub)",'~'.expand("<slnum>")) |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11164 if ok =~# 'a\%[ll]' |
1621 | 11165 let all= 1 |
11166 endif | |
11167 endif | |
11168 | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11169 if all || ok =~# 'y\%[es]' || ok == "" |
1668 | 11170 let ret= s:NetrwDelete(rmfile) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11171 " call Decho("errcode=".v:shell_error." ret=".ret,'~'.expand("<slnum>")) |
1621 | 11172 endif |
11173 | |
11174 else | |
11175 " attempt to remove directory | |
11176 if !all | |
11177 echohl Statement | |
11178 call inputsave() | |
11179 let ok= input("Confirm deletion of directory<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ") | |
11180 call inputrestore() | |
11181 let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e') | |
11182 if ok == "" | |
11183 let ok="no" | |
11184 endif | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11185 if ok =~# 'a\%[ll]' |
1621 | 11186 let all= 1 |
11187 endif | |
11188 endif | |
11189 let rmfile= substitute(rmfile,'[\/]$','','e') | |
11190 | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11191 if all || ok =~# 'y\%[es]' || ok == "" |
17433 | 11192 if v:version < 704 || (v:version == 704 && !has("patch1107")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11193 " " call Decho("1st attempt: system(netrw#WinPath(".g:netrw_localrmdir.') '.s:ShellEscape(rmfile).')','~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11194 call system(netrw#WinPath(g:netrw_localrmdir).' '.s:ShellEscape(rmfile)) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11195 " " call Decho("v:shell_error=".v:shell_error,'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11196 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11197 if v:shell_error != 0 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11198 " " call Decho("2nd attempt to remove directory<".rmfile.">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11199 let errcode= s:NetrwDelete(rmfile) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11200 " " call Decho("errcode=".errcode,'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11201 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11202 if errcode != 0 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11203 if has("unix") |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11204 " " call Decho("3rd attempt to remove directory<".rmfile.">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11205 call system("rm ".s:ShellEscape(rmfile)) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11206 if v:shell_error != 0 && !exists("g:netrw_quiet") |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11207 call netrw#ErrorMsg(s:ERROR,"unable to remove directory<".rmfile."> -- is it empty?",34) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11208 let ok="no" |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11209 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11210 elseif !exists("g:netrw_quiet") |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11211 call netrw#ErrorMsg(s:ERROR,"unable to remove directory<".rmfile."> -- is it empty?",35) |
1621 | 11212 let ok="no" |
11213 endif | |
11214 endif | |
11215 endif | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11216 else |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11217 if delete(rmfile,"d") |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11218 call netrw#ErrorMsg(s:ERROR,"unable to delete directory <".rmfile.">!",103) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11219 endif |
1621 | 11220 endif |
11221 endif | |
11222 endif | |
11223 | |
11224 " call Dret("s:NetrwLocalRmFile ".ok) | |
11225 return ok | |
11226 endfun | |
11227 | |
17433 | 11228 " ===================================================================== |
1121 | 11229 " Support Functions: {{{1 |
11230 | |
482 | 11231 " --------------------------------------------------------------------- |
5734 | 11232 " netrw#Access: intended to provide access to variable values for netrw's test suite {{{2 |
11233 " 0: marked file list of current buffer | |
11234 " 1: marked file target | |
11235 fun! netrw#Access(ilist) | |
11236 if a:ilist == 0 | |
11237 if exists("s:netrwmarkfilelist_".bufnr('%')) | |
11238 return s:netrwmarkfilelist_{bufnr('%')} | |
11239 else | |
11240 return "no-list-buf#".bufnr('%') | |
11241 endif | |
11242 elseif a:ilist == 1 | |
11243 return s:netrwmftgt | |
17433 | 11244 endif |
5734 | 11245 endfun |
11246 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11247 " --------------------------------------------------------------------- |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11248 " netrw#Call: allows user-specified mappings to call internal netrw functions {{{2 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11249 fun! netrw#Call(funcname,...) |
17433 | 11250 return call("s:".a:funcname,a:000) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11251 endfun |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11252 |
5734 | 11253 " --------------------------------------------------------------------- |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11254 " netrw#Expose: allows UserMaps and pchk to look at otherwise script-local variables {{{2 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11255 " I expect this function to be used in |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11256 " :PChkAssert netrw#Expose("netrwmarkfilelist") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11257 " for example. |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11258 fun! netrw#Expose(varname) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11259 " call Dfunc("netrw#Expose(varname<".a:varname.">)") |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11260 if exists("s:".a:varname) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11261 exe "let retval= s:".a:varname |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11262 if exists("g:netrw_pchk") |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11263 if type(retval) == 3 |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11264 let retval = copy(retval) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11265 let i = 0 |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11266 while i < len(retval) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11267 let retval[i]= substitute(retval[i],expand("$HOME"),'~','') |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11268 let i = i + 1 |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11269 endwhile |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11270 endif |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11271 " call Dret("netrw#Expose ".string(retval)) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11272 return string(retval) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11273 endif |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11274 else |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11275 let retval= "n/a" |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11276 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11277 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11278 " call Dret("netrw#Expose ".string(retval)) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11279 return retval |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11280 endfun |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11281 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11282 " --------------------------------------------------------------------- |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11283 " netrw#Modify: allows UserMaps to set (modify) script-local variables {{{2 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11284 fun! netrw#Modify(varname,newvalue) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11285 " call Dfunc("netrw#Modify(varname<".a:varname.">,newvalue<".string(a:newvalue).">)") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11286 exe "let s:".a:varname."= ".string(a:newvalue) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11287 " call Dret("netrw#Modify") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11288 endfun |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11289 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11290 " --------------------------------------------------------------------- |
5734 | 11291 " netrw#RFC2396: converts %xx into characters {{{2 |
11292 fun! netrw#RFC2396(fname) | |
11293 " call Dfunc("netrw#RFC2396(fname<".a:fname.">)") | |
11294 let fname = escape(substitute(a:fname,'%\(\x\x\)','\=nr2char("0x".submatch(1))','ge')," \t") | |
11295 " call Dret("netrw#RFC2396 ".fname) | |
11296 return fname | |
11297 endfun | |
11298 | |
11299 " --------------------------------------------------------------------- | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11300 " netrw#UserMaps: supports user-specified maps {{{2 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11301 " see :help function() |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11302 " |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11303 " g:Netrw_UserMaps is a List with members such as: |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11304 " [[keymap sequence, function reference],...] |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11305 " |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11306 " The referenced function may return a string, |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11307 " refresh : refresh the display |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11308 " -other- : this string will be executed |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11309 " or it may return a List of strings. |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11310 " |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11311 " Each keymap-sequence will be set up with a nnoremap |
17433 | 11312 " to invoke netrw#UserMaps(a:islocal). |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11313 " Related functions: |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11314 " netrw#Expose(varname) -- see s:varname variables |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11315 " netrw#Modify(varname,newvalue) -- modify value of s:varname variable |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11316 " netrw#Call(funcname,...) -- call internal netrw function with optional arguments |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11317 fun! netrw#UserMaps(islocal) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11318 " call Dfunc("netrw#UserMaps(islocal=".a:islocal.")") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11319 " call Decho("g:Netrw_UserMaps ".(exists("g:Netrw_UserMaps")? "exists" : "does NOT exist"),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11320 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11321 " set up usermaplist |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11322 if exists("g:Netrw_UserMaps") && type(g:Netrw_UserMaps) == 3 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11323 " call Decho("g:Netrw_UserMaps has type 3<List>",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11324 for umap in g:Netrw_UserMaps |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11325 " call Decho("type(umap[0]<".string(umap[0]).">)=".type(umap[0])." (should be 1=string)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11326 " call Decho("type(umap[1])=".type(umap[1])." (should be 1=string)",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11327 " if umap[0] is a string and umap[1] is a string holding a function name |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11328 if type(umap[0]) == 1 && type(umap[1]) == 1 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11329 " call Decho("nno <buffer> <silent> ".umap[0]." :call s:UserMaps(".a:islocal.",".string(umap[1]).")<cr>",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11330 exe "nno <buffer> <silent> ".umap[0]." :call <SID>UserMaps(".a:islocal.",'".umap[1]."')<cr>" |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11331 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11332 call netrw#ErrorMsg(s:WARNING,"ignoring usermap <".string(umap[0])."> -- not a [string,funcref] entry",99) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11333 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11334 endfor |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11335 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11336 " call Dret("netrw#UserMaps") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11337 endfun |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11338 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11339 " --------------------------------------------------------------------- |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
11340 " netrw#WinPath: tries to insure that the path is windows-acceptable, whether cygwin is used or not {{{2 |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
11341 fun! netrw#WinPath(path) |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
11342 " call Dfunc("netrw#WinPath(path<".a:path.">)") |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
11343 if (!g:netrw_cygwin || &shell !~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$') && (has("win32") || has("win95") || has("win64") || has("win16")) |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
11344 " remove cygdrive prefix, if present |
5618 | 11345 let path = substitute(a:path,g:netrw_cygdrive.'/\(.\)','\1:','') |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
11346 " remove trailing slash (Win95) |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
11347 let path = substitute(path, '\(\\\|/\)$', '', 'g') |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
11348 " remove escaped spaces |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
11349 let path = substitute(path, '\ ', ' ', 'g') |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
11350 " convert slashes to backslashes |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
11351 let path = substitute(path, '/', '\', 'g') |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
11352 else |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
11353 let path= a:path |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
11354 endif |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
11355 " call Dret("netrw#WinPath <".path.">") |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
11356 return path |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
11357 endfun |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
11358 |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
11359 " --------------------------------------------------------------------- |
17433 | 11360 " s:NetrwBadd: adds marked files to buffer list or vice versa {{{2 |
11361 " cb : bl2mf=0 add marked files to buffer list | |
11362 " cB : bl2mf=1 use bufferlist to mark files | |
11363 " (mnemonic: cb = copy (marked files) to buffer list) | |
11364 fun! s:NetrwBadd(islocal,bl2mf) | |
11365 " " call Dfunc("s:NetrwBadd(islocal=".a:islocal." mf2bl=".mf2bl.")") | |
11366 if a:bl2mf | |
11367 " cB: add buffer list to marked files | |
11368 redir => bufl | |
11369 ls | |
11370 redir END | |
11371 let bufl = map(split(bufl,"\n"),'substitute(v:val,''^.\{-}"\(.*\)".\{-}$'',''\1'','''')') | |
11372 for fname in bufl | |
11373 call s:NetrwMarkFile(a:islocal,fname) | |
11374 endfor | |
11375 else | |
11376 " cb: add marked files to buffer list | |
11377 for fname in s:netrwmarkfilelist_{bufnr("%")} | |
11378 " " call Decho("badd ".fname,'~'.expand("<slnum>")) | |
11379 exe "badd ".fnameescape(fname) | |
11380 endfor | |
11381 let curbufnr = bufnr("%") | |
11382 let curdir = s:NetrwGetCurdir(a:islocal) | |
11383 call s:NetrwUnmarkList(curbufnr,curdir) " remove markings from local buffer | |
11384 endif | |
11385 " call Dret("s:NetrwBadd") | |
11386 endfun | |
11387 | |
11388 " --------------------------------------------------------------------- | |
1668 | 11389 " s:ComposePath: Appends a new part to a path taking different systems into consideration {{{2 |
11390 fun! s:ComposePath(base,subdir) | |
11391 " call Dfunc("s:ComposePath(base<".a:base."> subdir<".a:subdir.">)") | |
11392 | |
3456 | 11393 if has("amiga") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11394 " call Decho("amiga",'~'.expand("<slnum>")) |
2034 | 11395 let ec = a:base[s:Strlen(a:base)-1] |
1668 | 11396 if ec != '/' && ec != ':' |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11397 let ret = a:base."/" . a:subdir |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11398 else |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11399 let ret = a:base.a:subdir |
1668 | 11400 endif |
11401 | |
17433 | 11402 " COMBAK: test on windows with changing to root directory: :e C:/ |
11403 elseif a:subdir =~ '^\a:[/\\]\([^/\\]\|$\)' && (has("win32") || has("win95") || has("win64") || has("win16")) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11404 " call Decho("windows",'~'.expand("<slnum>")) |
1668 | 11405 let ret= a:subdir |
11406 | |
17433 | 11407 elseif a:base =~ '^\a:[/\\]\([^/\\]\|$\)' && (has("win32") || has("win95") || has("win64") || has("win16")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11408 " call Decho("windows",'~'.expand("<slnum>")) |
2034 | 11409 if a:base =~ '[/\\]$' |
11410 let ret= a:base.a:subdir | |
11411 else | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11412 let ret= a:base.'/'.a:subdir |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11413 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11414 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11415 elseif a:base =~ '^\a\{3,}://' |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11416 " call Decho("remote linux/macos",'~'.expand("<slnum>")) |
1668 | 11417 let urlbase = substitute(a:base,'^\(\a\+://.\{-}/\)\(.*\)$','\1','') |
11418 let curpath = substitute(a:base,'^\(\a\+://.\{-}/\)\(.*\)$','\2','') | |
11419 if a:subdir == '../' | |
11420 if curpath =~ '[^/]/[^/]\+/$' | |
11421 let curpath= substitute(curpath,'[^/]\+/$','','') | |
11422 else | |
11423 let curpath="" | |
11424 endif | |
11425 let ret= urlbase.curpath | |
11426 else | |
11427 let ret= urlbase.curpath.a:subdir | |
11428 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11429 " call Decho("urlbase<".urlbase.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11430 " call Decho("curpath<".curpath.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11431 " call Decho("ret<".ret.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11432 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11433 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11434 " call Decho("local linux/macos",'~'.expand("<slnum>")) |
1668 | 11435 let ret = substitute(a:base."/".a:subdir,"//","/","g") |
11436 if a:base =~ '^//' | |
11437 " keeping initial '//' for the benefit of network share listing support | |
11438 let ret= '/'.ret | |
11439 endif | |
11440 let ret= simplify(ret) | |
11441 endif | |
11442 | |
11443 " call Dret("s:ComposePath ".ret) | |
11444 return ret | |
11445 endfun | |
11446 | |
11447 " --------------------------------------------------------------------- | |
6476 | 11448 " s:DeleteBookmark: deletes a file/directory from Netrw's bookmark system {{{2 |
11449 " Related Functions: s:MakeBookmark() s:NetrwBookHistHandler() s:NetrwBookmark() | |
11450 fun! s:DeleteBookmark(fname) | |
11451 " call Dfunc("s:DeleteBookmark(fname<".a:fname.">)") | |
11452 call s:MergeBookmarks() | |
11453 | |
11454 if exists("g:netrw_bookmarklist") | |
11455 let indx= index(g:netrw_bookmarklist,a:fname) | |
11456 if indx == -1 | |
11457 let indx= 0 | |
11458 while indx < len(g:netrw_bookmarklist) | |
11459 if g:netrw_bookmarklist[indx] =~ a:fname | |
11460 call remove(g:netrw_bookmarklist,indx) | |
11461 let indx= indx - 1 | |
11462 endif | |
11463 let indx= indx + 1 | |
11464 endwhile | |
11465 else | |
11466 " remove exact match | |
11467 call remove(g:netrw_bookmarklist,indx) | |
11468 endif | |
11469 endif | |
11470 | |
11471 " call Dret("s:DeleteBookmark") | |
11472 endfun | |
11473 | |
11474 " --------------------------------------------------------------------- | |
1121 | 11475 " s:FileReadable: o/s independent filereadable {{{2 |
11476 fun! s:FileReadable(fname) | |
11477 " call Dfunc("s:FileReadable(fname<".a:fname.">)") | |
11478 | |
11479 if g:netrw_cygwin | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11480 let ret= filereadable(s:NetrwFile(substitute(a:fname,g:netrw_cygdrive.'/\(.\)','\1:/',''))) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11481 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11482 let ret= filereadable(s:NetrwFile(a:fname)) |
1121 | 11483 endif |
11484 | |
11485 " call Dret("s:FileReadable ".ret) | |
11486 return ret | |
482 | 11487 endfun |
11488 | |
11489 " --------------------------------------------------------------------- | |
1121 | 11490 " s:GetTempfile: gets a tempname that'll work for various o/s's {{{2 |
11491 " Places correct suffix on end of temporary filename, | |
11492 " using the suffix provided with fname | |
11493 fun! s:GetTempfile(fname) | |
11494 " call Dfunc("s:GetTempfile(fname<".a:fname.">)") | |
11495 | |
11496 if !exists("b:netrw_tmpfile") | |
11497 " get a brand new temporary filename | |
11498 let tmpfile= tempname() | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11499 " call Decho("tmpfile<".tmpfile."> : from tempname()",'~'.expand("<slnum>")) |
1621 | 11500 |
1668 | 11501 let tmpfile= substitute(tmpfile,'\','/','ge') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11502 " call Decho("tmpfile<".tmpfile."> : chgd any \\ -> /",'~'.expand("<slnum>")) |
1621 | 11503 |
1121 | 11504 " sanity check -- does the temporary file's directory exist? |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11505 if !isdirectory(s:NetrwFile(substitute(tmpfile,'[^/]\+$','','e'))) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11506 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
6476 | 11507 NetrwKeepj call netrw#ErrorMsg(s:ERROR,"your <".substitute(tmpfile,'[^/]\+$','','e')."> directory is missing!",2) |
1121 | 11508 " call Dret("s:GetTempfile getcwd<".getcwd().">") |
11509 return "" | |
11510 endif | |
1621 | 11511 |
1121 | 11512 " let netrw#NetSource() know about the tmpfile |
6476 | 11513 let s:netrw_tmpfile= tmpfile " used by netrw#NetSource() and netrw#BrowseX() |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11514 " call Decho("tmpfile<".tmpfile."> s:netrw_tmpfile<".s:netrw_tmpfile.">",'~'.expand("<slnum>")) |
1621 | 11515 |
1121 | 11516 " o/s dependencies |
1621 | 11517 if g:netrw_cygwin != 0 |
5618 | 11518 let tmpfile = substitute(tmpfile,'^\(\a\):',g:netrw_cygdrive.'/\1','e') |
1121 | 11519 elseif has("win32") || has("win95") || has("win64") || has("win16") |
1621 | 11520 if !exists("+shellslash") || !&ssl |
11521 let tmpfile = substitute(tmpfile,'/','\','g') | |
11522 endif | |
1121 | 11523 else |
1621 | 11524 let tmpfile = tmpfile |
1121 | 11525 endif |
11526 let b:netrw_tmpfile= tmpfile | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11527 " call Decho("o/s dependent fixed tempname<".tmpfile.">",'~'.expand("<slnum>")) |
1121 | 11528 else |
11529 " re-use temporary filename | |
11530 let tmpfile= b:netrw_tmpfile | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11531 " call Decho("tmpfile<".tmpfile."> re-using",'~'.expand("<slnum>")) |
1121 | 11532 endif |
11533 | |
11534 " use fname's suffix for the temporary file | |
11535 if a:fname != "" | |
11536 if a:fname =~ '\.[^./]\+$' | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11537 " call Decho("using fname<".a:fname.">'s suffix",'~'.expand("<slnum>")) |
2420
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
11538 if a:fname =~ '\.tar\.gz$' || a:fname =~ '\.tar\.bz2$' || a:fname =~ '\.tar\.xz$' |
1121 | 11539 let suffix = ".tar".substitute(a:fname,'^.*\(\.[^./]\+\)$','\1','e') |
2420
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
11540 elseif a:fname =~ '.txz$' |
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
11541 let suffix = ".txz".substitute(a:fname,'^.*\(\.[^./]\+\)$','\1','e') |
1121 | 11542 else |
11543 let suffix = substitute(a:fname,'^.*\(\.[^./]\+\)$','\1','e') | |
11544 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11545 " call Decho("suffix<".suffix.">",'~'.expand("<slnum>")) |
1121 | 11546 let tmpfile= substitute(tmpfile,'\.tmp$','','e') |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11547 " call Decho("chgd tmpfile<".tmpfile."> (removed any .tmp suffix)",'~'.expand("<slnum>")) |
1121 | 11548 let tmpfile .= suffix |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11549 " call Decho("chgd tmpfile<".tmpfile."> (added ".suffix." suffix) netrw_fname<".b:netrw_fname.">",'~'.expand("<slnum>")) |
1121 | 11550 let s:netrw_tmpfile= tmpfile " supports netrw#NetSource() |
11551 endif | |
11552 endif | |
11553 | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11554 " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
1121 | 11555 " call Dret("s:GetTempfile <".tmpfile.">") |
11556 return tmpfile | |
1621 | 11557 endfun |
1121 | 11558 |
11559 " --------------------------------------------------------------------- | |
11560 " s:MakeSshCmd: transforms input command using USEPORT HOSTNAME into {{{2 | |
1668 | 11561 " a correct command for use with a system() call |
1121 | 11562 fun! s:MakeSshCmd(sshcmd) |
1621 | 11563 " call Dfunc("s:MakeSshCmd(sshcmd<".a:sshcmd.">) user<".s:user."> machine<".s:machine.">") |
5929 | 11564 if s:user == "" |
11565 let sshcmd = substitute(a:sshcmd,'\<HOSTNAME\>',s:machine,'') | |
11566 else | |
11567 let sshcmd = substitute(a:sshcmd,'\<HOSTNAME\>',s:user."@".s:machine,'') | |
11568 endif | |
1121 | 11569 if exists("g:netrw_port") && g:netrw_port != "" |
1209 | 11570 let sshcmd= substitute(sshcmd,"USEPORT",g:netrw_sshport.' '.g:netrw_port,'') |
1121 | 11571 elseif exists("s:port") && s:port != "" |
1209 | 11572 let sshcmd= substitute(sshcmd,"USEPORT",g:netrw_sshport.' '.s:port,'') |
1121 | 11573 else |
11574 let sshcmd= substitute(sshcmd,"USEPORT ",'','') | |
11575 endif | |
11576 " call Dret("s:MakeSshCmd <".sshcmd.">") | |
11577 return sshcmd | |
482 | 11578 endfun |
11579 | |
11580 " --------------------------------------------------------------------- | |
6476 | 11581 " s:MakeBookmark: enters a bookmark into Netrw's bookmark system {{{2 |
11582 fun! s:MakeBookmark(fname) | |
11583 " call Dfunc("s:MakeBookmark(fname<".a:fname.">)") | |
11584 | |
11585 if !exists("g:netrw_bookmarklist") | |
11586 let g:netrw_bookmarklist= [] | |
11587 endif | |
11588 | |
11589 if index(g:netrw_bookmarklist,a:fname) == -1 | |
11590 " curdir not currently in g:netrw_bookmarklist, so include it | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11591 if isdirectory(s:NetrwFile(a:fname)) && a:fname !~ '/$' |
6476 | 11592 call add(g:netrw_bookmarklist,a:fname.'/') |
11593 elseif a:fname !~ '/' | |
11594 call add(g:netrw_bookmarklist,getcwd()."/".a:fname) | |
11595 else | |
11596 call add(g:netrw_bookmarklist,a:fname) | |
11597 endif | |
11598 call sort(g:netrw_bookmarklist) | |
11599 endif | |
11600 | |
11601 " call Dret("s:MakeBookmark") | |
11602 endfun | |
11603 | |
11604 " --------------------------------------------------------------------- | |
11605 " s:MergeBookmarks: merge current bookmarks with saved bookmarks {{{2 | |
11606 fun! s:MergeBookmarks() | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11607 " call Dfunc("s:MergeBookmarks() : merge current bookmarks into .netrwbook") |
6476 | 11608 " get bookmarks from .netrwbook file |
11609 let savefile= s:NetrwHome()."/.netrwbook" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11610 if filereadable(s:NetrwFile(savefile)) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11611 " call Decho("merge bookmarks (active and file)",'~'.expand("<slnum>")) |
6476 | 11612 NetrwKeepj call s:NetrwBookHistSave() |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11613 " call Decho("bookmark delete savefile<".savefile.">",'~'.expand("<slnum>")) |
6476 | 11614 NetrwKeepj call delete(savefile) |
11615 endif | |
11616 " call Dret("s:MergeBookmarks") | |
11617 endfun | |
11618 | |
11619 " --------------------------------------------------------------------- | |
1668 | 11620 " s:NetrwBMShow: {{{2 |
11621 fun! s:NetrwBMShow() | |
11622 " call Dfunc("s:NetrwBMShow()") | |
11623 redir => bmshowraw | |
11624 menu | |
11625 redir END | |
11626 let bmshowlist = split(bmshowraw,'\n') | |
11627 if bmshowlist != [] | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11628 let bmshowfuncs= filter(bmshowlist,'v:val =~# "<SNR>\\d\\+_BMShow()"') |
1668 | 11629 if bmshowfuncs != [] |
11630 let bmshowfunc = substitute(bmshowfuncs[0],'^.*:\(call.*BMShow()\).*$','\1','') | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11631 if bmshowfunc =~# '^call.*BMShow()' |
6476 | 11632 exe "sil! NetrwKeepj ".bmshowfunc |
1668 | 11633 endif |
11634 endif | |
11635 endif | |
11636 " call Dret("s:NetrwBMShow : bmshowfunc<".(exists("bmshowfunc")? bmshowfunc : 'n/a').">") | |
11637 endfun | |
11638 | |
11639 " --------------------------------------------------------------------- | |
2751 | 11640 " s:NetrwCursor: responsible for setting cursorline/cursorcolumn based upon g:netrw_cursor {{{2 |
11641 fun! s:NetrwCursor() | |
2152 | 11642 if !exists("w:netrw_liststyle") |
11643 let w:netrw_liststyle= g:netrw_liststyle | |
11644 endif | |
3153 | 11645 " call Dfunc("s:NetrwCursor() ft<".&ft."> liststyle=".w:netrw_liststyle." g:netrw_cursor=".g:netrw_cursor." s:netrw_usercuc=".s:netrw_usercuc." s:netrw_usercul=".s:netrw_usercul) |
2751 | 11646 |
11647 if &ft != "netrw" | |
11648 " if the current window isn't a netrw directory listing window, then use user cursorline/column | |
11649 " settings. Affects when netrw is used to read/write a file using scp/ftp/etc. | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11650 " call Decho("case ft!=netrw: use user cul,cuc",'~'.expand("<slnum>")) |
2751 | 11651 let &l:cursorline = s:netrw_usercul |
11652 let &l:cursorcolumn = s:netrw_usercuc | |
11653 | |
11654 elseif g:netrw_cursor == 4 | |
11655 " all styles: cursorline, cursorcolumn | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11656 " call Decho("case g:netrw_cursor==4: setl cul cuc",'~'.expand("<slnum>")) |
3153 | 11657 setl cursorline |
11658 setl cursorcolumn | |
2751 | 11659 |
11660 elseif g:netrw_cursor == 3 | |
11661 " thin-long-tree: cursorline, user's cursorcolumn | |
11662 " wide : cursorline, cursorcolumn | |
11663 if w:netrw_liststyle == s:WIDELIST | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11664 " call Decho("case g:netrw_cursor==3 and wide: setl cul cuc",'~'.expand("<slnum>")) |
3153 | 11665 setl cursorline |
11666 setl cursorcolumn | |
2751 | 11667 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11668 " call Decho("case g:netrw_cursor==3 and not wide: setl cul (use user's cuc)",'~'.expand("<slnum>")) |
3153 | 11669 setl cursorline |
2751 | 11670 let &l:cursorcolumn = s:netrw_usercuc |
11671 endif | |
11672 | |
11673 elseif g:netrw_cursor == 2 | |
11674 " thin-long-tree: cursorline, user's cursorcolumn | |
11675 " wide : cursorline, user's cursorcolumn | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11676 " call Decho("case g:netrw_cursor==2: setl cuc (use user's cul)",'~'.expand("<slnum>")) |
2751 | 11677 let &l:cursorcolumn = s:netrw_usercuc |
3153 | 11678 setl cursorline |
2751 | 11679 |
11680 elseif g:netrw_cursor == 1 | |
11681 " thin-long-tree: user's cursorline, user's cursorcolumn | |
11682 " wide : cursorline, user's cursorcolumn | |
11683 let &l:cursorcolumn = s:netrw_usercuc | |
11684 if w:netrw_liststyle == s:WIDELIST | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11685 " call Decho("case g:netrw_cursor==2 and wide: setl cul (use user's cuc)",'~'.expand("<slnum>")) |
5618 | 11686 setl cursorline |
2751 | 11687 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11688 " call Decho("case g:netrw_cursor==2 and not wide: (use user's cul,cuc)",'~'.expand("<slnum>")) |
2751 | 11689 let &l:cursorline = s:netrw_usercul |
2152 | 11690 endif |
11691 | |
11692 else | |
2751 | 11693 " all styles: user's cursorline, user's cursorcolumn |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11694 " call Decho("default: (use user's cul,cuc)",'~'.expand("<slnum>")) |
2751 | 11695 let &l:cursorline = s:netrw_usercul |
11696 let &l:cursorcolumn = s:netrw_usercuc | |
11697 endif | |
11698 | |
11699 " call Dret("s:NetrwCursor : l:cursorline=".&l:cursorline." l:cursorcolumn=".&l:cursorcolumn) | |
2152 | 11700 endfun |
11701 | |
11702 " --------------------------------------------------------------------- | |
11703 " s:RestoreCursorline: restores cursorline/cursorcolumn to original user settings {{{2 | |
11704 fun! s:RestoreCursorline() | |
5618 | 11705 " call Dfunc("s:RestoreCursorline() currently, cul=".&l:cursorline." cuc=".&l:cursorcolumn." win#".winnr()." buf#".bufnr("%")) |
2751 | 11706 if exists("s:netrw_usercul") |
11707 let &l:cursorline = s:netrw_usercul | |
11708 endif | |
11709 if exists("s:netrw_usercuc") | |
11710 let &l:cursorcolumn = s:netrw_usercuc | |
11711 endif | |
2152 | 11712 " call Dret("s:RestoreCursorline : restored cul=".&l:cursorline." cuc=".&l:cursorcolumn) |
11713 endfun | |
11714 | |
11715 " --------------------------------------------------------------------- | |
1668 | 11716 " s:NetrwDelete: Deletes a file. {{{2 |
11717 " Uses Steve Hall's idea to insure that Windows paths stay | |
11718 " acceptable. No effect on Unix paths. | |
11719 " Examples of use: let result= s:NetrwDelete(path) | |
11720 fun! s:NetrwDelete(path) | |
11721 " call Dfunc("s:NetrwDelete(path<".a:path.">)") | |
11722 | |
2034 | 11723 let path = netrw#WinPath(a:path) |
1668 | 11724 if !g:netrw_cygwin && (has("win32") || has("win95") || has("win64") || has("win16")) |
11725 if exists("+shellslash") | |
11726 let sskeep= &shellslash | |
4339 | 11727 setl noshellslash |
1668 | 11728 let result = delete(path) |
11729 let &shellslash = sskeep | |
11730 else | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11731 " call Decho("exe let result= ".a:cmd."('".path."')",'~'.expand("<slnum>")) |
1668 | 11732 let result= delete(path) |
11733 endif | |
1621 | 11734 else |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11735 " call Decho("let result= delete(".path.")",'~'.expand("<slnum>")) |
1668 | 11736 let result= delete(path) |
11737 endif | |
11738 if result < 0 | |
6476 | 11739 NetrwKeepj call netrw#ErrorMsg(s:WARNING,"delete(".path.") failed!",71) |
1668 | 11740 endif |
11741 | |
11742 " call Dret("s:NetrwDelete ".result) | |
11743 return result | |
1621 | 11744 endfun |
11745 | |
11746 " --------------------------------------------------------------------- | |
1121 | 11747 " s:NetrwEnew: opens a new buffer, passes netrw buffer variables through {{{2 |
2034 | 11748 fun! s:NetrwEnew(...) |
17433 | 11749 " call Dfunc("s:NetrwEnew() a:0=".a:0." bufnr($)=".bufnr("$")." expand(%)<".expand("%").">") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11750 " call Decho("curdir<".((a:0>0)? a:1 : "")."> buf#".bufnr("%")."<".bufname("%").">",'~'.expand("<slnum>")) |
1121 | 11751 |
1621 | 11752 " grab a function-local-variable copy of buffer variables |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11753 " call Decho("make function-local copy of netrw variables",'~'.expand("<slnum>")) |
1121 | 11754 if exists("b:netrw_bannercnt") |let netrw_bannercnt = b:netrw_bannercnt |endif |
11755 if exists("b:netrw_browser_active") |let netrw_browser_active = b:netrw_browser_active |endif | |
11756 if exists("b:netrw_cpf") |let netrw_cpf = b:netrw_cpf |endif | |
11757 if exists("b:netrw_curdir") |let netrw_curdir = b:netrw_curdir |endif | |
11758 if exists("b:netrw_explore_bufnr") |let netrw_explore_bufnr = b:netrw_explore_bufnr |endif | |
11759 if exists("b:netrw_explore_indx") |let netrw_explore_indx = b:netrw_explore_indx |endif | |
11760 if exists("b:netrw_explore_line") |let netrw_explore_line = b:netrw_explore_line |endif | |
11761 if exists("b:netrw_explore_list") |let netrw_explore_list = b:netrw_explore_list |endif | |
11762 if exists("b:netrw_explore_listlen")|let netrw_explore_listlen = b:netrw_explore_listlen|endif | |
11763 if exists("b:netrw_explore_mtchcnt")|let netrw_explore_mtchcnt = b:netrw_explore_mtchcnt|endif | |
11764 if exists("b:netrw_fname") |let netrw_fname = b:netrw_fname |endif | |
11765 if exists("b:netrw_lastfile") |let netrw_lastfile = b:netrw_lastfile |endif | |
11766 if exists("b:netrw_liststyle") |let netrw_liststyle = b:netrw_liststyle |endif | |
11767 if exists("b:netrw_method") |let netrw_method = b:netrw_method |endif | |
11768 if exists("b:netrw_option") |let netrw_option = b:netrw_option |endif | |
11769 if exists("b:netrw_prvdir") |let netrw_prvdir = b:netrw_prvdir |endif | |
11770 | |
17433 | 11771 NetrwKeepj call s:NetrwOptionsRestore("w:") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11772 " call Decho("generate a buffer with NetrwKeepj keepalt enew!",'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11773 " when tree listing uses file TreeListing... a new buffer is made. |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11774 " Want the old buffer to be unlisted. |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11775 " COMBAK: this causes a problem, see P43 |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11776 " setl nobl |
2420
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
11777 let netrw_keepdiff= &l:diff |
6476 | 11778 noswapfile NetrwKeepj keepalt enew! |
2420
6de9efd58dc0
Updated runtime files. New netrw plugin version.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
11779 let &l:diff= netrw_keepdiff |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11780 " call Decho("bufnr($)=".bufnr("$")."<".bufname(bufnr("$"))."> winnr($)=".winnr("$"),'~'.expand("<slnum>")) |
17433 | 11781 NetrwKeepj call s:NetrwOptionsSave("w:") |
1621 | 11782 |
11783 " copy function-local-variables to buffer variable equivalents | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11784 " call Decho("copy function-local variables back to buffer netrw variables",'~'.expand("<slnum>")) |
1121 | 11785 if exists("netrw_bannercnt") |let b:netrw_bannercnt = netrw_bannercnt |endif |
11786 if exists("netrw_browser_active") |let b:netrw_browser_active = netrw_browser_active |endif | |
11787 if exists("netrw_cpf") |let b:netrw_cpf = netrw_cpf |endif | |
11788 if exists("netrw_curdir") |let b:netrw_curdir = netrw_curdir |endif | |
11789 if exists("netrw_explore_bufnr") |let b:netrw_explore_bufnr = netrw_explore_bufnr |endif | |
11790 if exists("netrw_explore_indx") |let b:netrw_explore_indx = netrw_explore_indx |endif | |
11791 if exists("netrw_explore_line") |let b:netrw_explore_line = netrw_explore_line |endif | |
11792 if exists("netrw_explore_list") |let b:netrw_explore_list = netrw_explore_list |endif | |
11793 if exists("netrw_explore_listlen")|let b:netrw_explore_listlen = netrw_explore_listlen|endif | |
11794 if exists("netrw_explore_mtchcnt")|let b:netrw_explore_mtchcnt = netrw_explore_mtchcnt|endif | |
11795 if exists("netrw_fname") |let b:netrw_fname = netrw_fname |endif | |
11796 if exists("netrw_lastfile") |let b:netrw_lastfile = netrw_lastfile |endif | |
11797 if exists("netrw_liststyle") |let b:netrw_liststyle = netrw_liststyle |endif | |
11798 if exists("netrw_method") |let b:netrw_method = netrw_method |endif | |
11799 if exists("netrw_option") |let b:netrw_option = netrw_option |endif | |
11800 if exists("netrw_prvdir") |let b:netrw_prvdir = netrw_prvdir |endif | |
11801 | |
2034 | 11802 if a:0 > 0 |
11803 let b:netrw_curdir= a:1 | |
11804 if b:netrw_curdir =~ '/$' | |
11805 if exists("w:netrw_liststyle") && w:netrw_liststyle == s:TREELIST | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11806 setl nobl |
2034 | 11807 file NetrwTreeListing |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11808 setl nobl bt=nowrite bh=hide |
2751 | 11809 nno <silent> <buffer> [ :sil call <SID>TreeListMove('[')<cr> |
11810 nno <silent> <buffer> ] :sil call <SID>TreeListMove(']')<cr> | |
2034 | 11811 else |
17433 | 11812 call s:NetrwBufRename(b:netrw_curdir) |
2034 | 11813 endif |
1621 | 11814 endif |
11815 endif | |
11816 | |
5618 | 11817 " call Dret("s:NetrwEnew : buf#".bufnr("%")."<".bufname("%")."> expand(%)<".expand("%")."> expand(#)<".expand("#")."> bh=".&bh." win#".winnr()." winnr($)#".winnr("$")) |
1621 | 11818 endfun |
11819 | |
3456 | 11820 " --------------------------------------------------------------------- |
6476 | 11821 " s:NetrwExe: executes a string using "!" {{{2 |
11822 fun! s:NetrwExe(cmd) | |
17433 | 11823 " call Dfunc("s:NetrwExe(a:cmd<".a:cmd.">)") |
6476 | 11824 if has("win32") && &shell !~? 'cmd' && !g:netrw_cygwin |
17433 | 11825 " call Decho("using win32:",expand("<slnum>")) |
6476 | 11826 let savedShell=[&shell,&shellcmdflag,&shellxquote,&shellxescape,&shellquote,&shellpipe,&shellredir,&shellslash] |
11827 set shell& shellcmdflag& shellxquote& shellxescape& | |
11828 set shellquote& shellpipe& shellredir& shellslash& | |
11829 exe a:cmd | |
11830 let [&shell,&shellcmdflag,&shellxquote,&shellxescape,&shellquote,&shellpipe,&shellredir,&shellslash] = savedShell | |
11831 else | |
17433 | 11832 " call Decho("exe ".a:cmd,'~'.expand("<slnum>")) |
6476 | 11833 exe a:cmd |
11834 endif | |
17433 | 11835 " call Dret("s:NetrwExe : v:shell_error=".v:shell_error) |
6476 | 11836 endfun |
11837 | |
11838 " --------------------------------------------------------------------- | |
3456 | 11839 " s:NetrwInsureWinVars: insure that a netrw buffer has its w: variables in spite of a wincmd v or s {{{2 |
11840 fun! s:NetrwInsureWinVars() | |
11841 if !exists("w:netrw_liststyle") | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11842 " call Dfunc("s:NetrwInsureWinVars() win#".winnr()) |
3456 | 11843 let curbuf = bufnr("%") |
11844 let curwin = winnr() | |
11845 let iwin = 1 | |
11846 while iwin <= winnr("$") | |
11847 exe iwin."wincmd w" | |
11848 if winnr() != curwin && bufnr("%") == curbuf && exists("w:netrw_liststyle") | |
11849 " looks like ctrl-w_s or ctrl-w_v was used to split a netrw buffer | |
11850 let winvars= w: | |
11851 break | |
11852 endif | |
11853 let iwin= iwin + 1 | |
11854 endwhile | |
4339 | 11855 exe "keepalt ".curwin."wincmd w" |
3456 | 11856 if exists("winvars") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11857 " call Decho("copying w#".iwin." window variables to w#".curwin,'~'.expand("<slnum>")) |
3456 | 11858 for k in keys(winvars) |
11859 let w:{k}= winvars[k] | |
11860 endfor | |
11861 endif | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11862 " call Dret("s:NetrwInsureWinVars win#".winnr()) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
11863 endif |
3456 | 11864 endfun |
11865 | |
5734 | 11866 " --------------------------------------------------------------------- |
11867 " s:NetrwLcd: handles changing the (local) directory {{{2 | |
17433 | 11868 " Returns: 0=success |
11869 " -1=failed | |
5734 | 11870 fun! s:NetrwLcd(newdir) |
11871 " call Dfunc("s:NetrwLcd(newdir<".a:newdir.">)") | |
11872 | |
17433 | 11873 let err472= 0 |
5734 | 11874 try |
6476 | 11875 exe 'NetrwKeepj sil lcd '.fnameescape(a:newdir) |
5734 | 11876 catch /^Vim\%((\a\+)\)\=:E344/ |
11877 " Vim's lcd fails with E344 when attempting to go above the 'root' of a Windows share. | |
11878 " Therefore, detect if a Windows share is present, and if E344 occurs, just settle at | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11879 " 'root' (ie. '\'). The share name may start with either backslashes ('\\Foo') or |
5734 | 11880 " forward slashes ('//Foo'), depending on whether backslashes have been converted to |
11881 " forward slashes by earlier code; so check for both. | |
11882 if (has("win32") || has("win95") || has("win64") || has("win16")) && !g:netrw_cygwin | |
11883 if a:newdir =~ '^\\\\\w\+' || a:newdir =~ '^//\w\+' | |
11884 let dirname = '\' | |
6476 | 11885 exe 'NetrwKeepj sil lcd '.fnameescape(dirname) |
5734 | 11886 endif |
11887 endif | |
11888 catch /^Vim\%((\a\+)\)\=:E472/ | |
17433 | 11889 let err472= 1 |
11890 endtry | |
11891 | |
11892 if err472 | |
5734 | 11893 call netrw#ErrorMsg(s:ERROR,"unable to change directory to <".a:newdir."> (permissions?)",61) |
11894 if exists("w:netrw_prvdir") | |
11895 let a:newdir= w:netrw_prvdir | |
11896 else | |
17433 | 11897 call s:NetrwOptionsRestore("w:") |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11898 " call Decho("setl noma nomod nowrap",'~'.expand("<slnum>")) |
5929 | 11899 exe "setl ".g:netrw_bufsettings |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
11900 " call Decho(" ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>")) |
5734 | 11901 let a:newdir= dirname |
17433 | 11902 endif |
11903 " call Dret("s:NetrwBrowse -1 : reusing buffer#".(exists("bufnum")? bufnum : 'N/A')."<".dirname."> getcwd<".getcwd().">") | |
11904 return -1 | |
11905 endif | |
11906 | |
11907 " call Dret("s:NetrwLcd 0") | |
11908 return 0 | |
5734 | 11909 endfun |
11910 | |
1621 | 11911 " ------------------------------------------------------------------------ |
11912 " s:NetrwSaveWordPosn: used to keep cursor on same word after refresh, {{{2 | |
11913 " changed sorting, etc. Also see s:NetrwRestoreWordPosn(). | |
11914 fun! s:NetrwSaveWordPosn() | |
11915 " call Dfunc("NetrwSaveWordPosn()") | |
11916 let s:netrw_saveword= '^'.fnameescape(getline('.')).'$' | |
11917 " call Dret("NetrwSaveWordPosn : saveword<".s:netrw_saveword.">") | |
11918 endfun | |
11919 | |
11920 " --------------------------------------------------------------------- | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11921 " s:NetrwHumanReadable: takes a number and makes it "human readable" {{{2 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11922 " 1000 -> 1K, 1000000 -> 1M, 1000000000 -> 1G |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11923 fun! s:NetrwHumanReadable(sz) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11924 " call Dfunc("s:NetrwHumanReadable(sz=".a:sz.") type=".type(a:sz)." style=".g:netrw_sizestyle ) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11925 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11926 if g:netrw_sizestyle == 'h' |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11927 if a:sz >= 1000000000 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11928 let sz = printf("%.1f",a:sz/1000000000.0)."g" |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11929 elseif a:sz >= 10000000 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11930 let sz = printf("%d",a:sz/1000000)."m" |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11931 elseif a:sz >= 1000000 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11932 let sz = printf("%.1f",a:sz/1000000.0)."m" |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11933 elseif a:sz >= 10000 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11934 let sz = printf("%d",a:sz/1000)."k" |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11935 elseif a:sz >= 1000 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11936 let sz = printf("%.1f",a:sz/1000.0)."k" |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11937 else |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11938 let sz= a:sz |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11939 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11940 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11941 elseif g:netrw_sizestyle == 'H' |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11942 if a:sz >= 1073741824 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11943 let sz = printf("%.1f",a:sz/1073741824.0)."G" |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11944 elseif a:sz >= 10485760 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11945 let sz = printf("%d",a:sz/1048576)."M" |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11946 elseif a:sz >= 1048576 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11947 let sz = printf("%.1f",a:sz/1048576.0)."M" |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11948 elseif a:sz >= 10240 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11949 let sz = printf("%d",a:sz/1024)."K" |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11950 elseif a:sz >= 1024 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11951 let sz = printf("%.1f",a:sz/1024.0)."K" |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11952 else |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11953 let sz= a:sz |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11954 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11955 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11956 else |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11957 let sz= a:sz |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11958 endif |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11959 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11960 " call Dret("s:NetrwHumanReadable ".sz) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11961 return sz |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11962 endfun |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11963 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
11964 " --------------------------------------------------------------------- |
1621 | 11965 " s:NetrwRestoreWordPosn: used to keep cursor on same word after refresh, {{{2 |
11966 " changed sorting, etc. Also see s:NetrwSaveWordPosn(). | |
11967 fun! s:NetrwRestoreWordPosn() | |
11968 " call Dfunc("NetrwRestoreWordPosn()") | |
2751 | 11969 sil! call search(s:netrw_saveword,'w') |
1621 | 11970 " call Dret("NetrwRestoreWordPosn") |
11971 endfun | |
11972 | |
11973 " --------------------------------------------------------------------- | |
1668 | 11974 " s:RestoreBufVars: {{{2 |
11975 fun! s:RestoreBufVars() | |
11976 " call Dfunc("s:RestoreBufVars()") | |
11977 | |
11978 if exists("s:netrw_curdir") |let b:netrw_curdir = s:netrw_curdir |endif | |
11979 if exists("s:netrw_lastfile") |let b:netrw_lastfile = s:netrw_lastfile |endif | |
11980 if exists("s:netrw_method") |let b:netrw_method = s:netrw_method |endif | |
11981 if exists("s:netrw_fname") |let b:netrw_fname = s:netrw_fname |endif | |
11982 if exists("s:netrw_machine") |let b:netrw_machine = s:netrw_machine |endif | |
11983 if exists("s:netrw_browser_active")|let b:netrw_browser_active = s:netrw_browser_active|endif | |
11984 | |
11985 " call Dret("s:RestoreBufVars") | |
11986 endfun | |
11987 | |
11988 " --------------------------------------------------------------------- | |
1121 | 11989 " s:RemotePathAnalysis: {{{2 |
11990 fun! s:RemotePathAnalysis(dirname) | |
2908 | 11991 " call Dfunc("s:RemotePathAnalysis(a:dirname<".a:dirname.">)") |
1121 | 11992 |
5734 | 11993 " method :// user @ machine :port /path |
5618 | 11994 let dirpat = '^\(\w\{-}\)://\(\(\w\+\)@\)\=\([^/:#]\+\)\%([:#]\(\d\+\)\)\=/\(.*\)$' |
1121 | 11995 let s:method = substitute(a:dirname,dirpat,'\1','') |
5618 | 11996 let s:user = substitute(a:dirname,dirpat,'\3','') |
11997 let s:machine = substitute(a:dirname,dirpat,'\4','') | |
11998 let s:port = substitute(a:dirname,dirpat,'\5','') | |
11999 let s:path = substitute(a:dirname,dirpat,'\6','') | |
5929 | 12000 let s:fname = substitute(s:path,'^.*/\ze.','','') |
5734 | 12001 if s:machine =~ '@' |
12002 let dirpat = '^\(.*\)@\(.\{-}\)$' | |
12003 let s:user = s:user.'@'.substitute(s:machine,dirpat,'\1','') | |
12004 let s:machine = substitute(s:machine,dirpat,'\2','') | |
12005 endif | |
1121 | 12006 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12007 " call Decho("set up s:method <".s:method .">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12008 " call Decho("set up s:user <".s:user .">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12009 " call Decho("set up s:machine<".s:machine.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12010 " call Decho("set up s:port <".s:port.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12011 " call Decho("set up s:path <".s:path .">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12012 " call Decho("set up s:fname <".s:fname .">",'~'.expand("<slnum>")) |
1121 | 12013 |
12014 " call Dret("s:RemotePathAnalysis") | |
12015 endfun | |
12016 | |
12017 " --------------------------------------------------------------------- | |
1668 | 12018 " s:RemoteSystem: runs a command on a remote host using ssh {{{2 |
12019 " Returns status | |
12020 " Runs system() on | |
12021 " [cd REMOTEDIRPATH;] a:cmd | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12022 " Note that it doesn't do s:ShellEscape(a:cmd)! |
1668 | 12023 fun! s:RemoteSystem(cmd) |
12024 " call Dfunc("s:RemoteSystem(cmd<".a:cmd.">)") | |
12025 if !executable(g:netrw_ssh_cmd) | |
6476 | 12026 NetrwKeepj call netrw#ErrorMsg(s:ERROR,"g:netrw_ssh_cmd<".g:netrw_ssh_cmd."> is not executable!",52) |
1668 | 12027 elseif !exists("b:netrw_curdir") |
6476 | 12028 NetrwKeepj call netrw#ErrorMsg(s:ERROR,"for some reason b:netrw_curdir doesn't exist!",53) |
1668 | 12029 else |
12030 let cmd = s:MakeSshCmd(g:netrw_ssh_cmd." USEPORT HOSTNAME") | |
12031 let remotedir= substitute(b:netrw_curdir,'^.*//[^/]\+/\(.*\)$','\1','') | |
12032 if remotedir != "" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12033 let cmd= cmd.' cd '.s:ShellEscape(remotedir).";" |
1668 | 12034 else |
12035 let cmd= cmd.' ' | |
12036 endif | |
12037 let cmd= cmd.a:cmd | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12038 " call Decho("call system(".cmd.")",'~'.expand("<slnum>")) |
1668 | 12039 let ret= system(cmd) |
12040 endif | |
12041 " call Dret("s:RemoteSystem ".ret) | |
12042 return ret | |
1121 | 12043 endfun |
12044 | |
12045 " --------------------------------------------------------------------- | |
1621 | 12046 " s:RestoreWinVars: (used by Explore() and NetrwSplit()) {{{2 |
1121 | 12047 fun! s:RestoreWinVars() |
12048 " call Dfunc("s:RestoreWinVars()") | |
12049 if exists("s:bannercnt") |let w:netrw_bannercnt = s:bannercnt |unlet s:bannercnt |endif | |
12050 if exists("s:col") |let w:netrw_col = s:col |unlet s:col |endif | |
12051 if exists("s:curdir") |let w:netrw_curdir = s:curdir |unlet s:curdir |endif | |
12052 if exists("s:explore_bufnr") |let w:netrw_explore_bufnr = s:explore_bufnr |unlet s:explore_bufnr |endif | |
12053 if exists("s:explore_indx") |let w:netrw_explore_indx = s:explore_indx |unlet s:explore_indx |endif | |
12054 if exists("s:explore_line") |let w:netrw_explore_line = s:explore_line |unlet s:explore_line |endif | |
12055 if exists("s:explore_listlen")|let w:netrw_explore_listlen = s:explore_listlen|unlet s:explore_listlen|endif | |
12056 if exists("s:explore_list") |let w:netrw_explore_list = s:explore_list |unlet s:explore_list |endif | |
12057 if exists("s:explore_mtchcnt")|let w:netrw_explore_mtchcnt = s:explore_mtchcnt|unlet s:explore_mtchcnt|endif | |
12058 if exists("s:fpl") |let w:netrw_fpl = s:fpl |unlet s:fpl |endif | |
12059 if exists("s:hline") |let w:netrw_hline = s:hline |unlet s:hline |endif | |
12060 if exists("s:line") |let w:netrw_line = s:line |unlet s:line |endif | |
12061 if exists("s:liststyle") |let w:netrw_liststyle = s:liststyle |unlet s:liststyle |endif | |
12062 if exists("s:method") |let w:netrw_method = s:method |unlet s:method |endif | |
12063 if exists("s:prvdir") |let w:netrw_prvdir = s:prvdir |unlet s:prvdir |endif | |
12064 if exists("s:treedict") |let w:netrw_treedict = s:treedict |unlet s:treedict |endif | |
12065 if exists("s:treetop") |let w:netrw_treetop = s:treetop |unlet s:treetop |endif | |
12066 if exists("s:winnr") |let w:netrw_winnr = s:winnr |unlet s:winnr |endif | |
12067 " call Dret("s:RestoreWinVars") | |
12068 endfun | |
12069 | |
12070 " --------------------------------------------------------------------- | |
1621 | 12071 " s:Rexplore: implements returning from a buffer to a netrw directory {{{2 |
12072 " | |
12073 " s:SetRexDir() sets up <2-leftmouse> maps (if g:netrw_retmap | |
12074 " is true) and a command, :Rexplore, which call this function. | |
12075 " | |
17433 | 12076 " s:netrw_posn is set up by s:NetrwBrowseChgDir() |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12077 " |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12078 " s:rexposn_BUFNR used to save/restore cursor position |
1621 | 12079 fun! s:NetrwRexplore(islocal,dirname) |
4339 | 12080 if exists("s:netrwdrag") |
12081 return | |
12082 endif | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12083 " call Dfunc("s:NetrwRexplore() w:netrw_rexlocal=".w:netrw_rexlocal." w:netrw_rexdir<".w:netrw_rexdir."> win#".winnr()) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12084 " call Decho("currently in bufname<".bufname("%").">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12085 " call Decho("ft=".&ft." win#".winnr()." w:netrw_rexfile<".(exists("w:netrw_rexfile")? w:netrw_rexfile : 'n/a').">",'~'.expand("<slnum>")) |
5734 | 12086 |
12087 if &ft == "netrw" && exists("w:netrw_rexfile") && w:netrw_rexfile != "" | |
6476 | 12088 " a :Rex while in a netrw buffer means: edit the file in w:netrw_rexfile |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12089 " call Decho("in netrw buffer, will edit file<".w:netrw_rexfile.">",'~'.expand("<slnum>")) |
6476 | 12090 exe "NetrwKeepj e ".w:netrw_rexfile |
5734 | 12091 unlet w:netrw_rexfile |
12092 " call Dret("s:NetrwRexplore returning from netrw to buf#".bufnr("%")."<".bufname("%")."> (ft=".&ft.")") | |
3153 | 12093 return |
6476 | 12094 " else " Decho |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12095 " call Decho("treating as not-netrw-buffer: ft=".&ft.((&ft == "netrw")? " == netrw" : "!= netrw"),'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12096 " call Decho("treating as not-netrw-buffer: w:netrw_rexfile<".((exists("w:netrw_rexfile"))? w:netrw_rexfile : 'n/a').">",'~'.expand("<slnum>")) |
6476 | 12097 endif |
12098 | |
12099 " --------------------------- | |
12100 " :Rex issued while in a file | |
12101 " --------------------------- | |
5734 | 12102 |
12103 " record current file so :Rex can return to it from netrw | |
12104 let w:netrw_rexfile= expand("%") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12105 " call Decho("set w:netrw_rexfile<".w:netrw_rexfile."> (win#".winnr().")",'~'.expand("<slnum>")) |
5734 | 12106 |
12107 if !exists("w:netrw_rexlocal") | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12108 " call Dret("s:NetrwRexplore w:netrw_rexlocal doesn't exist (".&ft." win#".winnr().")") |
5734 | 12109 return |
12110 endif | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12111 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("<slnum>")) |
2751 | 12112 if w:netrw_rexlocal |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12113 NetrwKeepj call netrw#LocalBrowseCheck(w:netrw_rexdir) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12114 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12115 NetrwKeepj call s:NetrwBrowse(0,w:netrw_rexdir) |
1621 | 12116 endif |
3153 | 12117 if exists("s:initbeval") |
5734 | 12118 setl beval |
3153 | 12119 endif |
3456 | 12120 if exists("s:rexposn_".bufnr("%")) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12121 " call Decho("restore posn, then unlet s:rexposn_".bufnr('%')."<".bufname("%").">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12122 " restore position in directory listing |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12123 " call Decho("restoring posn to s:rexposn_".bufnr('%')."<".string(s:rexposn_{bufnr('%')}).">",'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12124 NetrwKeepj call winrestview(s:rexposn_{bufnr('%')}) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12125 if exists("s:rexposn_".bufnr('%')) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12126 unlet s:rexposn_{bufnr('%')} |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12127 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12128 else |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12129 " call Decho("s:rexposn_".bufnr('%')."<".bufname("%")."> doesn't exist",'~'.expand("<slnum>")) |
5734 | 12130 endif |
12131 | |
17433 | 12132 if has("syntax") && exists("g:syntax_on") && g:syntax_on |
12133 if exists("s:explore_match") | |
12134 exe "2match netrwMarkFile /".s:explore_match."/" | |
12135 endif | |
2034 | 12136 endif |
5734 | 12137 |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12138 " call Decho("settings buf#".bufnr("%")."<".bufname("%").">: ".((&l:ma == 0)? "no" : "")."ma ".((&l:mod == 0)? "no" : "")."mod ".((&l:bl == 0)? "no" : "")."bl ".((&l:ro == 0)? "no" : "")."ro fo=".&l:fo,'~'.expand("<slnum>")) |
5734 | 12139 " call Dret("s:NetrwRexplore : ft=".&ft) |
1621 | 12140 endfun |
12141 | |
12142 " --------------------------------------------------------------------- | |
5618 | 12143 " s:SaveBufVars: save selected b: variables to s: variables {{{2 |
12144 " use s:RestoreBufVars() to restore b: variables from s: variables | |
1121 | 12145 fun! s:SaveBufVars() |
2034 | 12146 " call Dfunc("s:SaveBufVars() buf#".bufnr("%")) |
1121 | 12147 |
12148 if exists("b:netrw_curdir") |let s:netrw_curdir = b:netrw_curdir |endif | |
12149 if exists("b:netrw_lastfile") |let s:netrw_lastfile = b:netrw_lastfile |endif | |
12150 if exists("b:netrw_method") |let s:netrw_method = b:netrw_method |endif | |
12151 if exists("b:netrw_fname") |let s:netrw_fname = b:netrw_fname |endif | |
12152 if exists("b:netrw_machine") |let s:netrw_machine = b:netrw_machine |endif | |
12153 if exists("b:netrw_browser_active")|let s:netrw_browser_active = b:netrw_browser_active|endif | |
12154 | |
12155 " call Dret("s:SaveBufVars") | |
12156 endfun | |
12157 | |
12158 " --------------------------------------------------------------------- | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12159 " s:SavePosn: saves position associated with current buffer into a dictionary {{{2 |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12160 fun! s:SavePosn(posndict) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12161 " call Dfunc("s:SavePosn(posndict) curbuf#".bufnr("%")."<".bufname("%").">") |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12162 |
17433 | 12163 if !exists("a:posndict[bufnr('%')]") |
12164 let a:posndict[bufnr("%")]= [] | |
12165 endif | |
12166 " call Decho("before push: a:posndict[buf#".bufnr("%")."]=".string(a:posndict[bufnr('%')])) | |
12167 call add(a:posndict[bufnr("%")],winsaveview()) | |
12168 " call Decho("after push: a:posndict[buf#".bufnr("%")."]=".string(a:posndict[bufnr('%')])) | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12169 |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12170 " call Dret("s:SavePosn posndict") |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12171 return a:posndict |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12172 endfun |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12173 |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12174 " --------------------------------------------------------------------- |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12175 " s:RestorePosn: restores position associated with current buffer using dictionary {{{2 |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12176 fun! s:RestorePosn(posndict) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12177 " call Dfunc("s:RestorePosn(posndict) curbuf#".bufnr("%")."<".bufname("%").">") |
17433 | 12178 if exists("a:posndict") |
12179 if has_key(a:posndict,bufnr("%")) | |
12180 " call Decho("before pop: a:posndict[buf#".bufnr("%")."]=".string(a:posndict[bufnr('%')])) | |
12181 let posnlen= len(a:posndict[bufnr("%")]) | |
12182 if posnlen > 0 | |
12183 let posnlen= posnlen - 1 | |
12184 " call Decho("restoring posn posndict[".bufnr("%")."][".posnlen."]=".string(a:posndict[bufnr("%")][posnlen]),'~'.expand("<slnum>")) | |
12185 call winrestview(a:posndict[bufnr("%")][posnlen]) | |
12186 call remove(a:posndict[bufnr("%")],posnlen) | |
12187 " call Decho("after pop: a:posndict[buf#".bufnr("%")."]=".string(a:posndict[bufnr('%')])) | |
12188 endif | |
12189 endif | |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12190 endif |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12191 " call Dret("s:RestorePosn") |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12192 endfun |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12193 |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12194 " --------------------------------------------------------------------- |
1621 | 12195 " s:SaveWinVars: (used by Explore() and NetrwSplit()) {{{2 |
1121 | 12196 fun! s:SaveWinVars() |
2034 | 12197 " call Dfunc("s:SaveWinVars() win#".winnr()) |
1121 | 12198 if exists("w:netrw_bannercnt") |let s:bannercnt = w:netrw_bannercnt |endif |
12199 if exists("w:netrw_col") |let s:col = w:netrw_col |endif | |
12200 if exists("w:netrw_curdir") |let s:curdir = w:netrw_curdir |endif | |
12201 if exists("w:netrw_explore_bufnr") |let s:explore_bufnr = w:netrw_explore_bufnr |endif | |
12202 if exists("w:netrw_explore_indx") |let s:explore_indx = w:netrw_explore_indx |endif | |
12203 if exists("w:netrw_explore_line") |let s:explore_line = w:netrw_explore_line |endif | |
12204 if exists("w:netrw_explore_listlen")|let s:explore_listlen = w:netrw_explore_listlen|endif | |
12205 if exists("w:netrw_explore_list") |let s:explore_list = w:netrw_explore_list |endif | |
12206 if exists("w:netrw_explore_mtchcnt")|let s:explore_mtchcnt = w:netrw_explore_mtchcnt|endif | |
12207 if exists("w:netrw_fpl") |let s:fpl = w:netrw_fpl |endif | |
12208 if exists("w:netrw_hline") |let s:hline = w:netrw_hline |endif | |
12209 if exists("w:netrw_line") |let s:line = w:netrw_line |endif | |
12210 if exists("w:netrw_liststyle") |let s:liststyle = w:netrw_liststyle |endif | |
12211 if exists("w:netrw_method") |let s:method = w:netrw_method |endif | |
12212 if exists("w:netrw_prvdir") |let s:prvdir = w:netrw_prvdir |endif | |
12213 if exists("w:netrw_treedict") |let s:treedict = w:netrw_treedict |endif | |
12214 if exists("w:netrw_treetop") |let s:treetop = w:netrw_treetop |endif | |
12215 if exists("w:netrw_winnr") |let s:winnr = w:netrw_winnr |endif | |
12216 " call Dret("s:SaveWinVars") | |
12217 endfun | |
12218 | |
12219 " --------------------------------------------------------------------- | |
1621 | 12220 " s:SetBufWinVars: (used by NetrwBrowse() and LocalBrowseCheck()) {{{2 |
482 | 12221 " To allow separate windows to have their own activities, such as |
12222 " Explore **/pattern, several variables have been made window-oriented. | |
12223 " However, when the user splits a browser window (ex: ctrl-w s), these | |
559 | 12224 " variables are not inherited by the new window. SetBufWinVars() and |
482 | 12225 " UseBufWinVars() get around that. |
559 | 12226 fun! s:SetBufWinVars() |
2034 | 12227 " call Dfunc("s:SetBufWinVars() win#".winnr()) |
1121 | 12228 if exists("w:netrw_liststyle") |let b:netrw_liststyle = w:netrw_liststyle |endif |
12229 if exists("w:netrw_bannercnt") |let b:netrw_bannercnt = w:netrw_bannercnt |endif | |
12230 if exists("w:netrw_method") |let b:netrw_method = w:netrw_method |endif | |
12231 if exists("w:netrw_prvdir") |let b:netrw_prvdir = w:netrw_prvdir |endif | |
12232 if exists("w:netrw_explore_indx") |let b:netrw_explore_indx = w:netrw_explore_indx |endif | |
12233 if exists("w:netrw_explore_listlen")|let b:netrw_explore_listlen= w:netrw_explore_listlen|endif | |
12234 if exists("w:netrw_explore_mtchcnt")|let b:netrw_explore_mtchcnt= w:netrw_explore_mtchcnt|endif | |
12235 if exists("w:netrw_explore_bufnr") |let b:netrw_explore_bufnr = w:netrw_explore_bufnr |endif | |
12236 if exists("w:netrw_explore_line") |let b:netrw_explore_line = w:netrw_explore_line |endif | |
12237 if exists("w:netrw_explore_list") |let b:netrw_explore_list = w:netrw_explore_list |endif | |
12238 " call Dret("s:SetBufWinVars") | |
482 | 12239 endfun |
12240 | |
12241 " --------------------------------------------------------------------- | |
1621 | 12242 " s:SetRexDir: set directory for :Rexplore {{{2 |
12243 fun! s:SetRexDir(islocal,dirname) | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12244 " call Dfunc("s:SetRexDir(islocal=".a:islocal." dirname<".a:dirname.">) win#".winnr()) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12245 let w:netrw_rexdir = a:dirname |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12246 let w:netrw_rexlocal = a:islocal |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12247 let s:rexposn_{bufnr("%")} = winsaveview() |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12248 " call Decho("setting w:netrw_rexdir =".w:netrw_rexdir,'~'.expand("<slnum>")) |
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12249 " call Decho("setting w:netrw_rexlocal=".w:netrw_rexlocal,'~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12250 " call Decho("saving posn to s:rexposn_".bufnr("%")."<".string(s:rexposn_{bufnr("%")}).">",'~'.expand("<slnum>")) |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12251 " call Decho("setting s:rexposn_".bufnr("%")."<".bufname("%")."> to ".string(winsaveview()),'~'.expand("<slnum>")) |
3920 | 12252 " call Dret("s:SetRexDir : win#".winnr()." ".(a:islocal? "local" : "remote")." dir: ".a:dirname) |
1621 | 12253 endfun |
12254 | |
12255 " --------------------------------------------------------------------- | |
6476 | 12256 " s:ShowLink: used to modify thin and tree listings to show links {{{2 |
12257 fun! s:ShowLink() | |
12258 " " call Dfunc("s:ShowLink()") | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12259 " " call Decho("b:netrw_curdir<".(exists("b:netrw_curdir")? b:netrw_curdir : "doesn't exist").">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12260 " " call Decho(printf("line#%4d: %s",line("."),getline(".")),'~'.expand("<slnum>")) |
6476 | 12261 if exists("b:netrw_curdir") |
12262 norm! $?\a | |
12263 let fname = b:netrw_curdir.'/'.s:NetrwGetWord() | |
12264 let resname = resolve(fname) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12265 " " call Decho("fname <".fname.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12266 " " call Decho("resname <".resname.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12267 " " call Decho("b:netrw_curdir<".b:netrw_curdir.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12268 if resname =~ '^\M'.b:netrw_curdir.'/' |
6476 | 12269 let dirlen = strlen(b:netrw_curdir) |
12270 let resname = strpart(resname,dirlen+1) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12271 " " call Decho("resname<".resname."> (b:netrw_curdir elided)",'~'.expand("<slnum>")) |
6476 | 12272 endif |
12273 let modline = getline(".")."\t --> ".resname | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12274 " " call Decho("fname <".fname.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12275 " " call Decho("modline<".modline.">",'~'.expand("<slnum>")) |
6476 | 12276 setl noro ma |
12277 call setline(".",modline) | |
12278 setl ro noma nomod | |
12279 endif | |
12280 " " call Dret("s:ShowLink".((exists("fname")? ' : '.fname : 'n/a'))) | |
12281 endfun | |
12282 | |
12283 " --------------------------------------------------------------------- | |
12284 " s:ShowStyle: {{{2 | |
12285 fun! s:ShowStyle() | |
12286 if !exists("w:netrw_liststyle") | |
12287 let liststyle= g:netrw_liststyle | |
12288 else | |
12289 let liststyle= w:netrw_liststyle | |
12290 endif | |
12291 if liststyle == s:THINLIST | |
12292 return s:THINLIST.":thin" | |
12293 elseif liststyle == s:LONGLIST | |
12294 return s:LONGLIST.":long" | |
12295 elseif liststyle == s:WIDELIST | |
12296 return s:WIDELIST.":wide" | |
12297 elseif liststyle == s:TREELIST | |
12298 return s:TREELIST.":tree" | |
12299 else | |
12300 return 'n/a' | |
12301 endif | |
12302 endfun | |
12303 | |
12304 " --------------------------------------------------------------------- | |
5618 | 12305 " s:Strlen: this function returns the length of a string, even if its using multi-byte characters. {{{2 |
12306 " Solution from Nicolai Weibull, vim docs (:help strlen()), | |
12307 " Tony Mechelynck, and my own invention. | |
1621 | 12308 fun! s:Strlen(x) |
5618 | 12309 " "" call Dfunc("s:Strlen(x<".a:x."> g:Align_xstrlen=".g:Align_xstrlen.")") |
12310 | |
12311 if v:version >= 703 && exists("*strdisplaywidth") | |
12312 let ret= strdisplaywidth(a:x) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12313 |
5618 | 12314 elseif type(g:Align_xstrlen) == 1 |
12315 " allow user to specify a function to compute the string length (ie. let g:Align_xstrlen="mystrlenfunc") | |
12316 exe "let ret= ".g:Align_xstrlen."('".substitute(a:x,"'","''","g")."')" | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12317 |
5618 | 12318 elseif g:Align_xstrlen == 1 |
1621 | 12319 " number of codepoints (Latin a + combining circumflex is two codepoints) |
12320 " (comment from TM, solution from NW) | |
12321 let ret= strlen(substitute(a:x,'.','c','g')) | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12322 |
5618 | 12323 elseif g:Align_xstrlen == 2 |
12324 " number of spacing codepoints (Latin a + combining circumflex is one spacing | |
1621 | 12325 " codepoint; a hard tab is one; wide and narrow CJK are one each; etc.) |
12326 " (comment from TM, solution from TM) | |
5618 | 12327 let ret=strlen(substitute(a:x, '.\Z', 'x', 'g')) |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12328 |
5618 | 12329 elseif g:Align_xstrlen == 3 |
12330 " virtual length (counting, for instance, tabs as anything between 1 and | |
12331 " 'tabstop', wide CJK as 2 rather than 1, Arabic alif as zero when immediately | |
1621 | 12332 " preceded by lam, one otherwise, etc.) |
12333 " (comment from TM, solution from me) | |
5618 | 12334 let modkeep= &l:mod |
12335 exe "norm! o\<esc>" | |
1621 | 12336 call setline(line("."),a:x) |
12337 let ret= virtcol("$") - 1 | |
5618 | 12338 d |
6476 | 12339 NetrwKeepj norm! k |
5618 | 12340 let &l:mod= modkeep |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12341 |
1621 | 12342 else |
12343 " at least give a decent default | |
5618 | 12344 let ret= strlen(a:x) |
12345 endif | |
12346 " "" call Dret("s:Strlen ".ret) | |
1621 | 12347 return ret |
12348 endfun | |
12349 | |
12350 " --------------------------------------------------------------------- | |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12351 " s:ShellEscape: shellescape(), or special windows handling {{{2 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12352 fun! s:ShellEscape(s, ...) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12353 if (has('win32') || has('win64')) && $SHELL == '' && &shellslash |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12354 return printf('"%s"', substitute(a:s, '"', '""', 'g')) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12355 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12356 let f = a:0 > 0 ? a:1 : 0 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12357 return shellescape(a:s, f) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12358 endfun |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12359 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12360 " --------------------------------------------------------------------- |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12361 " s:TreeListMove: supports [[, ]], [], and ][ in tree mode {{{2 |
1621 | 12362 fun! s:TreeListMove(dir) |
12363 " call Dfunc("s:TreeListMove(dir<".a:dir.">)") | |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12364 let curline = getline('.') |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12365 let prvline = (line(".") > 1)? getline(line(".")-1) : '' |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12366 let nxtline = (line(".") < line("$"))? getline(line(".")+1) : '' |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12367 let curindent = substitute(getline('.'),'^\(\%('.s:treedepthstring.'\)*\)[^'.s:treedepthstring.'].\{-}$','\1','e') |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12368 let indentm1 = substitute(curindent,'^'.s:treedepthstring,'','') |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12369 let treedepthchr = substitute(s:treedepthstring,' ','','g') |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12370 let stopline = exists("w:netrw_bannercnt")? w:netrw_bannercnt : 1 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12371 " call Decho("prvline <".prvline."> #".(line(".")-1), '~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12372 " call Decho("curline <".curline."> #".line(".") , '~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12373 " call Decho("nxtline <".nxtline."> #".(line(".")+1), '~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12374 " call Decho("curindent<".curindent.">" , '~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12375 " call Decho("indentm1 <".indentm1.">" , '~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12376 " COMBAK : need to handle when on a directory |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12377 " COMBAK : need to handle ]] and ][. In general, needs work!!! |
1621 | 12378 if curline !~ '/$' |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12379 if a:dir == '[[' && prvline != '' |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12380 NetrwKeepj norm! 0 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12381 let nl = search('^'.indentm1.'\%('.s:treedepthstring.'\)\@!','bWe',stopline) " search backwards |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12382 " call Decho("regfile srch back: ".nl,'~'.expand("<slnum>")) |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12383 elseif a:dir == '[]' && nxtline != '' |
6476 | 12384 NetrwKeepj norm! 0 |
8951
0bdeaf7092bc
commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed
Christian Brabandt <cb@256bit.org>
parents:
8148
diff
changeset
|
12385 " call Decho('srchpat<'.'^\%('.curindent.'\)\@!'.'>','~'.expand("<slnum>")) |
8148
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12386 let nl = search('^\%('.curindent.'\)\@!','We') " search forwards |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12387 if nl != 0 |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12388 NetrwKeepj norm! k |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12389 else |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12390 NetrwKeepj norm! G |
f5da459c5698
commit https://github.com/vim/vim/commit/e0fa3742ead676a3074a10edadbc955e1a89153d
Christian Brabandt <cb@256bit.org>
parents:
7183
diff
changeset
|
12391 endif |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12392 " call Decho("regfile srch fwd: ".nl,'~'.expand("<slnum>")) |
1621 | 12393 endif |
12394 endif | |
12395 | |
12396 " call Dret("s:TreeListMove") | |
12397 endfun | |
12398 | |
12399 " --------------------------------------------------------------------- | |
1668 | 12400 " s:UpdateBuffersMenu: does emenu Buffers.Refresh (but due to locale, the menu item may not be called that) {{{2 |
12401 " The Buffers.Refresh menu calls s:BMShow(); unfortunately, that means that that function | |
12402 " can't be called except via emenu. But due to locale, that menu line may not be called | |
12403 " Buffers.Refresh; hence, s:NetrwBMShow() utilizes a "cheat" to call that function anyway. | |
12404 fun! s:UpdateBuffersMenu() | |
12405 " call Dfunc("s:UpdateBuffersMenu()") | |
2751 | 12406 if has("gui") && has("menu") && has("gui_running") && &go =~# 'm' && g:netrw_menu |
1668 | 12407 try |
2751 | 12408 sil emenu Buffers.Refresh\ menu |
1668 | 12409 catch /^Vim\%((\a\+)\)\=:E/ |
12410 let v:errmsg= "" | |
6476 | 12411 sil NetrwKeepj call s:NetrwBMShow() |
1668 | 12412 endtry |
12413 endif | |
12414 " call Dret("s:UpdateBuffersMenu") | |
12415 endfun | |
12416 | |
12417 " --------------------------------------------------------------------- | |
1621 | 12418 " s:UseBufWinVars: (used by NetrwBrowse() and LocalBrowseCheck() {{{2 |
2751 | 12419 " Matching function to s:SetBufWinVars() |
482 | 12420 fun! s:UseBufWinVars() |
1121 | 12421 " call Dfunc("s:UseBufWinVars()") |
12422 if exists("b:netrw_liststyle") && !exists("w:netrw_liststyle") |let w:netrw_liststyle = b:netrw_liststyle |endif | |
482 | 12423 if exists("b:netrw_bannercnt") && !exists("w:netrw_bannercnt") |let w:netrw_bannercnt = b:netrw_bannercnt |endif |
12424 if exists("b:netrw_method") && !exists("w:netrw_method") |let w:netrw_method = b:netrw_method |endif | |
12425 if exists("b:netrw_prvdir") && !exists("w:netrw_prvdir") |let w:netrw_prvdir = b:netrw_prvdir |endif | |
12426 if exists("b:netrw_explore_indx") && !exists("w:netrw_explore_indx") |let w:netrw_explore_indx = b:netrw_explore_indx |endif | |
12427 if exists("b:netrw_explore_listlen") && !exists("w:netrw_explore_listlen")|let w:netrw_explore_listlen = b:netrw_explore_listlen|endif | |
12428 if exists("b:netrw_explore_mtchcnt") && !exists("w:netrw_explore_mtchcnt")|let w:netrw_explore_mtchcnt = b:netrw_explore_mtchcnt|endif | |
12429 if exists("b:netrw_explore_bufnr") && !exists("w:netrw_explore_bufnr") |let w:netrw_explore_bufnr = b:netrw_explore_bufnr |endif | |
12430 if exists("b:netrw_explore_line") && !exists("w:netrw_explore_line") |let w:netrw_explore_line = b:netrw_explore_line |endif | |
12431 if exists("b:netrw_explore_list") && !exists("w:netrw_explore_list") |let w:netrw_explore_list = b:netrw_explore_list |endif | |
1121 | 12432 " call Dret("s:UseBufWinVars") |
482 | 12433 endfun |
12434 | |
559 | 12435 " --------------------------------------------------------------------- |
7183
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12436 " s:UserMaps: supports user-defined UserMaps {{{2 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12437 " * calls a user-supplied funcref(islocal,curdir) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12438 " * interprets result |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12439 " See netrw#UserMaps() |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12440 fun! s:UserMaps(islocal,funcname) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12441 " call Dfunc("s:UserMaps(islocal=".a:islocal.",funcname<".a:funcname.">)") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12442 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12443 if !exists("b:netrw_curdir") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12444 let b:netrw_curdir= getcwd() |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12445 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12446 let Funcref = function(a:funcname) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12447 let result = Funcref(a:islocal) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12448 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12449 if type(result) == 1 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12450 " if result from user's funcref is a string... |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12451 " call Decho("result string from user funcref<".result.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12452 if result == "refresh" |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12453 " call Decho("refreshing display",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12454 call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12455 elseif result != "" |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12456 " call Decho("executing result<".result.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12457 exe result |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12458 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12459 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12460 elseif type(result) == 3 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12461 " if result from user's funcref is a List... |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12462 " call Decho("result List from user funcref<".string(result).">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12463 for action in result |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12464 if action == "refresh" |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12465 " call Decho("refreshing display",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12466 call s:NetrwRefresh(a:islocal,s:NetrwBrowseChgDir(a:islocal,'./')) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12467 elseif action != "" |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12468 " call Decho("executing action<".action.">",'~'.expand("<slnum>")) |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12469 exe action |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12470 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12471 endfor |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12472 endif |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12473 |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12474 " call Dret("s:UserMaps") |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12475 endfun |
ffad29dc7eee
commit https://github.com/vim/vim/commit/a0f849ee40cbea3c889345256786b640b0becca2
Christian Brabandt <cb@256bit.org>
parents:
6476
diff
changeset
|
12476 |
17433 | 12477 " ========================== |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
12478 " Settings Restoration: {{{1 |
17433 | 12479 " ========================== |
482 | 12480 let &cpo= s:keepcpo |
12481 unlet s:keepcpo | |
12482 | |
17433 | 12483 " =============== |
482 | 12484 " Modelines: {{{1 |
17433 | 12485 " =============== |
482 | 12486 " vim:ts=8 fdm=marker |