0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

updated for version 7.1-125

This commit is contained in:
Bram Moolenaar
2007-09-29 12:16:41 +00:00
parent 51b8436f09
commit 78ab331e0d
9 changed files with 62 additions and 21 deletions

View File

@@ -5515,11 +5515,11 @@ wipe_buffer(buf, aucmd)
#ifdef FEAT_AUTOCMD #ifdef FEAT_AUTOCMD
if (!aucmd) /* Don't trigger BufDelete autocommands here. */ if (!aucmd) /* Don't trigger BufDelete autocommands here. */
++autocmd_block; block_autocmds();
#endif #endif
close_buffer(NULL, buf, DOBUF_WIPE); close_buffer(NULL, buf, DOBUF_WIPE);
#ifdef FEAT_AUTOCMD #ifdef FEAT_AUTOCMD
if (!aucmd) if (!aucmd)
--autocmd_block; unblock_autocmds();
#endif #endif
} }

View File

@@ -840,11 +840,11 @@ diff_file(tmp_orig, tmp_new, tmp_diff)
tmp_orig, tmp_new); tmp_orig, tmp_new);
append_redir(cmd, p_srr, tmp_diff); append_redir(cmd, p_srr, tmp_diff);
#ifdef FEAT_AUTOCMD #ifdef FEAT_AUTOCMD
++autocmd_block; /* Avoid ShellCmdPost stuff */ block_autocmds(); /* Avoid ShellCmdPost stuff */
#endif #endif
(void)call_shell(cmd, SHELL_FILTER|SHELL_SILENT|SHELL_DOOUT); (void)call_shell(cmd, SHELL_FILTER|SHELL_SILENT|SHELL_DOOUT);
#ifdef FEAT_AUTOCMD #ifdef FEAT_AUTOCMD
--autocmd_block; unblock_autocmds();
#endif #endif
vim_free(cmd); vim_free(cmd);
} }
@@ -949,11 +949,11 @@ ex_diffpatch(eap)
# endif # endif
eap->arg); eap->arg);
#ifdef FEAT_AUTOCMD #ifdef FEAT_AUTOCMD
++autocmd_block; /* Avoid ShellCmdPost stuff */ block_autocmds(); /* Avoid ShellCmdPost stuff */
#endif #endif
(void)call_shell(buf, SHELL_FILTER | SHELL_COOKED); (void)call_shell(buf, SHELL_FILTER | SHELL_COOKED);
#ifdef FEAT_AUTOCMD #ifdef FEAT_AUTOCMD
--autocmd_block; unblock_autocmds();
#endif #endif
} }

View File

@@ -5925,7 +5925,7 @@ ex_window()
# ifdef FEAT_AUTOCMD # ifdef FEAT_AUTOCMD
/* Don't execute autocommands while creating the window. */ /* Don't execute autocommands while creating the window. */
++autocmd_block; block_autocmds();
# endif # endif
/* don't use a new tab page */ /* don't use a new tab page */
cmdmod.tab = 0; cmdmod.tab = 0;
@@ -5934,6 +5934,9 @@ ex_window()
if (win_split((int)p_cwh, WSP_BOT) == FAIL) if (win_split((int)p_cwh, WSP_BOT) == FAIL)
{ {
beep_flush(); beep_flush();
# ifdef FEAT_AUTOCMD
unblock_autocmds();
# endif
return K_IGNORE; return K_IGNORE;
} }
cmdwin_type = ccline.cmdfirstc; cmdwin_type = ccline.cmdfirstc;
@@ -5956,7 +5959,7 @@ ex_window()
# ifdef FEAT_AUTOCMD # ifdef FEAT_AUTOCMD
/* Do execute autocommands for setting the filetype (load syntax). */ /* Do execute autocommands for setting the filetype (load syntax). */
--autocmd_block; unblock_autocmds();
# endif # endif
/* Showing the prompt may have set need_wait_return, reset it. */ /* Showing the prompt may have set need_wait_return, reset it. */
@@ -6110,7 +6113,7 @@ ex_window()
# ifdef FEAT_AUTOCMD # ifdef FEAT_AUTOCMD
/* Don't execute autocommands while deleting the window. */ /* Don't execute autocommands while deleting the window. */
++autocmd_block; block_autocmds();
# endif # endif
wp = curwin; wp = curwin;
bp = curbuf; bp = curbuf;
@@ -6122,7 +6125,7 @@ ex_window()
win_size_restore(&winsizes); win_size_restore(&winsizes);
# ifdef FEAT_AUTOCMD # ifdef FEAT_AUTOCMD
--autocmd_block; unblock_autocmds();
# endif # endif
} }

View File

@@ -7165,6 +7165,7 @@ static void auto_next_pat __ARGS((AutoPatCmd *apc, int stop_at_last));
static event_T last_event; static event_T last_event;
static int last_group; static int last_group;
static int autocmd_blocked = 0; /* block all autocmds */
/* /*
* Show the autocommands for one AutoPat. * 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 * Quickly return if there are no autocommands for this event or
* autocommands are blocked. * autocommands are blocked.
*/ */
if (first_autopat[(int)event] == NULL || autocmd_block > 0) if (first_autopat[(int)event] == NULL || autocmd_blocked > 0)
goto BYPASS_AU; goto BYPASS_AU;
/* /*
@@ -8768,6 +8769,40 @@ BYPASS_AU:
return retval; 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. * Find next autocommand pattern that matches.
*/ */

View File

