stefandtw / quickfix-reflector.vim

Change code right in the quickfix window
MIT License
340 stars 19 forks source link

BufWritePost is not triggered when buffer is written by quickfix-reflector #18

Closed ronakg closed 8 years ago

ronakg commented 8 years ago

I have a BufWritePost for specific files which triggers a database update. When those files are written by quickfix-reflector, the BufWritePost autocmd is not triggered.

stefandtw commented 8 years ago

Activating all the usual Vim events when doing the replacements is not really an option. Several events would be sent that people may not expect, and may trigger undesired autocommand calls. It would also require quite a few changes that may result in more complex code.

I could manually trigger BufWritePost. I'm not sure about doing this by default, as there may still be some people using autocommand not suited to this. For instance, there might be one that auto-compiles a changed file, and depending on how long it takes, that may or may not be what you want after updating 100 files at once. So perhaps a plugin option would be best, like g:qf_replacement_events=BufWritePost,....

Alternatively I could trigger a custom event, like QfReplacementBufWritePost. This is the least confusing solution. It also does not require adding more plugin options. The downside is that obviously autocommands need listen to this custom event, which makes it difficult to use in other Vim plugins that do not know it.

Any thoughts? Would the custom event be enough for you?

ronakg commented 8 years ago

Custom event would work for me. From what you've explained above, that looks like the safest approach as well considering no one else has asked such a change before.

stefandtw commented 8 years ago

see https://github.com/stefandtw/quickfix-reflector.vim#events

Let me know if that works for you.

ronakg commented 8 years ago

This is perfect, thanks.