Hi Bram!

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.
> 
> I was thinking of still doing it for the current window, since
> ":let &option = val" is equivalent to ":set option=val".
> If someone doesn't want this prepend ":noau".

In that case the patch from Hirohito Higashi fixes it.

> > > 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?
> 
> If we ever find mentors...

If we ask early enough, I am sure we'll find some. I would volunteer.

Best,
Christian
-- 
Gewissen Geistern muss man ihre Idiotismen lassen.
                -- Goethe, Maximen und Reflektionen, Nr. 269

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