Thursday, February 26, 2015

Re: Capturing setting ro/noro



On Thu, Feb 26, 2015 at 12:17 PM, Salman Halim <salmanhalim@gmail.com> wrote:


On Feb 26, 2015 11:36 AM, "Tim Chase" <vim@tim.thechases.com> wrote:
>
> On 2015-02-26 12:01, Christian Brabandt wrote:
> > >> I had to dismiss a solution based on CursorHold as it isn't
> > >> immediate. Sadly there is no ReadonlyChanged event...
> > >
> > > Where in the sources would I start btw. if I wanted to implement
> > > a new event?
> >
> > I would rather add a new autocommand au Option or au OptionSet
>
> I second Christian's suggestion, making it more generic.  There are
> times I've wanted to catch changes in other settings (mostly for
> debugging purposes), and a broader OptionSet event with some variable
> containing the option name, the old value, and the new value.
>
> Though this would get particularly hairy for settings that impact
> other settings such as
>
>   :set cp
>
> which changes a whole bunch of other settings.  Does one just fire a
> single "OptionSet", or does one then cascade the firing of more
> "OptionSet" events for the ~48 settings it would impact?
>
> Then you also have "useless machine"[1] cases where the code fired on
> the event re-sets the option back to its previous state:
>
>   :autocmd OptionSet * if g:option_name=='expandtab'|set et|endif
>
> You'd also have issues of option names:  do you use the long or short
> form to identify them?
>
> It's a big ugly can of worms, and while I'd enjoy seeing the
> functionality come to Vim, I'd rather it be done "right".
>
> -tim
>

I think that a second event fires after 'cp' is changed, but without some indication that it's a secondary reaction or some such, people will go mad trying to find out how the option was triggered. I would consider such a thing to be a single operation and create one event and have the variable be a list of all options.

Maybe also indicate the old value in there?


Yes, if it is a list I would want to see:
1.  current value  
2.  previous value

Whether this event fires before or after the option is actually changed.

In that list it would nice to have what triggered the option setting.  Not sure how we would describe that, maybe the statement itself "set cp" or some enumeration of it.

David

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment