I wonder if there are any non squash-heavy workflows that this goes well with.

" requires vim-python and python-git
function! CommitFile()
python << EOF
import vim, git
curfile = vim.current.buffer.name
if curfile:
    try:
        repo = git.Repo(curfile)
        repo.git.add(curfile)
        repo.git.commit(m='Update')
    except (git.InvalidGitRepositoryError, git.GitCommandError):
        pass
EOF
endfunction
au BufWritePost * call CommitFile()

§

Tags: Hacks
Planets: ALUG UWCS WUGLUG Debian

§

Four comments

  1. terrible feature but nice poc! :)

    nion

  2. I wouldn't say terrible feature necessarily. Bad work-flow idea for normal code development though. If you are going to use it for writing this is might be a different story. Cory Doctorow just had a python based tool created for a writers work-flow called FlashBake, in case you are interested.

    Sam Williams

  3. Hi!

    Neat hack. I found out it makes sense to use, for my latex files!

    So this is what I hacked up for editing LaTeX files, with a bit of help from vim gurus from #vim.

    1. Use git's gitattribute *.tex diff=tex to get nice hunk headers
    2. Tweak the script to put in the first hunk header in the commit message, that way the log tells me where I changed something
    3. Use a "dotted filetype" (thanks vim gurus) to enable this. I have an autocommand trigger on FileType *.autocommit, so for the files where I want this I define "set ft=tex.autocommit"

    .vimrc code here:

    http://gist....

    ulrik

  4. Thanks!

    This helped me to get my Taglist updated everytime I save the current buffer.

    autocmd BufWritePost * :TlistUpdate

    Dani

Reply

§