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