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