annotate runtime/ftplugin/debchangelog.vim @ 30829:d7066cbac096 v9.0.0749

patch 9.0.0749: alloc/free of buffer for each quickfix entry is inefficient Commit: https://github.com/vim/vim/commit/975a665d4811649a51e2c6a97a6ce096290d87ae Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Fri Oct 14 13:11:13 2022 +0100 patch 9.0.0749: alloc/free of buffer for each quickfix entry is inefficient Problem: Alloc/free of buffer for each quickfix entry is inefficient. Solution: Use a shared grow array. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/11365)
author Bram Moolenaar <Bram@vim.org>
date Fri, 14 Oct 2022 14:15:03 +0200
parents 34c1f4cd0c18
children cc751d944b7e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1620
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
1 " Vim filetype plugin file (GUI menu, folding and completion)
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
2 " Language: Debian Changelog
29533
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
3 " Maintainer: Debian Vim Maintainers <team+vim@tracker.debian.org>
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
4 " Former Maintainers: Michael Piefel <piefel@informatik.hu-berlin.de>
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
5 " Stefano Zacchiroli <zack@debian.org>
29533
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
6 " Last Change: 2022 Jul 25
3312
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 2370
diff changeset
7 " License: Vim License
13231
167a030448fa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 5663
diff changeset
8 " URL: https://salsa.debian.org/vim-team/vim-debian/blob/master/ftplugin/debchangelog.vim
848
f4d8553715f7 updated for version 7.0f04
vimboss
parents: 845
diff changeset
9
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
10 " Bug completion requires apt-listbugs installed for Debian packages or
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
11 " python-launchpadlib installed for Ubuntu packages
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
12
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
13 if exists('b:did_ftplugin')
848
f4d8553715f7 updated for version 7.0f04
vimboss
parents: 845
diff changeset
14 finish
f4d8553715f7 updated for version 7.0f04
vimboss
parents: 845
diff changeset
15 endif
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 848
diff changeset
16 let b:did_ftplugin=1
848
f4d8553715f7 updated for version 7.0f04
vimboss
parents: 845
diff changeset
17
f4d8553715f7 updated for version 7.0f04
vimboss
parents: 845
diff changeset
18 " {{{1 Local settings (do on every load)
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
19 if exists('g:debchangelog_fold_enable')
1620
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
20 setlocal foldmethod=expr
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
21 setlocal foldexpr=DebGetChangelogFold(v:lnum)
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
22 setlocal foldtext=DebChangelogFoldText()
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
23 endif
848
f4d8553715f7 updated for version 7.0f04
vimboss
parents: 845
diff changeset
24
f4d8553715f7 updated for version 7.0f04
vimboss
parents: 845
diff changeset
25 " Debian changelogs are not supposed to have any other text width,
f4d8553715f7 updated for version 7.0f04
vimboss
parents: 845
diff changeset
26 " so the user cannot override this setting
f4d8553715f7 updated for version 7.0f04
vimboss
parents: 845
diff changeset
27 setlocal tw=78
f4d8553715f7 updated for version 7.0f04
vimboss
parents: 845
diff changeset
28 setlocal comments=f:*
f4d8553715f7 updated for version 7.0f04
vimboss
parents: 845
diff changeset
29
f4d8553715f7 updated for version 7.0f04
vimboss
parents: 845
diff changeset
30 " Clean unloading
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
31 let b:undo_ftplugin = 'setlocal tw< comments< foldmethod< foldexpr< foldtext<'
848
f4d8553715f7 updated for version 7.0f04
vimboss
parents: 845
diff changeset
32 " }}}1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
34 if exists('g:did_changelog_ftplugin')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37
29533
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
38 " Make sure the '<' and 'C' flags are not included in 'cpoptions', otherwise
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
39 " <CR> would not be recognized. See ":help 'cpoptions'".
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
40 let s:cpo_save = &cpo
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
41 set cpo&vim
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
42
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 " Don't load another plugin (this is global)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 let g:did_changelog_ftplugin = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
46 " {{{1 GUI menu
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
47
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 " Helper functions returning various data.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 " Returns full name, either from $DEBFULLNAME or debianfullname.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 " TODO Is there a way to determine name from anywhere else?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 function <SID>FullName()
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
52 if exists('$DEBFULLNAME')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 return $DEBFULLNAME
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
54 elseif exists('g:debianfullname')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 return g:debianfullname
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 else
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
57 return 'Your Name'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 " Returns email address, from $DEBEMAIL, $EMAIL or debianemail.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 function <SID>Email()
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
63 if exists('$DEBEMAIL')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 return $DEBEMAIL
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
65 elseif exists('$EMAIL')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 return $EMAIL
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
67 elseif exists('g:debianemail')
481
66080ac5dab7 updated for version 7.0130
vimboss
parents: 7
diff changeset
68 return g:debianemail
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 else
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
70 return 'your@email.address'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 " Returns date in RFC822 format.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 function <SID>Date()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 let savelang = v:lc_time
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
77 execute 'language time C'
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
78 let dateandtime = strftime('%a, %d %b %Y %X %z')
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
79 execute 'language time ' . savelang
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 return dateandtime
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 function <SID>WarnIfNotUnfinalised()
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
84 if match(getline('.'), ' -- [[:alpha:]][[:alnum:].]')!=-1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 echohl WarningMsg
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
86 echo 'The entry has not been unfinalised before editing.'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 echohl None
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 return 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 function <SID>Finalised()
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
94 let savelinenum = line('.')
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
95 1
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
96 call search('^ -- ')
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
97 if match(getline('.'), ' -- [[:alpha:]][[:alnum:].]')!=-1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 let returnvalue = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 let returnvalue = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 execute savelinenum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 return returnvalue
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 " These functions implement the menus
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 function NewVersion()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 " The new entry is unfinalised and shall be changed
29533
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
109 amenu disable &Changelog.&New\ Version
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
110 amenu enable &Changelog.&Add\ Entry
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
111 amenu enable &Changelog.&Close\ Bug
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
112 amenu enable &Changelog.Set\ &Distribution
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
113 amenu enable &Changelog.Set\ &Urgency
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
114 amenu disable &Changelog.U&nfinalise
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
115 amenu enable &Changelog.&Finalise
848
f4d8553715f7 updated for version 7.0f04
vimboss
parents: 845
diff changeset
116 call append(0, substitute(getline(1), '-\([[:digit:]]\+\))', '-$$\1)', ''))
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
117 call append(1, '')
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
118 call append(2, '')
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
119 call append(3, ' -- ')
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
120 call append(4, '')
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
121 call Urgency('low')
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
122 normal! 1G0
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
123 call search(')')
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
124 normal! h
29533
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
125 " ':normal' doens't support key annotation (<c-a>) directly.
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
126 " Vim's manual recommends using ':exe' to use key annotation indirectly (backslash-escaping needed though).
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
127 exe "normal! \<c-a>"
848
f4d8553715f7 updated for version 7.0f04
vimboss
parents: 845
diff changeset
128 call setline(1, substitute(getline(1), '-\$\$', '-', ''))
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
129 if exists('g:debchangelog_fold_enable')
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
130 foldopen
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
131 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 call AddEntry()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 function AddEntry()
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
136 1
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
137 call search('^ -- ')
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
138 .-2
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
139 call append('.', ' * ')
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
140 .+3
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 let warn=<SID>WarnIfNotUnfinalised()
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
142 .-2
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 if warn
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 echohl MoreMsg
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
145 call input('Hit ENTER')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 echohl None
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 startinsert!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 function CloseBug()
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
152 1
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
153 call search('^ -- ')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 let warn=<SID>WarnIfNotUnfinalised()
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
155 .-2
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
156 call append('.', ' * (closes: #' . input('Bug number to close: ') . ')')
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
157 normal! j^ll
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 startinsert
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 function Distribution(dist)
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
162 call setline(1, substitute(getline(1), ') *\%(UNRELEASED\|\l\+\);', ') ' . a:dist . ';', ''))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 function Urgency(urg)
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
166 call setline(1, substitute(getline(1), 'urgency=.*$', 'urgency=' . a:urg, ''))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 function <SID>UnfinaliseMenu()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 " This means the entry shall be changed
29533
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
171 amenu disable &Changelog.&New\ Version
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
172 amenu enable &Changelog.&Add\ Entry
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
173 amenu enable &Changelog.&Close\ Bug
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
174 amenu enable &Changelog.Set\ &Distribution
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
175 amenu enable &Changelog.Set\ &Urgency
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
176 amenu disable &Changelog.U&nfinalise
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
177 amenu enable &Changelog.&Finalise
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 function Unfinalise()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 call <SID>UnfinaliseMenu()
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
182 1
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
183 call search('^ -- ')
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
184 call setline('.', ' -- ')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 function <SID>FinaliseMenu()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 " This means the entry should not be changed anymore
29533
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
189 amenu enable &Changelog.&New\ Version
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
190 amenu disable &Changelog.&Add\ Entry
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
191 amenu disable &Changelog.&Close\ Bug
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
192 amenu disable &Changelog.Set\ &Distribution
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
193 amenu disable &Changelog.Set\ &Urgency
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
194 amenu enable &Changelog.U&nfinalise
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
195 amenu disable &Changelog.&Finalise
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 function Finalise()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 call <SID>FinaliseMenu()
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
200 1
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
201 call search('^ -- ')
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
202 call setline('.', ' -- ' . <SID>FullName() . ' <' . <SID>Email() . '> ' . <SID>Date())
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 function <SID>MakeMenu()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 amenu &Changelog.&New\ Version :call NewVersion()<CR>
29533
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
208 amenu &Changelog.&Add\ Entry :call AddEntry()<CR>
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
209 amenu &Changelog.&Close\ Bug :call CloseBug()<CR>
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
210 menu &Changelog.-sep- <nul>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211
29533
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
212 amenu &Changelog.Set\ &Distribution.&unstable :call Distribution("unstable")<CR>
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
213 amenu &Changelog.Set\ &Distribution.&frozen :call Distribution("frozen")<CR>
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
214 amenu &Changelog.Set\ &Distribution.&stable :call Distribution("stable")<CR>
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
215 menu &Changelog.Set\ &Distribution.-sep- <nul>
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
216 amenu &Changelog.Set\ &Distribution.frozen\ unstable :call Distribution("frozen unstable")<CR>
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
217 amenu &Changelog.Set\ &Distribution.stable\ unstable :call Distribution("stable unstable")<CR>
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
218 amenu &Changelog.Set\ &Distribution.stable\ frozen :call Distribution("stable frozen")<CR>
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
219 amenu &Changelog.Set\ &Distribution.stable\ frozen\ unstable :call Distribution("stable frozen unstable")<CR>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220
29533
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
221 amenu &Changelog.Set\ &Urgency.&low :call Urgency("low")<CR>
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
222 amenu &Changelog.Set\ &Urgency.&medium :call Urgency("medium")<CR>
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
223 amenu &Changelog.Set\ &Urgency.&high :call Urgency("high")<CR>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224
29533
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
225 menu &Changelog.-sep- <nul>
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
226 amenu &Changelog.U&nfinalise :call Unfinalise()<CR>
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
227 amenu &Changelog.&Finalise :call Finalise()<CR>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 if <SID>Finalised()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 call <SID>FinaliseMenu()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 call <SID>UnfinaliseMenu()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 augroup changelogMenu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 au BufEnter * if &filetype == "debchangelog" | call <SID>MakeMenu() | endif
29533
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
238 au BufLeave * if &filetype == "debchangelog" | silent! aunmenu &Changelog | endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 augroup END
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
241 " }}}
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
242 " {{{1 folding
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
243
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 848
diff changeset
244 " look for an author name in the [zonestart zoneend] lines searching backward
e63691e7c504 updated for version 7.1a
vimboss
parents: 848
diff changeset
245 function! s:getAuthor(zonestart, zoneend)
e63691e7c504 updated for version 7.1a
vimboss
parents: 848
diff changeset
246 let linepos = a:zoneend
e63691e7c504 updated for version 7.1a
vimboss
parents: 848
diff changeset
247 while linepos >= a:zonestart
e63691e7c504 updated for version 7.1a
vimboss
parents: 848
diff changeset
248 let line = getline(linepos)
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
249 if line =~# '^ --'
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 848
diff changeset
250 return substitute(line, '^ --\s*\([^<]\+\)\s*.*', '\1', '')
e63691e7c504 updated for version 7.1a
vimboss
parents: 848
diff changeset
251 endif
e63691e7c504 updated for version 7.1a
vimboss
parents: 848
diff changeset
252 let linepos -= 1
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
253 endwhile
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 848
diff changeset
254 return '[unknown]'
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
255 endfunction
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
256
1620
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
257 " Look for a package source name searching backward from the givenline and
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
258 " returns it. Return the empty string if the package name can't be found
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
259 function! DebGetPkgSrcName(lineno)
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
260 let lineidx = a:lineno
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
261 let pkgname = ''
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
262 while lineidx > 0
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
263 let curline = getline(lineidx)
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
264 if curline =~# '^\S'
1620
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
265 let pkgname = matchlist(curline, '^\(\S\+\).*$')[1]
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
266 break
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
267 endif
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
268 let lineidx = lineidx - 1
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
269 endwhile
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
270 return pkgname
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
271 endfunction
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
272
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
273 function! DebChangelogFoldText()
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
274 if v:folddashes ==# '-' " changelog entry fold
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 848
diff changeset
275 return foldtext() . ' -- ' . s:getAuthor(v:foldstart, v:foldend) . ' '
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
276 endif
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
277 return foldtext()
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
278 endfunction
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
279
1620
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
280 function! DebGetChangelogFold(lnum)
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
281 let line = getline(a:lnum)
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
282 if line =~# '^\w\+'
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
283 return '>1' " beginning of a changelog entry
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
284 endif
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
285 if line =~# '^\s\+\[.*\]'
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
286 return '>2' " beginning of an author-specific chunk
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
287 endif
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
288 if line =~# '^ --'
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
289 return '1'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
290 endif
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
291 return '='
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
292 endfunction
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
293
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
294 if exists('g:debchangelog_fold_enable')
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
295 silent! foldopen! " unfold the entry the cursor is on (usually the first one)
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
296 endif
1620
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
297
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
298 " }}}
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
299
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
300 " {{{1 omnicompletion for Closes: #
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
301
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
302 if !exists('g:debchangelog_listbugs_severities')
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
303 let g:debchangelog_listbugs_severities = 'critical,grave,serious,important,normal,minor,wishlist'
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
304 endif
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
305
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
306 fun! DebCompleteBugs(findstart, base)
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
307 if a:findstart
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
308 let line = getline('.')
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
309
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
310 " try to detect whether this is closes: or lp:
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
311 let g:debchangelog_complete_mode = 'debbugs'
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
312 let try_colidx = col('.') - 1
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
313 let colidx = -1 " default to no-completion-possible
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
314
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
315 while try_colidx > 0 && line[try_colidx - 1] =~# '\s\|\d\|#\|,\|:'
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
316 let try_colidx = try_colidx - 1
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
317 if line[try_colidx] ==# '#' && colidx == -1
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
318 " found hash, where we complete from:
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
319 let colidx = try_colidx
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
320 elseif line[try_colidx] ==# ':'
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
321 if try_colidx > 1 && strpart(line, try_colidx - 2, 3) =~? '\clp:'
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
322 let g:debchangelog_complete_mode = 'lp'
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
323 endif
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
324 break
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
325 endif
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
326 endwhile
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
327 return colidx
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
328 else " return matches:
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
329 let bug_lines = []
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
330 if g:debchangelog_complete_mode ==? 'lp'
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
331 if ! has('python')
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
332 echoerr 'vim must be built with Python support to use LP bug completion'
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
333 return
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
334 endif
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
335 let pkgsrc = DebGetPkgSrcName(line('.'))
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
336 python << EOF
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
337 import vim
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
338 try:
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
339 from launchpadlib.launchpad import Launchpad
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
340 from lazr.restfulclient.errors import HTTPError
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
341 # login anonymously
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
342 lp = Launchpad.login_anonymously('debchangelog.vim', 'production')
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
343 ubuntu = lp.distributions['ubuntu']
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
344 try:
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
345 sp = ubuntu.getSourcePackage(name=vim.eval('pkgsrc'))
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
346 status = ('New', 'Incomplete', 'Confirmed', 'Triaged',
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
347 'In Progress', 'Fix Committed')
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
348 tasklist = sp.searchTasks(status=status, order_by='id')
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
349 liststr = '['
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
350 for task in tasklist:
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
351 bug = task.bug
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
352 liststr += "'#%d - %s'," % (bug.id, bug.title.replace('\'', '\'\''))
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
353 liststr += ']'
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
354 vim.command('silent let bug_lines = %s' % liststr.encode('utf-8'))
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
355 except HTTPError:
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
356 pass
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
357 except ImportError:
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
358 vim.command('echoerr \'python-launchpadlib >= 1.5.4 needs to be installed to use Launchpad bug completion\'')
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
359 EOF
1620
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
360 else
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
361 if ! filereadable('/usr/sbin/apt-listbugs')
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
362 echoerr 'apt-listbugs not found, you should install it to use Closes bug completion'
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
363 return
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
364 endif
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
365 let pkgsrc = DebGetPkgSrcName(line('.'))
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
366 let listbugs_output = system('/usr/sbin/apt-listbugs -s ' . g:debchangelog_listbugs_severities . ' list ' . pkgsrc . ' | grep "^ #" 2> /dev/null')
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
367 let bug_lines = split(listbugs_output, '\n')
1620
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
368 endif
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
369 let completions = []
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
370 for line in bug_lines
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
371 let parts = matchlist(line, '^\s*\(#\S\+\)\s*-\s*\(.*\)$')
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
372 " filter only those which match a:base:
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13231
diff changeset
373 if parts[1] !~ '^' . a:base
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
374 continue
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1620
diff changeset
375 endif
1620
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
376 let completion = {}
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
377 let completion['word'] = parts[1]
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
378 let completion['menu'] = parts[2]
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
379 let completion['info'] = parts[0]
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
380 let completions += [completion]
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
381 endfor
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
382 return completions
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
383 endif
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
384 endfun
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
385
73fe8baea242 updated for version 7.2a
vimboss
parents: 1121
diff changeset
386 setlocal omnifunc=DebCompleteBugs
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 848
diff changeset
387
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
388 " }}}
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
389
29533
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
390 " Restore the previous value of 'cpoptions'.
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
391 let &cpo = s:cpo_save
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
392 unlet s:cpo_save
34c1f4cd0c18 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13857
diff changeset
393
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 481
diff changeset
394 " vim: set foldmethod=marker: