blob: 356bb8c9f9e41394de03efaa917075550b6160b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
" Vim plugin
" Purpose: Intelligently create content for metadata.xml
" Author: Ciaran McCreesh <ciaranm@gentoo.org>
" Copyright: Copyright (c) 2004-2005 Ciaran McCreesh
" Licence: You may redistribute this under the same terms as Vim itself
if &compatible || v:version < 603 || exists("g:loaded_newmetadata")
finish
endif
let g:loaded_newmetadata=1
runtime! plugin/gentoo-common.vim
fun! <SID>MakeNewMetadata()
let l:pastebackup = &paste
set nopaste
" {{{ variables
let l:filename = expand("%:p")
let l:dir = expand("%:p:h")
if glob(l:dir . '/*/*.ebuild') =~ '\S'
let l:category = substitute(l:filename, '^.*/\([a-z][a-z0-9]\+-[a-z]\+\)/metadata.xml$',
\ '\1', '')
let l:iscatmetadata = 1
else
let l:category = substitute(l:filename,
\ "^.*/\\([^/]\\+\\)/[^/]\\+/metadata\\.xml", "\\1", "g")
let l:iscatmetadata = 0
let l:user = GentooGetUser()
let l:email = matchstr(l:user, "\\(<\\)\\@<=[^>]\\+\\(>\\)\\@=")
let l:name = matchstr(l:user, "^[^<]\\+\\( <\\)\\@=")
endif
" }}}
" {{{ catmetadata
if l:iscatmetadata
" {{{ content
0 put ='<?xml version=\"1.0\" encoding=\"UTF-8\"?>'
put ='<!DOCTYPE catmetadata SYSTEM \"https://www.gentoo.org/dtd/metadata.dtd\">'
put ='<catmetadata>'
put ='<longdescription lang=\"en\">'
put ='</longdescription>'
put ='</catmetadata>'
exec "normal gg=G"
" }}}
" }}}
else
" {{{ pkgmetadata
" {{{ project
let l:project = ""
if l:category ==# "app-vim"
let l:project = "vim"
elseif l:category ==# "dev-haskell"
let l:project = "haskell"
elseif l:category ==# "dev-perl"
let l:project = "perl"
elseif l:category ==# "dev-php"
let l:project = "php-bugs"
elseif l:category ==# "dev-ruby"
let l:project = "ruby"
elseif l:category ==# "dev-tex"
let l:project = "tex"
elseif l:category ==# "dev-java"
let l:project = "java"
endif
" }}}
" {{{ content
0 put ='<?xml version=\"1.0\" encoding=\"UTF-8\"?>'
put ='<!DOCTYPE pkgmetadata SYSTEM \"https://www.gentoo.org/dtd/metadata.dtd\">'
put ='<pkgmetadata>'
if l:project != ""
put ='<maintainer type=\"project\">'
put ='<email>' . l:project . '@gentoo.org</email>'
put ='</maintainer>'
endif
put ='<maintainer type=\"person\">'
put ='<email>' . l:email . '</email>'
if l:name != ""
put ='<name>' . l:name . '</name>'
endif
put ='</maintainer>'
put ='</pkgmetadata>'
exec "normal gg=G"
" }}}
endif
" }}}
" Jump back to the first line
0
" Delete last/empty line
$ delete
if pastebackup == 0
set nopaste
endif
endfun
com! -nargs=0 NewMetadata call <SID>MakeNewMetadata()
augroup NewMetadata
au!
autocmd BufNewFile metadata.xml
\ call <SID>MakeNewMetadata()
augroup END
" vim: set et foldmethod=marker : "
|