Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37874448
en ru br
Репозитории ALT
S:0.3-alt1
5.1: 0.1-alt2
www.altlinux.org/Changes

Группа :: Редакторы
Пакет: vim-plugin-spec_alt-ftplugin

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

vim-plugin-spec_alt-ftplugin-0.1/000075500000000000000000000000001116767152500170705ustar00rootroot00000000000000vim-plugin-spec_alt-ftplugin-0.1/ftplugin/000075500000000000000000000000001116767152500207205ustar00rootroot00000000000000vim-plugin-spec_alt-ftplugin-0.1/ftplugin/spec_alt.vim000064400000000000000000000065721116767152500232410ustar00rootroot00000000000000" Plugin to update the %changelog section of RPM spec files
" This is a combination of ideas and code from
" spec.vim by Gustavo Niemeyer <niemeyer@conectiva.com>
" spec_ftplugin.vim by Guillaume Rousse <rousse@ccr.jussieu.fr>
" and Sir Raorn <raorn@altlinux.ru>
" add_changelog utility by Dmitry V. Levin <ldv@altlinux.ru>
" Filename: spec_alt.vim
" Version: 0.0.1

if exists("b:did_altchangelog_ftplugin") | finish | endif

let b:did_altchangelog_ftplugin = 1

if !exists("no_plugin_maps") && !exists("no_spec_maps")
if !hasmapto("<Plug>SpecAltChangelog")
map <buffer> <LocalLeader>ac <Plug>SpecAltChangelog
endif
endif

noremap <buffer> <unique> <script> <Plug>SpecAltChangelog :call <SID>SpecAltChangelog()<CR>

" Useful settings
setlocal makeprg=rpm\ -ba\ %
setlocal errorformat=error:\ line\ %l:\ %m

" Helper functions
function <SID>Date()
let savelang = v:lc_time
execute "language time C"
let date = strftime("%a %b %d %Y")
execute "language time " . savelang
return date
endfunction

if !exists("*s:GetFirstLocation")
" Return location of first line matching
" the given pattern after the given line
" Return -1 if not found at the end of the file
function s:GetFirstLocation(from, pattern)
let linenb = a:from
while (linenb <= line("$"))
let linenb = linenb + 1
let linestr = getline(linenb)
if (linestr =~ a:pattern)
return linenb
endif
endwhile
return -1
endfunction
endif

" Main function
if !exists("*s:SpecAltChangelog")
function s:SpecAltChangelog()
let line = 0
let packager = system("rpm --eval %packager")
" get rid of this !#&* trailing <NL>
let packager = strpart(packager, 0, strlen(packager)-1)
if packager == "%packager"
echomsg "Configuration error: undefined packager"
" Correct? Really exit?
exit
endif
let date = <SID>Date()
let svr = system("rpm -q --qf '%|SERIAL?{%{SERIAL}:}|%{VERSION}-%{RELEASE}\n' --specfile ".expand("%")." |head -1")
let svr = strpart(svr, 0, strlen(svr)-1)
let full = "* ".date." ".packager." ".svr
let chgline = <SID>GetFirstLocation(0, '^%changelog')
if (chgline == -1)
let option = confirm("Can't find %changelog. Create one? ","&End of file\n&Here\n&Cancel",3)
if (option == 1)
call append(line("$"),"")
call append(line("$"),"%changelog")
execute line("$")
let chgline = line(".")
elseif (option == 2)
call append(line("."),"%changelog")
normal j
let chgline = line(".")
endif
endif
if (chgline != -1)
let insert_line = 0
" TODO
" echo "$spec: version \"$oldver\" unchanged, skipping"
" like add_changelog do this
"
" empty line just after chgline may break this
"
" Really compare whole line, or only packager+svr?
" The best variant - do this configurable
if (getline(chgline+1) != full)
call append(chgline, full)
call append(chgline+1,"- ")
call append(chgline+2,"")
let insert_line = chgline+2
else
let line = chgline
if !exists("g:spec_chglog_prepend")
while !(getline(line+2) =~ '^\( *\|\*.*\)$')
let line = line+1
endwhile
endif
call append(line+1,"- ")
let insert_line = line+2
endif
execute insert_line
startinsert!
endif
endfunction
endif

 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin