11" Vim filetype plugin file
22" Language: generic Changelog file
33" Maintainer: Nikolai Weibull <now@bitwi.se>
4- " Latest Revision: 2012-08-23
4+ " Latest Revision: 2013-12-15
55" Variables:
66" g:changelog_timeformat (deprecated: use g:changelog_dateformat instead) -
77" description: the timeformat used in ChangeLog entries.
@@ -122,12 +122,12 @@ if &filetype == 'changelog'
122122
123123 " Format used for new date entries.
124124 if ! exists (' g:changelog_new_date_format' )
125- let g: changelog_new_date_format = " %d %u\n\n \t * %c\n\n "
125+ let g: changelog_new_date_format = " %d %u\n\n \t * %p% c\n\n "
126126 endif
127127
128128 " Format used for new entries to current date entry.
129129 if ! exists (' g:changelog_new_entry_format' )
130- let g: changelog_new_entry_format = " \t * %c"
130+ let g: changelog_new_entry_format = " \t * %p% c"
131131 endif
132132
133133 " Regular expression used to find a given date entry.
@@ -143,9 +143,9 @@ if &filetype == 'changelog'
143143
144144 " Substitutes specific items in new date-entry formats and search strings.
145145 " Can be done with substitute of course, but unclean, and need \@! then.
146- function ! s: substitute_items (str, date, user )
146+ function ! s: substitute_items (str, date, user , prefix )
147147 let str = a: str
148- let middles = {' %' : ' %' , ' d' : a: date , ' u' : a: user , ' c' : ' {cursor}' }
148+ let middles = {' %' : ' %' , ' d' : a: date , ' u' : a: user , ' p ' : a: prefix , ' c' : ' {cursor}' }
149149 let i = stridx (str, ' %' )
150150 while i != -1
151151 let inc = 0
@@ -171,15 +171,15 @@ if &filetype == 'changelog'
171171 endfunction
172172
173173 " Internal function to create a new entry in the ChangeLog.
174- function ! s: new_changelog_entry ()
174+ function ! s: new_changelog_entry (prefix )
175175 " Deal with 'paste' option.
176176 let save_paste = &paste
177177 let &paste = 1
178178 call cursor (1 , 1 )
179179 " Look for an entry for today by our user.
180180 let date = strftime (g: changelog_dateformat )
181181 let search = s: substitute_items (g: changelog_date_entry_search , date,
182- \ s: username ())
182+ \ s: username (), a: prefix )
183183 if search (search ) > 0
184184 " Ok, now we look for the end of the date entry, and add an entry.
185185 call cursor (nextnonblank (line (' .' ) + 1 ), 1 )
@@ -188,7 +188,7 @@ if &filetype == 'changelog'
188188 else
189189 let p = line (' .' )
190190 endif
191- let ls = split (s: substitute_items (g: changelog_new_entry_format , ' ' , ' ' ),
191+ let ls = split (s: substitute_items (g: changelog_new_entry_format , ' ' , ' ' , a: prefix ),
192192 \ ' \n' )
193193 call append (p , ls )
194194 call cursor (p + 1 , 1 )
@@ -198,15 +198,15 @@ if &filetype == 'changelog'
198198
199199 " No entry today, so create a date-user header and insert an entry.
200200 let todays_entry = s: substitute_items (g: changelog_new_date_format ,
201- \ date, s: username ())
201+ \ date, s: username (), a: prefix )
202202 " Make sure we have a cursor positioning.
203203 if stridx (todays_entry, ' {cursor}' ) == -1
204204 let todays_entry = todays_entry . ' {cursor}'
205205 endif
206206
207207 " Now do the work.
208208 call append (0 , split (todays_entry, ' \n' ))
209-
209+
210210 " Remove empty lines at end of file.
211211 if remove_empty
212212 $ - /^\s*$/ -1 ,$delete
@@ -223,8 +223,8 @@ if &filetype == 'changelog'
223223 endfunction
224224
225225 if exists (" :NewChangelogEntry" ) != 2
226- noremap <buffer> <silent> <Leader> o <Esc> :call <SID> new_changelog_entry()<CR>
227- command ! -nargs =0 NewChangelogEntry call s: new_changelog_entry ()
226+ noremap <buffer> <silent> <Leader> o <Esc> :call <SID> new_changelog_entry('' )<CR>
227+ command ! -nargs =0 NewChangelogEntry call s: new_changelog_entry (' ' )
228228 endif
229229
230230 let b: undo_ftplugin = " setl com< fo< et< ai<"
@@ -277,10 +277,7 @@ else
277277 if exists (' b:changelog_entry_prefix' )
278278 let prefix = call (b: changelog_entry_prefix , [])
279279 else
280- let prefix = substitute (strpart (expand (' %:p' ), strlen (path )), ' ^/\+' , " " , " " ) . ' :'
281- endif
282- if ! empty (prefix)
283- let prefix = ' ' . prefix
280+ let prefix = substitute (strpart (expand (' %:p' ), strlen (path )), ' ^/\+' , " " , " " )
284281 endif
285282
286283 let buf = bufnr (changelog)
0 commit comments