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