Wednesday, September 19, 2012

Re: FileTypePre autocmd

On Wednesday, September 19, 2012 11:38:42 PM UTC+8, Ben Fritz wrote:
> On Wednesday, September 19, 2012 10:36:05 AM UTC-5, Ben Fritz wrote:
>
> > On Wednesday, September 19, 2012 2:04:34 AM UTC-5, Fermat 618 wrote:
>
> >
>
> > > I tried to do some clean-up work when using
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > :setfiletype another_file_type
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > command, but didn't manage to find a FileTypePre auto command.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Is there anyway to do clean-up work before a set it to another filetype?
>
> >
>
> >
>
> >
>
> > :setfiletype will not not change the filetype if it's already set
>
>
>
> ...or so I thought, except :help undo_ftplugin specifically mentions :setfiletype, and :help :setfiletype mentions a specific context of inside a nested autocmd. Experimentation shows that it will in fact override the filetype whenever it's used directly.

Thanks, but actually what I want to do is not about a specific filetype, but
all types.

I used BufEnter and BufLeave event autocmd to handle filetype specific menus
add and remove, but that failed when I set a buffer to another filetype. The
autotocmd should be executed in a context that the filetype is the old one.

I read the $VIMRUNTIME/ftplugin.vim where the b:undo_ftplugin take effects, but
that is also trigger by the FileType event, where the old context is left.
Therefore event if I add my clean up code to b:undo_ftplugin, (which is not
that esay), it will not work.

Information about what the old filetype is is needed.

Best regards,
Fermat

--
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

No comments:

Post a Comment