Gary Johnson wrote:

> > > I discovered that the outputs were correct up to a point, then the
> > > values of v:option_old and v:option_new became empty.  That occurred
> > > after the following autocommand.
> > > 
> > >     autocmd OptionSet diff if &diff && !exists("g:ve") | let g:ve = &ve | 
> > > set ve=all | endif
> > > 
> > > I don't know what's going on, but something in that autocommand
> > > causes v:option_old and v:option_new to be cleared.
> > 
> > It's the ":set ve=all" command, it tries triggering OptionSet again,
> > which probably doesn't do anything because of nesting, but it does clear
> > the v:option_new and v:option_old variables.
> > 
> > Perhaps we can do this:
> > 
> > --- git/vim81/src/option.c  2018-09-13 20:31:47.111018149 +0200
> > +++ option.c        2018-09-19 23:18:45.761370196 +0200
> ...
> 
> After applying that patch, the OptionSet event doesn't appear to be
> triggered at all.  I executed the following:
> 
>     :autocmd OptionSet diff echo "OptionSet diff" v:option_old v:option_new
>     :autocmd OptionSet * echo "OptionSet any" v:option_old v:option_new
>     :autocmd OptionSet * echom "OptionSet any" v:option_old v:option_new
> 
> and tried setting and unsetting 'diff' and 'number' and never saw
> a message.

This should work better:

--- git/vim81/src/option.c      2018-09-13 20:31:47.111018149 +0200
+++ option.c    2018-09-20 21:26:55.954190027 +0200
@@ -4359,7 +4359,9 @@
        char_u *oldval,
        char_u *newval)
 {
-    if (oldval != NULL && newval != NULL)
+    // Don't do this recursively.
+    if (oldval != NULL && newval != NULL
+                                   && *get_vim_var_str(VV_OPTION_TYPE) == NUL)
     {
        char_u buf_type[7];
 
@@ -8858,9 +8860,11 @@
     options[opt_idx].flags |= P_WAS_SET;
 
 #if defined(FEAT_EVAL)
-    if (!starting)
+    // Don't do this while starting up or recursively.
+    if (!starting && *get_vim_var_str(VV_OPTION_TYPE) == NUL)
     {
        char_u buf_old[2], buf_new[2], buf_type[7];
+
        vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
        vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
        vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? 
"local" : "global");
@@ -9415,7 +9419,8 @@
     options[opt_idx].flags |= P_WAS_SET;
 
 #if defined(FEAT_EVAL)
-    if (!starting && errmsg == NULL)
+    // Don't do this while starting up, failure or recursively.
+    if (!starting && errmsg == NULL && *get_vim_var_str(VV_OPTION_TYPE) == NUL)
     {
        char_u buf_old[11], buf_new[11], buf_type[7];
        vim_snprintf((char *)buf_old, 10, "%ld", old_value);

-- 
>From "know your smileys":
 *<|:-) Santa Claus (Ho Ho Ho)

 /// 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/d/optout.

Raspunde prin e-mail lui