>From :help :doautocmd in Vim 7.3.353:
> *:do* *:doau* *:doautocmd* *E217*
> :do[autocmd] [group] {event} [fname]
> Apply the autocommands matching [fname] (default:
> current file name) for {event} to the current buffer.
> You can use this when the current file name does not
> match the right pattern, after changing settings, or
> to execute autocommands for a certain event.
> It's possible to use this inside an autocommand too,
> so you can base the autocommands for one extension on
> another extension. Example: >
> :au Bufenter *.cpp so ~/.vimrc_cpp
> :au Bufenter *.cpp doau BufEnter x.c
> < Be careful to avoid endless loops. See
> |autocmd-nested|.
>
> When the [group] argument is not given, Vim executes
> the autocommands for all groups. When the [group]
> argument is included, Vim executes only the matching
> autocommands for that group. Note: if you use an
> undefined group name, Vim gives you an error message.
>
> After applying the autocommands the modelines are
> processed, so that their settings overrule the
> settings from autocommands, like what happens when
> editing a file.
I wonder about the last paragraph. There is not any condition to
process modelines by :doautocmd. It means that :doautocmd triggers
modeline processing in any context.
For example, I have something like the following in my vimrc to
indicate
the same code will be run at both CursorHold and CursorHoldI events:
augroup MyConfig
autocmd CursorHold * call s:save_stat()
autocmd CursorHoldI * doautocmd MyConfig CursorHold
augroup END
Suppose that the current buffer contains some modelines. Modelines
will
be processed for each time whenever CursorHoldI is happened, even if
the
file is already loaded. Moreover, running :doautocmd like ":doautocmd
User foo" by hand also triggers modeline processing.
The current behavior seems to be odd, and it causes side effects at
unexpected timing depending on user's configuration. I think that
modelines should be processed while opening a file and it should not
be
processed other timing.
Is the current behavior intended one? If so, what is the reason?
--
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