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