On Jul 18, 2015, at 0:40, Bram Moolenaar <[email protected]> wrote:

> 
> Patch 7.4.786
> Problem:    It is not possible for a plugin to adjust to a changed setting.
> Solution:   Add the OptionSet autocommand event. (Christian Brabandt)
> Files:      …
>            …src/testdir/Makefile,
>            src/testdir/test_autocmd_option.in,
>            src/testdir/test_autocmd_option.ok, …
> 
> 
<snip>
> *** ../vim-7.4.785/src/testdir/test_autocmd_option.in 2015-07-17 
> 17:13:44.769224683 +0200
> --- src/testdir/test_autocmd_option.in        2015-07-17 14:58:39.362642959 
> +0200
> ***************
> *** 0 ****
> --- 1,73 ----
> + Test for option autocommand
> + 
> + STARTTEST
> + :so small.vim
> + :if !has("eval") || !has("autocmd") | e! test.ok | w! test.out | qa! | endif
> + :fu! AutoCommand(match)
> + :   let c=g:testcase
> + :       let item=remove(g:options, 0)
> + :       let c.=printf("Expected: Name: <%s>, Oldval: <%s>, NewVal: <%s>, 
> Scope: <%s>\n", item[0], item[1], item[2], item[3])
> + :       let c.=printf("Autocmd Option: <%s>,", a:match)
> + :       let c.=printf(" OldVal: <%s>,", v:option_old)
> + :       let c.=printf(" NewVal: <%s>,", v:option_new)
> + :       let c.=printf(" Scope: <%s>\n", v:option_type)
> + :       call setreg('r', printf("%s\n%s", getreg('r'), c))
> + :endfu
> + :au OptionSet * :call AutoCommand(expand("<amatch>"))
> + :let g:testcase="1: Setting number option\n"
> + :let g:options=[['number', 0, 1, 'global']]
> + :set nu
> + :let g:testcase="2: Setting local number option\n"
> + :let g:options=[['number', 1, 0, 'local']]
> + :setlocal nonu
> + :let g:testcase="3: Setting global number option\n"
> + :let g:options=[['number', 1, 0, 'global']]
> + :setglobal nonu
> + :let g:testcase="4: Setting local autoindent option\n"
> + :let g:options=[['autoindent', 0, 1, 'local']]
> + :setlocal ai
> + :let g:testcase="5: Setting global autoindent option\n"
> + :let g:options=[['autoindent', 0, 1, 'global']]
> + :setglobal ai
> + :let g:testcase="6: Setting global autoindent option\n"
> + :let g:options=[['autoindent', 1, 0, 'global']]
> + :set ai!
> + : Should not print anything, use :noa
> + :noa :set nonu
> + :let g:testcase="7: Setting several global list and number option\n"
> + :let g:options=[['list', 0, 1, 'global'], ['number', 0, 1, 'global']]
> + :set list nu
> + :noa set nolist nonu
> + :let g:testcase="8: Setting global acd\n"
> + :let g:options=[['autochdir', 0, 1, 'global']]
> + :setlocal acd
> + :let g:testcase="9: Setting global autoread\n"
> + :let g:options=[['autoread', 0, 1, 'global']]
> + :set ar
> + :let g:testcase="10: Setting local autoread\n"
> + :let g:options=[['autoread', 0, 1, 'local']]
> + :setlocal ar
> + :let g:testcase="11: Setting global autoread\n"
> + :let g:options=[['autoread', 1, 0, 'global']]
> + :setglobal invar
> + :let g:testcase="12: Setting option backspace through :let\n"
> + :let g:options=[['backspace', '', 'eol,indent,start', 'global']]
> + :let &bs="eol,indent,start"
> + :let g:testcase="13: Setting option backspace through setbufvar()\n"
> + :let g:options=[['backup', '', '1', 'local']]
> + : "try twice, first time, shouldn't trigger because option name is invalid, 
> second time, it should trigger
> + :call setbufvar(1, '&l:bk', 1)
> + : "should trigger, use correct option name
> + :call setbufvar(1, '&backup', 1)
> + :" Write register now, because next test shouldn't output anything.
> + :$put r
> + :let @r=''
> + :let g:testcase="\n14: Setting key option, shouldn't trigger\n"
> + :let g:options=[['key', 'invalid', 'invalid1', 'invalid']]
> + :setlocal key=blah
> + :setlocal key=
> + :$put =g:testcase
> + :%w! test.out
> + :qa!
> + ENDTEST
> + dummy text
> *** ../vim-7.4.785/src/testdir/test_autocmd_option.ok 2015-07-17 
> 17:13:44.777224608 +0200
> --- src/testdir/test_autocmd_option.ok        2015-07-17 14:58:39.362642959 
> +0200
> ***************
> *** 0 ****
> --- 1,131 ----
> + Test for option autocommand
> + 
> + STARTTEST
> + :so small.vim
> + :if !has("eval") || !has("autocmd") | e! test.ok | w! test.out | qa! | endif
> + :fu! AutoCommand(match)
> + :   let c=g:testcase
> + :       let item=remove(g:options, 0)
> + :       let c.=printf("Expected: Name: <%s>, Oldval: <%s>, NewVal: <%s>, 
> Scope: <%s>\n", item[0], item[1], item[2], item[3])
> + :       let c.=printf("Autocmd Option: <%s>,", a:match)
> + :       let c.=printf(" OldVal: <%s>,", v:option_old)
> + :       let c.=printf(" NewVal: <%s>,", v:option_new)
> + :       let c.=printf(" Scope: <%s>\n", v:option_type)
> + :       call setreg('r', printf("%s\n%s", getreg('r'), c))
> + :endfu
> + :au OptionSet * :call AutoCommand(expand("<amatch>"))
> + :let g:testcase="1: Setting number option\n"
> + :let g:options=[['number', 0, 1, 'global']]
> + :set nu
> + :let g:testcase="2: Setting local number option\n"
> + :let g:options=[['number', 1, 0, 'local']]
> + :setlocal nonu
> + :let g:testcase="3: Setting global number option\n"
> + :let g:options=[['number', 1, 0, 'global']]
> + :setglobal nonu
> + :let g:testcase="4: Setting local autoindent option\n"
> + :let g:options=[['autoindent', 0, 1, 'local']]
> + :setlocal ai
> + :let g:testcase="5: Setting global autoindent option\n"
> + :let g:options=[['autoindent', 0, 1, 'global']]
> + :setglobal ai
> + :let g:testcase="6: Setting global autoindent option\n"
> + :let g:options=[['autoindent', 1, 0, 'global']]
> + :set ai!
> + : Should not print anything, use :noa
> + :noa :set nonu
> + :let g:testcase="7: Setting several global list and number option\n"
> + :let g:options=[['list', 0, 1, 'global'], ['number', 0, 1, 'global']]
> + :set list nu
> + :noa set nolist nonu
> + :let g:testcase="8: Setting global acd\n"
> + :let g:options=[['autochdir', 0, 1, 'global']]
> + :setlocal acd
> + :let g:testcase="9: Setting global autoread\n"
> + :let g:options=[['autoread', 0, 1, 'global']]
> + :set ar
> + :let g:testcase="10: Setting local autoread\n"
> + :let g:options=[['autoread', 0, 1, 'local']]
> + :setlocal ar
> + :let g:testcase="11: Setting global autoread\n"
> + :let g:options=[['autoread', 1, 0, 'global']]
> + :setglobal invar
> + :let g:testcase="12: Setting option backspace through :let\n"
> + :let g:options=[['backspace', '', 'eol,indent,start', 'global']]
> + :let &bs="eol,indent,start"
> + :let g:testcase="13: Setting option backspace through setbufvar()\n"
> + :let g:options=[['backup', '', '1', 'local']]
> + : "try twice, first time, shouldn't trigger because option name is invalid, 
> second time, it should trigger
> + :call setbufvar(1, '&l:bk', 1)
> + : "should trigger, use correct option name
> + :call setbufvar(1, '&backup', 1)
> + :" Write register now, because next test shouldn't output anything.
> + :$put r
> + :let @r=''
> + :let g:testcase="\n14: Setting key option, shouldn't trigger\n"
> + :let g:options=[['key', 'invalid', 'invalid1', 'invalid']]
> + :setlocal key=blah
> + :setlocal key=
> + :$put =g:testcase
> + :%w! test.out
> + :qa!
> + ENDTEST
> + dummy text
> + 
> + 1: Setting number option
> + Expected: Name: <number>, Oldval: <0>, NewVal: <1>, Scope: <global>
> + Autocmd Option: <number>, OldVal: <0>, NewVal: <1>, Scope: <global>
> + 
> + 2: Setting local number option
> + Expected: Name: <number>, Oldval: <1>, NewVal: <0>, Scope: <local>
> + Autocmd Option: <number>, OldVal: <1>, NewVal: <0>, Scope: <local>
> + 
> + 3: Setting global number option
> + Expected: Name: <number>, Oldval: <1>, NewVal: <0>, Scope: <global>
> + Autocmd Option: <number>, OldVal: <1>, NewVal: <0>, Scope: <global>
> + 
> + 4: Setting local autoindent option
> + Expected: Name: <autoindent>, Oldval: <0>, NewVal: <1>, Scope: <local>
> + Autocmd Option: <autoindent>, OldVal: <0>, NewVal: <1>, Scope: <local>
> + 
> + 5: Setting global autoindent option
> + Expected: Name: <autoindent>, Oldval: <0>, NewVal: <1>, Scope: <global>
> + Autocmd Option: <autoindent>, OldVal: <0>, NewVal: <1>, Scope: <global>
> + 
> + 6: Setting global autoindent option
> + Expected: Name: <autoindent>, Oldval: <1>, NewVal: <0>, Scope: <global>
> + Autocmd Option: <autoindent>, OldVal: <1>, NewVal: <0>, Scope: <global>
> + 
> + 7: Setting several global list and number option
> + Expected: Name: <list>, Oldval: <0>, NewVal: <1>, Scope: <global>
> + Autocmd Option: <list>, OldVal: <0>, NewVal: <1>, Scope: <global>
> + 
> + 7: Setting several global list and number option
> + Expected: Name: <number>, Oldval: <0>, NewVal: <1>, Scope: <global>
> + Autocmd Option: <number>, OldVal: <0>, NewVal: <1>, Scope: <global>
> + 
> + 8: Setting global acd
> + Expected: Name: <autochdir>, Oldval: <0>, NewVal: <1>, Scope: <global>
> + Autocmd Option: <autochdir>, OldVal: <0>, NewVal: <1>, Scope: <local>
> + 
> + 9: Setting global autoread
> + Expected: Name: <autoread>, Oldval: <0>, NewVal: <1>, Scope: <global>
> + Autocmd Option: <autoread>, OldVal: <0>, NewVal: <1>, Scope: <global>
> + 
> + 10: Setting local autoread
> + Expected: Name: <autoread>, Oldval: <0>, NewVal: <1>, Scope: <local>
> + Autocmd Option: <autoread>, OldVal: <1>, NewVal: <1>, Scope: <local>
> + 
> + 11: Setting global autoread
> + Expected: Name: <autoread>, Oldval: <1>, NewVal: <0>, Scope: <global>
> + Autocmd Option: <autoread>, OldVal: <1>, NewVal: <0>, Scope: <global>
> + 
> + 12: Setting option backspace through :let
> + Expected: Name: <backspace>, Oldval: <>, NewVal: <eol,indent,start>, Scope: 
> <global>
> + Autocmd Option: <backspace>, OldVal: <>, NewVal: <eol,indent,start>, Scope: 
> <global>
> + 
> + 13: Setting option backspace through setbufvar()
> + Expected: Name: <backup>, Oldval: <>, NewVal: <1>, Scope: <local>
> + Autocmd Option: <backup>, OldVal: <0>, NewVal: <1>, Scope: <local>
> + 
> + 14: Setting key option, shouldn't trigger

Hi,

Test 8 of test_autocmd_option fails when vim is built with FEAT_AUTOCHDIR 
undefined (src/feature.h:1334).

As can be seen from the header, such a case is quite possible; in particular, 
passing —disable-netbeans to the configure script is highly likely to cause the 
failure.  Actually, that was just my case ;-)

Attached is a patch to fix it.

The general idea is quite simple: Skip test 8 when exists(“+autochdir”) returns 
false.

More specifically,

- Let test_autocmd_option.in rewrite test.ok automatically in such a way that 
test 8 is thrown away from the whole test if exists(“+autochdir”) returns false.

- Modify test_autocmd_option.in to suppress the output of test 8, accordingly.

- Slightly modify Makefile to use a diff between test.out and test.ok, instead 
of test.out and $*.ok.  (This modification looks consistent with the comment at 
line 126, doesn’t it?)

As I wrote previously, I’m not an export of vim tests.  So, I’m quite open to 
any better solutions.

Best regards,
Kazunobu Kuriyama

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

Attachment: test_autocmd_option.patch
Description: Binary data

Raspunde prin e-mail lui