I'm struggling with using .vimrc to apply specific configurations based on the filetype.  Following the autocmd FileType suggestion here, I have attempted to apply a configuration based on filetype.  Here is what I have in my .vimrc:autocmd FileType tex call Tex_config()  function Tex_config()    let g:LatexBox_viewer = 'skim'    let g:LatexBox_latexmk_options = '-pvc'    let g:tex_flavor = latex    setlocal spell spelllang=en_ca  endfunctionI can call the function Tex_config() with :debug Tex_config: Vim happily spets through the function.  So, everything seems like it should work.But, when I issue :set filetype=tex something strange happens: spell checking turns off.  And when I issue :set filetype=foo spell checking turns on.  Just the reverse of what I expect to happen from this configuration snippet!Any assistance would be greatly appreciated.  Here is the full vimrc (function at 44-50).  Thanks.Update: Another part of the puzzle: when I load a TeX file, preferences are read without a problem.  The problem arises on :set filetype=tex.
Vim config for specific filetypes
vim