Mercurial > vim
diff src/fileio.c @ 1410:cdd82acd75b4 v7.1.125
updated for version 7.1-125
author | vimboss |
---|---|
date | Sat, 29 Sep 2007 12:16:41 +0000 |
parents | c544a3507e83 |
children | 0e6b369b9760 |
line wrap: on
line diff
--- a/src/fileio.c +++ b/src/fileio.c @@ -7165,6 +7165,7 @@ static void auto_next_pat __ARGS((AutoPa static event_T last_event; static int last_group; +static int autocmd_blocked = 0; /* block all autocmds */ /* * Show the autocommands for one AutoPat. @@ -8454,7 +8455,7 @@ apply_autocmds_group(event, fname, fname * Quickly return if there are no autocommands for this event or * autocommands are blocked. */ - if (first_autopat[(int)event] == NULL || autocmd_block > 0) + if (first_autopat[(int)event] == NULL || autocmd_blocked > 0) goto BYPASS_AU; /* @@ -8768,6 +8769,40 @@ BYPASS_AU: return retval; } +# ifdef FEAT_EVAL +static char_u *old_termresponse = NULL; +# endif + +/* + * Block triggering autocommands until unblock_autocmd() is called. + * Can be used recursively, so long as it's symmetric. + */ + void +block_autocmds() +{ +# ifdef FEAT_EVAL + /* Remember the value of v:termresponse. */ + if (autocmd_blocked == 0) + old_termresponse = get_vim_var_str(VV_TERMRESPONSE); +# endif + ++autocmd_blocked; +} + + void +unblock_autocmds() +{ + --autocmd_blocked; + +# ifdef FEAT_EVAL + /* When v:termresponse was set while autocommands were blocked, trigger + * the autocommands now. Esp. useful when executing a shell command + * during startup (vimdiff). */ + if (autocmd_blocked == 0 + && get_vim_var_str(VV_TERMRESPONSE) != old_termresponse) + apply_autocmds(EVENT_TERMRESPONSE, NULL, NULL, FALSE, curbuf); +# endif +} + /* * Find next autocommand pattern that matches. */