On Sa, 26 Sep 2015, Bram Moolenaar wrote:
> Christian Brabandt wrote:
> 
> > Bram,
> > it has been mentioned, that the OptionSet autocommand is not triggered, 
> > for setwinvar() function calls. Reason is, the setwinvar() function 
> > calls switch_win() to switch to the window which will block 
> > autocommands. 
> > 
> > Therefore here is a patch, that unblocks the autocommands, if an 
> > optionset autocommand is defined and while I was there, I also made the 
> > swich_win() function only trigger, if it will actually needs to change 
> > windows or tabpages.
> > 
> > Attached is the patch, including a test.
> 
> I'm not sure it is such a good idea to trigger OptionSet when setting an
> option in another window.  It may have nasty side effects.

Yes true. Especially since this may be evaluated in the wrong 
buffer/window.

> Perhaps we should document how this works, and suggest using WinEnter to
> check option values when needed?

Like this?
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -5646,6 +5646,9 @@ settabwinvar({tabnr}, {winnr}, {varname}
                        :call settabwinvar(1, 1, "&list", 0)
                        :call settabwinvar(3, 2, "myvar", "foobar")
 <              This function is not available in the |sandbox|.
+
+               When setting options using |:let-&|, won't trigger the
+               |OptionSet| autocommand, to avoid nasty side effects.

 setwinvar({nr}, {varname}, {val})                      *setwinvar()*
                Like |settabwinvar()| for the current tab page.


> 
> > Another question has been raised. Sometimes options will get set 
> > directly (e.g. diffmode). Should those place converted to use the 
> > set_option_...() so that the autocommand is triggered? Currently, using 
> > :diffthis does not trigger the autocommand. If so, should it be 
> > triggered only for setting the diffmode or for every setting?
> 
> This whole code needs to be cleaned up.  We should consistently use the
> code that checks the new value and takes care of side-effects, no matter
> what command was used to set the option.  Except for the first
> initialization. 

Might be a good Google Summer of Code project?

> Also ":set all&" should work differently.

Why? Is anybody actually using this?

Best,
Christian
-- 
Wußten Sie schon...
... daß Taucher, die vor Wut kochen, deswegen noch lange  
keine Tauchsieder sind?

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

Raspunde prin e-mail lui