summaryrefslogtreecommitdiff
path: root/src/fileio.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2007-09-29 12:16:41 +0000
committerBram Moolenaar <Bram@vim.org>2007-09-29 12:16:41 +0000
commit78ab331e0d8a76f553830f0347ac27311e4dc0f8 (patch)
treedf1c313bb5c0cae5db59d08f852971a0c10fd89c /src/fileio.c
parent51b8436f09c0ea855758b2086d92f838acab7631 (diff)
downloadvim-git-78ab331e0d8a76f553830f0347ac27311e4dc0f8.tar.gz
updated for version 7.1-125v7.1.125
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 801caba96..84416df08 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -7165,6 +7165,7 @@ static void auto_next_pat __ARGS((AutoPatCmd *apc, int stop_at_last));
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_io, force, group, buf, eap)
* 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.
*/