By default <leader>o as mapped in ftplugin/changelog.vim opens the file ChangeLog in the current directory. The following patch makes this slightly more flexible.
#1 The name of the change log can be defined in b:changelog and can refer to a file in a different directory. #2 The variable b:changelog_entry_prefix can contain a function name that will be called to create an appropriate prefix for the current entry. If this variable isn't defined the "filename:" will be used instead. This prefix can be inserted into entry templates with "%p". For ruby, such a function could look like this: if !exists('*RubyChangeLogEntry') function! RubyChangeLogEntry() "{{{3 let e = expand('%:t') let rx = '^\s*\(def\|module\|class\)\>\s\+\zs\([^[:space:]({]\+ \)' let l = search(rx, 'bcnW') if l let e .= ' ('. matchstr(getline(l), rx) .'):' endif return e endf endif This could be used to insert entries like * file.rb (method_name): Regards, Thomas --- src/vim/runtime/ftplugin/changelog.vim 2008-07-08 15:36:43.554801600 +0200 +++ ftplugin/changelog.vim 2008-07-08 16:12:49.278960000 +0200 @@ -116,12 +116,12 @@ " Format used for new date entries. if !exists('g:changelog_new_date_format') - let g:changelog_new_date_format = "%d %u\n\n\t* %c\n\n" + let g:changelog_new_date_format = "%d %u\n\n\t*%p %c\n\n" endif " Format used for new entries to current date entry. if !exists('g:changelog_new_entry_format') - let g:changelog_new_entry_format = "\t* %c" + let g:changelog_new_entry_format = "\t*%p %c" endif " Regular expression used to find a given date entry. @@ -137,9 +137,9 @@ " Substitutes specific items in new date-entry formats and search strings. " Can be done with substitute of course, but unclean, and need [EMAIL PROTECTED] then. - function! s:substitute_items(str, date, user) + function! s:substitute_items(str, date, user, prefix) let str = a:str - let middles = {'%': '%', 'd': a:date, 'u': a:user, 'c': '{cursor}'} + let middles = {'%': '%', 'd': a:date, 'u': a:user, 'c': '{cursor}', 'p': a:prefix} let i = stridx(str, '%') while i != -1 let inc = 0 @@ -165,7 +165,8 @@ endfunction " Internal function to create a new entry in the ChangeLog. - function! s:new_changelog_entry() + function! s:new_changelog_entry(...) + let prefix = a:0 >= 1 ? a:1 : '' " Deal with 'paste' option. let save_paste = &paste let &paste = 1 @@ -173,7 +174,7 @@ " Look for an entry for today by our user. let date = strftime(g:changelog_dateformat) let search = s:substitute_items(g:changelog_date_entry_search, date, - \ g:changelog_username) + \ g:changelog_username, prefix) if search(search) > 0 " Ok, now we look for the end of the date entry, and add an entry. call cursor(nextnonblank(line('.') + 1), 1) @@ -182,7 +183,7 @@ else let p = line('.') endif - let ls = split(s:substitute_items(g:changelog_new_entry_format, '', ''), + let ls = split(s:substitute_items(g:changelog_new_entry_format, '', '', prefix), \ '\n') call append(p, ls) call cursor(p + 1, 1) @@ -192,7 +193,7 @@ " No entry today, so create a date-user header and insert an entry. let todays_entry = s:substitute_items(g:changelog_new_date_format, - \ date, g:changelog_username) + \ date, g:changelog_username, prefix) " Make sure we have a cursor positioning. if stridx(todays_entry, '{cursor}') == -1 let todays_entry = todays_entry . '{cursor}' @@ -240,10 +241,26 @@ nmap <silent> <Leader>o :call <SID>open_changelog()<CR> function! s:open_changelog() - if !filereadable('ChangeLog') + if exists('b:changelog') + let changelog = b:changelog + else + let changelog = 'ChangeLog' + endif + echom changelog + if !filereadable(changelog) return endif - let buf = bufnr('ChangeLog') + + if exists('b:changelog_entry_prefix') + let prefix = call(b:changelog_entry_prefix, []) + else + let prefix = expand('%:t') .':' + endif + if !empty(prefix) + let prefix = ' '. prefix + endif + + let buf = bufnr(changelog) if buf != -1 if bufwinnr(buf) != -1 execute bufwinnr(buf) . 'wincmd w' @@ -251,9 +268,9 @@ execute 'sbuffer' buf endif else - split ChangeLog + exec 'split '. fnameescape(changelog) endif - - call s:new_changelog_entry() + + call s:new_changelog_entry(prefix) endfunction endif --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---