4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: The TermResponse autocommand event is not always triggered. (Aron
13 Solution: When unblocking autocommands check if v:termresponse changed and
14 trigger the event then.
15 Files: src/buffer.c, src/diff.c, src/ex_getln.c, src/fileio.c,
16 src/globals.h, src/misc2.c, src/proto/fileio.pro, src/window.c
19 *** ../vim-7.1.124/src/buffer.c Sun Aug 12 15:50:26 2007
20 --- src/buffer.c Wed Sep 26 20:05:38 2007
25 if (!aucmd) /* Don't trigger BufDelete autocommands here. */
28 close_buffer(NULL, buf, DOBUF_WIPE);
37 if (!aucmd) /* Don't trigger BufDelete autocommands here. */
40 close_buffer(NULL, buf, DOBUF_WIPE);
46 *** ../vim-7.1.124/src/diff.c Tue Feb 20 04:43:13 2007
47 --- src/diff.c Tue Sep 25 22:01:40 2007
51 append_redir(cmd, p_srr, tmp_diff);
53 ! ++autocmd_block; /* Avoid ShellCmdPost stuff */
55 (void)call_shell(cmd, SHELL_FILTER|SHELL_SILENT|SHELL_DOOUT);
63 append_redir(cmd, p_srr, tmp_diff);
65 ! block_autocmds(); /* Avoid ShellCmdPost stuff */
67 (void)call_shell(cmd, SHELL_FILTER|SHELL_SILENT|SHELL_DOOUT);
78 ! ++autocmd_block; /* Avoid ShellCmdPost stuff */
80 (void)call_shell(buf, SHELL_FILTER | SHELL_COOKED);
90 ! block_autocmds(); /* Avoid ShellCmdPost stuff */
92 (void)call_shell(buf, SHELL_FILTER | SHELL_COOKED);
98 *** ../vim-7.1.124/src/ex_getln.c Thu Sep 13 18:25:08 2007
99 --- src/ex_getln.c Tue Sep 25 22:03:05 2007
104 /* Don't execute autocommands while creating the window. */
107 /* don't use a new tab page */
112 /* Don't execute autocommands while creating the window. */
115 /* don't use a new tab page */
120 if (win_split((int)p_cwh, WSP_BOT) == FAIL)
123 + # ifdef FEAT_AUTOCMD
124 + unblock_autocmds();
128 cmdwin_type = ccline.cmdfirstc;
133 /* Do execute autocommands for setting the filetype (load syntax). */
137 /* Showing the prompt may have set need_wait_return, reset it. */
141 /* Do execute autocommands for setting the filetype (load syntax). */
142 ! unblock_autocmds();
145 /* Showing the prompt may have set need_wait_return, reset it. */
150 /* Don't execute autocommands while deleting the window. */
158 /* Don't execute autocommands while deleting the window. */
165 win_size_restore(&winsizes);
173 win_size_restore(&winsizes);
176 ! unblock_autocmds();
180 *** ../vim-7.1.124/src/fileio.c Sun Aug 12 15:50:26 2007
181 --- src/fileio.c Wed Sep 26 20:02:54 2007
186 static event_T last_event;
187 static int last_group;
188 + static int autocmd_blocked = 0; /* block all autocmds */
191 * Show the autocommands for one AutoPat.
194 * Quickly return if there are no autocommands for this event or
195 * autocommands are blocked.
197 ! if (first_autopat[(int)event] == NULL || autocmd_block > 0)
202 * Quickly return if there are no autocommands for this event or
203 * autocommands are blocked.
205 ! if (first_autopat[(int)event] == NULL || autocmd_blocked > 0)
212 aubuflocal_remove(buf);
218 + static char_u *old_termresponse = NULL;
222 + * Block triggering autocommands until unblock_autocmd() is called.
223 + * Can be used recursively, so long as it's symmetric.
229 + /* Remember the value of v:termresponse. */
230 + if (autocmd_blocked == 0)
231 + old_termresponse = get_vim_var_str(VV_TERMRESPONSE);
242 + /* When v:termresponse was set while autocommands were blocked, trigger
243 + * the autocommands now. Esp. useful when executing a shell command
244 + * during startup (vimdiff). */
245 + if (autocmd_blocked == 0
246 + && get_vim_var_str(VV_TERMRESPONSE) != old_termresponse)
247 + apply_autocmds(EVENT_TERMRESPONSE, NULL, NULL, FALSE, curbuf);
252 *** ../vim-7.1.124/src/globals.h Tue Sep 25 17:54:41 2007
253 --- src/globals.h Tue Sep 25 22:03:39 2007
256 EXTERN int autocmd_busy INIT(= FALSE); /* Is apply_autocmds() busy? */
257 EXTERN int autocmd_no_enter INIT(= FALSE); /* *Enter autocmds disabled */
258 EXTERN int autocmd_no_leave INIT(= FALSE); /* *Leave autocmds disabled */
259 - EXTERN int autocmd_block INIT(= 0); /* block all autocmds */
260 EXTERN int modified_was_set; /* did ":set modified" */
261 EXTERN int did_filetype INIT(= FALSE); /* FileType event found */
262 EXTERN int keep_filetype INIT(= FALSE); /* value for did_filetype when
264 *** ../vim-7.1.124/src/misc2.c Thu May 10 19:58:47 2007
265 --- src/misc2.c Tue Sep 25 22:04:39 2007
271 ! ++autocmd_block; /* don't want to trigger autocommands here */
274 /* close all tabs and windows */
279 ! block_autocmds(); /* don't want to trigger autocommands here */
282 /* close all tabs and windows */
283 *** ../vim-7.1.124/src/proto/fileio.pro Thu Jun 28 21:57:08 2007
284 --- src/proto/fileio.pro Wed Sep 26 20:05:02 2007
288 int trigger_cursorhold __ARGS((void));
289 int has_cursormoved __ARGS((void));
290 int has_cursormovedI __ARGS((void));
291 + void block_autocmds __ARGS((void));
292 + void unblock_autocmds __ARGS((void));
293 int has_autocmd __ARGS((event_T event, char_u *sfname, buf_T *buf));
294 char_u *get_augroup_name __ARGS((expand_T *xp, int idx));
295 char_u *set_context_in_autocmd __ARGS((expand_T *xp, char_u *arg, int doautocmd));
296 *** ../vim-7.1.124/src/window.c Tue Sep 25 14:50:19 2007
297 --- src/window.c Tue Sep 25 22:05:45 2007
300 * Don't execute autocommands while creating the windows. Must do that
301 * when putting the buffers in the windows.
306 /* todo is number of windows left to create */
308 * Don't execute autocommands while creating the windows. Must do that
309 * when putting the buffers in the windows.
314 /* todo is number of windows left to create */
323 /* return actual number of windows */
328 ! unblock_autocmds();
331 /* return actual number of windows */
334 * Don't execute autocommands while creating the tab pages. Must do that
335 * when putting the buffers in the windows.
340 for (todo = count - 1; todo > 0; --todo)
342 * Don't execute autocommands while creating the tab pages. Must do that
343 * when putting the buffers in the windows.
348 for (todo = count - 1; todo > 0; --todo)
357 /* return actual number of tab pages */
362 ! unblock_autocmds();
365 /* return actual number of tab pages */
368 /* Don't execute autocommands while the window is not properly
369 * initialized yet. gui_create_scrollbar() may trigger a FocusGained
374 * link the window in the window list
376 /* Don't execute autocommands while the window is not properly
377 * initialized yet. gui_create_scrollbar() may trigger a FocusGained
382 * link the window in the window list
390 #ifdef FEAT_SEARCH_EXTRA
391 newwin->w_match_head = NULL;
396 ! unblock_autocmds();
398 #ifdef FEAT_SEARCH_EXTRA
399 newwin->w_match_head = NULL;
403 /* Don't execute autocommands while the window is halfway being deleted.
404 * gui_mch_destroy_scrollbar() may trigger a FocusGained event. */
411 /* Don't execute autocommands while the window is halfway being deleted.
412 * gui_mch_destroy_scrollbar() may trigger a FocusGained event. */
430 ! unblock_autocmds();
434 *** ../vim-7.1.124/src/version.c Sat Sep 29 13:15:29 2007
435 --- src/version.c Sat Sep 29 14:08:31 2007
439 { /* Add new patch number below this line */
445 MICHAEL PALIN PLAYED: 1ST SOLDIER WITH A KEEN INTEREST IN BIRDS, DENNIS, MR
446 DUCK (A VILLAGE CARPENTER WHO IS ALMOST KEENER THAN
447 ANYONE ELSE TO BURN WITCHES), THREE-HEADED KNIGHT, SIR
448 GALAHAD, KING OF SWAMP CASTLE, BROTHER MAYNARD'S ROOMATE
449 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
451 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
452 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
453 \\\ download, build and distribute -- http://www.A-A-P.org ///
454 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///