Disable or change an augroup for a particular filetype?

classic Classic list List threaded Threaded
1 message Options
A S
Reply | Threaded
Open this post in threaded view
|

Disable or change an augroup for a particular filetype?

A S
Hi!

What would be the best way to 1) disable or 2) change  an augroup for some filetype? For now, in my after/ftplugin/some_filetype.vim, I have something like this (not at the same time, of course):

" if I want to disable it
augroup DisableMyAugroup
    autocmd!
    autocmd BufEnter,BufWinEnter,WinEnter,TabEnter <buffer> autocmd! MyAugroup
augroup END

" if I want to change it
function! s:ChangeMyAugroup()
    augroup MyAugroup
        autocmd!
        autocmd SomeEvent <buffer> MY_NEW_COMMAND
    augroup END
endfunction
autocmd! BufEnter,BufWinEnter,WinEnter,TabEnter <buffer> call <SID>ChangeMyAugroup()

function! s:RestoreMyAugroup
    augroup MyAugroup
        autocmd!
        autocmd SomeEvent * MY_ORIGINAL_COMMAND
    augroup END
endfunction
autocmd! BufLeave <buffer> call <SID>RestoreMyAugroup()

It works OK, and I seem to have no problems with it but may be it can be tweaked in some way or enhanced? Any suggestions?


Thank you for your time :)



--
AS

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.