Mercurial > vim
comparison runtime/ftplugin/spec.vim @ 6823:0303182665d5
Updated runtime files.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Tue, 09 Jun 2015 19:44:55 +0200 |
parents | 3af822eb4da5 |
children | ecb621205ed1 |
comparison
equal
deleted
inserted
replaced
6822:856ac8b406e6 | 6823:0303182665d5 |
---|---|
1 " Plugin to update the %changelog section of RPM spec files | 1 " Plugin to update the %changelog section of RPM spec files |
2 " Filename: spec.vim | 2 " Filename: spec.vim |
3 " Maintainer: Igor Gnatenko i.gnatenko.brain@gmail.com | 3 " Maintainer: Igor Gnatenko i.gnatenko.brain@gmail.com |
4 " Former Maintainer: Gustavo Niemeyer <niemeyer@conectiva.com> (until March 2014) | 4 " Former Maintainer: Gustavo Niemeyer <niemeyer@conectiva.com> (until March 2014) |
5 " Last Change: Fri Feb 20 16:01 MSK 2014 Igor Gnatenko | 5 " Last Change: Mon Jun 01 21:15 MSK 2015 Igor Gnatenko |
6 | 6 |
7 if exists("b:did_ftplugin") | 7 if exists("b:did_ftplugin") |
8 finish | 8 finish |
9 endif | 9 endif |
10 let b:did_ftplugin = 1 | 10 let b:did_ftplugin = 1 |
20 | 20 |
21 if !hasmapto("call <SID>SpecChangelog(\"\")<CR>") | 21 if !hasmapto("call <SID>SpecChangelog(\"\")<CR>") |
22 noremap <buffer> <unique> <script> <Plug>SpecChangelog :call <SID>SpecChangelog("")<CR> | 22 noremap <buffer> <unique> <script> <Plug>SpecChangelog :call <SID>SpecChangelog("")<CR> |
23 endif | 23 endif |
24 | 24 |
25 if !exists("*s:GetRelVer") | |
26 function! s:GetRelVer() | |
27 if has('python') | |
28 python << PYEND | |
29 import sys, datetime, shutil, tempfile | |
30 import vim | |
31 | |
32 try: | |
33 import rpm | |
34 except ImportError: | |
35 pass | |
36 else: | |
37 specfile = vim.current.buffer.name | |
38 if specfile: | |
39 spec = rpm.spec(specfile) | |
40 headers = spec.packages[0].header | |
41 version = headers['Version'] | |
42 release = ".".join(headers['Release'].split(".")[:-1]) | |
43 vim.command("let ver = " + version) | |
44 vim.command("let rel = " + release) | |
45 PYEND | |
46 endif | |
47 endfunction | |
48 endif | |
49 | |
25 if !exists("*s:SpecChangelog") | 50 if !exists("*s:SpecChangelog") |
26 function s:SpecChangelog(format) | 51 function s:SpecChangelog(format) |
27 if strlen(a:format) == 0 | 52 if strlen(a:format) == 0 |
28 if !exists("g:spec_chglog_format") | 53 if !exists("g:spec_chglog_format") |
29 let email = input("Email address: ") | 54 let email = input("Name <email address>: ") |
30 let g:spec_chglog_format = "%a %b %d %Y " . l:email | 55 let g:spec_chglog_format = "%a %b %d %Y " . l:email |
31 echo "\r" | 56 echo "\r" |
32 endif | 57 endif |
33 let format = g:spec_chglog_format | 58 let format = g:spec_chglog_format |
34 else | 59 else |
69 let ver = s:ParseRpmVars(ver, verline) | 94 let ver = s:ParseRpmVars(ver, verline) |
70 let rel = s:ParseRpmVars(rel, relline) | 95 let rel = s:ParseRpmVars(rel, relline) |
71 else | 96 else |
72 let include_release_info = 0 | 97 let include_release_info = 0 |
73 endif | 98 endif |
99 | |
100 call s:GetRelVer() | |
101 | |
74 if (chgline == -1) | 102 if (chgline == -1) |
75 let option = confirm("Can't find %changelog. Create one? ","&End of file\n&Here\n&Cancel",3) | 103 let option = confirm("Can't find %changelog. Create one? ","&End of file\n&Here\n&Cancel",3) |
76 if (option == 1) | 104 if (option == 1) |
77 call append(line("$"),"") | 105 call append(line("$"),"") |
78 call append(line("$"),"%changelog") | 106 call append(line("$"),"%changelog") |
83 normal j | 111 normal j |
84 chgline = line(".") | 112 chgline = line(".") |
85 endif | 113 endif |
86 endif | 114 endif |
87 if (chgline != -1) | 115 if (chgline != -1) |
88 let parsed_format = "* ".strftime(format) | 116 let parsed_format = "* ".strftime(format)." - ".ver."-".rel |
89 let release_info = "+ ".name."-".ver."-".rel | 117 let release_info = "+ ".name."-".ver."-".rel |
90 let wrong_format = 0 | 118 let wrong_format = 0 |
91 let wrong_release = 0 | 119 let wrong_release = 0 |
92 let insert_line = 0 | 120 let insert_line = 0 |
93 if (getline(chgline+1) != parsed_format) | 121 if (getline(chgline+1) != parsed_format) |