> Maybe code somewhere uses curwin to get current buffer in place of curbuf.
Testing with the following patch applied (note the hash after diff -r, it is
the same as parent of the posted patch) seems to prove my guess: it indeed does
work. I don’t know where bugs may lie if you set curwin->w_buffer without all
the stuff aucmd_prepbuf does, but this approach may be preferred for
performance reasons. If we don’t need autocommands maybe using non-autocommand
version should be preferred:
/*
* Prepare for executing commands for (hidden) buffer "buf".
* This is the non-autocommand version, it simply saves "curbuf" and sets
* "curbuf" and "curwin" to match "buf".
*/
void
aucmd_prepbuf(aco, buf)
aco_save_T *aco; /* structure to save values in */
buf_T *buf; /* new curbuf */
{
aco->save_curbuf = curbuf;
--curbuf->b_nwindows;
curbuf = buf;
curwin->w_buffer = buf;
++curbuf->b_nwindows;
}
, but I have not checked how setting non-current buffer should interact with
TextChanged events. Currently I do not see TextChanged event in non-current
buffer (prepended `-c 'au TextChanged * :echom expand("<abuf>")'` to
command-line, got two lines with `1` on both; should be `1` then `2` I guess;
tested against both this and patch in previous message), probably this should
be fixed.
diff -r 5f8adb1d88b9 src/if_py_both.h
--- a/src/if_py_both.h Thu May 16 06:49:12 2013 +0400
+++ b/src/if_py_both.h Thu May 16 08:28:15 2013 +0400
@@ -2602,6 +2602,7 @@
PyErr_Clear();
curbuf = buf;
+ curwin->w_buffer = curbuf;
if (u_save((linenr_T)n, (linenr_T)(n+1)) == FAIL)
PyErr_SetVim(_("cannot save undo information"));
@@ -2612,6 +2613,7 @@
vim_free(str);
curbuf = savebuf;
+ curwin->w_buffer = savebuf;
update_screen(VALID);
if (PyErr_Occurred() || VimErrorCheck())
--
--
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.