ZyX wrote:

> > 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.

This comes up once in a while.  Just changing "curwin" and/or "curbuf"
causes problems for some code.  It's very hard to predict what code will
be executed.  E.g., setting an option may cause window sizes to be
recomputed.

Let me take the existing switch_win() function and add switch_buf().
And disable autocommands in this state, that whould avoid a lot of
trouble.


-- 
My girlfriend told me I should be more affectionate.
So I got TWO girlfriends.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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.


Raspunde prin e-mail lui