patch 7.4.2075
Problem: No autocommand event to initialize a window or tab page.
Solution: Add WinNew and TabNew events. (partly by Felipe Morales)
diff --git a/src/window.c b/src/window.c
index b9e75d6..bf650f8 100644
--- a/src/window.c
+++ b/src/window.c
@@ -45,7 +45,7 @@
static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, int trigger_enter_autocmds, int trigger_leave_autocmds);
static void frame_fix_height(win_T *wp);
static int frame_minheight(frame_T *topfrp, win_T *next_curwin);
-static void win_enter_ext(win_T *wp, int undo_sync, int no_curwin, int trigger_enter_autocmds, int trigger_leave_autocmds);
+static void win_enter_ext(win_T *wp, int undo_sync, int no_curwin, int trigger_new_autocmds, int trigger_enter_autocmds, int trigger_leave_autocmds);
static void win_free(win_T *wp, tabpage_T *tp);
static void frame_append(frame_T *after, frame_T *frp);
static void frame_insert(frame_T *before, frame_T *frp);
@@ -1259,7 +1259,7 @@
/*
* make the new window the current window
*/
- win_enter(wp, FALSE);
+ win_enter_ext(wp, FALSE, FALSE, TRUE, TRUE, TRUE);
if (flags & WSP_VERT)
p_wiw = i;
else
@@ -2416,7 +2416,7 @@
win_comp_pos();
if (close_curwin)
{
- win_enter_ext(wp, FALSE, TRUE, TRUE, TRUE);
+ win_enter_ext(wp, FALSE, TRUE, FALSE, TRUE, TRUE);
#ifdef FEAT_AUTOCMD
if (other_buffer)
/* careful: after this wp and win may be invalid! */
@@ -3629,7 +3629,9 @@
redraw_all_later(CLEAR);
#ifdef FEAT_AUTOCMD
+ apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf);
apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf);
+ apply_autocmds(EVENT_TABNEW, NULL, NULL, FALSE, curbuf);
apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf);
#endif
return OK;
@@ -3808,7 +3810,7 @@
/* We would like doing the TabEnter event first, but we don't have a
* valid current window yet, which may break some commands.
* This triggers autocommands, thus may make "tp" invalid. */
- win_enter_ext(tp->tp_curwin, FALSE, TRUE,
+ win_enter_ext(tp->tp_curwin, FALSE, TRUE, FALSE,
trigger_enter_autocmds, trigger_leave_autocmds);
prevwin = next_prevwin;
@@ -4242,7 +4244,7 @@
void
win_enter(win_T *wp, int undo_sync)
{
- win_enter_ext(wp, undo_sync, FALSE, TRUE, TRUE);
+ win_enter_ext(wp, undo_sync, FALSE, FALSE, TRUE, TRUE);
}
/*
@@ -4255,6 +4257,7 @@
win_T *wp,
int undo_sync,
int curwin_invalid,
+ int trigger_new_autocmds UNUSED,
int trigger_enter_autocmds UNUSED,
int trigger_leave_autocmds UNUSED)
{
@@ -4340,6 +4343,8 @@
}
#ifdef FEAT_AUTOCMD
+ if (trigger_new_autocmds)
+ apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf);
if (trigger_enter_autocmds)
{
apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf);