I based this on the ftplugin/changelog.vim that came in 7.0 w/ the 1-17 patches and yes. I can provide a patch. I think there were only a couple bugs in the s:open_changelog function, something like bsplit actually being sbuffer and using buf number with the wincmd instead of the window number returned by bufwinnr. This is off the top of my head. I'll verify and send you the patch later today.
I'll switch to vim License also but I don't mind removing it from distribution in vim.org (is that possible?) and letting you take over it either. In fact, it didn't come that way but that was my intention all along. I just put it in vim.org for you or anybody who wanted it to get it. I thought of talking to you first but I started from the assumption that you didn't want to be bothered with it or that the enhancements didn't mean much to you to warrant changing the script. I didn't know, so I decided to enhance it to make it behave like emacs (including class/method/function name) and then ask here what to do with it. In the meantime, I'll upload a new version with the VIM license. I've created a patch, which I'm including at the end but I didn't test it. One of the main things I did was to split the current script into a plugin and an ftplugin. It sounds like you'd prefer only that fixes for the current script, so I quickly edited the existing changelog.vim script to include the changes I made to it had it been only on ftplugin script. There's one set of changes that are not really bugs but just a simplification I made to make it clearer to me and that is the use of printf instead of substitute_items. I included those too but just for reference I guess. Thanks again for your understanding and writing the original scripts, indent, and syntax files. -- lpc $ diff -u /usr/local/share/vim/vim70/ftplugin/changelog.vim ~/vimfiles/changelog.vim --- /usr/local/share/vim/vim70/ftplugin/changelog.vim 2006-08-04 21:53:16.531250000 -0400 +++ /home/lpc/vimfiles/changelog.vim 2006-08-08 10:54:28.578125000 -0400 @@ -114,39 +114,6 @@ endif endif - " 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" - 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" - endif - - " Regular expression used to find a given date entry. - if !exists('g:changelog_date_entry_search') - let g:changelog_date_entry_search = '^\s*%d\_s*%u' - endif - - " 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) - let str = a:str - let middles = {'%': '%', 'd': a:date, 'u': a:user, 'c': '{cursor}'} - let i = stridx(str, '%') - while i != -1 - let inc = 0 - if has_key(middles, str[i + 1]) - let mid = middles[str[i + 1]] - let str = strpart(str, 0, i) . mid . strpart(str, i + 2) - let inc = strlen(mid) - endif - let i = stridx(str, '%', i + 1 + inc) - endwhile - return str - endfunction - " Position the cursor once we've done all the funky substitution. function! s:position_cursor() if search('{cursor}') > 0 @@ -166,8 +133,8 @@ call cursor(1, 1) " 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) + let etitle = "\t* {cursor}" + let search = printf('^\s*%s\_s*%s', date, g:changelog_username) 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) @@ -176,21 +143,15 @@ else let p = line('.') endif - let ls = split(s:substitute_items(g:changelog_new_entry_format, '', ''), - \ '\n') - call append(p, ls) + call append(p, split(etitle, '\n')) call cursor(p + 1, 1) else " Flag for removing empty lines at end of new ChangeLogs. let remove_empty = line('$') == 1 " 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) - " Make sure we have a cursor positioning. - if stridx(todays_entry, '{cursor}') == -1 - let todays_entry = todays_entry . '{cursor}' - endif + let fmt = "%s %s\n\n\%s\n\n" + let todays_entry = printf(fmt, date, g:changelog_username, etitle) " Now do the work. call append(0, split(todays_entry, '\n')) @@ -211,7 +172,7 @@ endfunction if exists(":NewChangelogEntry") != 2 - map <buffer> <silent> <Leader>o <Esc>:call <SID>new_changelog_entry()<CR> + map <buffer> <silent> <Leader>o :call <SID>new_changelog_entry()<CR> command! -nargs=0 NewChangelogEntry call s:new_changelog_entry() endif @@ -222,7 +183,7 @@ setlocal noexpandtab setlocal autoindent - if &textwidth == 0 + if &textwidth == 0 || &textwidth > 78 setlocal textwidth=78 let b:undo_ftplugin .= " tw<" endif @@ -231,7 +192,11 @@ unlet s:cpo_save else " Add the Changelog opening mapping - nmap <silent> <Leader>o :call <SID>open_changelog()<CR> + if !hasmapto('<Plug>GnuchlogOpen') + nmap <unique> <Leader>o <Plug>GnuchlogOpen + endif + nmap <silent> <Plug>GnuchlogOpen :call <SID>open_changelog()<CR> + function! s:open_changelog() if !filereadable('ChangeLog') @@ -239,10 +204,11 @@ endif let buf = bufnr('ChangeLog') if buf != -1 - if bufwinnr(buf) != -1 - execute buf . 'wincmd w' + let window_nr = bufwinnr(buf) + if window_nr != -1 + execute window_nr . 'wincmd w' else - execute 'bsplit' buf + execute 'sbuffer ' buf endif else split ChangeLog On 8/8/06, Nikolai Weibull <[EMAIL PROTECTED]> wrote:
On 8/8/06, Luis P Caamano <[EMAIL PROTECTED]> wrote: > There are several bug fixes, integration with tag searches to include > the class/method/function and it searches multiple ChangeLog files > upwards. Have you based this off of the latest ftplugin/changelog.vim? Could you perhaps provide a patch against that one so that I can fix the bugs you've found in the file distributed with Vim as well? > I apologize if I'm breaking any rules, this is the first time I > publish a vim script in vim.org. Some folks suggested that in the > #vim irc channel. > > Just tell me what I should do with it. Anything you say is fine with me. I don't know. Perhaps just switch to the Vim license. That's the easiest. Thanks. nikolai
-- Luis P Caamano Atlanta, GA USA