Bram,
if you run:
:au BufEnter * echomsg printf("Entering buffer: %s buftype: %s",
expand("<afile>"), &buftype)
and then you type :term
you'll notice that by the time the BufEnter is triggered, the buftype
option is not set yet. So one cannot detect reliably that the new buffer
will be a terminal buffer.
So how about this current patch:
diff --git a/src/terminal.c b/src/terminal.c
index 9660c64ba..a70ed0ebb 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -253,6 +253,11 @@ term_start(typval_T *argvar, jobopt_T *opt, int forceit)
if (check_restricted() || check_secure())
return;
+#ifdef FEAT_AUTOCMD
+ /* Don't execute Win/Buf Enter autocommands here, until the terminal
+ * is proper setup (buftype option is set) */
+ ++autocmd_no_enter;
+#endif
if ((opt->jo_set & (JO_IN_IO + JO_OUT_IO + JO_ERR_IO))
== (JO_IN_IO + JO_OUT_IO + JO_ERR_IO)
|| (!(opt->jo_set & JO_OUT_IO) && (opt->jo_set & JO_OUT_BUF))
@@ -406,7 +411,6 @@ term_start(typval_T *argvar, jobopt_T *opt, int forceit)
set_term_and_win_size(term);
setup_job_options(opt, term->tl_rows, term->tl_cols);
-
/* System dependent: setup the vterm and maybe start the job in it. */
if (argvar->v_type == VAR_STRING
&& argvar->vval.v_string != NULL
@@ -432,6 +436,14 @@ term_start(typval_T *argvar, jobopt_T *opt, int forceit)
curwin->w_buffer = curbuf;
++curbuf->b_nwindows;
}
+
+#ifdef FEAT_AUTOCMD
+ if (autocmd_no_enter)
+ --autocmd_no_enter;
+ apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf);
+ apply_autocmds(EVENT_BUFWINENTER, NULL, NULL, FALSE, curbuf);
+#endif
+
}
else
{
@@ -445,6 +457,10 @@ term_start(typval_T *argvar, jobopt_T *opt, int forceit)
curwin->w_buffer = curbuf;
++curbuf->b_nwindows;
}
+#ifdef FEAT_AUTOCMD
+ if (autocmd_no_enter)
+ --autocmd_no_enter;
+#endif
/* Wiping out the buffer will also close the window and call
* free_terminal(). */
Best,
Christian
--
Hallo Bademantelträger!
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.