Closed GoogleCodeExporter closed 9 years ago
I'm having trouble replicating this issue. The autocommands that are based on
file name shouldn't execute at all during VCSVimDiff, as the plugin explicitly
disables autocommands when naming the scratch buffer.
The autocommands for file type SHOULD run, because scratch buffers are given
the same type as their parent when they contain file content (as opposed to
messages).
Could you please determine which autocommand is running on the output buffer?
Original comment by bob.hies...@gmail.com
on 12 Apr 2013 at 4:29
I have these commands in my .vimrc
augroup python_tabs
" Remove all python_tabs autocommands
au!
autocmd BufWritePre,FileWritePre *.py,*.pyw,<PYTHON;python> call
s:writepre()
autocmd BufWritePost,FileWritePost *.py,*.pyw,<PYTHON;python> call
s:writepost()
autocmd BufAdd,BufFilePost,BufReadPost,FileReadPost,FilterReadPost
*.py,*.pyw,<PYTHON;python> call s:readpost()
augroup END
I get s.readpost() to run for python files so it can do space / tab
normalization on the file because I prefer tabs.
I need this to happen for the VCS buffers, but it doesn't seem to work
properly in unaltered vcscommand.
If I apply this patch
*** vcscommand.vim 2011-12-05 10:25:28.000000000 +0000
--- /home/robin/.vim/plugin/vcscommand.vim 2013-01-26 09:38:26.548521662
+0000
***************
*** 1107,1112 ****
--- 1107,1114 ----
finally
call setbufvar(currentBuffer, '&modeline', saveModeline)
endtry
+ doauto BufAdd
+ diffupdate
return resultBuffer
finally
let s:isEditFileRunning = s:isEditFileRunning - 1
then my commands do get run on the buffer.
However, if I quit the VCS buffer and then re-run VCSVimDiff the commands
aren't re-executed. I would either like to know how I can get my user
commands executed with an event from vcscommand or at least figure out how
to make my patch do the right thing. Is there an event I can use to get
s.readpost to work properly? My understanding of the vim buffer events is
probably wrong so perhaps an event is already being generated that I should
be hooking.
Thanks for the good work
Original comment by becker...@gmail.com
on 20 Apr 2013 at 12:56
I suspect that your autocommand pattern isn't matching on subsequent VCSVimDiff
because you're not getting rid of the VCS buffer completely. You may just be
closing it without deleting it. If that is correct, the second (and any
subequent) VCS buffer that is created will have a number appended to the name,
which won't match your patterns.
Rather than modify the plugin, I'd suggest you hook into the autocommands that
it provides. If you generally want to run BufAdd for every VCS buffer, but run
it with the original file name, you could do the following:
augroup VCSCommand
au User VCSBufferCreated execute('doauto BufAdd ' . b:VCSCommandSourceFile)
augroup END
You could use VCSVimDiffFinish instead of VCSBufferCreated if you only want to
run it after VCSVimDiff. Or, if there are other buffer types you want to run
it on, use VCSBufferCreated but test the type of VCS buffer with the
b:VCSCommandCommand variable.
function RunVCSAuto()
if(match(b:VCSCommandCommand, '^\(review\|diff\|vimdiff\)$') == 0)
execute 'doauto BufAdd ' . b:VCSCommandSourceFile
endif
endfunction
augroup VCSCommand
au!
au User VCSBufferCreated call RunVCSAuto()
augroup END
Original comment by bob.hies...@gmail.com
on 22 Apr 2013 at 3:49
Thanks I will give one or more of these a try. I didn't realize that
vcscommand had its own events. Naively I assumed that :q on a buffer would
remove the whole buffer. This plugin is one of the most useful and I thank
you for it.
Original comment by becker...@gmail.com
on 24 Apr 2013 at 11:01
OK I tried the VCSBufferCreated hook and that works ie my BufAdd code is
called, but I think it's too early for my stuff to work.
I did get the following to work as I intended
augroup VCSCommand
au User VCSVimDiffFinish execute('doauto BufAdd ' .
b:VCSCommandSourceFile)
augroup END
this seems to run on the buffer after it is filled and then I do get the
intended tab/space changes for python.
Thanks a lot for this advice and the great software.
Original comment by becker...@gmail.com
on 26 Apr 2013 at 4:00
I'm glad you have a solution. Out of curiosity, does VCSBufferCreated not work
for you because the filetype isn't set yet, or is there some other issue? It
might make sense for me to delay calling it until the filetype is set.
Thanks for the encouraging words.
Original comment by bob.hies...@gmail.com
on 30 Apr 2013 at 4:12
Original comment by bob.hies...@gmail.com
on 19 Mar 2014 at 4:12
Original issue reported on code.google.com by
becker...@gmail.com
on 22 Sep 2012 at 12:02