With the rising complexity of our spec files, I get more to the
situations when spec.vim is not able to parse the spec file
properly and doesn't generate verrel properly.

However, we have rpm-python library in Fedora, which should be
able to parse anything valid in any SPEC file. This patches
additional (optional, doesn't change anything in situation when
either the library or the python feature is not available)
functionality using the library for the additional parsing of the
spec file.

Signed-off-by: Matěj Cepl <[email protected]>
---
 runtime/ftplugin/spec.vim | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/runtime/ftplugin/spec.vim b/runtime/ftplugin/spec.vim
index 9778e1c..e70bc71 100644
--- a/runtime/ftplugin/spec.vim
+++ b/runtime/ftplugin/spec.vim
@@ -19,6 +19,30 @@ endif
 
 noremap <buffer> <unique> <script> <Plug>SpecChangelog :call 
<SID>SpecChangelog("")<CR>
 
+if !exists("*s:GetRelVer")
+    function! s:GetRelVer()
+        if has('python')
+python << PYEND
+import sys, datetime, shutil, tempfile
+import vim
+
+try:
+    import rpm
+except ImportError:
+    pass
+else:
+    specfile = vim.current.buffer.name
+    spec = rpm.spec(specfile)
+    headers = spec.packages[0].header
+    version = headers['Version']
+    release = ".".join(headers['Release'].split(".")[:-1])
+    vim.command("let ver = " + version)
+    vim.command("let rel = " + release)
+PYEND
+        endif
+    endfunction
+endif
+
 if !exists("*s:SpecChangelog")
        function s:SpecChangelog(format)
                if strlen(a:format) == 0
@@ -68,6 +92,9 @@ if !exists("*s:SpecChangelog")
                else
                        let include_release_info = 0
                endif
+
+        call s:GetRelVer()
+
                if (chgline == -1)
                        let option = confirm("Can't find %changelog. Create 
one? ","&End of file\n&Here\n&Cancel",3)
                        if (option == 1)
@@ -82,7 +109,7 @@ if !exists("*s:SpecChangelog")
                        endif
                endif
                if (chgline != -1)
-                       let parsed_format = "* ".strftime(format)
+                       let parsed_format = "* ".strftime(format)." - 
".ver."-".rel
                        let release_info = "+ ".name."-".ver."-".rel
                        let wrong_format = 0
                        let wrong_release = 0
-- 
1.8.4.474.g128a96c

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Raspunde prin e-mail lui