" Vim support file to detect file types
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2017 Jun 12
+" Last Change: 2017 Jun 20
" Listen very carefully, I will say this only once
if exists("did_load_filetypes")
endif
endfunc
+" Vim help file
+au BufNewFile,BufRead $VIMRUNTIME/doc/*.txt setf help
+
" Abaqus or Trasys
au BufNewFile,BufRead *.inp call s:Check_inp()
char_u *rt;
int mustfree;
- /* set filetype to "help". */
- set_option_value((char_u *)"ft", 0L, (char_u *)"help", OPT_LOCAL);
+ /* Set filetype to "help" if still needed. */
+ if (STRCMP(curbuf->b_p_ft, "help") != 0)
+ set_option_value((char_u *)"ft", 0L, (char_u *)"help", OPT_LOCAL);
#ifdef FEAT_SYN_HL
if (!syntax_present(curwin))
/* set when changing an option that only requires a redraw in the GUI */
int redraw_gui_only = FALSE;
#endif
+#ifdef FEAT_AUTOCMD
+ int ft_changed = FALSE;
+#endif
/* Get the global option to compare with, otherwise we would have to check
* two values for all local options. */
{
if (!valid_filetype(*varp))
errmsg = e_invarg;
+ else
+ ft_changed = STRCMP(oldval, *varp) != 0;
}
#endif
# endif
else if (varp == &(curbuf->b_p_ft))
{
- /* 'filetype' is set, trigger the FileType autocommand */
- did_filetype = TRUE;
- apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
+ /* 'filetype' is set, trigger the FileType autocommand.
+ * Skip this when called from a modeline and the filetype was
+ * already set to this value. */
+ if (!(opt_flags & OPT_MODELINE) || ft_changed)
+ {
+ did_filetype = TRUE;
+ apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
curbuf->b_fname, TRUE, curbuf);
+ }
}
#endif
#ifdef FEAT_SPELL