11" ---------------------------------------------------------------------
22" getscript.vim
33" Author: Charles E. Campbell, Jr.
4- " Date: Nov 27, 2006
5- " Version: 23
4+ " Date: May 05, 2007
5+ " Version: 25
66" Installing: :help glvs-install
77" Usage: :help glvs
88"
@@ -15,14 +15,14 @@ if &cp
1515 echoerr " GetLatestVimScripts is not vi-compatible; not loaded (you need to set nocp)"
1616 finish
1717endif
18- let s: keepfo = &fo
1918let s: keepcpo = &cpo
2019set cpo &vim
20+ " DechoTabOn
2121
2222if exists (" g:loaded_getscript" )
2323 finish
2424endif
25- let g: loaded_getscript= " v23 "
25+ let g: loaded_getscript= " v25 "
2626
2727" ---------------------------------------------------------------------
2828" Global Variables: {{{1
@@ -278,22 +278,28 @@ fun! s:GetOneScript(...)
278278" call Decho("attempting to do autoinstall: getcwd<".getcwd()."> filereadable(".fname.")=".filereadable(fname))
279279 if filereadable (fname)
280280" call Decho("move <".fname."> to ".s:autoinstall)
281- " call Decho("DISABLED for testing")
282281 exe " silent !" .g: GetLatestVimScripts_mv ." " .fname." " .s: autoinstall
283282 let curdir= escape (substitute (getcwd (),' \' ,' /' ,' ge' )," |[]*'\" #" )
283+ " call Decho("exe cd ".s:autoinstall)
284284 exe " cd " .s: autoinstall
285+
286+ " decompress
285287 if fname = ~ ' \.bz2$'
286288" call Decho("attempt to bunzip2 ".fname)
287289 exe " silent !bunzip2 " .fname
288290 let fname= substitute (fname,' \.bz2$' ,' ' ,' ' )
291+ " call Decho("new fname<".fname."> after bunzip2")
289292 elseif fname = ~ ' \.gz$'
290293" call Decho("attempt to gunzip ".fname)
291294 exe " silent !gunzip " .fname
292295 let fname= substitute (fname,' \.gz$' ,' ' ,' ' )
296+ " call Decho("new fname<".fname."> after gunzip")
293297 endif
298+
299+ " distribute archive(.zip, .tar, .vba) contents
294300 if fname = ~ ' \.zip$'
295301" call Decho("attempt to unzip ".fname)
296- exe " silent !unzip -o" .fname
302+ exe " silent !unzip -o " .fname
297303 elseif fname = ~ ' \.tar$'
298304" call Decho("attempt to untar ".fname)
299305 exe " silent !tar -xvf " .fname
@@ -304,10 +310,13 @@ fun! s:GetOneScript(...)
304310 so %
305311 q
306312 endif
313+
307314 if fname = ~ ' .vim$'
308315" call Decho("attempt to simply move ".fname." to plugin")
309316 exe " silent !" .g: GetLatestVimScripts_mv ." " .fname." plugin"
310317 endif
318+
319+ " helptags step
311320 let docdir= substitute (&rtp ,' ,.*' ,' ' ,' e' )." /doc"
312321" call Decho("helptags docdir<".docdir.">")
313322 exe " helptags " .docdir
@@ -318,7 +327,7 @@ fun! s:GetOneScript(...)
318327 " update the data in the <GetLatestVimScripts.dat> file
319328 let modline= scriptid." " .latestsrcid." " .fname.cmmnt
320329 call setline (line (" ." ),modline)
321- " call Decho("modline<".modline."> (updated GetLatestVimScripts.dat file) ")
330+ " call Decho("update data in ".expand("%")."#".line(".").": modline<".modline.">")
322331 endif
323332
324333 " restore options
@@ -351,10 +360,11 @@ fun! getscript#GetLatestVimScripts()
351360 break
352361 endif
353362 if filereadable (datadir." GetLatestVimScripts.dat" )
354- " call Decho("found ".datadir."/GetLatestVimScripts.dat")
355- break
363+ " call Decho("found ".datadir."/GetLatestVimScripts.dat")
364+ break
356365 endif
357366 endfor
367+
358368 " Sanity checks: readability and writability
359369 if datadir == " "
360370 echoerr ' Missing "GetLatest/" on your runtimepath - see :help glvs-dist-install'
@@ -399,63 +409,84 @@ fun! getscript#GetLatestVimScripts()
399409" call Decho(" ")
400410" call Decho("searching plugins for GetLatestVimScripts dependencies")
401411 let lastline = line (" $" )
402- let plugins = globpath (&rtp ," plugin/*.vim" )
412+ " call Decho("lastline#".lastline)
413+ let plugins = split (globpath (&rtp ," plugin/*.vim" ))
403414 let foundscript = 0
415+ let firstdir= " "
404416
405- " call Decho("plugins<".plugins."> lastline#".lastline)
406- while plugins != " "
407- let plugin = substitute (plugins,' \n.*$' ,' ' ,' e' )
408- let plugins= (plugins = ~ ' \n' )? substitute (plugins,' ^.\{-}\n\(.*\)$' ,' \1' ,' e' ) : " "
417+ for plugin in plugins
418+
419+ " don't process plugins in system directories
420+ if firstdir == " "
421+ let firstdir= substitute (plugin ,' [/\\][^/\\]\+$' ,' ' ,' ' )
422+ " call Decho("firstdir<".firstdir.">")
423+ else
424+ let curdir= substitute (plugin ,' [/\\][^/\\]\+$' ,' ' ,' ' )
425+ " call Decho("curdir<".curdir.">")
426+ if curdir != firstdir
427+ break
428+ endif
429+ endif
430+
431+ " read plugin in
409432 $
433+ " call Decho(" ")
410434" call Decho(".dependency checking<".plugin."> line$=".line("$"))
411435 exe " silent r " .plugin
436+
412437 while search (' ^"\s\+GetLatestVimScripts:\s\+\d\+\s\+\d\+' ,' W' ) != 0
413438 let newscript= substitute (getline (" ." ),' ^"\s\+GetLatestVimScripts:\s\+\d\+\s\+\d\+\s\+\(.*\)$' ,' \1' ,' e' )
414439 let llp1 = lastline+ 1
415-
416- if newscript !~ ' ^"'
417- " found a "GetLatestVimScripts: # #" line in the script; check if its already in the datafile
418- let curline = line (" ." )
419- let noai_script = substitute (newscript,' \s*:AutoInstall:\s*' ,' ' ,' e' )
420- exe llp1
421- let srchline = search (' \<' .noai_script.' \>' ,' bW' )
422- " call Decho("..newscript<".newscript."> noai_script<".noai_script."> srch=".srchline." lastline=".lastline)
423-
424- if srchline == 0
425- " found a new script to permanently include in the datafile
426- let keep_rega = @a
427- let @a = substitute (getline (curline),' ^"\s\+GetLatestVimScripts:\s\+' ,' ' ,' ' )
428- exe lastline." put a"
429- echomsg " Appending <" .@a ." > to " .datafile." for " .newscript
430- " call Decho("..APPEND (".noai_script.")<".@a."> to GetLatestVimScripts.dat")
431- let @a = keep_rega
432- let lastline = llp1
433- let curline = curline + 1
434- let foundscript = foundscript + 1
435- " else " Decho
436- " call Decho("..found <".noai_script."> (already in datafile at line#".srchline.")")
437- endif
438-
439- let curline = curline + 1
440- exe curline
441- endif
442-
440+ " call Decho("..newscript<".newscript.">")
441+
442+ " don't process ""GetLatestVimScripts lines
443+ if newscript !~ ' ^"'
444+ " found a "GetLatestVimScripts: # #" line in the script; check if its already in the datafile
445+ let curline = line (" ." )
446+ let noai_script = substitute (newscript,' \s*:AutoInstall:\s*' ,' ' ,' e' )
447+ exe llp1
448+ let srchline = search (' \<' .noai_script.' \>' ,' bW' )
449+ " call Decho("..noai_script<".noai_script."> srch=".srchline."curline#".line(".")." lastline#".lastline)
450+
451+ if srchline == 0
452+ " found a new script to permanently include in the datafile
453+ let keep_rega = @a
454+ let @a = substitute (getline (curline),' ^"\s\+GetLatestVimScripts:\s\+' ,' ' ,' ' )
455+ exe lastline." put a"
456+ echomsg " Appending <" .@a ." > to " .datafile." for " .newscript
457+ " call Decho("..APPEND (".noai_script.")<".@a."> to GetLatestVimScripts.dat")
458+ let @a = keep_rega
459+ let lastline = llp1
460+ let curline = curline + 1
461+ let foundscript = foundscript + 1
462+ " else " Decho
463+ " call Decho("..found <".noai_script."> (already in datafile at line#".srchline.")")
464+ endif
465+
466+ let curline = curline + 1
467+ exe curline
468+ endif
443469 endwhile
470+
444471 let llp1= lastline + 1
445472" call Decho(".deleting lines: ".llp1.",$d")
446473 exe " silent! " .llp1." ,$d"
447- endwhile
474+ endfor
475+ " call Decho("--- end dependency checking loop --- foundscript=".foundscript)
476+ " call Decho(" ")
448477
449478 if foundscript == 0
450479 set nomod
451480 endif
452481
453482 " Check on out-of-date scripts using GetLatest/GetLatestVimScripts.dat
483+ " call Decho("begin: checking out-of-date scripts using datafile<".datafile.">")
454484 set lz
455- " call Decho(" --- end of dependency checking loop --- ")
456- " call Decho("call GetOneScript on lines at end of datafile<".datafile.">")
457485 1
458- /^-----/ ,$g /^\s*\d/ call <SID> GetOneScript ()
486+ " /^-----/,$g/^\s*\d/call Decho(getline("."))
487+ 1
488+ /^-----/ ,$g /^\s*\d/ call s: GetOneScript ()
489+ " call Decho("--- end out-of-date checking --- ")
459490
460491 " Final report (an echomsg)
461492 try
@@ -495,7 +526,6 @@ endfun
495526" ---------------------------------------------------------------------
496527
497528" Restore Options: {{{1
498- let &fo = s: keepfo
499529let &cpo = s: keepcpo
500530
501531" vim: ts = 8 sts = 2 fdm = marker nowrap
0 commit comments