{"action":"created","comment":{"url":"https://api.github.com/repos/neovim/neovim/pulls/comments/46081046","id":46081046,"diff_hunk":"@@ -2350,10 +2373,30 @@ set_string_option (\n       : opt_flags);\n   oldval = *varp;\n   *varp = s;\n+\n+  if (!starting) {\n+    saved_oldval = vim_strsave(oldval);\n+  }\n+\n   if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,\n           opt_flags)) == NULL)\n     did_set_option(opt_idx, opt_flags, TRUE);\n \n+  // call autocommand after handling side effects\n+  if (saved_oldval != NULL) {\n+    char_u buf_type[7];","path":"src/nvim/option.c","position":71,"original_position":71,"commit_id":"8c00c34b91b44115275dc8d1c10bab95ae62a7a9","original_commit_id":"8c00c34b91b44115275dc8d1c10bab95ae62a7a9","user":{"login":"ZyX-I","id":322097,"avatar_url":"https://avatars.githubusercontent.com/u/322097?v=3","gravatar_id":"","url":"https://api.github.com/users/ZyX-I","html_url":"https://github.com/ZyX-I","followers_url":"https://api.github.com/users/ZyX-I/followers","following_url":"https://api.github.com/users/ZyX-I/following{/other_user}","gists_url":"https://api.github.com/users/ZyX-I/gists{/gist_id}","starred_url":"https://api.github.com/users/ZyX-I/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZyX-I/subscriptions","organizations_url":"https://api.github.com/users/ZyX-I/orgs","repos_url":"https://api.github.com/users/ZyX-I/repos","events_url":"https://api.github.com/users/ZyX-I/events{/privacy}","received_events_url":"https://api.github.com/users/ZyX-I/received_events","type":"User","site_admin":false},"body":"`char`","created_at":"2015-11-28T15:49:56Z","updated_at":"2015-11-28T15:49:56Z","html_url":"https://github.com/neovim/neovim/pull/3753#discussion_r46081046","pull_request_url":"https://api.github.com/repos/neovim/neovim/pulls/3753","_links":{"self":{"href":"https://api.github.com/repos/neovim/neovim/pulls/comments/46081046"},"html":{"href":"https://github.com/neovim/neovim/pull/3753#discussion_r46081046"},"pull_request":{"href":"https://api.github.com/repos/neovim/neovim/pulls/3753"}}},"pull_request":{"url":"https://api.github.com/repos/neovim/neovim/pulls/3753","id":52036015,"html_url":"https://github.com/neovim/neovim/pull/3753","diff_url":"https://github.com/neovim/neovim/pull/3753.diff","patch_url":"https://github.com/neovim/neovim/pull/3753.patch","issue_url":"https://api.github.com/repos/neovim/neovim/issues/3753","number":3753,"state":"open","locked":false,"title":"Vim 7.4.{786,787,789,790}","user":{"login":"watiko","id":199728,"avatar_url":"https://avatars.githubusercontent.com/u/199728?v=3","gravatar_id":"","url":"https://api.github.com/users/watiko","html_url":"https://github.com/watiko","followers_url":"https://api.github.com/users/watiko/followers","following_url":"https://api.github.com/users/watiko/following{/other_user}","gists_url":"https://api.github.com/users/watiko/gists{/gist_id}","starred_url":"https://api.github.com/users/watiko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/watiko/subscriptions","organizations_url":"https://api.github.com/users/watiko/orgs","repos_url":"https://api.github.com/users/watiko/repos","events_url":"https://api.github.com/users/watiko/events{/privacy}","received_events_url":"https://api.github.com/users/watiko/received_events","type":"User","site_admin":false},"body":"```\r\nProblem:    It is not possible for a plugin to adjust to a changed setting.\r\nSolution:   Add the OptionSet autocommand event. (Christian Brabandt)\r\n```\r\n\r\nhttps://github.com/vim/vim/commit/537443018d41918639695a442c91b34ccec69fc3\r\n\r\nOriginal patch:\r\n\r\n```diff\r\ncommit 537443018d41918639695a442c91b34ccec69fc3\r\nAuthor: Bram Moolenaar <Bram@vim.org>\r\nDate:   Fri Jul 17 17:38:22 2015 +0200\r\n\r\n    patch 7.4.786\r\n    Problem:    It is not possible for a plugin to adjust to a changed setting.\r\n    Solution:   Add the OptionSet autocommand event. (Christian Brabandt)\r\n\r\ndiff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt\r\nindex 8a968b9..20523ea 100644\r\n--- a/runtime/doc/autocmd.txt\r\n+++ b/runtime/doc/autocmd.txt\r\n@@ -259,6 +259,7 @@ Name\t\t\ttriggered by ~\r\n |Syntax|\t\twhen the 'syntax' option has been set\r\n |EncodingChanged|\tafter the 'encoding' option has been changed\r\n |TermChanged|\t\tafter the value of 'term' has changed\r\n+|OptionSet|\t\tafter setting any option\r\n \r\n \tStartup and exit\r\n |VimEnter|\t\tafter doing all the startup stuff\r\n@@ -744,6 +745,27 @@ MenuPopup\t\t\tJust before showing the popup menu (under the\r\n \t\t\t\t\to\tOperator-pending\r\n \t\t\t\t\ti\tInsert\r\n \t\t\t\t\tc\tCommand line\r\n+\t\t\t\t\t\t\t*OptionSet*\r\n+OptionSet\t\t\tAfter setting an option.  The pattern is\r\n+\t\t\t\tmatched against the long option name.\r\n+\t\t\t\tThe |v:option_old| variable indicates the\r\n+\t\t\t\told option value, |v:option_new| variable\r\n+\t\t\t\tindicates the newly set value, the\r\n+\t\t\t\t|v:option_type| variable indicates whether\r\n+\t\t\t\tit's global or local scoped and |<amatch>|\r\n+\t\t\t\tindicates what option has been set.\r\n+\r\n+\t\t\t\tIs not triggered on startup and for the 'key'\r\n+\t\t\t\toption for obvious reasons.\r\n+\r\n+\t\t\t\tNote: It's a bad idea, to reset an option\r\n+\t\t\t\tduring this autocommand, since this will\r\n+\t\t\t\tprobably break plugins. You can always use\r\n+\t\t\t\t|noa| to prevent triggering this autocommand.\r\n+\t\t\t\tCould be used, to check for existence of the\r\n+\t\t\t\t'backupdir' and 'undodir' options and create\r\n+\t\t\t\tdirectories, if they don't exist yet.\r\n+\r\n \t\t\t\t\t\t\t*QuickFixCmdPre*\r\n QuickFixCmdPre\t\t\tBefore a quickfix command is run (|:make|,\r\n \t\t\t\t|:lmake|, |:grep|, |:lgrep|, |:grepadd|,\r\ndiff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt\r\nindex b24a2a3..1a9e4f3 100644\r\n--- a/runtime/doc/eval.txt\r\n+++ b/runtime/doc/eval.txt\r\n@@ -1535,6 +1535,15 @@ v:oldfiles\tList of file names that is loaded from the |viminfo| file on\r\n \t\tthan String this will cause trouble.\r\n \t\t{only when compiled with the |+viminfo| feature}\r\n \r\n+\t\t\t\t\t\t    *v:option_new*\r\n+v:option_new    New value of the option. Valid while executing an |OptionSet|\r\n+\t\tautocommand.\r\n+\t\t\t\t\t\t    *v:option_old*\r\n+v:option_old    Old value of the option. Valid while executing an |OptionSet|\r\n+\t\tautocommand.\r\n+\t\t\t\t\t\t    *v:option_type*\r\n+v:option_type   Scope of the set command. Valid while executing an\r\n+\t\t|OptionSet| autocommand. Can be either \"global\" or \"local\"\r\n \t\t\t\t\t*v:operator* *operator-variable*\r\n v:operator\tThe last operator given in Normal mode.  This is a single\r\n \t\tcharacter except for commands starting with <g> or <z>,\r\ndiff --git a/src/nvim/eval.c b/src/nvim/eval.c\r\nindex f163829..6a844e4 100644\r\n--- a/src/nvim/eval.c\r\n+++ b/src/nvim/eval.c\r\n@@ -365,6 +365,9 @@ static struct vimvar\r\n     {VV_NAME(\"windowid\",\t VAR_NUMBER), VV_RO},\r\n     {VV_NAME(\"progpath\",\t VAR_STRING), VV_RO},\r\n     {VV_NAME(\"completed_item\",\t VAR_DICT), VV_RO},\r\n+    {VV_NAME(\"option_new\",\t VAR_STRING), VV_RO},\r\n+    {VV_NAME(\"option_old\",\t VAR_STRING), VV_RO},\r\n+    {VV_NAME(\"option_type\",\t VAR_STRING), VV_RO},\r\n };\r\n \r\n /* shorthand */\r\n@@ -24720,6 +24723,16 @@ ex_oldfiles(eap)\r\n     }\r\n }\r\n \r\n+/* reset v:option_new, v:option_old and v:option_type */\r\n+    void\r\n+reset_v_option_vars()\r\n+{\r\n+    set_vim_var_string(VV_OPTION_NEW,  NULL, -1);\r\n+    set_vim_var_string(VV_OPTION_OLD,  NULL, -1);\r\n+    set_vim_var_string(VV_OPTION_TYPE, NULL, -1);\r\n+}\r\n+\r\n+\r\n #endif /* FEAT_EVAL */\r\n \r\n \r\ndiff --git a/src/nvim/fileio.c b/src/nvim/fileio.c\r\nindex fb14dbf..17b73bf 100644\r\n--- a/src/nvim/fileio.c\r\n+++ b/src/nvim/fileio.c\r\n@@ -7699,6 +7699,7 @@ static struct event_name\r\n     {\"InsertLeave\",\tEVENT_INSERTLEAVE},\r\n     {\"InsertCharPre\",\tEVENT_INSERTCHARPRE},\r\n     {\"MenuPopup\",\tEVENT_MENUPOPUP},\r\n+    {\"OptionSet\",\tEVENT_OPTIONSET},\r\n     {\"QuickFixCmdPost\",\tEVENT_QUICKFIXCMDPOST},\r\n     {\"QuickFixCmdPre\",\tEVENT_QUICKFIXCMDPRE},\r\n     {\"QuitPre\",\t\tEVENT_QUITPRE},\r\n@@ -7736,7 +7737,7 @@ static AutoPat *first_autopat[NUM_EVENTS] =\r\n     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\r\n     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\r\n     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\r\n-    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL\r\n+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL\r\n };\r\n \r\n /*\r\n@@ -9321,7 +9322,7 @@ apply_autocmds_group(event, fname, fname_io, force, group, buf, eap)\r\n      */\r\n     if (fname_io == NULL)\r\n     {\r\n-\tif (event == EVENT_COLORSCHEME)\r\n+\tif (event == EVENT_COLORSCHEME || event == EVENT_OPTIONSET)\r\n \t    autocmd_fname = NULL;\r\n \telse if (fname != NULL && *fname != NUL)\r\n \t    autocmd_fname = fname;\r\n@@ -9385,6 +9386,7 @@ apply_autocmds_group(event, fname, fname_io, force, group, buf, eap)\r\n \t\t|| event == EVENT_SPELLFILEMISSING\r\n \t\t|| event == EVENT_QUICKFIXCMDPRE\r\n \t\t|| event == EVENT_COLORSCHEME\r\n+\t\t|| event == EVENT_OPTIONSET\r\n \t\t|| event == EVENT_QUICKFIXCMDPOST)\r\n \t    fname = vim_strsave(fname);\r\n \telse\r\ndiff --git a/src/nvim/option.c b/src/nvim/option.c\r\nindex 40dcc8d..c51d082 100644\r\n--- a/src/nvim/option.c\r\n+++ b/src/nvim/option.c\r\n@@ -4592,9 +4592,12 @@ do_set(arg, opt_flags)\r\n \t\t    {\r\n \t\t\tchar_u\t    *save_arg = NULL;\r\n \t\t\tchar_u\t    *s = NULL;\r\n-\t\t\tchar_u\t    *oldval;\t/* previous value if *varp */\r\n+\t\t\tchar_u\t    *oldval = NULL;\t/* previous value if *varp */\r\n \t\t\tchar_u\t    *newval;\r\n-\t\t\tchar_u\t    *origval;\r\n+\t\t\tchar_u\t    *origval = NULL;\r\n+#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)\r\n+\t\t\tchar_u\t    *saved_origval = NULL;\r\n+#endif\r\n \t\t\tunsigned    newlen;\r\n \t\t\tint\t    comma;\r\n \t\t\tint\t    bs;\r\n@@ -4914,6 +4917,14 @@ do_set(arg, opt_flags)\r\n \t\t\t/* Set the new value. */\r\n \t\t\t*(char_u **)(varp) = newval;\r\n \r\n+#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)\r\n+\t\t\tif (!starting && options[opt_idx].indir != PV_KEY\r\n+\t\t\t\t\t\t\t   && origval != NULL)\r\n+\t\t\t    /* origval may be freed by\r\n+\t\t\t     * did_set_string_option(), make a copy. */\r\n+\t\t\t    saved_origval = vim_strsave(origval);\r\n+#endif\r\n+\r\n \t\t\t/* Handle side effects, and set the global value for\r\n \t\t\t * \":set\" on local options. */\r\n \t\t\terrmsg = did_set_string_option(opt_idx, (char_u **)varp,\r\n@@ -4922,6 +4933,24 @@ do_set(arg, opt_flags)\r\n \t\t\t/* If error detected, print the error message. */\r\n \t\t\tif (errmsg != NULL)\r\n \t\t\t    goto skip;\r\n+#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)\r\n+\t\t\tif (saved_origval != NULL)\r\n+\t\t\t{\r\n+\t\t\t    char_u buf_type[7];\r\n+\r\n+\t\t\t    sprintf((char *)buf_type, \"%s\",\r\n+\t\t\t\t(opt_flags & OPT_LOCAL) ? \"local\" : \"global\");\r\n+\t\t\t    set_vim_var_string(VV_OPTION_NEW, newval, -1);\r\n+\t\t\t    set_vim_var_string(VV_OPTION_OLD, saved_origval, -1);\r\n+\t\t\t    set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);\r\n+\t\t\t    apply_autocmds(EVENT_OPTIONSET,\r\n+\t\t\t\t\t  (char_u *)options[opt_idx].fullname,\r\n+\t\t\t\tNULL, FALSE, NULL);\r\n+\t\t\t    reset_v_option_vars();\r\n+\t\t\t    vim_free(saved_origval);\r\n+\t\t\t}\r\n+#endif\r\n+\r\n \t\t    }\r\n \t\t    else\t    /* key code option */\r\n \t\t    {\r\n@@ -5668,6 +5697,9 @@ set_string_option(opt_idx, value, opt_flags)\r\n     char_u\t*s;\r\n     char_u\t**varp;\r\n     char_u\t*oldval;\r\n+#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)\r\n+    char_u\t*saved_oldval = NULL;\r\n+#endif\r\n     char_u\t*r = NULL;\r\n \r\n     if (options[opt_idx].var == NULL)\t/* don't set hidden option */\r\n@@ -5683,9 +5715,30 @@ set_string_option(opt_idx, value, opt_flags)\r\n \t\t    : opt_flags);\r\n \toldval = *varp;\r\n \t*varp = s;\r\n+\r\n+#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)\r\n+\tif (!starting && options[opt_idx].indir != PV_KEY)\r\n+\t    saved_oldval = vim_strsave(oldval);\r\n+#endif\r\n \tif ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,\r\n \t\t\t\t\t\t\t   opt_flags)) == NULL)\r\n \t    did_set_option(opt_idx, opt_flags, TRUE);\r\n+\r\n+\t/* call autocomamnd after handling side effects */\r\n+#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)\r\n+\tif (saved_oldval != NULL)\r\n+\t{\r\n+\t    char_u buf_type[7];\r\n+\t    sprintf((char *)buf_type, \"%s\",\r\n+\t\t(opt_flags & OPT_LOCAL) ? \"local\" : \"global\");\r\n+\t    set_vim_var_string(VV_OPTION_NEW, s, -1);\r\n+\t    set_vim_var_string(VV_OPTION_OLD, oldval, -1);\r\n+\t    set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);\r\n+\t    apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);\r\n+\t    reset_v_option_vars();\r\n+\t    vim_free(saved_oldval);\r\n+\t}\r\n+#endif\r\n     }\r\n     return r;\r\n }\r\n@@ -8230,8 +8283,25 @@ set_bool_option(opt_idx, varp, value, opt_flags)\r\n      * End of handling side effects for bool options.\r\n      */\r\n \r\n+    /* after handling side effects, call autocommand */\r\n+\r\n     options[opt_idx].flags |= P_WAS_SET;\r\n \r\n+#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)\r\n+    if (!starting)\r\n+    {\r\n+\tchar_u buf_old[2], buf_new[2], buf_type[7];\r\n+\tsnprintf((char *)buf_old, 2, \"%d\", old_value ? TRUE: FALSE);\r\n+\tsnprintf((char *)buf_new, 2, \"%d\", value ? TRUE: FALSE);\r\n+\tsprintf((char *)buf_type, \"%s\", (opt_flags & OPT_LOCAL) ? \"local\" : \"global\");\r\n+\tset_vim_var_string(VV_OPTION_NEW, buf_new, -1);\r\n+\tset_vim_var_string(VV_OPTION_OLD, buf_old, -1);\r\n+\tset_vim_var_string(VV_OPTION_TYPE, buf_type, -1);\r\n+\tapply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);\r\n+\treset_v_option_vars();\r\n+    }\r\n+#endif\r\n+\r\n     comp_col();\t\t\t    /* in case 'ruler' or 'showcmd' changed */\r\n     if (curwin->w_curswant != MAXCOL\r\n \t\t     && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)\r\n@@ -8767,6 +8837,21 @@ set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)\r\n \r\n     options[opt_idx].flags |= P_WAS_SET;\r\n \r\n+#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)\r\n+    if (!starting && errmsg == NULL)\r\n+    {\r\n+\tchar_u buf_old[11], buf_new[11], buf_type[7];\r\n+\tsnprintf((char *)buf_old, 10, \"%ld\", old_value);\r\n+\tsnprintf((char *)buf_new, 10, \"%ld\", value);\r\n+\tsnprintf((char *)buf_type, 7, \"%s\", (opt_flags & OPT_LOCAL) ? \"local\" : \"global\");\r\n+\tset_vim_var_string(VV_OPTION_NEW, buf_new, -1);\r\n+\tset_vim_var_string(VV_OPTION_OLD, buf_old, -1);\r\n+\tset_vim_var_string(VV_OPTION_TYPE, buf_type, -1);\r\n+\tapply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);\r\n+\treset_v_option_vars();\r\n+    }\r\n+#endif\r\n+\r\n     comp_col();\t\t\t    /* in case 'columns' or 'ls' changed */\r\n     if (curwin->w_curswant != MAXCOL\r\n \t\t     && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)\r\ndiff --git a/src/nvim/proto/eval.pro b/src/nvim/proto/eval.pro\r\nindex 22b8b18..b807baf 100644\r\n--- a/src/nvim/proto/eval.pro\r\n+++ b/src/nvim/proto/eval.pro\r\n@@ -133,6 +133,7 @@ void write_viminfo_varlist __ARGS((FILE *fp));\r\n int store_session_globals __ARGS((FILE *fd));\r\n void last_set_msg __ARGS((scid_T scriptID));\r\n void ex_oldfiles __ARGS((exarg_T *eap));\r\n+void reset_v_option_vars __ARGS((void));\r\n int modify_fname __ARGS((char_u *src, int *usedlen, char_u **fnamep, char_u **bufp, int *fnamelen));\r\n char_u *do_string_sub __ARGS((char_u *str, char_u *pat, char_u *sub, char_u *flags));\r\n /* vim: set ft=c : */\r\ndiff --git a/src/nvim/testdir/Make_amiga.mak b/src/nvim/testdir/Make_amiga.mak\r\nindex da47989..5128087 100644\r\n--- a/src/nvim/testdir/Make_amiga.mak\r\n+++ b/src/nvim/testdir/Make_amiga.mak\r\n@@ -38,6 +38,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \\\r\n \t\ttest104.out test105.out test106.out test107.out \\\r\n \t\ttest_argument_0count.out \\\r\n \t\ttest_argument_count.out \\\r\n+\t\ttest_autocmd_option.out \\\r\n \t\ttest_autoformat_join.out \\\r\n \t\ttest_breakindent.out \\\r\n \t\ttest_changelist.out \\\r\n@@ -188,6 +189,7 @@ test106.out: test106.in\r\n test107.out: test107.in\r\n test_argument_0count.out: test_argument_0count.in\r\n test_argument_count.out: test_argument_count.in\r\n+test_autocmd_option.out: test_autocmd_option.in\r\n test_autoformat_join.out: test_autoformat_join.in\r\n test_breakindent.out: test_breakindent.in\r\n test_changelist.out: test_changelist.in\r\ndiff --git a/src/nvim/testdir/Make_dos.mak b/src/nvim/testdir/Make_dos.mak\r\nindex 6bb0577..8c0169b 100644\r\n--- a/src/nvim/testdir/Make_dos.mak\r\n+++ b/src/nvim/testdir/Make_dos.mak\r\n@@ -37,6 +37,7 @@ SCRIPTS =\ttest3.out test4.out test5.out test6.out test7.out \\\r\n \t\ttest105.out test106.out  test107.out\\\r\n \t\ttest_argument_0count.out \\\r\n \t\ttest_argument_count.out \\\r\n+\t\ttest_autocmd_option.out \\\r\n \t\ttest_autoformat_join.out \\\r\n \t\ttest_breakindent.out \\\r\n \t\ttest_changelist.out \\\r\ndiff --git a/src/nvim/testdir/Make_ming.mak b/src/nvim/testdir/Make_ming.mak\r\nindex faa2294..2f00124 100644\r\n--- a/src/nvim/testdir/Make_ming.mak\r\n+++ b/src/nvim/testdir/Make_ming.mak\r\n@@ -59,6 +59,7 @@ SCRIPTS =\ttest3.out test4.out test5.out test6.out test7.out \\\r\n \t\ttest105.out test106.out test107.out \\\r\n \t\ttest_argument_0count.out \\\r\n \t\ttest_argument_count.out \\\r\n+\t\ttest_autocmd_option.out \\\r\n \t\ttest_autoformat_join.out \\\r\n \t\ttest_breakindent.out \\\r\n \t\ttest_changelist.out \\\r\ndiff --git a/src/nvim/testdir/Make_os2.mak b/src/nvim/testdir/Make_os2.mak\r\nindex b93408c..7277556 100644\r\n--- a/src/nvim/testdir/Make_os2.mak\r\n+++ b/src/nvim/testdir/Make_os2.mak\r\n@@ -39,6 +39,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \\\r\n \t\ttest105.out test106.out test107.out \\\r\n \t\ttest_argument_0count.out \\\r\n \t\ttest_argument_count.out \\\r\n+\t\ttest_autocmd_option.out \\\r\n \t\ttest_autoformat_join.out \\\r\n \t\ttest_breakindent.out \\\r\n \t\ttest_changelist.out \\\r\ndiff --git a/src/nvim/testdir/Make_vms.mms b/src/nvim/testdir/Make_vms.mms\r\nindex 1c6a56d..726c233 100644\r\n--- a/src/nvim/testdir/Make_vms.mms\r\n+++ b/src/nvim/testdir/Make_vms.mms\r\n@@ -98,6 +98,7 @@ SCRIPT = test1.out  test2.out  test3.out  test4.out  test5.out  \\\r\n \t test105.out test106.out test107.out \\\r\n \t test_argument_0count.out \\\r\n \t test_argument_count.out \\\r\n+\t test_autocmd_option.out \\\r\n \t test_autoformat_join.out \\\r\n \t test_breakindent.out \\\r\n \t test_changelist.out \\\r\ndiff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile\r\nindex 1a3ff85..4d5aea7 100644\r\n--- a/src/nvim/testdir/Makefile\r\n+++ b/src/nvim/testdir/Makefile\r\n@@ -35,6 +35,7 @@ SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \\\r\n \t\ttest104.out test105.out test106.out test107.out \\\r\n \t\ttest_argument_0count.out \\\r\n \t\ttest_argument_count.out \\\r\n+\t\ttest_autocmd_option.out \\\r\n \t\ttest_autoformat_join.out \\\r\n \t\ttest_breakindent.out \\\r\n \t\ttest_changelist.out \\\r\ndiff --git a/src/nvim/testdir/test_autocmd_option.in b/src/nvim/testdir/test_autocmd_option.in\r\nnew file mode 100644\r\nindex 0000000..4d71c50\r\n--- /dev/null\r\n+++ b/src/nvim/testdir/test_autocmd_option.in\r\n@@ -0,0 +1,73 @@\r\n+Test for option autocommand\r\n+\r\n+STARTTEST\r\n+:so small.vim\r\n+:if !has(\"eval\") || !has(\"autocmd\") | e! test.ok | w! test.out | qa! | endif\r\n+:fu! AutoCommand(match)\r\n+:\tlet c=g:testcase\r\n+:       let item=remove(g:options, 0)\r\n+:       let c.=printf(\"Expected: Name: <%s>, Oldval: <%s>, NewVal: <%s>, Scope: <%s>\\n\", item[0], item[1], item[2], item[3])\r\n+:       let c.=printf(\"Autocmd Option: <%s>,\", a:match)\r\n+:       let c.=printf(\" OldVal: <%s>,\", v:option_old)\r\n+:       let c.=printf(\" NewVal: <%s>,\", v:option_new)\r\n+:       let c.=printf(\" Scope: <%s>\\n\", v:option_type)\r\n+:       call setreg('r', printf(\"%s\\n%s\", getreg('r'), c))\r\n+:endfu\r\n+:au OptionSet * :call AutoCommand(expand(\"<amatch>\"))\r\n+:let g:testcase=\"1: Setting number option\\n\"\r\n+:let g:options=[['number', 0, 1, 'global']]\r\n+:set nu\r\n+:let g:testcase=\"2: Setting local number option\\n\"\r\n+:let g:options=[['number', 1, 0, 'local']]\r\n+:setlocal nonu\r\n+:let g:testcase=\"3: Setting global number option\\n\"\r\n+:let g:options=[['number', 1, 0, 'global']]\r\n+:setglobal nonu\r\n+:let g:testcase=\"4: Setting local autoindent option\\n\"\r\n+:let g:options=[['autoindent', 0, 1, 'local']]\r\n+:setlocal ai\r\n+:let g:testcase=\"5: Setting global autoindent option\\n\"\r\n+:let g:options=[['autoindent', 0, 1, 'global']]\r\n+:setglobal ai\r\n+:let g:testcase=\"6: Setting global autoindent option\\n\"\r\n+:let g:options=[['autoindent', 1, 0, 'global']]\r\n+:set ai!\r\n+: Should not print anything, use :noa\r\n+:noa :set nonu\r\n+:let g:testcase=\"7: Setting several global list and number option\\n\"\r\n+:let g:options=[['list', 0, 1, 'global'], ['number', 0, 1, 'global']]\r\n+:set list nu\r\n+:noa set nolist nonu\r\n+:let g:testcase=\"8: Setting global acd\\n\"\r\n+:let g:options=[['autochdir', 0, 1, 'global']]\r\n+:setlocal acd\r\n+:let g:testcase=\"9: Setting global autoread\\n\"\r\n+:let g:options=[['autoread', 0, 1, 'global']]\r\n+:set ar\r\n+:let g:testcase=\"10: Setting local autoread\\n\"\r\n+:let g:options=[['autoread', 0, 1, 'local']]\r\n+:setlocal ar\r\n+:let g:testcase=\"11: Setting global autoread\\n\"\r\n+:let g:options=[['autoread', 1, 0, 'global']]\r\n+:setglobal invar\r\n+:let g:testcase=\"12: Setting option backspace through :let\\n\"\r\n+:let g:options=[['backspace', '', 'eol,indent,start', 'global']]\r\n+:let &bs=\"eol,indent,start\"\r\n+:let g:testcase=\"13: Setting option backspace through setbufvar()\\n\"\r\n+:let g:options=[['backup', '', '1', 'local']]\r\n+: \"try twice, first time, shouldn't trigger because option name is invalid, second time, it should trigger\r\n+:call setbufvar(1, '&l:bk', 1)\r\n+: \"should trigger, use correct option name\r\n+:call setbufvar(1, '&backup', 1)\r\n+:\" Write register now, because next test shouldn't output anything.\r\n+:$put r\r\n+:let @r=''\r\n+:let g:testcase=\"\\n14: Setting key option, shouldn't trigger\\n\"\r\n+:let g:options=[['key', 'invalid', 'invalid1', 'invalid']]\r\n+:setlocal key=blah\r\n+:setlocal key=\r\n+:$put =g:testcase\r\n+:%w! test.out\r\n+:qa!\r\n+ENDTEST\r\n+dummy text\r\ndiff --git a/src/nvim/testdir/test_autocmd_option.ok b/src/nvim/testdir/test_autocmd_option.ok\r\nnew file mode 100644\r\nindex 0000000..b66b8f6\r\n--- /dev/null\r\n+++ b/src/nvim/testdir/test_autocmd_option.ok\r\n@@ -0,0 +1,131 @@\r\n+Test for option autocommand\r\n+\r\n+STARTTEST\r\n+:so small.vim\r\n+:if !has(\"eval\") || !has(\"autocmd\") | e! test.ok | w! test.out | qa! | endif\r\n+:fu! AutoCommand(match)\r\n+:\tlet c=g:testcase\r\n+:       let item=remove(g:options, 0)\r\n+:       let c.=printf(\"Expected: Name: <%s>, Oldval: <%s>, NewVal: <%s>, Scope: <%s>\\n\", item[0], item[1], item[2], item[3])\r\n+:       let c.=printf(\"Autocmd Option: <%s>,\", a:match)\r\n+:       let c.=printf(\" OldVal: <%s>,\", v:option_old)\r\n+:       let c.=printf(\" NewVal: <%s>,\", v:option_new)\r\n+:       let c.=printf(\" Scope: <%s>\\n\", v:option_type)\r\n+:       call setreg('r', printf(\"%s\\n%s\", getreg('r'), c))\r\n+:endfu\r\n+:au OptionSet * :call AutoCommand(expand(\"<amatch>\"))\r\n+:let g:testcase=\"1: Setting number option\\n\"\r\n+:let g:options=[['number', 0, 1, 'global']]\r\n+:set nu\r\n+:let g:testcase=\"2: Setting local number option\\n\"\r\n+:let g:options=[['number', 1, 0, 'local']]\r\n+:setlocal nonu\r\n+:let g:testcase=\"3: Setting global number option\\n\"\r\n+:let g:options=[['number', 1, 0, 'global']]\r\n+:setglobal nonu\r\n+:let g:testcase=\"4: Setting local autoindent option\\n\"\r\n+:let g:options=[['autoindent', 0, 1, 'local']]\r\n+:setlocal ai\r\n+:let g:testcase=\"5: Setting global autoindent option\\n\"\r\n+:let g:options=[['autoindent', 0, 1, 'global']]\r\n+:setglobal ai\r\n+:let g:testcase=\"6: Setting global autoindent option\\n\"\r\n+:let g:options=[['autoindent', 1, 0, 'global']]\r\n+:set ai!\r\n+: Should not print anything, use :noa\r\n+:noa :set nonu\r\n+:let g:testcase=\"7: Setting several global list and number option\\n\"\r\n+:let g:options=[['list', 0, 1, 'global'], ['number', 0, 1, 'global']]\r\n+:set list nu\r\n+:noa set nolist nonu\r\n+:let g:testcase=\"8: Setting global acd\\n\"\r\n+:let g:options=[['autochdir', 0, 1, 'global']]\r\n+:setlocal acd\r\n+:let g:testcase=\"9: Setting global autoread\\n\"\r\n+:let g:options=[['autoread', 0, 1, 'global']]\r\n+:set ar\r\n+:let g:testcase=\"10: Setting local autoread\\n\"\r\n+:let g:options=[['autoread', 0, 1, 'local']]\r\n+:setlocal ar\r\n+:let g:testcase=\"11: Setting global autoread\\n\"\r\n+:let g:options=[['autoread', 1, 0, 'global']]\r\n+:setglobal invar\r\n+:let g:testcase=\"12: Setting option backspace through :let\\n\"\r\n+:let g:options=[['backspace', '', 'eol,indent,start', 'global']]\r\n+:let &bs=\"eol,indent,start\"\r\n+:let g:testcase=\"13: Setting option backspace through setbufvar()\\n\"\r\n+:let g:options=[['backup', '', '1', 'local']]\r\n+: \"try twice, first time, shouldn't trigger because option name is invalid, second time, it should trigger\r\n+:call setbufvar(1, '&l:bk', 1)\r\n+: \"should trigger, use correct option name\r\n+:call setbufvar(1, '&backup', 1)\r\n+:\" Write register now, because next test shouldn't output anything.\r\n+:$put r\r\n+:let @r=''\r\n+:let g:testcase=\"\\n14: Setting key option, shouldn't trigger\\n\"\r\n+:let g:options=[['key', 'invalid', 'invalid1', 'invalid']]\r\n+:setlocal key=blah\r\n+:setlocal key=\r\n+:$put =g:testcase\r\n+:%w! test.out\r\n+:qa!\r\n+ENDTEST\r\n+dummy text\r\n+\r\n+1: Setting number option\r\n+Expected: Name: <number>, Oldval: <0>, NewVal: <1>, Scope: <global>\r\n+Autocmd Option: <number>, OldVal: <0>, NewVal: <1>, Scope: <global>\r\n+\r\n+2: Setting local number option\r\n+Expected: Name: <number>, Oldval: <1>, NewVal: <0>, Scope: <local>\r\n+Autocmd Option: <number>, OldVal: <1>, NewVal: <0>, Scope: <local>\r\n+\r\n+3: Setting global number option\r\n+Expected: Name: <number>, Oldval: <1>, NewVal: <0>, Scope: <global>\r\n+Autocmd Option: <number>, OldVal: <1>, NewVal: <0>, Scope: <global>\r\n+\r\n+4: Setting local autoindent option\r\n+Expected: Name: <autoindent>, Oldval: <0>, NewVal: <1>, Scope: <local>\r\n+Autocmd Option: <autoindent>, OldVal: <0>, NewVal: <1>, Scope: <local>\r\n+\r\n+5: Setting global autoindent option\r\n+Expected: Name: <autoindent>, Oldval: <0>, NewVal: <1>, Scope: <global>\r\n+Autocmd Option: <autoindent>, OldVal: <0>, NewVal: <1>, Scope: <global>\r\n+\r\n+6: Setting global autoindent option\r\n+Expected: Name: <autoindent>, Oldval: <1>, NewVal: <0>, Scope: <global>\r\n+Autocmd Option: <autoindent>, OldVal: <1>, NewVal: <0>, Scope: <global>\r\n+\r\n+7: Setting several global list and number option\r\n+Expected: Name: <list>, Oldval: <0>, NewVal: <1>, Scope: <global>\r\n+Autocmd Option: <list>, OldVal: <0>, NewVal: <1>, Scope: <global>\r\n+\r\n+7: Setting several global list and number option\r\n+Expected: Name: <number>, Oldval: <0>, NewVal: <1>, Scope: <global>\r\n+Autocmd Option: <number>, OldVal: <0>, NewVal: <1>, Scope: <global>\r\n+\r\n+8: Setting global acd\r\n+Expected: Name: <autochdir>, Oldval: <0>, NewVal: <1>, Scope: <global>\r\n+Autocmd Option: <autochdir>, OldVal: <0>, NewVal: <1>, Scope: <local>\r\n+\r\n+9: Setting global autoread\r\n+Expected: Name: <autoread>, Oldval: <0>, NewVal: <1>, Scope: <global>\r\n+Autocmd Option: <autoread>, OldVal: <0>, NewVal: <1>, Scope: <global>\r\n+\r\n+10: Setting local autoread\r\n+Expected: Name: <autoread>, Oldval: <0>, NewVal: <1>, Scope: <local>\r\n+Autocmd Option: <autoread>, OldVal: <1>, NewVal: <1>, Scope: <local>\r\n+\r\n+11: Setting global autoread\r\n+Expected: Name: <autoread>, Oldval: <1>, NewVal: <0>, Scope: <global>\r\n+Autocmd Option: <autoread>, OldVal: <1>, NewVal: <0>, Scope: <global>\r\n+\r\n+12: Setting option backspace through :let\r\n+Expected: Name: <backspace>, Oldval: <>, NewVal: <eol,indent,start>, Scope: <global>\r\n+Autocmd Option: <backspace>, OldVal: <>, NewVal: <eol,indent,start>, Scope: <global>\r\n+\r\n+13: Setting option backspace through setbufvar()\r\n+Expected: Name: <backup>, Oldval: <>, NewVal: <1>, Scope: <local>\r\n+Autocmd Option: <backup>, OldVal: <0>, NewVal: <1>, Scope: <local>\r\n+\r\n+14: Setting key option, shouldn't trigger\r\ndiff --git a/src/nvim/version.c b/src/nvim/version.c\r\nindex 27a19ad..cef927d 100644\r\n--- a/src/nvim/version.c\r\n+++ b/src/nvim/version.c\r\n@@ -742,6 +742,8 @@ static char *(features[]) =\r\n static int included_patches[] =\r\n {   /* Add new patch number below this line */\r\n /**/\r\n+    786,\r\n+/**/\r\n     785,\r\n /**/\r\n     784,\r\ndiff --git a/src/nvim/vim.h b/src/nvim/vim.h\r\nindex 4e36f3d..809f312 100644\r\n--- a/src/nvim/vim.h\r\n+++ b/src/nvim/vim.h\r\n@@ -1335,6 +1335,7 @@ enum auto_event\r\n     EVENT_TEXTCHANGED,\t\t/* text was modified */\r\n     EVENT_TEXTCHANGEDI,\t\t/* text was modified in Insert mode*/\r\n     EVENT_CMDUNDEFINED,\t\t/* command undefined */\r\n+    EVENT_OPTIONSET,\t\t/* option was set */\r\n     NUM_EVENTS\t\t\t/* MUST be the last one */\r\n };\r\n \r\n@@ -1898,7 +1899,10 @@ typedef int proftime_T;\t    /* dummy for function prototypes */\r\n #define VV_WINDOWID\t56\r\n #define VV_PROGPATH\t57\r\n #define VV_COMPLETED_ITEM 58\r\n-#define VV_LEN\t\t59\t/* number of v: vars */\r\n+#define VV_OPTION_NEW   59\r\n+#define VV_OPTION_OLD   60\r\n+#define VV_OPTION_TYPE  61\r\n+#define VV_LEN\t\t62\t/* number of v: vars */\r\n \r\n #ifdef FEAT_CLIPBOARD\r\n \r\n```\r\n\r\n--------\r\n\r\n```\r\nProblem:    snprintf() isn't available everywhere.\r\nSolution:   Use vim_snprintf(). (Ken Takata)\r\n```\r\n\r\nhttps://github.com/vim/vim/commit/fb9bc4829a1442fc8e93f078c9f923c9d382dbd2\r\n\r\nOriginal patch:\r\n\r\n```diff\r\ncommit fb9bc4829a1442fc8e93f078c9f923c9d382dbd2\r\nAuthor: Bram Moolenaar <Bram@vim.org>\r\nDate:   Fri Jul 17 22:04:48 2015 +0200\r\n\r\n    patch 7.4.787\r\n    Problem:    snprintf() isn't available everywhere.\r\n    Solution:   Use vim_snprintf(). (Ken Takata)\r\n\r\ndiff --git a/src/nvim/option.c b/src/nvim/option.c\r\nindex c51d082..8b63938 100644\r\n--- a/src/nvim/option.c\r\n+++ b/src/nvim/option.c\r\n@@ -8291,9 +8291,9 @@ set_bool_option(opt_idx, varp, value, opt_flags)\r\n     if (!starting)\r\n     {\r\n \tchar_u buf_old[2], buf_new[2], buf_type[7];\r\n-\tsnprintf((char *)buf_old, 2, \"%d\", old_value ? TRUE: FALSE);\r\n-\tsnprintf((char *)buf_new, 2, \"%d\", value ? TRUE: FALSE);\r\n-\tsprintf((char *)buf_type, \"%s\", (opt_flags & OPT_LOCAL) ? \"local\" : \"global\");\r\n+\tvim_snprintf((char *)buf_old, 2, \"%d\", old_value ? TRUE: FALSE);\r\n+\tvim_snprintf((char *)buf_new, 2, \"%d\", value ? TRUE: FALSE);\r\n+\tvim_snprintf((char *)buf_type, 7, \"%s\", (opt_flags & OPT_LOCAL) ? \"local\" : \"global\");\r\n \tset_vim_var_string(VV_OPTION_NEW, buf_new, -1);\r\n \tset_vim_var_string(VV_OPTION_OLD, buf_old, -1);\r\n \tset_vim_var_string(VV_OPTION_TYPE, buf_type, -1);\r\n@@ -8841,9 +8841,9 @@ set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)\r\n     if (!starting && errmsg == NULL)\r\n     {\r\n \tchar_u buf_old[11], buf_new[11], buf_type[7];\r\n-\tsnprintf((char *)buf_old, 10, \"%ld\", old_value);\r\n-\tsnprintf((char *)buf_new, 10, \"%ld\", value);\r\n-\tsnprintf((char *)buf_type, 7, \"%s\", (opt_flags & OPT_LOCAL) ? \"local\" : \"global\");\r\n+\tvim_snprintf((char *)buf_old, 10, \"%ld\", old_value);\r\n+\tvim_snprintf((char *)buf_new, 10, \"%ld\", value);\r\n+\tvim_snprintf((char *)buf_type, 7, \"%s\", (opt_flags & OPT_LOCAL) ? \"local\" : \"global\");\r\n \tset_vim_var_string(VV_OPTION_NEW, buf_new, -1);\r\n \tset_vim_var_string(VV_OPTION_OLD, buf_old, -1);\r\n \tset_vim_var_string(VV_OPTION_TYPE, buf_type, -1);\r\ndiff --git a/src/nvim/version.c b/src/nvim/version.c\r\nindex cef927d..fe17b71 100644\r\n--- a/src/nvim/version.c\r\n+++ b/src/nvim/version.c\r\n@@ -742,6 +742,8 @@ static char *(features[]) =\r\n static int included_patches[] =\r\n {   /* Add new patch number below this line */\r\n /**/\r\n+    787,\r\n+/**/\r\n     786,\r\n /**/\r\n     785,\r\n```\r\n\r\n--------\r\n\r\n\r\n```\r\nProblem:    Using freed memory and crash. (Dominique Pellej)\r\nSolution:   Correct use of pointers. (Hirohito Higashi)\r\n```\r\n\r\nhttps://github.com/vim/vim/commit/9cac424d05c0e79cd621f1b9f2f01a9f459fcbe6\r\n\r\nOriginal patch:\r\n\r\n```diff\r\ncommit 9cac424d05c0e79cd621f1b9f2f01a9f459fcbe6\r\nAuthor: Bram Moolenaar <Bram@vim.org>\r\nDate:   Sun Jul 19 14:42:23 2015 +0200\r\n\r\n    patch 7.4.789\r\n    Problem:    Using freed memory and crash. (Dominique Pellej)\r\n    Solution:   Correct use of pointers. (Hirohito Higashi)\r\n\r\ndiff --git a/src/nvim/option.c b/src/nvim/option.c\r\nindex 35cfd2b..a356f96 100644\r\n--- a/src/nvim/option.c\r\n+++ b/src/nvim/option.c\r\n@@ -4943,7 +4943,8 @@ do_set(arg, opt_flags)\r\n \r\n \t\t\t    sprintf((char *)buf_type, \"%s\",\r\n \t\t\t\t(opt_flags & OPT_LOCAL) ? \"local\" : \"global\");\r\n-\t\t\t    set_vim_var_string(VV_OPTION_NEW, newval, -1);\r\n+\t\t\t    set_vim_var_string(VV_OPTION_NEW,\r\n+\t\t\t\t\t\t\t*(char_u **)varp, -1);\r\n \t\t\t    set_vim_var_string(VV_OPTION_OLD, saved_origval, -1);\r\n \t\t\t    set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);\r\n \t\t\t    apply_autocmds(EVENT_OPTIONSET,\r\n@@ -5738,8 +5739,8 @@ set_string_option(opt_idx, value, opt_flags)\r\n \t    char_u buf_type[7];\r\n \t    sprintf((char *)buf_type, \"%s\",\r\n \t\t(opt_flags & OPT_LOCAL) ? \"local\" : \"global\");\r\n-\t    set_vim_var_string(VV_OPTION_NEW, s, -1);\r\n-\t    set_vim_var_string(VV_OPTION_OLD, oldval, -1);\r\n+\t    set_vim_var_string(VV_OPTION_NEW, *varp, -1);\r\n+\t    set_vim_var_string(VV_OPTION_OLD, saved_oldval, -1);\r\n \t    set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);\r\n \t    apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);\r\n \t    reset_v_option_vars();\r\ndiff --git a/src/nvim/version.c b/src/nvim/version.c\r\nindex aa7b033..d2c8bc5 100644\r\n--- a/src/nvim/version.c\r\n+++ b/src/nvim/version.c\r\n@@ -742,6 +742,8 @@ static char *(features[]) =\r\n static int included_patches[] =\r\n {   /* Add new patch number below this line */\r\n /**/\r\n+    789,\r\n+/**/\r\n     788,\r\n /**/\r\n     787,\r\n```\r\n\r\n--------\r\n\r\n```\r\nProblem:    Test fails when the autochdir feature is not available.  Test\r\n            output contains the test script.\r\nSolution:   Check for the autochdir feature. (Kazunobu Kuriyama)  Only write\r\n            the relevant test output.\r\n```\r\n\r\nhttps://github.com/vim/vim/commit/d113a80c77101e9f5723abb075882012753cf611\r\n\r\nOriginal patch:\r\n\r\n```diff\r\ncommit d113a80c77101e9f5723abb075882012753cf611\r\nAuthor: Bram Moolenaar <Bram@vim.org>\r\nDate:   Tue Jul 21 10:57:44 2015 +0200\r\n\r\n    patch 7.4.790\r\n    Problem:    Test fails when the autochdir feature is not available.  Test\r\n                output contains the test script.\r\n    Solution:   Check for the autochdir feature. (Kazunobu Kuriyama)  Only write\r\n                the relevant test output.\r\n\r\ndiff --git a/src/nvim/testdir/test_autocmd_option.in b/src/nvim/testdir/test_autocmd_option.in\r\nindex 4d71c50..1ccfe8c 100644\r\n--- a/src/nvim/testdir/test_autocmd_option.in\r\n+++ b/src/nvim/testdir/test_autocmd_option.in\r\n@@ -2,7 +2,7 @@ Test for option autocommand\r\n \r\n STARTTEST\r\n :so small.vim\r\n-:if !has(\"eval\") || !has(\"autocmd\") | e! test.ok | w! test.out | qa! | endif\r\n+:if !has(\"eval\") || !has(\"autocmd\") || !exists(\"+autochdir\") | e! test.ok | w! test.out | qa! | endif\r\n :fu! AutoCommand(match)\r\n :\tlet c=g:testcase\r\n :       let item=remove(g:options, 0)\r\n@@ -67,7 +67,7 @@ STARTTEST\r\n :setlocal key=blah\r\n :setlocal key=\r\n :$put =g:testcase\r\n-:%w! test.out\r\n+:/^dummy text/,$w! test.out\r\n :qa!\r\n ENDTEST\r\n dummy text\r\ndiff --git a/src/nvim/testdir/test_autocmd_option.ok b/src/nvim/testdir/test_autocmd_option.ok\r\nindex b66b8f6..e98c651 100644\r\n--- a/src/nvim/testdir/test_autocmd_option.ok\r\n+++ b/src/nvim/testdir/test_autocmd_option.ok\r\n@@ -1,75 +1,3 @@\r\n-Test for option autocommand\r\n-\r\n-STARTTEST\r\n-:so small.vim\r\n-:if !has(\"eval\") || !has(\"autocmd\") | e! test.ok | w! test.out | qa! | endif\r\n-:fu! AutoCommand(match)\r\n-:\tlet c=g:testcase\r\n-:       let item=remove(g:options, 0)\r\n-:       let c.=printf(\"Expected: Name: <%s>, Oldval: <%s>, NewVal: <%s>, Scope: <%s>\\n\", item[0], item[1], item[2], item[3])\r\n-:       let c.=printf(\"Autocmd Option: <%s>,\", a:match)\r\n-:       let c.=printf(\" OldVal: <%s>,\", v:option_old)\r\n-:       let c.=printf(\" NewVal: <%s>,\", v:option_new)\r\n-:       let c.=printf(\" Scope: <%s>\\n\", v:option_type)\r\n-:       call setreg('r', printf(\"%s\\n%s\", getreg('r'), c))\r\n-:endfu\r\n-:au OptionSet * :call AutoCommand(expand(\"<amatch>\"))\r\n-:let g:testcase=\"1: Setting number option\\n\"\r\n-:let g:options=[['number', 0, 1, 'global']]\r\n-:set nu\r\n-:let g:testcase=\"2: Setting local number option\\n\"\r\n-:let g:options=[['number', 1, 0, 'local']]\r\n-:setlocal nonu\r\n-:let g:testcase=\"3: Setting global number option\\n\"\r\n-:let g:options=[['number', 1, 0, 'global']]\r\n-:setglobal nonu\r\n-:let g:testcase=\"4: Setting local autoindent option\\n\"\r\n-:let g:options=[['autoindent', 0, 1, 'local']]\r\n-:setlocal ai\r\n-:let g:testcase=\"5: Setting global autoindent option\\n\"\r\n-:let g:options=[['autoindent', 0, 1, 'global']]\r\n-:setglobal ai\r\n-:let g:testcase=\"6: Setting global autoindent option\\n\"\r\n-:let g:options=[['autoindent', 1, 0, 'global']]\r\n-:set ai!\r\n-: Should not print anything, use :noa\r\n-:noa :set nonu\r\n-:let g:testcase=\"7: Setting several global list and number option\\n\"\r\n-:let g:options=[['list', 0, 1, 'global'], ['number', 0, 1, 'global']]\r\n-:set list nu\r\n-:noa set nolist nonu\r\n-:let g:testcase=\"8: Setting global acd\\n\"\r\n-:let g:options=[['autochdir', 0, 1, 'global']]\r\n-:setlocal acd\r\n-:let g:testcase=\"9: Setting global autoread\\n\"\r\n-:let g:options=[['autoread', 0, 1, 'global']]\r\n-:set ar\r\n-:let g:testcase=\"10: Setting local autoread\\n\"\r\n-:let g:options=[['autoread', 0, 1, 'local']]\r\n-:setlocal ar\r\n-:let g:testcase=\"11: Setting global autoread\\n\"\r\n-:let g:options=[['autoread', 1, 0, 'global']]\r\n-:setglobal invar\r\n-:let g:testcase=\"12: Setting option backspace through :let\\n\"\r\n-:let g:options=[['backspace', '', 'eol,indent,start', 'global']]\r\n-:let &bs=\"eol,indent,start\"\r\n-:let g:testcase=\"13: Setting option backspace through setbufvar()\\n\"\r\n-:let g:options=[['backup', '', '1', 'local']]\r\n-: \"try twice, first time, shouldn't trigger because option name is invalid, second time, it should trigger\r\n-:call setbufvar(1, '&l:bk', 1)\r\n-: \"should trigger, use correct option name\r\n-:call setbufvar(1, '&backup', 1)\r\n-:\" Write register now, because next test shouldn't output anything.\r\n-:$put r\r\n-:let @r=''\r\n-:let g:testcase=\"\\n14: Setting key option, shouldn't trigger\\n\"\r\n-:let g:options=[['key', 'invalid', 'invalid1', 'invalid']]\r\n-:setlocal key=blah\r\n-:setlocal key=\r\n-:$put =g:testcase\r\n-:%w! test.out\r\n-:qa!\r\n-ENDTEST\r\n dummy text\r\n \r\n 1: Setting number option\r\ndiff --git a/src/nvim/version.c b/src/nvim/version.c\r\nindex d2c8bc5..18ba7d0 100644\r\n--- a/src/nvim/version.c\r\n+++ b/src/nvim/version.c\r\n@@ -742,6 +742,8 @@ static char *(features[]) =\r\n static int included_patches[] =\r\n {   /* Add new patch number below this line */\r\n /**/\r\n+    790,\r\n+/**/\r\n     789,\r\n /**/\r\n     788,\r\n```","created_at":"2015-11-28T08:18:41Z","updated_at":"2015-11-28T15:49:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bfc1d8b2d60b478cc1d9c61166a7acbc7f46cde1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/neovim/neovim/pulls/3753/commits","review_comments_url":"https://api.github.com/repos/neovim/neovim/pulls/3753/comments","review_comment_url":"https://api.github.com/repos/neovim/neovim/pulls/comments{/number}","comments_url":"https://api.github.com/repos/neovim/neovim/issues/3753/comments","statuses_url":"https://api.github.com/repos/neovim/neovim/statuses/8c00c34b91b44115275dc8d1c10bab95ae62a7a9","head":{"label":"watiko:vim-7.4.790","ref":"vim-7.4.790","sha":"8c00c34b91b44115275dc8d1c10bab95ae62a7a9","user":{"login":"watiko","id":199728,"avatar_url":"https://avatars.githubusercontent.com/u/199728?v=3","gravatar_id":"","url":"https://api.github.com/users/watiko","html_url":"https://github.com/watiko","followers_url":"https://api.github.com/users/watiko/followers","following_url":"https://api.github.com/users/watiko/following{/other_user}","gists_url":"https://api.github.com/users/watiko/gists{/gist_id}","starred_url":"https://api.github.com/users/watiko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/watiko/subscriptions","organizations_url":"https://api.github.com/users/watiko/orgs","repos_url":"https://api.github.com/users/watiko/repos","events_url":"https://api.github.com/users/watiko/events{/privacy}","received_events_url":"https://api.github.com/users/watiko/received_events","type":"User","site_admin":false},"repo":{"id":47015688,"name":"neovim","full_name":"watiko/neovim","owner":{"login":"watiko","id":199728,"avatar_url":"https://avatars.githubusercontent.com/u/199728?v=3","gravatar_id":"","url":"https://api.github.com/users/watiko","html_url":"https://github.com/watiko","followers_url":"https://api.github.com/users/watiko/followers","following_url":"https://api.github.com/users/watiko/following{/other_user}","gists_url":"https://api.github.com/users/watiko/gists{/gist_id}","starred_url":"https://api.github.com/users/watiko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/watiko/subscriptions","organizations_url":"https://api.github.com/users/watiko/orgs","repos_url":"https://api.github.com/users/watiko/repos","events_url":"https://api.github.com/users/watiko/events{/privacy}","received_events_url":"https://api.github.com/users/watiko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/watiko/neovim","description":"Vim-fork focused on extensibility and agility. Consider helping sustain Neovim development! ","fork":true,"url":"https://api.github.com/repos/watiko/neovim","forks_url":"https://api.github.com/repos/watiko/neovim/forks","keys_url":"https://api.github.com/repos/watiko/neovim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/watiko/neovim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/watiko/neovim/teams","hooks_url":"https://api.github.com/repos/watiko/neovim/hooks","issue_events_url":"https://api.github.com/repos/watiko/neovim/issues/events{/number}","events_url":"https://api.github.com/repos/watiko/neovim/events","assignees_url":"https://api.github.com/repos/watiko/neovim/assignees{/user}","branches_url":"https://api.github.com/repos/watiko/neovim/branches{/branch}","tags_url":"https://api.github.com/repos/watiko/neovim/tags","blobs_url":"https://api.github.com/repos/watiko/neovim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/watiko/neovim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/watiko/neovim/git/refs{/sha}","trees_url":"https://api.github.com/repos/watiko/neovim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/watiko/neovim/statuses/{sha}","languages_url":"https://api.github.com/repos/watiko/neovim/languages","stargazers_url":"https://api.github.com/repos/watiko/neovim/stargazers","contributors_url":"https://api.github.com/repos/watiko/neovim/contributors","subscribers_url":"https://api.github.com/repos/watiko/neovim/subscribers","subscription_url":"https://api.github.com/repos/watiko/neovim/subscription","commits_url":"https://api.github.com/repos/watiko/neovim/commits{/sha}","git_commits_url":"https://api.github.com/repos/watiko/neovim/git/commits{/sha}","comments_url":"https://api.github.com/repos/watiko/neovim/comments{/number}","issue_comment_url":"https://api.github.com/repos/watiko/neovim/issues/comments{/number}","contents_url":"https://api.github.com/repos/watiko/neovim/contents/{+path}","compare_url":"https://api.github.com/repos/watiko/neovim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/watiko/neovim/merges","archive_url":"https://api.github.com/repos/watiko/neovim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/watiko/neovim/downloads","issues_url":"https://api.github.com/repos/watiko/neovim/issues{/number}","pulls_url":"https://api.github.com/repos/watiko/neovim/pulls{/number}","milestones_url":"https://api.github.com/repos/watiko/neovim/milestones{/number}","notifications_url":"https://api.github.com/repos/watiko/neovim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/watiko/neovim/labels{/name}","releases_url":"https://api.github.com/repos/watiko/neovim/releases{/id}","created_at":"2015-11-28T08:10:34Z","updated_at":"2015-11-28T08:10:45Z","pushed_at":"2015-11-28T11:16:20Z","git_url":"git://github.com/watiko/neovim.git","ssh_url":"git@github.com:watiko/neovim.git","clone_url":"https://github.com/watiko/neovim.git","svn_url":"https://github.com/watiko/neovim","homepage":"https://salt.bountysource.com/teams/neovim","size":34788,"stargazers_count":0,"watchers_count":0,"language":"VimL","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"neovim:master","ref":"master","sha":"b9139e009f3eb833ab57e73d1ecdbe68752112fe","user":{"login":"neovim","id":6471485,"avatar_url":"https://avatars.githubusercontent.com/u/6471485?v=3","gravatar_id":"","url":"https://api.github.com/users/neovim","html_url":"https://github.com/neovim","followers_url":"https://api.github.com/users/neovim/followers","following_url":"https://api.github.com/users/neovim/following{/other_user}","gists_url":"https://api.github.com/users/neovim/gists{/gist_id}","starred_url":"https://api.github.com/users/neovim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neovim/subscriptions","organizations_url":"https://api.github.com/users/neovim/orgs","repos_url":"https://api.github.com/users/neovim/repos","events_url":"https://api.github.com/users/neovim/events{/privacy}","received_events_url":"https://api.github.com/users/neovim/received_events","type":"Organization","site_admin":false},"repo":{"id":16408992,"name":"neovim","full_name":"neovim/neovim","owner":{"login":"neovim","id":6471485,"avatar_url":"https://avatars.githubusercontent.com/u/6471485?v=3","gravatar_id":"","url":"https://api.github.com/users/neovim","html_url":"https://github.com/neovim","followers_url":"https://api.github.com/users/neovim/followers","following_url":"https://api.github.com/users/neovim/following{/other_user}","gists_url":"https://api.github.com/users/neovim/gists{/gist_id}","starred_url":"https://api.github.com/users/neovim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neovim/subscriptions","organizations_url":"https://api.github.com/users/neovim/orgs","repos_url":"https://api.github.com/users/neovim/repos","events_url":"https://api.github.com/users/neovim/events{/privacy}","received_events_url":"https://api.github.com/users/neovim/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/neovim/neovim","description":"Vim-fork focused on extensibility and agility. Consider helping sustain Neovim development! ","fork":false,"url":"https://api.github.com/repos/neovim/neovim","forks_url":"https://api.github.com/repos/neovim/neovim/forks","keys_url":"https://api.github.com/repos/neovim/neovim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/neovim/neovim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/neovim/neovim/teams","hooks_url":"https://api.github.com/repos/neovim/neovim/hooks","issue_events_url":"https://api.github.com/repos/neovim/neovim/issues/events{/number}","events_url":"https://api.github.com/repos/neovim/neovim/events","assignees_url":"https://api.github.com/repos/neovim/neovim/assignees{/user}","branches_url":"https://api.github.com/repos/neovim/neovim/branches{/branch}","tags_url":"https://api.github.com/repos/neovim/neovim/tags","blobs_url":"https://api.github.com/repos/neovim/neovim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/neovim/neovim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/neovim/neovim/git/refs{/sha}","trees_url":"https://api.github.com/repos/neovim/neovim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/neovim/neovim/statuses/{sha}","languages_url":"https://api.github.com/repos/neovim/neovim/languages","stargazers_url":"https://api.github.com/repos/neovim/neovim/stargazers","contributors_url":"https://api.github.com/repos/neovim/neovim/contributors","subscribers_url":"https://api.github.com/repos/neovim/neovim/subscribers","subscription_url":"https://api.github.com/repos/neovim/neovim/subscription","commits_url":"https://api.github.com/repos/neovim/neovim/commits{/sha}","git_commits_url":"https://api.github.com/repos/neovim/neovim/git/commits{/sha}","comments_url":"https://api.github.com/repos/neovim/neovim/comments{/number}","issue_comment_url":"https://api.github.com/repos/neovim/neovim/issues/comments{/number}","contents_url":"https://api.github.com/repos/neovim/neovim/contents/{+path}","compare_url":"https://api.github.com/repos/neovim/neovim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/neovim/neovim/merges","archive_url":"https://api.github.com/repos/neovim/neovim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/neovim/neovim/downloads","issues_url":"https://api.github.com/repos/neovim/neovim/issues{/number}","pulls_url":"https://api.github.com/repos/neovim/neovim/pulls{/number}","milestones_url":"https://api.github.com/repos/neovim/neovim/milestones{/number}","notifications_url":"https://api.github.com/repos/neovim/neovim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/neovim/neovim/labels{/name}","releases_url":"https://api.github.com/repos/neovim/neovim/releases{/id}","created_at":"2014-01-31T13:39:22Z","updated_at":"2015-11-28T15:31:51Z","pushed_at":"2015-11-28T15:37:29Z","git_url":"git://github.com/neovim/neovim.git","ssh_url":"git@github.com:neovim/neovim.git","clone_url":"https://github.com/neovim/neovim.git","svn_url":"https://github.com/neovim/neovim","homepage":"https://salt.bountysource.com/teams/neovim","size":56426,"stargazers_count":16306,"watchers_count":16306,"language":"VimL","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1142,"mirror_url":null,"open_issues_count":601,"forks":1142,"open_issues":601,"watchers":16306,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/neovim/neovim/pulls/3753"},"html":{"href":"https://github.com/neovim/neovim/pull/3753"},"issue":{"href":"https://api.github.com/repos/neovim/neovim/issues/3753"},"comments":{"href":"https://api.github.com/repos/neovim/neovim/issues/3753/comments"},"review_comments":{"href":"https://api.github.com/repos/neovim/neovim/pulls/3753/comments"},"review_comment":{"href":"https://api.github.com/repos/neovim/neovim/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/neovim/neovim/pulls/3753/commits"},"statuses":{"href":"https://api.github.com/repos/neovim/neovim/statuses/8c00c34b91b44115275dc8d1c10bab95ae62a7a9"}}}}