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