-
Bram Moolenaar authored582fd85b
To find the state of this project's repository at the time of any of these versions, check out the tags.
changelog.vim 7.20 KiB
" Vim filetype plugin file
" Language: generic Changelog file
" Maintainer: Nikolai Weibull <source@pcppopper.org>
" URL: http://www.pcppopper.org/vim/ftplugin/pcp/changelog/
" Latest Revision: 2004-04-25
" arch-tag: b00e2974-c559-4477-b7b2-3ef3f4061bdb
" Variables:
" g:changelog_timeformat -
" description: the timeformat used in ChangeLog entries.
" default: "%Y-%m-%d".
" g:changelog_username -
" description: the username to use in ChangeLog entries
" default: try to deduce it from environment variables and system files.
" Local Mappings:
" <Leader>o -
" adds a new changelog entry for the current user for the current date.
" Global Mappings:
" <Leader>o -
" switches to the ChangeLog buffer opened for the current directory, or
" opens it in a new buffer if it exists in the current directory. Then
" it does the same as the local <Leader>o described above.
" Notes:
" run 'runtime ftplugin/changelog.vim' to enable the global mapping for
" changelog files.
" TODO:
" should we perhaps open the ChangeLog file even if it doesn't exist already?
" Problem is that you might end up with ChangeLog files all over the place.
" If 'filetype' isn't "changelog", we must have been to add ChangeLog opener
if &filetype == "changelog"
" Only do this when not done yet for this buffer
if exists("b:did_ftplugin")
finish
endif
" Don't load another plugin for this buffer
let b:did_ftplugin = 1
let cpo_save = &cpo
set cpo-=C
" The format of the date-time field (should have been called dateformat)
if !exists("g:changelog_timeformat")
let g:changelog_timeformat = "%Y-%m-%d"
endif
" Try to figure out a reasonable username of the form:
" Full Name <user@host>
if !exists("g:changelog_username")
if exists("$EMAIL_ADDRESS")
let g:changelog_username = $EMAIL_ADDRESS
elseif exists("$EMAIL")
let g:changelog_username = $EMAIL
else
" Get the users login name
let login = system('whoami')
if v:shell_error
let login = 'unknown'
else
let newline = stridx(login, "\n")
if newline != -1
let login = strpart(login, 0, newline)
endif
endif
" Try to full name from gecos field in /etc/passwd
if filereadable('/etc/passwd')
let name = substitute(
\system('cat /etc/passwd | grep ^`whoami`'),
\'^\%([^:]*:\)\{4}\([^:]*\):.*$', '\1', '')