Merged from the latest developing branch.
[MacVim.git] / runtime / autoload / getscript.vim
blobc1e1aa34a56eb69527e2788c29b687af06bfc76c
1 " ---------------------------------------------------------------------
2 " getscript.vim
3 "  Author:      Charles E. Campbell, Jr.
4 "  Date:        May 30, 2008
5 "  Version:     30
6 "  Installing:  :help glvs-install
7 "  Usage:       :help glvs
9 " GetLatestVimScripts: 642 1 :AutoInstall: getscript.vim
10 "redraw!|call inputsave()|call input("Press <cr> to continue")|call inputrestore()
11 " ---------------------------------------------------------------------
12 " Initialization:       {{{1
13 " if you're sourcing this file, surely you can't be
14 " expecting vim to be in its vi-compatible mode!
15 if &cp
16  echoerr "GetLatestVimScripts is not vi-compatible; not loaded (you need to set nocp)"
17  finish
18 endif
19 let s:keepcpo = &cpo
20 set cpo&vim
21 "DechoTabOn
23 if exists("g:loaded_getscript")
24  finish
25 endif
26 let g:loaded_getscript= "v30"
28 " ---------------------------
29 " Global Variables: {{{1
30 " ---------------------------
31 " Cygwin Detection ------- {{{2
32 if !exists("g:getscript_cygwin")
33  if has("win32") || has("win95") || has("win64") || has("win16")
34   if &shell =~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$'
35    let g:getscript_cygwin= 1
36   else
37    let g:getscript_cygwin= 0
38   endif
39  else
40   let g:getscript_cygwin= 0
41  endif
42 endif
43 " shell quoting character {{{2
44 if exists("g:netrw_shq") && !exists("g:getscript_shq")
45  let g:getscript_shq= g:netrw_shq
46 elseif !exists("g:getscript_shq")
47  if exists("&shq") && &shq != ""
48   let g:getscript_shq= &shq
49  elseif exists("&sxq") && &sxq != ""
50   let g:getscript_shq= &sxq
51  elseif has("win32") || has("win95") || has("win64") || has("win16")
52   if g:getscript_cygwin
53    let g:getscript_shq= "'"
54   else
55    let g:getscript_shq= '"'
56   endif
57  else
58   let g:getscript_shq= "'"
59  endif
60 " call Decho("g:getscript_shq<".g:getscript_shq.">")
61 endif
63 " wget vs curl {{{2
64 if !exists("g:GetLatestVimScripts_wget")
65  if executable("wget")
66   let g:GetLatestVimScripts_wget= "wget"
67  elseif executable("curl")
68   let g:GetLatestVimScripts_wget= "curl"
69  else
70   let g:GetLatestVimScripts_wget    = 'echo "GetLatestVimScripts needs wget or curl"'
71   let g:GetLatestVimScripts_options = ""
72  endif
73 endif
75 " options that wget and curl require:
76 if !exists("g:GetLatestVimScripts_options")
77  if g:GetLatestVimScripts_wget == "wget"
78   let g:GetLatestVimScripts_options= "-q -O"
79  elseif g:GetLatestVimScripts_wget == "curl"
80   let g:GetLatestVimScripts_options= "-s -O"
81  else
82   let g:GetLatestVimScripts_options= ""
83  endif
84 endif
86 " by default, allow autoinstall lines to work
87 if !exists("g:GetLatestVimScripts_allowautoinstall")
88  let g:GetLatestVimScripts_allowautoinstall= 1
89 endif
91 "" For debugging:
92 "let g:GetLatestVimScripts_wget    = "echo"
93 "let g:GetLatestVimScripts_options = "options"
95 " ---------------------------------------------------------------------
96 " Check If AutoInstall Capable: {{{1
97 let s:autoinstall= ""
98 if g:GetLatestVimScripts_allowautoinstall
100  if (has("win32") || has("gui_win32") || has("gui_win32s") || has("win16") || has("win64") || has("win32unix") || has("win95")) && &shell != "bash"
101   " windows (but not cygwin/bash)
102   let s:dotvim= "vimfiles"
103   if !exists("g:GetLatestVimScripts_mv")
104    let g:GetLatestVimScripts_mv= "ren"
105   endif
107  else
108   " unix
109   let s:dotvim= ".vim"
110   if !exists("g:GetLatestVimScripts_mv")
111    let g:GetLatestVimScripts_mv= "mv"
112   endif
113  endif
115  if exists('$HOME') && isdirectory(expand("$HOME")."/".s:dotvim)
116   let s:autoinstall= $HOME."/".s:dotvim
117  endif
118 " call Decho("s:autoinstall<".s:autoinstall.">")
119 "else "Decho
120 " call Decho("g:GetLatestVimScripts_allowautoinstall=".g:GetLatestVimScripts_allowautoinstall.": :AutoInstall: disabled")
121 endif
123 " ---------------------------------------------------------------------
124 "  Public Interface: {{{1
125 com!        -nargs=0 GetLatestVimScripts call getscript#GetLatestVimScripts()
126 com!        -nargs=0 GetScript           call getscript#GetLatestVimScripts()
127 silent! com -nargs=0 GLVS                call getscript#GetLatestVimScripts()
129 " ---------------------------------------------------------------------
130 " GetLatestVimScripts: this function gets the latest versions of {{{1
131 "                      scripts based on the list in
132 "   (first dir in runtimepath)/GetLatest/GetLatestVimScripts.dat
133 fun! getscript#GetLatestVimScripts()
134 "  call Dfunc("GetLatestVimScripts() autoinstall<".s:autoinstall.">")
136 " insure that wget is executable
137   if executable(g:GetLatestVimScripts_wget) != 1
138    echoerr "GetLatestVimScripts needs ".g:GetLatestVimScripts_wget." which apparently is not available on your system"
139 "   call Dret("GetLatestVimScripts : wget not executable/availble")
140    return
141   endif
143   " Find the .../GetLatest subdirectory under the runtimepath
144   for datadir in split(&rtp,',') + ['']
145    if isdirectory(datadir."/GetLatest")
146 "    call Decho("found directory<".datadir.">")
147     let datadir= datadir . "/GetLatest"
148     break
149    endif
150    if filereadable(datadir."GetLatestVimScripts.dat")
151 "    call Decho("found ".datadir."/GetLatestVimScripts.dat")
152     break
153    endif
154   endfor
156   " Sanity checks: readability and writability
157   if datadir == ""
158    echoerr 'Missing "GetLatest/" on your runtimepath - see :help glvs-dist-install'
159 "   call Dret("GetLatestVimScripts : unable to find a GetLatest subdirectory")
160    return
161   endif
163   if filewritable(datadir) != 2
164    echoerr "(getLatestVimScripts) Your ".datadir." isn't writable"
165 "   call Dret("GetLatestVimScripts : non-writable directory<".datadir.">")
166    return
167   endif
168   let datafile= datadir."/GetLatestVimScripts.dat"
169   if !filereadable(datafile)
170    echoerr "Your data file<".datafile."> isn't readable"
171 "   call Dret("GetLatestVimScripts : non-readable datafile<".datafile.">")
172    return
173   endif
174   if !filewritable(datafile)
175    echoerr "Your data file<".datafile."> isn't writable"
176 "   call Dret("GetLatestVimScripts : non-writable datafile<".datafile.">")
177    return
178   endif
179 "  call Decho("datadir  <".datadir.">")
180 "  call Decho("datafile <".datafile.">")
182   " don't let any events interfere (like winmanager's, taglist's, etc)
183   let eikeep= &ei
184   set ei=all
186   " record current directory, change to datadir, open split window with
187   " datafile
188   let origdir= getcwd()
189 "  call Decho("exe cd ".fnameescape(substitute(datadir,'\','/','ge')))
190   exe "cd ".fnameescape(substitute(datadir,'\','/','ge'))
191   split
192 "  call Decho("exe e ".fnameescape(substitute(datafile,'\','/','ge')))
193   exe "e ".fnameescape(substitute(datafile,'\','/','ge'))
194   res 1000
195   let s:downloads = 0
196   let s:downerrors= 0
198   " Check on dependencies mentioned in plugins
199 "  call Decho(" ")
200 "  call Decho("searching plugins for GetLatestVimScripts dependencies")
201   let lastline    = line("$")
202 "  call Decho("lastline#".lastline)
203   let plugins     = split(globpath(&rtp,"plugin/*.vim"),'\n')
204   let foundscript = 0
205   let firstdir= ""
207   for plugin in plugins
208 "   call Decho("plugin<".plugin.">")
210    " don't process plugins in system directories
211    if firstdir == ""
212     let firstdir= substitute(plugin,'[/\\][^/\\]\+$','','')
213 "    call Decho("setting firstdir<".firstdir.">")
214    else
215     let curdir= substitute(plugin,'[/\\][^/\\]\+$','','')
216 "    call Decho("curdir<".curdir.">")
217     if curdir != firstdir
218 "     call Decho("skipping subsequent plugins: curdir<".curdir."> != firstdir<".firstdir.">")
219      break
220     endif
221    endif
223    " read plugin in
224    " evidently a :r creates a new buffer (the "#" buffer) that is subsequently unused -- bwiping it
225    $
226 "   call Decho(" ")
227 "   call Decho(".dependency checking<".plugin."> line$=".line("$"))
228 "   call Decho("exe silent r ".fnameescape(plugin))
229    exe "silent r ".fnameescape(plugin)
230    exe "silent bwipe ".bufnr("#")
232    while search('^"\s\+GetLatestVimScripts:\s\+\d\+\s\+\d\+','W') != 0
233     let newscript= substitute(getline("."),'^"\s\+GetLatestVimScripts:\s\+\d\+\s\+\d\+\s\+\(.*\)$','\1','e')
234     let llp1     = lastline+1
235 "    call Decho("..newscript<".newscript.">")
237     " don't process ""GetLatestVimScripts lines -- those that have been doubly-commented out
238     if newscript !~ '^"'
239      " found a "GetLatestVimScripts: # #" line in the script; check if its already in the datafile
240      let curline     = line(".")
241      let noai_script = substitute(newscript,'\s*:AutoInstall:\s*','','e')
242      exe llp1
243      let srchline    = search('\<'.noai_script.'\>','bW')
244 "     call Decho("..noai_script<".noai_script."> srch=".srchline."curline#".line(".")." lastline#".lastline)
246      if srchline == 0
247       " found a new script to permanently include in the datafile
248       let keep_rega   = @a
249       let @a          = substitute(getline(curline),'^"\s\+GetLatestVimScripts:\s\+','','')
250       exe lastline."put a"
251       echomsg "Appending <".@a."> to ".datafile." for ".newscript
252 "      call Decho("..APPEND (".noai_script.")<".@a."> to GetLatestVimScripts.dat")
253       let @a          = keep_rega
254       let lastline    = llp1
255       let curline     = curline     + 1
256       let foundscript = foundscript + 1
257 "     else      " Decho
258 "      call Decho("..found <".noai_script."> (already in datafile at line#".srchline.")")
259      endif
261      let curline = curline + 1
262      exe curline
263     endif
264    endwhile
266    let llp1= lastline + 1
267 "   call Decho(".deleting lines: ".llp1.",$d")
268    exe "silent! ".llp1.",$d"
269   endfor
270 "  call Decho("--- end dependency checking loop ---  foundscript=".foundscript)
271 "  call Decho(" ")
272 "  call Dredir("BUFFER TEST (GetLatestVimScripts 1)","ls!")
274   if foundscript == 0
275    setlocal nomod
276   endif
278   " Check on out-of-date scripts using GetLatest/GetLatestVimScripts.dat
279 "  call Decho("begin: checking out-of-date scripts using datafile<".datafile.">")
280   setlocal lz
281   1
282 "  /^-----/,$g/^\s*\d/call Decho(getline("."))
283   1
284   /^-----/,$g/^\s*\d/call s:GetOneScript()
285 "  call Decho("--- end out-of-date checking --- ")
287   " Final report (an echomsg)
288   try
289    silent! ?^-------?
290   catch /^Vim\%((\a\+)\)\=:E114/
291 "   call Dret("GetLatestVimScripts : nothing done!")
292    return
293   endtry
294   exe "norm! kz\<CR>"
295   redraw!
296   let s:msg = ""
297   if s:downloads == 1
298   let s:msg = "Downloaded one updated script to <".datadir.">"
299   elseif s:downloads == 2
300    let s:msg= "Downloaded two updated scripts to <".datadir.">"
301   elseif s:downloads > 1
302    let s:msg= "Downloaded ".s:downloads." updated scripts to <".datadir.">"
303   else
304    let s:msg= "Everything was already current"
305   endif
306   if s:downerrors > 0
307    let s:msg= s:msg." (".s:downerrors." downloading errors)"
308   endif
309   echomsg s:msg
310   " save the file
311   if &mod
312    silent! w!
313   endif
314   q
316   " restore events and current directory
317   exe "cd ".fnameescape(substitute(origdir,'\','/','ge'))
318   let &ei= eikeep
319   setlocal nolz
320 "  call Dredir("BUFFER TEST (GetLatestVimScripts 2)","ls!")
321 "  call Dret("GetLatestVimScripts : did ".s:downloads." downloads")
322 endfun
324 " ---------------------------------------------------------------------
325 "  GetOneScript: (Get Latest Vim Script) this function operates {{{1
326 "    on the current line, interpreting two numbers and text as
327 "    ScriptID, SourceID, and Filename.
328 "    It downloads any scripts that have newer versions from vim.sf.net.
329 fun! s:GetOneScript(...)
330 "   call Dfunc("GetOneScript()")
332  " set options to allow progress to be shown on screen
333   let rega= @a
334   let t_ti= &t_ti
335   let t_te= &t_te
336   let rs  = &rs
337   set t_ti= t_te= nors
339  " put current line on top-of-screen and interpret it into
340  " a      script identifer  : used to obtain webpage
341  "        source identifier : used to identify current version
342  " and an associated comment: used to report on what's being considered
343   if a:0 >= 3
344    let scriptid = a:1
345    let srcid    = a:2
346    let fname    = a:3
347    let cmmnt    = ""
348 "   call Decho("scriptid<".scriptid.">")
349 "   call Decho("srcid   <".srcid.">")
350 "   call Decho("fname   <".fname.">")
351   else
352    let curline  = getline(".")
353    if curline =~ '^\s*#'
354     let @a= rega
355 "    call Dret("GetOneScript : skipping a pure comment line")
356     return
357    endif
358    let parsepat = '^\s*\(\d\+\)\s\+\(\d\+\)\s\+\(.\{-}\)\(\s*#.*\)\=$'
359    try
360     let scriptid = substitute(curline,parsepat,'\1','e')
361    catch /^Vim\%((\a\+)\)\=:E486/
362     let scriptid= 0
363    endtry
364    try
365     let srcid    = substitute(curline,parsepat,'\2','e')
366    catch /^Vim\%((\a\+)\)\=:E486/
367     let srcid= 0
368    endtry
369    try
370     let fname= substitute(curline,parsepat,'\3','e')
371    catch /^Vim\%((\a\+)\)\=:E486/
372     let fname= ""
373    endtry
374    try
375     let cmmnt= substitute(curline,parsepat,'\4','e')
376    catch /^Vim\%((\a\+)\)\=:E486/
377     let cmmnt= ""
378    endtry
379 "   call Decho("curline <".curline.">")
380 "   call Decho("parsepat<".parsepat.">")
381 "   call Decho("scriptid<".scriptid.">")
382 "   call Decho("srcid   <".srcid.">")
383 "   call Decho("fname   <".fname.">")
384   endif
386   if scriptid == 0 || srcid == 0
387    " When looking for :AutoInstall: lines, skip scripts that have   0 0 scriptname
388    let @a= rega
389 "   call Dret("GetOneScript : skipping a scriptid==srcid==0 line")
390    return
391   endif
393   let doautoinstall= 0
394   if fname =~ ":AutoInstall:"
395 "   call Decho("case AutoInstall: fname<".fname.">")
396    let aicmmnt= substitute(fname,'\s\+:AutoInstall:\s\+',' ','')
397 "   call Decho("aicmmnt<".aicmmnt."> s:autoinstall=".s:autoinstall)
398    if s:autoinstall != ""
399     let doautoinstall = g:GetLatestVimScripts_allowautoinstall
400    endif
401   else
402    let aicmmnt= fname
403   endif
404 "  call Decho("aicmmnt<".aicmmnt.">: doautoinstall=".doautoinstall)
406   exe "norm z\<CR>"
407   redraw!
408 "  call Decho('considering <'.aicmmnt.'> scriptid='.scriptid.' srcid='.srcid)
409   echo 'considering <'.aicmmnt.'> scriptid='.scriptid.' srcid='.srcid
411   " grab a copy of the plugin's vim.sf.net webpage
412   let scriptaddr = 'http://vim.sf.net/script.php?script_id='.scriptid
413   let tmpfile    = tempname()
414   let v:errmsg   = ""
416   " make up to three tries at downloading the description
417   let itry= 1
418   while itry <= 3
419 "   call Decho("try#".itry." to download description of <".aicmmnt."> with addr=".scriptaddr)
420    if has("win32") || has("win16") || has("win95")
421 "    call Decho("new|exe silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".s:Escape(tmpfile).' '.s:Escape(scriptaddr)."|bw!")
422     new|exe "silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".s:Escape(tmpfile).' '.s:Escape(scriptaddr)|bw!
423    else
424 "    call Decho("exe silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".s:Escape(tmpfile)." ".s:Escape(scriptaddr))
425     exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".s:Escape(tmpfile)." ".s:Escape(scriptaddr)
426    endif
427    if itry == 1
428     exe "silent vsplit ".fnameescape(tmpfile)
429    else
430     silent! e %
431    endif
432    setlocal bh=wipe
433   
434    " find the latest source-id in the plugin's webpage
435    silent! 1
436    let findpkg= search('Click on the package to download','W')
437    if findpkg > 0
438     break
439    endif
440    let itry= itry + 1
441   endwhile
442 "  call Decho(" --- end downloading tries while loop --- itry=".itry)
444   " testing: did finding "Click on the package..." fail?
445   if findpkg == 0 || itry >= 4
446    silent q!
447    call delete(tmpfile)
448   " restore options
449    let &t_ti        = t_ti
450    let &t_te        = t_te
451    let &rs          = rs
452    let s:downerrors = s:downerrors + 1
453 "   call Decho("***warning*** couldn'".'t find "Click on the package..." in description page for <'.aicmmnt.">")
454    echomsg "***warning*** couldn'".'t find "Click on the package..." in description page for <'.aicmmnt.">"
455 "   call Dret("GetOneScript : srch for /Click on the package/ failed")
456    let @a= rega
457    return
458   endif
459 "  call Decho('found "Click on the package to download"')
461   let findsrcid= search('src_id=','W')
462   if findsrcid == 0
463    silent q!
464    call delete(tmpfile)
465   " restore options
466    let &t_ti        = t_ti
467    let &t_te        = t_te
468    let &rs          = rs
469    let s:downerrors = s:downerrors + 1
470 "   call Decho("***warning*** couldn'".'t find "src_id=" in description page for <'.aicmmnt.">")
471    echomsg "***warning*** couldn'".'t find "src_id=" in description page for <'.aicmmnt.">"
472    let @a= rega
473 "  call Dret("GetOneScript : srch for /src_id/ failed")
474    return
475   endif
476 "  call Decho('found "src_id=" in description page')
478   let srcidpat   = '^\s*<td class.*src_id=\(\d\+\)">\([^<]\+\)<.*$'
479   let latestsrcid= substitute(getline("."),srcidpat,'\1','')
480   let sname      = substitute(getline("."),srcidpat,'\2','') " script name actually downloaded
481 "  call Decho("srcidpat<".srcidpat."> latestsrcid<".latestsrcid."> sname<".sname.">")
482   silent q!
483   call delete(tmpfile)
485   " convert the strings-of-numbers into numbers
486   let srcid       = srcid       + 0
487   let latestsrcid = latestsrcid + 0
488 "  call Decho("srcid=".srcid." latestsrcid=".latestsrcid." sname<".sname.">")
490   " has the plugin's most-recent srcid increased, which indicates
491   " that it has been updated
492   if latestsrcid > srcid
493 "   call Decho("[latestsrcid=".latestsrcid."] <= [srcid=".srcid."]: need to update <".sname.">")
495    let s:downloads= s:downloads + 1
496    if sname == bufname("%")
497     " GetLatestVimScript has to be careful about downloading itself
498     let sname= "NEW_".sname
499    endif
501    " the plugin has been updated since we last obtained it, so download a new copy
502 "   call Decho("...downloading new <".sname.">")
503    echomsg "...downloading new <".sname.">"
504    if has("win32") || has("win16") || has("win95")
505 "    call Decho("new|exe silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".s:Escape(sname)." ".s:Escape('http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid)."|q")
506     new|exe "silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".s:Escape(sname)." ".s:Escape('http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid)|q
507    else
508 "    call Decho("exe silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".s:Escape(sname)." ".s:Escape('http://vim.sf.net/scripts/download_script.php?src_id='))
509     exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".s:Escape(sname)." ".s:Escape('http://vim.sf.net/scripts/download_script.php?src_id=')
510    endif
512    " AutoInstall: only if doautoinstall has been requested by the plugin itself
513    if doautoinstall
514 "    call Decho("attempting to do autoinstall: getcwd<".getcwd()."> filereadable(".sname.")=".filereadable(sname))
515     if filereadable(sname)
516      call Decho("exe silent !".g:GetLatestVimScripts_mv." ".s:Escape(sname)." ".s:Escape(s:autoinstall))
517      exe "silent !".g:GetLatestVimScripts_mv." ".s:Escape(sname)." ".s:Escape(s:autoinstall)
518      let curdir    = escape(substitute(getcwd(),'\','/','ge'),"|[]*'\" #")
519      let installdir= curdir."/Installed"
520      if !isdirectory(installdir)
521       call mkdir(installdir)
522      endif
523 "    call Decho("exe cd ".fnameescape(s:autoinstall))
524      exe "cd ".fnameescape(s:autoinstall)
525      
526      " decompress
527      if sname =~ '\.bz2$'
528 "      call Decho("decompress: attempt to bunzip2 ".sname)
529       exe "silent !bunzip2 ".s:Escape(sname)
530       let sname= substitute(sname,'\.bz2$','','')
531 "      call Decho("decompress: new sname<".sname."> after bunzip2")
532      elseif sname =~ '\.gz$'
533 "      call Decho("decompress: attempt to gunzip ".sname)
534       exe "silent !gunzip ".s:Escape(sname)
535       let sname= substitute(sname,'\.gz$','','')
536 "      call Decho("decompress: new sname<".sname."> after gunzip")
537      endif
538      
539      " distribute archive(.zip, .tar, .vba) contents
540      if sname =~ '\.zip$'
541 "      call Decho("dearchive: attempt to unzip ".sname)
542       exe "silent !unzip -o ".s:Escape(sname)
543      elseif sname =~ '\.tar$'
544 "      call Decho("dearchive: attempt to untar ".sname)
545       exe "silent !tar -xvf ".s:Escape(sname)
546      elseif sname =~ '\.vba$'
547 "      call Decho("dearchive: attempt to handle a vimball: ".sname)
548       silent 1split
549       exe "silent e ".fnameescape(sname)
550       silent so %
551       silent q
552      endif
553      
554      if sname =~ '.vim$'
555 "      call Decho("dearchive: attempt to simply move ".sname." to plugin")
556       exe "silent !".g:GetLatestVimScripts_mv." ".s:Escape(sname)." plugin"
557      else
558 "      call Decho("dearchive: move <".sname."> to installdir<".installdir.">")
559       exe "silent !".g:GetLatestVimScripts_mv." ".s:Escape(sname)." ".installdir
560      endif
561      
562      " helptags step
563      let docdir= substitute(&rtp,',.*','','e')."/doc"
564 "     call Decho("helptags: docdir<".docdir.">")
565      exe "helptags ".fnameescape(docdir)
566      exe "cd ".fnameescape(curdir)
567     endif
568     if fname !~ ':AutoInstall:'
569      let modline=scriptid." ".latestsrcid." :AutoInstall: ".fname.cmmnt
570     else
571      let modline=scriptid." ".latestsrcid." ".fname.cmmnt
572     endif
573    else
574     let modline=scriptid." ".latestsrcid." ".fname.cmmnt
575    endif
577    " update the data in the <GetLatestVimScripts.dat> file
578    call setline(line("."),modline)
579 "   call Decho("update data in ".expand("%")."#".line(".").": modline<".modline.">")
580 "  else " Decho
581 "   call Decho("[latestsrcid=".latestsrcid."] <= [srcid=".srcid."], no need to update")
582   endif
584  " restore options
585   let &t_ti = t_ti
586   let &t_te = t_te
587   let &rs   = rs
588   let @a    = rega
589 "  call Dredir("BUFFER TEST (GetOneScript)","ls!")
591 "  call Dret("GetOneScript")
592 endfun
594 " ---------------------------------------------------------------------
595 " s:Escape: makes a string safe&suitable for the shell {{{2
596 fun! s:Escape(name)
597 "  call Dfunc("s:Escape(name<".a:name.">)")
598   if exists("*shellescape")
599    " shellescape() was added by patch 7.0.111
600    let name= shellescape(a:name)
601   else
602    let name= g:getscript_shq . a:name . g:getscript_shq
603   endif
604 "  call Dret("s:Escape ".name)
605   return name
606 endfun
608 " ---------------------------------------------------------------------
609 " Restore Options: {{{1
610 let &cpo= s:keepcpo
611 unlet s:keepcpo
613 " ---------------------------------------------------------------------
614 "  Modelines: {{{1
615 " vim: ts=8 sts=2 fdm=marker nowrap