David Barnett wrote:

> I recently discovered that the FileType autocmd can fire in the middle
> of the sequence of BufRead autocmds if you have several
> BufRead/BufNewFile autocmds like:
>   autocmd BufRead *.foo setfiletype foo
>   autocmd BufRead *.foo set shiftwidth=8
> 
>   autocmd FileType foo set shiftwidth=4
> 
> This can cause unpredictable behavior. It can especially be a problem
> because cycling filetype off/on will wipe and redefine the
> filetypedetect autocmds, changing the sequence and reversing the
> behavior (in this case, causing sw=4 to win instead of sw=8).
> 
> It seems natural to expect the FileType autocmds to fire after all
> BufRead and BufNewFile autocmds have finished, but lots of people have
> found by trial-and-error that they can access &filetype from BufRead
> autocmds, so there's a lot of vimscript copypasta around that breaks
> if you reorder Buf autocmds.
> 
> Would it be reasonable to change vim so that FileType autocmds don't
> fire mid-BufRead or mid-BufNewFile?

This would involve keeping autocommands in a list and handle them later.
Too complicated and likely to cause new problems.


-- 
MESKIMEN'S LAW
    There's never time to do it right, but always time to do it over.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Raspunde prin e-mail lui