Gary,
Am 2014-02-17 23:52, schrieb Gary Johnson:
Thanks for your patience with this and willingness to work it
through. I think we're still not on the same page, however.
In my example I use the following autocommand:
au BufWinEnter * let a=line(".")
Let us assume that you are correct that this autocommand triggers
twice, once for the creation of buffer 1 and once for the creation
of buffer 2. After the creation of buffer 2, 'a' should contain the
value of some line number in buffer 2.
You are correct, I haven't thought about that. One would expect the
autocommand to trigger, after the cursor is positioned on the error,
but in fact it is triggered, when the file is loaded but before the
cursor is moved to the error.
One could consider this a bug. I am however sure, that once we fix
this behaviour, there are many more cases were we need to postpone the
BufWinEnter autocommand until the cursor is finally moved to the
correct position.
But hey, no risk, no fun ;)
so here is a patch, that prevents this behaviour in your case.
diff --git a/src/quickfix.c b/src/quickfix.c
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -1464,6 +1464,9 @@
#endif
int ok = OK;
int usable_win;
+#ifdef FEAT_AUTOCMD
+ char_u *save_ei = NULL;
+#endif
if (qi == NULL)
qi = &ql_info;
@@ -1782,6 +1785,13 @@
*/
old_curbuf = curbuf;
old_lnum = curwin->w_cursor.lnum;
+#ifdef FEAT_AUTOCMD
+ save_ei = vim_strsave(p_ei);
+ /* postpone triggering of BufWinEnter autocommand until the cursor
is
+ * positioned at the correct location */
+ set_string_option_direct((char_u *)"ei", -1, (char_u
*)"BufWinEnter",
+ OPT_FREE, SID_NONE);
+#endif
if (qf_ptr->qf_fnum != 0)
{
@@ -1931,6 +1941,15 @@
free_string_option(old_swb);
}
#endif
+#ifdef FEAT_AUTOCMD
+ if (save_ei != NULL)
+ {
+ set_string_option_direct((char_u *)"ei", -1, save_ei, OPT_FREE,
SID_NONE);
+ free_string_option(save_ei);
+ if (ok == OK && curbuf != old_curbuf)
+ apply_autocmds(EVENT_BUFWINENTER, NULL, NULL, FALSE, curbuf);
+ }
+#endif
}
/*
Best,
Christian
--
--
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/groups/opt_out.