I'm writing a BufUnload
autocmd
, and I want to conditionally prevent the buffer from actually being unloaded or closed from within the autocmd. Is there a way to do this?
For instance, I want to use the contents of the buffer as a commit message for mercurial using an autocmd that does:
autocmd BufUnload <buffer> !hg ci -l logfile
So if the commit fails (the hg
command returns non-zero error code), I want to leave the buffer open and unchanged.