@@ -366,7 +366,6 @@ EXTERN int cterm_normal_bg_color INIT(= 0);
EXTERN int autocmd_busy INIT(= FALSE); /* Is apply_autocmds() busy? */ EXTERN int autocmd_busy INIT(= FALSE); /* Is apply_autocmds() busy? */
EXTERN int autocmd_no_enter INIT(= FALSE); /* *Enter autocmds disabled */ EXTERN int autocmd_no_enter INIT(= FALSE); /* *Enter autocmds disabled */
EXTERN int autocmd_no_leave INIT(= FALSE); /* *Leave autocmds disabled */ EXTERN int autocmd_no_leave INIT(= FALSE); /* *Leave autocmds disabled */
EXTERN int autocmd_block INIT(= 0); /* block all autocmds */
EXTERN int modified_was_set; /* did ":set modified" */ EXTERN int modified_was_set; /* did ":set modified" */
EXTERN int did_filetype INIT(= FALSE); /* FileType event found */ EXTERN int did_filetype INIT(= FALSE); /* FileType event found */
EXTERN int keep_filetype INIT(= FALSE); /* value for did_filetype when EXTERN int keep_filetype INIT(= FALSE); /* value for did_filetype when

View File

@@ -972,7 +972,7 @@ free_all_mem()
return; return;
entered = TRUE; entered = TRUE;
++autocmd_block; /* don't want to trigger autocommands here */ block_autocmds(); /* don't want to trigger autocommands here */
#ifdef FEAT_WINDOWS #ifdef FEAT_WINDOWS
/* close all tabs and windows */ /* close all tabs and windows */

View File

@@ -40,6 +40,8 @@ int has_cursorhold __ARGS((void));
int trigger_cursorhold __ARGS((void)); int trigger_cursorhold __ARGS((void));
int has_cursormoved __ARGS((void)); int has_cursormoved __ARGS((void));
int has_cursormovedI __ARGS((void)); int has_cursormovedI __ARGS((void));
void block_autocmds __ARGS((void));
void unblock_autocmds __ARGS((void));
int has_autocmd __ARGS((event_T event, char_u *sfname, buf_T *buf)); int has_autocmd __ARGS((event_T event, char_u *sfname, buf_T *buf));
char_u *get_augroup_name __ARGS((expand_T *xp, int idx)); char_u *get_augroup_name __ARGS((expand_T *xp, int idx));
char_u *set_context_in_autocmd __ARGS((expand_T *xp, char_u *arg, int doautocmd)); char_u *set_context_in_autocmd __ARGS((expand_T *xp, char_u *arg, int doautocmd));

View File

@@ -666,6 +666,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
125,
/**/ /**/
124, 124,
/**/ /**/

View File

@@ -1291,7 +1291,7 @@ make_windows(count, vertical)
* Don't execute autocommands while creating the windows. Must do that * Don't execute autocommands while creating the windows. Must do that
* when putting the buffers in the windows. * when putting the buffers in the windows.
*/ */
++autocmd_block; block_autocmds();
#endif #endif
/* todo is number of windows left to create */ /* todo is number of windows left to create */
@@ -1313,7 +1313,7 @@ make_windows(count, vertical)
} }
#ifdef FEAT_AUTOCMD #ifdef FEAT_AUTOCMD
--autocmd_block; unblock_autocmds();
#endif #endif
/* return actual number of windows */ /* return actual number of windows */
@@ -3415,7 +3415,7 @@ make_tabpages(maxcount)
* Don't execute autocommands while creating the tab pages. Must do that * Don't execute autocommands while creating the tab pages. Must do that
* when putting the buffers in the windows. * when putting the buffers in the windows.
*/ */
++autocmd_block; block_autocmds();
#endif #endif
for (todo = count - 1; todo > 0; --todo) for (todo = count - 1; todo > 0; --todo)
@@ -3423,7 +3423,7 @@ make_tabpages(maxcount)
break; break;
#ifdef FEAT_AUTOCMD #ifdef FEAT_AUTOCMD
--autocmd_block; unblock_autocmds();
#endif #endif
/* return actual number of tab pages */ /* return actual number of tab pages */
@@ -4162,7 +4162,7 @@ win_alloc(after)
/* Don't execute autocommands while the window is not properly /* Don't execute autocommands while the window is not properly
* initialized yet. gui_create_scrollbar() may trigger a FocusGained * initialized yet. gui_create_scrollbar() may trigger a FocusGained
* event. */ * event. */
++autocmd_block; block_autocmds();
#endif #endif
/* /*
* link the window in the window list * link the window in the window list
@@ -4207,7 +4207,7 @@ win_alloc(after)
foldInitWin(newwin); foldInitWin(newwin);
#endif #endif
#ifdef FEAT_AUTOCMD #ifdef FEAT_AUTOCMD
--autocmd_block; unblock_autocmds();
#endif #endif
#ifdef FEAT_SEARCH_EXTRA #ifdef FEAT_SEARCH_EXTRA
newwin->w_match_head = NULL; newwin->w_match_head = NULL;
@@ -4232,7 +4232,7 @@ win_free(wp, tp)
#ifdef FEAT_AUTOCMD #ifdef FEAT_AUTOCMD
/* Don't execute autocommands while the window is halfway being deleted. /* Don't execute autocommands while the window is halfway being deleted.
* gui_mch_destroy_scrollbar() may trigger a FocusGained event. */ * gui_mch_destroy_scrollbar() may trigger a FocusGained event. */
++autocmd_block; block_autocmds();
#endif #endif
#ifdef FEAT_MZSCHEME #ifdef FEAT_MZSCHEME
@@ -4295,7 +4295,7 @@ win_free(wp, tp)
vim_free(wp); vim_free(wp);
#ifdef FEAT_AUTOCMD #ifdef FEAT_AUTOCMD
--autocmd_block; unblock_autocmds();
#endif #endif
} }