Runtime files update
[MacVim.git] / runtime / autoload / vimball.vim
blobf002b8a6f031afbba288e5929edcb51b25af9f94
1 " vimball.vim : construct a file containing both paths and files
2 " Author:       Charles E. Campbell, Jr.
3 " Date:         Jan 07, 2008
4 " Version:      24
5 " GetLatestVimScripts: 1502 1 :AutoInstall: vimball.vim
6 " Copyright: (c) 2004-2007 by Charles E. Campbell, Jr.
7 "            The VIM LICENSE applies to Vimball.vim, and Vimball.txt
8 "            (see |copyright|) except use "Vimball" instead of "Vim".
9 "            No warranty, express or implied.
10 "  *** ***   Use At-Your-Own-Risk!   *** ***
12 " ---------------------------------------------------------------------
13 "  Load Once: {{{1
14 if &cp || exists("g:loaded_vimball") || v:version < 700
15  finish
16 endif
17 let s:keepcpo        = &cpo
18 let g:loaded_vimball = "v24"
19 set cpo&vim
20 "DechoTabOn
22 " =====================================================================
23 " Constants: {{{1
24 if !exists("s:USAGE")
25  let s:USAGE   = 0
26  let s:WARNING = 1
27  let s:ERROR   = 2
28  if exists("g:vimball_shq") && !exists("g:netrw_shq")
29   let g:netrw_shq= g:vimball_shq
30  endif
31  if !exists("g:netrw_cygwin")
32   if has("win32") || has("win95") || has("win64") || has("win16")
33    if &shell =~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$'
34     let g:netrw_cygwin= 1
35    else
36     let g:netrw_cygwin= 0
37    endif
38   else
39    let g:netrw_cygwin= 0
40   endif
41  endif
42  if !exists("g:netrw_shq")
43   if exists("&shq") && &shq != ""
44    let g:netrw_shq= &shq
45   elseif has("win32") || has("win95") || has("win64") || has("win16")
46    if g:netrw_cygwin
47     let g:netrw_shq= "'"
48    else
49     let g:netrw_shq= '"'
50    endif
51   else
52    let g:netrw_shq= "'"
53   endif
54 " call Decho("g:netrw_shq<".g:netrw_shq.">")
55  endif
56  if !exists("g:vimball_path_escape")
57   let g:vimball_path_escape= ' ;#%'
58  endif
59 endif
61 " =====================================================================
62 "  Functions: {{{1
64 " ---------------------------------------------------------------------
65 " vimball#MkVimball: creates a vimball given a list of paths to files {{{2
66 " Input:
67 "     line1,line2: a range of lines containing paths to files to be included in the vimball
68 "     writelevel : if true, force a write to filename.vba, even if it exists
69 "                  (usually accomplished with :MkVimball! ...
70 "     filename   : base name of file to be created (ie. filename.vba)
71 " Output: a filename.vba using vimball format:
72 "     path
73 "     filesize
74 "     [file]
75 "     path
76 "     filesize
77 "     [file]
78 fun! vimball#MkVimball(line1,line2,writelevel,...) range
79 "  call Dfunc("MkVimball(line1=".a:line1." line2=".a:line2." writelevel=".a:writelevel." vimballname<".a:1.">) a:0=".a:0)
80   if a:1 =~ '.vim' || a:1 =~ '.txt'
81    let vbname= substitute(a:1,'\.\a\{3}$','.vba','')
82   else
83    let vbname= a:1
84   endif
85   if vbname !~ '\.vba$'
86    let vbname= vbname.'.vba'
87   endif
88 "  call Decho("vbname<".vbname.">")
89   if a:1 =~ '[\/]'
90    call vimball#ShowMesg(s:ERROR,"(MkVimball) vimball name<".a:1."> should not include slashes")
91 "   call Dret("MkVimball : vimball name<".a:1."> should not include slashes")
92    return
93   endif
94   if !a:writelevel && filereadable(vbname)
95    call vimball#ShowMesg(s:ERROR,"(MkVimball) file<".vbname."> exists; use ! to insist")
96 "   call Dret("MkVimball : file<".vbname."> already exists; use ! to insist")
97    return
98   endif
100   " user option bypass
101   call s:SaveSettings()
103   if a:0 >= 2
104    " allow user to specify where to get the files
105    let home= expand(a:2)
106   else
107    " use first existing directory from rtp
108    let home= s:VimballHome()
109   endif
111   " save current directory
112   let curdir = getcwd()
113   call s:ChgDir(home)
115   " record current tab, initialize while loop index
116   let curtabnr = tabpagenr()
117   let linenr   = a:line1
118 "  call Decho("curtabnr=".curtabnr)
120   while linenr <= a:line2
121    let svfile  = getline(linenr)
122 "   call Decho("svfile<".svfile.">")
124    if !filereadable(svfile)
125     call vimball#ShowMesg(s:ERROR,"unable to read file<".svfile.">")
126         call s:ChgDir(curdir)
127         call s:RestoreSettings()
128 "    call Dret("MkVimball")
129     return
130    endif
132    " create/switch to mkvimball tab
133    if !exists("vbtabnr")
134     tabnew
135     silent! file Vimball
136     let vbtabnr= tabpagenr()
137    else
138     exe "tabn ".vbtabnr
139    endif
141    let lastline= line("$") + 1
142    if lastline == 2 && getline("$") == ""
143         call setline(1,'" Vimball Archiver by Charles E. Campbell, Jr., Ph.D.')
144         call setline(2,'UseVimball')
145         call setline(3,'finish')
146         let lastline= line("$") + 1
147    endif
148    call setline(lastline  ,substitute(svfile,'$','      [[[1',''))
149    call setline(lastline+1,0)
151    " write the file from the tab
152    let svfilepath= s:Path(svfile,'')
153 "   call Decho("exe $r ".svfilepath)
154    exe "$r ".svfilepath
156    call setline(lastline+1,line("$") - lastline - 1)
157 "   call Decho("lastline=".lastline." line$=".line("$"))
159   " restore to normal tab
160    exe "tabn ".curtabnr
161    let linenr= linenr + 1
162   endwhile
164   " write the vimball
165   exe "tabn ".vbtabnr
166   call s:ChgDir(curdir)
167   setlocal ff=unix
168   if a:writelevel
169    let vbnamepath= s:Path(vbname,'')
170 "   call Decho("exe w! ".vbnamepath)
171    exe "w! ".vbnamepath
172   else
173    let vbnamepath= s:Path(vbname,'')
174 "   call Decho("exe w ".vbnamepath)
175    exe "w ".vbnamepath
176   endif
177 "  call Decho("Vimball<".vbname."> created")
178   echo "Vimball<".vbname."> created"
180   " remove the evidence
181   setlocal nomod bh=wipe
182   exe "tabn ".curtabnr
183   exe "tabc ".vbtabnr
185   " restore options
186   call s:RestoreSettings()
188 "  call Dret("MkVimball")
189 endfun
191 " ---------------------------------------------------------------------
192 " vimball#Vimball: extract and distribute contents from a vimball {{{2
193 "                  (invoked the the UseVimball command embedded in 
194 "                  vimballs' prologue)
195 fun! vimball#Vimball(really,...)
196 "  call Dfunc("vimball#Vimball(really=".a:really.") a:0=".a:0)
198   if getline(1) !~ '^" Vimball Archiver by Charles E. Campbell, Jr., Ph.D.$'
199    echoerr "(Vimball) The current file does not appear to be a Vimball!"
200 "   call Dret("vimball#Vimball")
201    return
202   endif
204   " set up standard settings
205   call s:SaveSettings()
206   let curtabnr = tabpagenr()
208   " set up vimball tab
209 "  call Decho("setting up vimball tab")
210   tabnew
211   silent! file Vimball
212   let vbtabnr= tabpagenr()
213   let didhelp= ""
215   " go to vim plugin home
216   if a:0 > 0
217    let home= expand(a:1)
218   else
219    let home= s:VimballHome()
220   endif
221 "  call Decho("home<".home.">")
223   " save current directory and remove older same-named vimball, if any
224   let curdir = getcwd()
225 "  call Decho("home<".home.">")
226 "  call Decho("curdir<".curdir.">")
228   call s:ChgDir(home)
229   call vimball#RmVimball()
231   let linenr  = 4
232   let filecnt = 0
234   " give title to listing of (extracted) files from Vimball Archive
235   if a:really
236    echohl Title | echomsg "Vimball Archive" | echohl None
237   else
238    echohl Title | echomsg "Vimball Archive Listing" | echohl None
239    echohl Statement | echomsg "files would be placed under: ".home | echohl None
240   endif
242   " apportion vimball contents to various files
243 "  call Decho("exe tabn ".curtabnr)
244   exe "tabn ".curtabnr
245 "  call Decho("linenr=".linenr." line$=".line("$"))
246   while 1 < linenr && linenr < line("$")
247    let fname   = substitute(getline(linenr),'\t\[\[\[1$','','')
248    let fname   = substitute(fname,'\\','/','g')
249    let fsize   = getline(linenr+1)
250    let filecnt = filecnt + 1
251 "   call Decho("fname<".fname."> fsize=".fsize." filecnt=".filecnt)
253    if a:really
254     echomsg "extracted <".fname.">: ".fsize." lines"
255    else
256     echomsg "would extract <".fname.">: ".fsize." lines"
257    endif
258 "   call Decho("using L#".linenr.": will extract file<".fname.">")
259 "   call Decho("using L#".(linenr+1).": fsize=".fsize)
261    " Allow AsNeeded/ directory to take place of plugin/ directory
262    " when AsNeeded/filename is filereadable
263    if fname =~ '\<plugin/'
264         let anfname= substitute(fname,'\<plugin/','AsNeeded/','')
265         if filereadable(anfname)
266 "        call Decho("using anfname<".anfname."> instead of <".fname.">")
267          let fname= anfname
268         endif
269    endif
271    " make directories if they don't exist yet
272    if a:really
273 "    call Decho("making directories if they don't exist yet (fname<".fname.">)")
274     let fnamebuf= substitute(fname,'\\','/','g')
275         let dirpath = substitute(home,'\\','/','g')
276     while fnamebuf =~ '/'
277      let dirname  = dirpath."/".substitute(fnamebuf,'/.*$','','')
278          let dirpath  = dirname
279      let fnamebuf = substitute(fnamebuf,'^.\{-}/\(.*\)$','\1','')
280 "        call Decho("dirname<".dirname.">")
281      if !isdirectory(dirname)
282 "      call Decho("making <".dirname.">")
283       call mkdir(dirname)
284           call s:RecordInVar(home,"rmdir('".dirname."')")
285      endif
286     endwhile
287    endif
288    call s:ChgDir(home)
290    " grab specified qty of lines and place into "a" buffer
291    " (skip over path/filename and qty-lines)
292    let linenr   = linenr + 2
293    let lastline = linenr + fsize - 1
294 "   call Decho("exe ".linenr.",".lastline."yank a")
295    exe "silent ".linenr.",".lastline."yank a"
297    " copy "a" buffer into tab
298 "   call Decho('copy "a buffer into tab#'.vbtabnr)
299    exe "tabn ".vbtabnr
300    setlocal ma
301    silent! %d
302    silent put a
303    1
304    silent d
306    " write tab to file
307    if a:really
308     let fnamepath= s:Path(home."/".fname,'')
309 "    call Decho("exe w! ".fnamepath)
310     exe "silent w! ".fnamepath
311     echo "wrote ".fnamepath
312         call s:RecordInVar(home,"call delete('".fnamepath."')")
313    endif
315    " return to tab with vimball
316 "   call Decho("exe tabn ".curtabnr)
317    exe "tabn ".curtabnr
319    " set up help if its a doc/*.txt file
320 "   call Decho("didhelp<".didhelp."> fname<".fname.">")
321    if a:really && didhelp == "" && fname =~ 'doc/[^/]\+\.txt$'
322         let didhelp= substitute(fname,'^\(.*\<doc\)[/\\][^.]*\.txt$','\1','')
323 "       call Decho("didhelp<".didhelp.">")
324    endif
326    " update for next file
327 "   let oldlinenr = linenr " Decho
328    let linenr    = linenr + fsize
329 "   call Decho("update linenr= [linenr=".oldlinenr."] + [fsize=".fsize."] = ".linenr)
330   endwhile
332   " set up help
333 "  call Decho("about to set up help: didhelp<".didhelp.">")
334   if didhelp != ""
335    let htpath= s:Path(home."/".didhelp,"")
336    "let htpath= escape(substitute(s:Path(home."/".didhelp,'"'),'"','','g'),' ')
337 "   call Decho("exe helptags ".htpath)
338    exe "helptags ".htpath
339    echo "did helptags"
340   endif
342   " make sure a "Press ENTER..." prompt appears to keep the messages showing!
343   while filecnt <= &ch
344    echomsg " "
345    let filecnt= filecnt + 1
346   endwhile
348   " record actions in <.VimballRecord>
349   call s:RecordInFile(home)
351   " restore events, delete tab and buffer
352   exe "tabn ".vbtabnr
353   setlocal nomod bh=wipe
354   exe "tabn ".curtabnr
355   exe "tabc ".vbtabnr
356   call s:RestoreSettings()
357   call s:ChgDir(curdir)
359 "  call Dret("vimball#Vimball")
360 endfun
362 " ---------------------------------------------------------------------
363 " vimball#RmVimball: remove any files, remove any directories made by any {{{2
364 "               previous vimball extraction based on a file of the current
365 "               name.
366 "  Usage:  RmVimball  (assume current file is a vimball; remove)
367 "          RmVimball vimballname
368 fun! vimball#RmVimball(...)
369 "  call Dfunc("vimball#RmVimball() a:0=".a:0)
370   if exists("g:vimball_norecord")
371 "   call Dret("vimball#RmVimball : (g:vimball_norecord)")
372    return
373   endif
374   let eikeep= &ei
375   set ei=all
376 "  call Decho("turned off all events")
378   if a:0 == 0
379    let curfile= '^'.expand("%:tr")
380   else
381    if a:1 =~ '[\/]'
382     call vimball#ShowMesg(s:USAGE,"RmVimball vimballname [path]")
383 "    call Dret("vimball#RmVimball : suspect a:1<".a:1.">")
384     return
385    endif
386    let curfile= a:1
387   endif
388   if curfile !~ '.vba$'
389    let curfile= curfile.".vba: "
390   else
391    let curfile= curfile.": "
392   endif
393   if a:0 >= 2
394    let home= expand(a:2)
395   else
396    let home= s:VimballHome()
397   endif
398   let curdir = getcwd()
399 "  call Decho("home   <".home.">")
400 "  call Decho("curfile<".curfile.">")
401 "  call Decho("curdir <".curdir.">")
403   call s:ChgDir(home)
404   if filereadable(".VimballRecord")
405 "   call Decho(".VimballRecord is readable")
406 "   call Decho("curfile<".curfile.">")
407    keepalt keepjumps 1split 
408    silent! keepalt keepjumps e .VimballRecord
409    let keepsrch= @/
410    if search(curfile,'cw')
411         let exestring= substitute(getline("."),curfile,'','')
412 "       call Decho("exe ".exestring)
413         silent! keepalt keepjumps exe exestring
414         silent! keepalt keepjumps d
415    else
416 "       call Decho("unable to find <".curfile."> in .VimballRecord")
417    endif
418    silent! keepalt keepjumps g/^\s*$/d
419    silent! keepalt keepjumps wq!
420    let @/= keepsrch
421   endif
422   call s:ChgDir(curdir)
424   " restoring events
425 "  call Decho("restoring events")
426   let &ei= eikeep
428 "  call Dret("vimball#RmVimball")
429 endfun
431 " ---------------------------------------------------------------------
432 " vimball#Decompress: attempts to automatically decompress vimballs {{{2
433 fun! vimball#Decompress(fname)
434 "  call Dfunc("Decompress(fname<".a:fname.">)")
436   " decompression:
437   if     expand("%") =~ '.*\.gz'  && executable("gunzip")
438    silent exe "!gunzip ".s:Escape(a:fname)
439    if v:shell_error != 0
440         call vimball#ShowMesg(s:WARNING,"(vimball#Decompress) gunzip may have failed with <".a:fname.">")
441    endif
442    let fname= substitute(a:fname,'\.gz$','','')
443    exe "e ".escape(fname,' \')
444    call vimball#ShowMesg(s:USAGE,"Source this file to extract it! (:so %)")
445   elseif expand("%") =~ '.*\.bz2' && executable("bunzip2")
446    silent exe "!bunzip2 ".s:Escape(a:fname)
447    if v:shell_error != 0
448         call vimball#ShowMesg(s:WARNING,"(vimball#Decompress) bunzip2 may have failed with <".a:fname.">")
449    endif
450    let fname= substitute(a:fname,'\.bz2$','','')
451    exe "e ".escape(fname,' \')
452    call vimball#ShowMesg(s:USAGE,"Source this file to extract it! (:so %)")
453   elseif expand("%") =~ '.*\.zip' && executable("unzip")
454    silent exe "!unzip ".s:Escape(a:fname)
455    if v:shell_error != 0
456         call vimball#ShowMesg(s:WARNING,"(vimball#Decompress) unzip may have failed with <".a:fname.">")
457    endif
458    let fname= substitute(a:fname,'\.zip$','','')
459    exe "e ".escape(fname,' \')
460    call vimball#ShowMesg(s:USAGE,"Source this file to extract it! (:so %)")
461   endif
462   set noma bt=nofile fmr=[[[,]]] fdm=marker
464 "  call Dret("Decompress")
465 endfun
467 " ---------------------------------------------------------------------
468 " vimball#ShowMesg: {{{2
469 fun! vimball#ShowMesg(level,msg)
470 "  call Dfunc("vimball#ShowMesg(level=".a:level." msg<".a:msg.">)")
471   let rulerkeep   = &ruler
472   let showcmdkeep = &showcmd
473   set noruler noshowcmd
474   redraw!
476   if &fo =~ '[ta]'
477    echomsg "***vimball*** " a:msg
478   else
479    if a:level == s:WARNING || a:level == s:USAGE
480     echohl WarningMsg
481    elseif a:level == s:ERROR
482     echohl Error
483    endif
484    echomsg "***vimball*** " a:msg
485    echohl None
486   endif
488   if a:level != s:USAGE
489    call inputsave()|let ok= input("Press <cr> to continue")|call inputrestore()
490   endif
492   let &ruler   = rulerkeep
493   let &showcmd = showcmdkeep
495 "  call Dret("vimball#ShowMesg")
496 endfun
498 " ---------------------------------------------------------------------
499 let &cpo= s:keepcpo
500 unlet s:keepcpo
501 " =====================================================================
502 " s:ChgDir: change directory (in spite of Windoze) {{{2
503 fun! s:ChgDir(newdir)
504 "  call Dfunc("ChgDir(newdir<".a:newdir.">)")
505   if (has("win32") || has("win95") || has("win64") || has("win16"))
506     exe 'silent cd '.escape(substitute(a:newdir,'/','\\','g'),' ')
507   else
508    exe 'silent cd '.escape(a:newdir,' ')
509   endif
510 "  call Dret("ChgDir : curdir<".getcwd().">")
511 endfun
513 " ---------------------------------------------------------------------
514 " s:Path: prepend and append quotes and do escaping {{{2
515 fun! s:Path(cmd,quote)
516 "  call Dfunc("Path(cmd<".a:cmd."> quote<".a:quote.">) vimball_path_escape<".g:vimball_path_escape.">")
517   if (has("win32") || has("win95") || has("win64") || has("win16"))
518 "   let cmdpath= a:quote.substitute(a:cmd,'/','\\','g').a:quote
519    let cmdpath= a:quote.substitute(a:cmd,'\\','/','g').a:quote
520 "   call Decho("cmdpath<".cmdpath."> (win32 mod)")
521   else
522    let cmdpath= a:quote.a:cmd.a:quote
523 "   call Decho("cmdpath<".cmdpath."> (not-win32 mod)")
524   endif
525   if a:quote == "" && g:vimball_path_escape !~ ' '
526    let cmdpath= escape(cmdpath,' ')
527 "   call Decho("cmdpath<".cmdpath."> (empty quote case)")
528   endif
529   let cmdpath= escape(cmdpath,g:vimball_path_escape)
530 "  call Dret("Path <".cmdpath.">")
531   return cmdpath
532 endfun
534 " ---------------------------------------------------------------------
535 " s:RecordInVar: record a un-vimball command in the .VimballRecord file {{{2
536 fun! s:RecordInVar(home,cmd)
537 "  call Dfunc("RecordInVar(home<".a:home."> cmd<".a:cmd.">)")
538   if a:cmd =~ '^rmdir'
539 "   if !exists("s:recorddir")
540 "    let s:recorddir= substitute(a:cmd,'^rmdir',"call s:Rmdir",'')
541 "   else
542 "    let s:recorddir= s:recorddir."|".substitute(a:cmd,'^rmdir',"call s:Rmdir",'')
543 "   endif
544   elseif !exists("s:recordfile")
545    let s:recordfile= a:cmd
546   else
547    let s:recordfile= s:recordfile."|".a:cmd
548   endif
549 "  call Dret("RecordInVar : s:recordfile<".(exists("s:recordfile")? s:recordfile : "")."> s:recorddir<".(exists("s:recorddir")? s:recorddir : "").">")
550 endfun
552 " ---------------------------------------------------------------------
553 " s:RecordInFile: {{{2
554 fun! s:RecordInFile(home)
555 "  call Dfunc("s:RecordInFile()")
556   if exists("g:vimball_norecord")
557 "   call Dret("s:RecordInFile : g:vimball_norecord")
558    return
559   endif
561   if exists("s:recordfile") || exists("s:recorddir")
562    let curdir= getcwd()
563    call s:ChgDir(a:home)
564    keepalt keepjumps 1split 
566    let cmd= expand("%:tr").": "
567 "   call Decho("cmd<".cmd.">")
569    silent! keepalt keepjumps e .VimballRecord
570    setlocal ma
571    $
572    if exists("s:recordfile") && exists("s:recorddir")
573         let cmd= cmd.s:recordfile."|".s:recorddir
574    elseif exists("s:recorddir")
575         let cmd= cmd.s:recorddir
576    elseif exists("s:recordfile")
577         let cmd= cmd.s:recordfile
578    else
579 "    call Dret("s:RecordInFile : neither recordfile nor recorddir exist")
580         return
581    endif
582 "   call Decho("cmd<".cmd.">")
584    " put command into buffer, write .VimballRecord `file
585    keepalt keepjumps put=cmd
586    silent! keepalt keepjumps g/^\s*$/d
587    silent! keepalt keepjumps wq!
588    call s:ChgDir(curdir)
590    if exists("s:recorddir")
591 "       call Decho("unlet s:recorddir<".s:recorddir.">")
592         unlet s:recorddir
593    endif
594    if exists("s:recordfile")
595 "       call Decho("unlet s:recordfile<".s:recordfile.">")
596         unlet s:recordfile
597    endif
598   else
599 "   call Decho("s:record[file|dir] doesn't exist")
600   endif
602 "  call Dret("s:RecordInFile")
603 endfun
605 " ---------------------------------------------------------------------
606 " s:VimballHome: determine/get home directory path (usually from rtp) {{{2
607 fun! s:VimballHome()
608 "  call Dfunc("VimballHome()")
609   if exists("g:vimball_home")
610    let home= g:vimball_home
611   else
612    " go to vim plugin home
613    for home in split(&rtp,',') + ['']
614     if isdirectory(home) && filewritable(home) | break | endif
615    endfor
616    if home == ""
617     " just pick the first directory
618     let home= substitute(&rtp,',.*$','','')
619    endif
620    if (has("win32") || has("win95") || has("win64") || has("win16"))
621     let home= substitute(home,'/','\\','g')
622    endif
623   endif
624 "  call Dret("VimballHome <".home.">")
625   return home
626 endfun
628 " ---------------------------------------------------------------------
629 " s:SaveSettings: {{{2
630 fun! s:SaveSettings()
631 "  call Dfunc("SaveSettings()")
632   let s:makeep  = getpos("'a")
633   let s:regakeep= @a
634   if exists("&acd")
635    let s:acdkeep = &acd
636   endif
637   let s:eikeep  = &ei
638   let s:fenkeep = &fen
639   let s:hidkeep = &hidden
640   let s:ickeep  = &ic
641   let s:lzkeep  = &lz
642   let s:pmkeep  = &pm
643   let s:repkeep = &report
644   let s:vekeep  = &ve
645   let s:ffkeep  = &ff
646   if exists("&acd")
647    setlocal ei=all ve=all noacd nofen noic report=999 nohid bt= ma lz pm= ff=unix
648   else
649    setlocal ei=all ve=all       nofen noic report=999 nohid bt= ma lz pm= ff=unix
650   endif
651   " vimballs should be in unix format
652   setlocal ff=unix
653 "  call Dret("SaveSettings")
654 endfun
656 " ---------------------------------------------------------------------
657 " s:RestoreSettings: {{{2
658 fun! s:RestoreSettings()
659 "  call Dfunc("RestoreSettings()")
660   let @a      = s:regakeep
661   if exists("&acd")
662    let &acd   = s:acdkeep
663   endif
664   let &fen    = s:fenkeep
665   let &hidden = s:hidkeep
666   let &ic     = s:ickeep
667   let &lz     = s:lzkeep
668   let &pm     = s:pmkeep
669   let &report = s:repkeep
670   let &ve     = s:vekeep
671   let &ei     = s:eikeep
672   let &ff     = s:ffkeep
673   if s:makeep[0] != 0
674    " restore mark a
675 "   call Decho("restore mark-a: makeep=".string(makeep))
676    call setpos("'a",s:makeep)
677   endif
678   if exists("&acd")
679    unlet s:acdkeep
680   endif
681   unlet s:regakeep s:eikeep s:fenkeep s:hidkeep s:ickeep s:repkeep s:vekeep s:makeep s:lzkeep s:pmkeep s:ffkeep
682 "  call Dret("RestoreSettings")
683 endfun
685 " ---------------------------------------------------------------------
686 " s:Escape: {{{2
687 fun s:Escape(name)
688   " shellescape() was added by patch 7.0.111
689   if exists("*shellescape")
690     return shellescape(a:name)
691   endif
692   return g:netrw_shq . a:name . g:netrw_shq
693 endfun
695 " ---------------------------------------------------------------------
696 " Modelines: {{{1
697 " vim: fdm=marker