]> granicus.if.org Git - vim/commitdiff
patch 8.2.4753: error from setting an option is silently ignored v8.2.4753
authorBram Moolenaar <Bram@vim.org>
Fri, 15 Apr 2022 12:53:33 +0000 (13:53 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 15 Apr 2022 12:53:33 +0000 (13:53 +0100)
Problem:    Error from setting an option is silently ignored.
Solution:   Handle option value errors better.  Fix uses of N_().

31 files changed:
src/channel.c
src/crypt.c
src/diff.c
src/edit.c
src/eval.c
src/evalfunc.c
src/evalvars.c
src/ex_cmds2.c
src/ex_docmd.c
src/ex_getln.c
src/getchar.c
src/gui.c
src/gui_gtk_x11.c
src/help.c
src/highlight.c
src/if_tcl.c
src/main.c
src/memline.c
src/message_test.c
src/option.c
src/optionstr.c
src/popupmenu.c
src/proto/option.pro
src/quickfix.c
src/scriptfile.c
src/spell.c
src/spellfile.c
src/term.c
src/undo.c
src/version.c
src/vim9script.c

index e971e17c09cdf98b929ed92cd2846425e991dff8..85089cb186a14c0dd12516421344d0d596fe138a 100644 (file)
@@ -1183,8 +1183,9 @@ prepare_buffer(buf_T *buf)
     buf_copy_options(buf, BCO_ENTER);
     curbuf = buf;
 #ifdef FEAT_QUICKFIX
-    set_option_value((char_u *)"bt", 0L, (char_u *)"nofile", OPT_LOCAL);
-    set_option_value((char_u *)"bh", 0L, (char_u *)"hide", OPT_LOCAL);
+    set_option_value_give_err((char_u *)"bt",
+                                           0L, (char_u *)"nofile", OPT_LOCAL);
+    set_option_value_give_err((char_u *)"bh", 0L, (char_u *)"hide", OPT_LOCAL);
 #endif
     if (curbuf->b_ml.ml_mfp == NULL)
        ml_open(curbuf);
index 86f48463686647a25e199f4eb9bb711c3a95123a..6a852fa1f9b5ed57010f01864868383da9a574be 100644 (file)
@@ -752,7 +752,7 @@ crypt_check_swapfile_curbuf(void)
        // encryption uses padding and MAC, that does not work very well with
        // swap and undo files, so disable them
        mf_close_file(curbuf, TRUE);    // remove the swap file
-       set_option_value((char_u *)"swf", 0, NULL, OPT_LOCAL);
+       set_option_value_give_err((char_u *)"swf", 0, NULL, OPT_LOCAL);
        msg_scroll = TRUE;
        msg(_("Note: Encryption of swapfile not supported, disabling swap file"));
     }
@@ -807,7 +807,7 @@ crypt_get_key(
 
            if (store)
            {
-               set_option_value((char_u *)"key", 0L, p1, OPT_LOCAL);
+               set_option_value_give_err((char_u *)"key", 0L, p1, OPT_LOCAL);
                crypt_free_key(p1);
                p1 = curbuf->b_p_key;
 #ifdef FEAT_SODIUM
index 00ccdb611fb78baefc09d8999825ae6ccd7c4e2c..df3dea0a179c7c33342beae96586b113474c45a8 100644 (file)
@@ -1466,7 +1466,7 @@ set_diff_option(win_T *wp, int value)
     curwin = wp;
     curbuf = curwin->w_buffer;
     ++curbuf_lock;
-    set_option_value((char_u *)"diff", (long)value, NULL, OPT_LOCAL);
+    set_option_value_give_err((char_u *)"diff", (long)value, NULL, OPT_LOCAL);
     --curbuf_lock;
     curwin = old_curwin;
     curbuf = curwin->w_buffer;
index c28c1f98a377a50480de8818e23887279bdbf3ad..3790bfb5d6785e826051306c55b74b7e1b604e87 100644 (file)
@@ -4407,7 +4407,7 @@ bracketed_paste(paste_mode_T mode, int drop, garray_T *gap)
     if (!p_paste)
        // Also have the side effects of setting 'paste' to make it work much
        // faster.
-       set_option_value((char_u *)"paste", TRUE, NULL, 0);
+       set_option_value_give_err((char_u *)"paste", TRUE, NULL, 0);
 
     for (;;)
     {
@@ -4482,7 +4482,7 @@ bracketed_paste(paste_mode_T mode, int drop, garray_T *gap)
     --no_mapping;
     allow_keys = save_allow_keys;
     if (!save_paste)
-       set_option_value((char_u *)"paste", FALSE, NULL, 0);
+       set_option_value_give_err((char_u *)"paste", FALSE, NULL, 0);
 
     return ret_char;
 }
index 793a5263dd4de872f52dacdac6743ec0aee42236..90ed14b60856d85a800c4fca37f92d70833b0e4a 100644 (file)
@@ -6801,7 +6801,7 @@ do_string_sub(
        // If it's still empty it was changed and restored, need to restore in
        // the complicated way.
        if (*p_cpo == NUL)
-           set_option_value((char_u *)"cpo", 0L, save_cpo, 0);
+           set_option_value_give_err((char_u *)"cpo", 0L, save_cpo, 0);
        free_string_option(save_cpo);
     }
 
index e30186b034b6c356cae62724630143f8ca89a285..da8f8457c59c577a10e3178efc502f311de0c113 100644 (file)
@@ -9060,7 +9060,7 @@ theend:
        // If it's still empty it was changed and restored, need to restore in
        // the complicated way.
        if (*p_cpo == NUL)
-           set_option_value((char_u *)"cpo", 0L, save_cpo, 0);
+           set_option_value_give_err((char_u *)"cpo", 0L, save_cpo, 0);
        free_string_option(save_cpo);
     }
 
index 0ee4b08d5cebd5d8a583b3c897efae6c84777f25..4690d1ac475258af8566456b77808974657938d2 100644 (file)
@@ -4014,7 +4014,7 @@ set_option_from_tv(char_u *varname, typval_T *varp)
        strval = tv_get_string_buf_chk(varp, nbuf);
     }
     if (!error && strval != NULL)
-       set_option_value(varname, numval, strval, OPT_LOCAL);
+       set_option_value_give_err(varname, numval, strval, OPT_LOCAL);
 }
 
 /*
index db82277aca197beb0d3599a32f3907082c01a87d..2de1798b18675d476a4fd160f8d51b9e49890f1c 100644 (file)
@@ -563,9 +563,11 @@ ex_listdo(exarg_T *eap)
                    // Clear 'shm' to avoid that the file message overwrites
                    // any output from the command.
                    p_shm_save = vim_strsave(p_shm);
-                   set_option_value((char_u *)"shm", 0L, (char_u *)"", 0);
+                   set_option_value_give_err((char_u *)"shm",
+                                                         0L, (char_u *)"", 0);
                    do_argfile(eap, i);
-                   set_option_value((char_u *)"shm", 0L, p_shm_save, 0);
+                   set_option_value_give_err((char_u *)"shm",
+                                                           0L, p_shm_save, 0);
                    vim_free(p_shm_save);
                }
                if (curwin->w_arg_idx != i)
@@ -623,9 +625,9 @@ ex_listdo(exarg_T *eap)
                // Go to the next buffer.  Clear 'shm' to avoid that the file
                // message overwrites any output from the command.
                p_shm_save = vim_strsave(p_shm);
-               set_option_value((char_u *)"shm", 0L, (char_u *)"", 0);
+               set_option_value_give_err((char_u *)"shm", 0L, (char_u *)"", 0);
                goto_buffer(eap, DOBUF_FIRST, FORWARD, next_fnum);
-               set_option_value((char_u *)"shm", 0L, p_shm_save, 0);
+               set_option_value_give_err((char_u *)"shm", 0L, p_shm_save, 0);
                vim_free(p_shm_save);
 
                // If autocommands took us elsewhere, quit here.
@@ -645,9 +647,9 @@ ex_listdo(exarg_T *eap)
                // Clear 'shm' to avoid that the file message overwrites
                // any output from the command.
                p_shm_save = vim_strsave(p_shm);
-               set_option_value((char_u *)"shm", 0L, (char_u *)"", 0);
+               set_option_value_give_err((char_u *)"shm", 0L, (char_u *)"", 0);
                ex_cnext(eap);
-               set_option_value((char_u *)"shm", 0L, p_shm_save, 0);
+               set_option_value_give_err((char_u *)"shm", 0L, p_shm_save, 0);
                vim_free(p_shm_save);
 
                // If jumping to the next quickfix entry fails, quit here
index ceb500dc131b38e0c08e2fdec732c2f050a50ba2..47a12fd2cf82a5d61bb966380e079bf37e9a8113 100644 (file)
@@ -9423,18 +9423,23 @@ ex_behave(exarg_T *eap)
 {
     if (STRCMP(eap->arg, "mswin") == 0)
     {
-       set_option_value((char_u *)"selection", 0L, (char_u *)"exclusive", 0);
-       set_option_value((char_u *)"selectmode", 0L, (char_u *)"mouse,key", 0);
-       set_option_value((char_u *)"mousemodel", 0L, (char_u *)"popup", 0);
-       set_option_value((char_u *)"keymodel", 0L,
-                                            (char_u *)"startsel,stopsel", 0);
+       set_option_value_give_err((char_u *)"selection",
+                                                0L, (char_u *)"exclusive", 0);
+       set_option_value_give_err((char_u *)"selectmode",
+                                                0L, (char_u *)"mouse,key", 0);
+       set_option_value_give_err((char_u *)"mousemodel",
+                                                    0L, (char_u *)"popup", 0);
+       set_option_value_give_err((char_u *)"keymodel",
+                                         0L, (char_u *)"startsel,stopsel", 0);
     }
     else if (STRCMP(eap->arg, "xterm") == 0)
     {
-       set_option_value((char_u *)"selection", 0L, (char_u *)"inclusive", 0);
-       set_option_value((char_u *)"selectmode", 0L, (char_u *)"", 0);
-       set_option_value((char_u *)"mousemodel", 0L, (char_u *)"extend", 0);
-       set_option_value((char_u *)"keymodel", 0L, (char_u *)"", 0);
+       set_option_value_give_err((char_u *)"selection",
+                                                0L, (char_u *)"inclusive", 0);
+       set_option_value_give_err((char_u *)"selectmode", 0L, (char_u *)"", 0);
+       set_option_value_give_err((char_u *)"mousemodel",
+                                                   0L, (char_u *)"extend", 0);
+       set_option_value_give_err((char_u *)"keymodel", 0L, (char_u *)"", 0);
     }
     else
        semsg(_(e_invalid_argument_str), eap->arg);
@@ -9548,7 +9553,7 @@ ex_setfiletype(exarg_T *eap)
        if (STRNCMP(arg, "FALLBACK ", 9) == 0)
            arg += 9;
 
-       set_option_value((char_u *)"filetype", 0L, arg, OPT_LOCAL);
+       set_option_value_give_err((char_u *)"filetype", 0L, arg, OPT_LOCAL);
        if (arg != eap->arg)
            did_filetype = FALSE;
     }
index 3cacf9df76ccf855d6c1a050265d935595ce3195..c351cf2566f31b4a059a098997967c51dc7d00d4 100644 (file)
@@ -4367,7 +4367,8 @@ open_cmdwin(void)
     apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, FALSE, curbuf);
     (void)setfname(curbuf, (char_u *)_("[Command Line]"), NULL, TRUE);
     apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf);
-    set_option_value((char_u *)"bt", 0L, (char_u *)"nofile", OPT_LOCAL);
+    set_option_value_give_err((char_u *)"bt",
+                                           0L, (char_u *)"nofile", OPT_LOCAL);
     curbuf->b_p_ma = TRUE;
 #ifdef FEAT_FOLDING
     curwin->w_p_fen = FALSE;
@@ -4392,7 +4393,8 @@ open_cmdwin(void)
            add_map((char_u *)"<buffer> <Tab> <C-X><C-V>", INSERT);
            add_map((char_u *)"<buffer> <Tab> a<C-X><C-V>", NORMAL);
        }
-       set_option_value((char_u *)"ft", 0L, (char_u *)"vim", OPT_LOCAL);
+       set_option_value_give_err((char_u *)"ft",
+                                              0L, (char_u *)"vim", OPT_LOCAL);
     }
     --curbuf_lock;
 
index fb7f00a95f98bc41389f33150e96cde483e519d2..73cf4208be2f8b91fe1554585b5b95ee0d4680af 100644 (file)
@@ -2645,7 +2645,8 @@ handle_mapping(
                                                     mlen - typebuf.tb_maplen);
 
            del_typebuf(mlen, 0); // remove the chars
-           set_option_value((char_u *)"paste", (long)!p_paste, NULL, 0);
+           set_option_value_give_err((char_u *)"paste",
+                                                     (long)!p_paste, NULL, 0);
            if (!(State & INSERT))
            {
                msg_col = 0;
index f2f541e79f34e770badbf5d2abdda3f5161f7da7..2d59ea27a7629f5159647c7c3bc55b5d22fea043 100644 (file)
--- a/src/gui.c
+++ b/src/gui.c
@@ -504,7 +504,7 @@ gui_init(void)
         * Reset 'paste'.  It's useful in the terminal, but not in the GUI.  It
         * breaks the Paste toolbar button.
         */
-       set_option_value((char_u *)"paste", 0L, NULL, 0);
+       set_option_value_give_err((char_u *)"paste", 0L, NULL, 0);
 
        // Set t_Co to the number of colors: RGB.
        set_color_count(256 * 256 * 256);
@@ -664,7 +664,8 @@ gui_init(void)
      * Set up the fonts.  First use a font specified with "-fn" or "-font".
      */
     if (font_argument != NULL)
-       set_option_value((char_u *)"gfn", 0L, (char_u *)font_argument, 0);
+       set_option_value_give_err((char_u *)"gfn",
+                                              0L, (char_u *)font_argument, 0);
     if (
 #ifdef FEAT_XFONTSET
            (*p_guifontset == NUL
@@ -4814,7 +4815,7 @@ init_gui_options(void)
     // background color, unless the user has set it already.
     if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
     {
-       set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
+       set_option_value_give_err((char_u *)"bg", 0L, gui_bg_default(), 0);
        highlight_changed();
     }
 }
index acd36d3adf425963d087052058010398c9631340..d756f55294fd175459ff18166115f4ddf8b9be2e 100644 (file)
@@ -3462,7 +3462,8 @@ gui_mch_init(void)
      * did_set_string_option() in option.c prohibits changing 'termencoding'
      * to something else than UTF-8 if the GUI is in use.
      */
-    set_option_value((char_u *)"termencoding", 0L, (char_u *)"utf-8", 0);
+    set_option_value_give_err((char_u *)"termencoding",
+                                                    0L, (char_u *)"utf-8", 0);
 
 #ifdef FEAT_TOOLBAR
     gui_gtk_register_stock_icons();
index 48178fda3bc050cb250f65214172e2cd0dfa8a24..e58068020cb7de3422d4ab21330c0e7042aff8bd 100644 (file)
@@ -708,7 +708,8 @@ fix_help_buffer(void)
     if (STRCMP(curbuf->b_p_ft, "help") != 0)
     {
        ++curbuf_lock;
-       set_option_value((char_u *)"ft", 0L, (char_u *)"help", OPT_LOCAL);
+       set_option_value_give_err((char_u *)"ft",
+                                             0L, (char_u *)"help", OPT_LOCAL);
        --curbuf_lock;
     }
 
index 61fea9a6696d2ac2e30528d6a7377761c663ff0d..6a2b0874df9265f778d06706539ef427d73d53c4 100644 (file)
@@ -974,8 +974,8 @@ highlight_set_ctermbg(int idx, int color, int is_normal_group)
                        && dark != (*p_bg == 'd')
                        && !option_was_set((char_u *)"bg"))
                {
-                   set_option_value((char_u *)"bg", 0L,
-                           (char_u *)(dark ? "dark" : "light"), 0);
+                   set_option_value_give_err((char_u *)"bg",
+                                  0L, (char_u *)(dark ? "dark" : "light"), 0);
                    reset_option_was_set((char_u *)"bg");
                }
            }
index f66bfd3860db890e9a6aa5c5d93231c929a47b2b..8a6af8db6b721a472a30789dce8403950659ce88 100644 (file)
@@ -1359,7 +1359,7 @@ tclsetoption(
            sval = (char_u *)Tcl_GetStringFromObj(objv[objn], NULL);
        if (err == TCL_OK)
        {
-           set_option_value(option, lval, sval, OPT_LOCAL);
+           set_option_value_give_err(option, lval, sval, OPT_LOCAL);
            err = vimerror(interp);
        }
     }
index f9b1920733e632a5752ec3b1d34495ed019516d1..931f6040bc93536542b63581a33d15ce421faa68 100644 (file)
@@ -2033,7 +2033,8 @@ command_line_scan(mparm_T *parmp)
                    use_gvimrc = (char_u *)"NONE";
 #endif
                    parmp->clean = TRUE;
-                   set_option_value((char_u *)"vif", 0L, (char_u *)"NONE", 0);
+                   set_option_value_give_err((char_u *)"vif",
+                                                     0L, (char_u *)"NONE", 0);
                }
                else if (STRNICMP(argv[0] + argv_idx, "literal", 7) == 0)
                {
@@ -2115,7 +2116,7 @@ command_line_scan(mparm_T *parmp)
 
            case 'A':           // "-A" start in Arabic mode
 #ifdef FEAT_ARABIC
-               set_option_value((char_u *)"arabic", 1L, NULL, 0);
+               set_option_value_give_err((char_u *)"arabic", 1L, NULL, 0);
 #else
                mch_errmsg(_(e_arabic_cannot_be_used_not_enabled_at_compile_time));
                mch_exit(2);
@@ -2171,7 +2172,7 @@ command_line_scan(mparm_T *parmp)
            case 'H':           // "-H" start in Hebrew mode: rl + hkmap set
 #ifdef FEAT_RIGHTLEFT
                p_hkmap = TRUE;
-               set_option_value((char_u *)"rl", 1L, NULL, 0);
+               set_option_value_give_err((char_u *)"rl", 1L, NULL, 0);
 #else
                mch_errmsg(_(e_hebrew_cannot_be_used_not_enabled_at_compile_time));
                mch_exit(2);
@@ -2180,7 +2181,7 @@ command_line_scan(mparm_T *parmp)
 
            case 'l':           // "-l" lisp mode, 'lisp' and 'showmatch' on
 #ifdef FEAT_LISP
-               set_option_value((char_u *)"lisp", 1L, NULL, 0);
+               set_option_value_give_err((char_u *)"lisp", 1L, NULL, 0);
                p_sm = TRUE;
 #endif
                break;
@@ -2316,8 +2317,8 @@ command_line_scan(mparm_T *parmp)
                p_verbose = get_number_arg((char_u *)argv[0], &argv_idx, 10);
                if (argv[0][argv_idx] != NUL)
                {
-                   set_option_value((char_u *)"verbosefile", 0L,
-                                            (char_u *)argv[0] + argv_idx, 0);
+                   set_option_value_give_err((char_u *)"verbosefile",
+                                         0L, (char_u *)argv[0] + argv_idx, 0);
                    argv_idx = (int)STRLEN(argv[0]);
                }
                break;
@@ -2334,7 +2335,7 @@ command_line_scan(mparm_T *parmp)
                if (vim_isdigit(((char_u *)argv[0])[argv_idx]))
                {
                    n = get_number_arg((char_u *)argv[0], &argv_idx, 10);
-                   set_option_value((char_u *)"window", n, NULL, 0);
+                   set_option_value_give_err((char_u *)"window", n, NULL, 0);
                    break;
                }
                want_argument = TRUE;
@@ -2463,7 +2464,8 @@ command_line_scan(mparm_T *parmp)
 #endif
 
                case 'i':       // "-i {viminfo}" use for viminfo
-                   set_option_value((char_u *)"vif", 0L, (char_u *)argv[0], 0);
+                   set_option_value_give_err((char_u *)"vif",
+                                                    0L, (char_u *)argv[0], 0);
                    break;
 
                case 's':       // "-s {scriptin}" read from script file
@@ -2522,7 +2524,8 @@ scripterror:
                    {
                        argv_idx = 0;
                        n = get_number_arg((char_u *)argv[0], &argv_idx, 10);
-                       set_option_value((char_u *)"window", n, NULL, 0);
+                       set_option_value_give_err((char_u *)"window",
+                                                                  n, NULL, 0);
                        argv_idx = -1;
                        break;
                    }
@@ -2967,7 +2970,8 @@ edit_buffers(
 
                    p_shm_save = vim_strsave(p_shm);
                    vim_snprintf(buf, 100, "F%s", p_shm);
-                   set_option_value((char_u *)"shm", 0L, (char_u *)buf, 0);
+                   set_option_value_give_err((char_u *)"shm",
+                                                        0L, (char_u *)buf, 0);
                }
            }
            else
@@ -3016,7 +3020,7 @@ edit_buffers(
 
     if (p_shm_save != NULL)
     {
-       set_option_value((char_u *)"shm", 0L, p_shm_save, 0);
+       set_option_value_give_err((char_u *)"shm", 0L, p_shm_save, 0);
        vim_free(p_shm_save);
     }
 
index f38e029bd16ef7ccee6b70d3332c55046179a6fe..e098aef552280966ff72cbfad948e327a308fb79 100644 (file)
@@ -1482,7 +1482,7 @@ ml_recover(int checkext)
        set_fileformat(b0_ff - 1, OPT_LOCAL);
     if (b0_fenc != NULL)
     {
-       set_option_value((char_u *)"fenc", 0L, b0_fenc, OPT_LOCAL);
+       set_option_value_give_err((char_u *)"fenc", 0L, b0_fenc, OPT_LOCAL);
        vim_free(b0_fenc);
     }
     unchanged(curbuf, TRUE, TRUE);
@@ -1759,7 +1759,7 @@ ml_recover(int checkext)
     if (*buf->b_p_key != NUL && STRCMP(curbuf->b_p_key, buf->b_p_key) != 0)
     {
        msg_puts(_("Using crypt key from swap file for the text file.\n"));
-       set_option_value((char_u *)"key", 0L, buf->b_p_key, OPT_LOCAL);
+       set_option_value_give_err((char_u *)"key", 0L, buf->b_p_key, OPT_LOCAL);
     }
 #endif
     redraw_curbuf_later(NOT_VALID);
index 882b591e43f0342b1b0950726e8b2978f174dea2..940c1cc0b0fd9e3f2c1a152e35ca4edbd6dd729c 100644 (file)
@@ -314,13 +314,13 @@ main(int argc, char **argv)
     params.argv = argv;
     common_init(&params);
 
-    set_option_value((char_u *)"encoding", 0, (char_u *)"utf-8", 0);
+    set_option_value_give_err((char_u *)"encoding", 0, (char_u *)"utf-8", 0);
     init_chartab();
     test_trunc_string();
     test_trunc_string_mbyte();
     test_vim_snprintf();
 
-    set_option_value((char_u *)"encoding", 0, (char_u *)"latin1", 0);
+    set_option_value_give_err((char_u *)"encoding", 0, (char_u *)"latin1", 0);
     init_chartab();
     test_trunc_string();
     test_vim_snprintf();
index cfd681756700d336c6279cf50be384213d0f5f39..518e787deed6898058414801fad370523e70f887 100644 (file)
@@ -331,7 +331,7 @@ set_init_1(int clean_arg)
 
 #ifdef FEAT_GUI
     if (found_reverse_arg)
-       set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
+       set_option_value_give_err((char_u *)"bg", 0L, (char_u *)"dark", 0);
 #endif
 
     curbuf->b_p_initialized = TRUE;
@@ -389,7 +389,7 @@ set_init_1(int clean_arg)
     // NOTE: mlterm's author is being asked to 'set' a variable
     //       instead of an environment variable due to inheritance.
     if (mch_getenv((char_u *)"MLTERM") != NULL)
-       set_option_value((char_u *)"tbidi", 1L, NULL, 0);
+       set_option_value_give_err((char_u *)"tbidi", 1L, NULL, 0);
 #endif
 
     didset_options2();
@@ -1406,7 +1406,7 @@ do_set(
                                  && vim_strchr((char_u *)"!&<", *arg) != NULL)
                    errmsg = e_no_white_space_allowed_between_option_and;
                else
-                   errmsg = N_(e_unknown_option);
+                   errmsg = e_unknown_option;
                goto skip;
            }
 
@@ -1419,7 +1419,7 @@ do_set(
                    if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
                            && (!(options[opt_idx].flags & P_BOOL)
                                || nextchar == '?'))
-                       errmsg = N_(e_option_not_supported);
+                       errmsg = e_option_not_supported;
                    goto skip;
                }
 
@@ -1457,12 +1457,12 @@ do_set(
            {
                if (flags & (P_SECURE | P_NO_ML))
                {
-                   errmsg = N_(e_not_allowed_in_modeline);
+                   errmsg = e_not_allowed_in_modeline;
                    goto skip;
                }
                if ((flags & P_MLE) && !p_mle)
                {
-                   errmsg = N_(e_not_allowed_in_modeline_when_modelineexpr_is_off);
+                   errmsg = e_not_allowed_in_modeline_when_modelineexpr_is_off;
                    goto skip;
                }
 #ifdef FEAT_DIFF
@@ -1558,7 +1558,7 @@ do_set(
                    p = find_termcode(key_name);
                    if (p == NULL)
                    {
-                       errmsg = N_(e_key_code_not_set);
+                       errmsg = e_key_code_not_set;
                        goto skip;
                    }
                    else
@@ -1682,13 +1682,13 @@ do_set(
                            if (i == 0 || (arg[i] != NUL
                                                      && !VIM_ISWHITE(arg[i])))
                            {
-                               errmsg = N_(e_number_required_after_equal);
+                               errmsg = e_number_required_after_equal;
                                goto skip;
                            }
                        }
                        else
                        {
-                           errmsg = N_(e_number_required_after_equal);
+                           errmsg = e_number_required_after_equal;
                            goto skip;
                        }
 
@@ -2140,7 +2140,7 @@ do_set(
                        if (nextchar == '&')
                        {
                            if (add_termcap_entry(key_name, TRUE) == FAIL)
-                               errmsg = N_(e_not_found_in_termcap);
+                               errmsg = e_not_found_in_termcap;
                        }
                        else
                        {
@@ -2724,6 +2724,7 @@ set_bool_option(
 #if defined(FEAT_EVAL)
     int                old_global_value = 0;
 #endif
+    char       *errmsg = NULL;
 
     // Disallow changing some options from secure mode
     if ((secure
@@ -2838,7 +2839,7 @@ set_bool_option(
                      && curbuf->b_term != NULL && !term_is_finished(curbuf))))
        {
            curbuf->b_p_ma = FALSE;
-           return N_(e_cannot_make_terminal_with_running_job_modifiable);
+           return e_cannot_make_terminal_with_running_job_modifiable;
        }
 # endif
        redraw_titles();
@@ -2966,7 +2967,7 @@ set_bool_option(
                if (win->w_p_pvw && win != curwin)
                {
                    curwin->w_p_pvw = FALSE;
-                   return N_(e_preview_window_already_exists);
+                   return e_preview_window_already_exists;
                }
        }
     }
@@ -3121,12 +3122,7 @@ set_bool_option(
     else if ((int *)varp == &curwin->w_p_spell)
     {
        if (curwin->w_p_spell)
-       {
-           char        *errmsg = did_set_spelllang(curwin);
-
-           if (errmsg != NULL)
-               emsg(_(errmsg));
-       }
+           errmsg = did_set_spelllang(curwin);
     }
 #endif
 
@@ -3173,8 +3169,8 @@ set_bool_option(
 
 # ifdef FEAT_KEYMAP
            // Force-set the necessary keymap for arabic
-           set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
-                                                                  OPT_LOCAL);
+           errmsg = set_option_value((char_u *)"keymap",
+                                           0L, (char_u *)"arabic", OPT_LOCAL);
 # endif
        }
        else
@@ -3239,7 +3235,7 @@ set_bool_option(
            !has_vtp_working())
        {
            p_tgc = 0;
-           return N_(e_24_bit_colors_are_not_supported_on_this_environment);
+           return e_24_bit_colors_are_not_supported_on_this_environment;
        }
        if (is_term_win32())
            swap_tcap();
@@ -3287,7 +3283,7 @@ set_bool_option(
     if ((opt_flags & OPT_NO_REDRAW) == 0)
        check_redraw(options[opt_idx].flags);
 
-    return NULL;
+    return errmsg;
 }
 
 /*
@@ -4329,7 +4325,7 @@ is_crypt_key_option(int opt_idx)
  * Set the value of option "name".
  * Use "string" for string options, use "number" for other options.
  *
- * Returns NULL on success or error message on error.
+ * Returns NULL on success or an untranslated error message on error.
  */
     char *
 set_option_value(
@@ -4418,6 +4414,22 @@ set_option_value(
     return NULL;
 }
 
+/*
+ * Call set_option_value() and when an error is returned report it.
+ */
+    void
+set_option_value_give_err(
+    char_u     *name,
+    long       number,
+    char_u     *string,
+    int                opt_flags)      // OPT_LOCAL or 0 (both)
+{
+    char *errmsg = set_option_value(name, number, string, opt_flags);
+
+    if (errmsg != NULL)
+       emsg(_(errmsg));
+}
+
 /*
  * Get the terminal code for a terminal option.
  * Returns NULL when not found.
index 7f130ddf8752b38ff001006405550695c3a5fa8a..698a3f3f9b290aee3b46ebc60ebb5ccbe230c631 100644 (file)
@@ -484,7 +484,7 @@ set_string_option_direct_in_buf(
 /*
  * Set a string option to a new value, and handle the effects.
  *
- * Returns NULL on success or error message on error.
+ * Returns NULL on success or an untranslated error message on error.
  */
     char *
 set_string_option(
@@ -503,7 +503,7 @@ set_string_option(
     char_u     *saved_oldval_g = NULL;
     char_u     *saved_newval = NULL;
 #endif
-    char       *r = NULL;
+    char       *errmsg = NULL;
     int                value_checked = FALSE;
 
     if (is_hidden_option(opt_idx))     // don't set hidden option
@@ -542,13 +542,13 @@ set_string_option(
            saved_newval = vim_strsave(s);
        }
 #endif
-       if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
+       if ((errmsg = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
                                           opt_flags, &value_checked)) == NULL)
            did_set_option(opt_idx, opt_flags, TRUE, value_checked);
 
 #if defined(FEAT_EVAL)
        // call autocommand after handling side effects
-       if (r == NULL)
+       if (errmsg == NULL)
            trigger_optionsset_string(opt_idx, opt_flags,
                                   saved_oldval, saved_oldval_l,
                                   saved_oldval_g, saved_newval);
@@ -558,7 +558,7 @@ set_string_option(
        vim_free(saved_newval);
 #endif
     }
-    return r;
+    return errmsg;
 }
 
 /*
@@ -753,7 +753,7 @@ did_set_string_option(
     {
        if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
                     *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
-           errmsg = N_(e_backupext_and_patchmode_are_equal);
+           errmsg = e_backupext_and_patchmode_are_equal;
     }
 #ifdef FEAT_LINEBREAK
     // 'breakindentopt'
@@ -878,7 +878,7 @@ did_set_string_option(
        if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
            errmsg = e_invalid_argument;
        else if (set_chars_option(curwin, &p_fcs) != NULL)
-           errmsg = _(e_conflicts_with_value_of_fillchars);
+           errmsg = e_conflicts_with_value_of_fillchars;
        else
        {
            tabpage_T   *tp;
@@ -888,7 +888,7 @@ did_set_string_option(
            {
                if (set_chars_option(wp, &wp->w_p_lcs) != NULL)
                {
-                   errmsg = _(e_conflicts_with_value_of_listchars);
+                   errmsg = e_conflicts_with_value_of_listchars;
                    goto ambw_end;
                }
            }
@@ -1492,7 +1492,7 @@ ambw_end:
        for (s = *varp; *s; )
        {
            if (ptr2cells(s) != 1)
-               errmsg = N_(e_showbreak_contains_unprintable_or_wide_character);
+               errmsg = e_showbreak_contains_unprintable_or_wide_character;
            MB_PTR_ADV(s);
        }
     }
@@ -1534,7 +1534,7 @@ ambw_end:
                }
                else
 # endif
-                   errmsg = N_(e_invalid_fonts);
+                   errmsg = e_invalid_fonts;
            }
        }
        redraw_gui_only = TRUE;
@@ -1543,9 +1543,9 @@ ambw_end:
     else if (varp == &p_guifontset)
     {
        if (STRCMP(p_guifontset, "*") == 0)
-           errmsg = N_(e_cant_select_fontset);
+           errmsg = e_cant_select_fontset;
        else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
-           errmsg = N_(e_invalid_fontset);
+           errmsg = e_invalid_fontset;
        redraw_gui_only = TRUE;
     }
 # endif
index f05b7bd94d2f21630a1a7c4858aa22c9e4c05eb4..9a9bfab1a93525a75a73a0395fc96cc5ac5565af 100644 (file)
@@ -876,14 +876,16 @@ pum_set_selected(int n, int repeat UNUSED)
                    {
                        // Edit a new, empty buffer. Set options for a "wipeout"
                        // buffer.
-                       set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);
-                       set_option_value((char_u *)"bl", 0L, NULL, OPT_LOCAL);
-                       set_option_value((char_u *)"bt", 0L,
-                                              (char_u *)"nofile", OPT_LOCAL);
-                       set_option_value((char_u *)"bh", 0L,
-                                                (char_u *)"wipe", OPT_LOCAL);
-                       set_option_value((char_u *)"diff", 0L,
-                                                            NULL, OPT_LOCAL);
+                       set_option_value_give_err((char_u *)"swf",
+                                                         0L, NULL, OPT_LOCAL);
+                       set_option_value_give_err((char_u *)"bl",
+                                                         0L, NULL, OPT_LOCAL);
+                       set_option_value_give_err((char_u *)"bt",
+                                           0L, (char_u *)"nofile", OPT_LOCAL);
+                       set_option_value_give_err((char_u *)"bh",
+                                             0L, (char_u *)"wipe", OPT_LOCAL);
+                       set_option_value_give_err((char_u *)"diff",
+                                                         0L, NULL, OPT_LOCAL);
                    }
                }
                if (res == OK)
index 373a60ca0e4785852a07180c8015ad6808df0dbe..9425bc71d8af2e2b66b15176dad1d03ff35278f5 100644 (file)
@@ -38,6 +38,7 @@ int is_window_local_option(int opt_idx);
 int is_hidden_option(int opt_idx);
 int is_crypt_key_option(int opt_idx);
 char *set_option_value(char_u *name, long number, char_u *string, int opt_flags);
+void set_option_value_give_err(char_u *name, long number, char_u *string, int opt_flags);
 char_u *get_term_code(char_u *tname);
 char_u *get_highlight_default(void);
 char_u *get_encoding_default(void);
@@ -63,7 +64,7 @@ void reset_modifiable(void);
 void set_iminsert_global(void);
 void set_imsearch_global(void);
 void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags);
-int ExpandSettings(expand_T *xp, regmatch_T *regmatch, char_u *pat, int *numMatches, char_u ***matches);
+int ExpandSettings(expand_T *xp, regmatch_T *regmatch, char_u *fuzzystr, int *numMatches, char_u ***matches);
 int ExpandOldSetting(int *num_file, char_u ***file);
 int shortmess(int x);
 void vimrc_found(char_u *fname, char_u *envname);
index 0b44dca6dd3eff4effe34a3dd84653e4fcea3905..aab1683f329c6f17f0becb234199bc6a68db91bd 100644 (file)
@@ -4173,16 +4173,16 @@ qf_goto_cwindow(qf_info_T *qi, int resize, int sz, int vertsplit)
 qf_set_cwindow_options(void)
 {
     // switch off 'swapfile'
-    set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);
-    set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix",
-           OPT_LOCAL);
-    set_option_value((char_u *)"bh", 0L, (char_u *)"hide", OPT_LOCAL);
+    set_option_value_give_err((char_u *)"swf", 0L, NULL, OPT_LOCAL);
+    set_option_value_give_err((char_u *)"bt",
+                                         0L, (char_u *)"quickfix", OPT_LOCAL);
+    set_option_value_give_err((char_u *)"bh", 0L, (char_u *)"hide", OPT_LOCAL);
     RESET_BINDING(curwin);
 #ifdef FEAT_DIFF
     curwin->w_p_diff = FALSE;
 #endif
 #ifdef FEAT_FOLDING
-    set_option_value((char_u *)"fdm", 0L, (char_u *)"manual",
+    set_option_value_give_err((char_u *)"fdm", 0L, (char_u *)"manual",
            OPT_LOCAL);
 #endif
 }
@@ -4796,7 +4796,8 @@ qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int qf_winid)
        // This resembles reading a file into a buffer, it's more logical when
        // using autocommands.
        ++curbuf_lock;
-       set_option_value((char_u *)"ft", 0L, (char_u *)"qf", OPT_LOCAL);
+       set_option_value_give_err((char_u *)"ft",
+                                               0L, (char_u *)"qf", OPT_LOCAL);
        curbuf->b_p_ma = FALSE;
 
        keep_filetype = TRUE;           // don't detect 'filetype'
@@ -8312,7 +8313,7 @@ ex_helpgrep(exarg_T *eap)
        // Darn, some plugin changed the value.  If it's still empty it was
        // changed and restored, need to restore in the complicated way.
        if (*p_cpo == NUL)
-           set_option_value((char_u *)"cpo", 0L, save_cpo, 0);
+           set_option_value_give_err((char_u *)"cpo", 0L, save_cpo, 0);
        if (save_cpo_allocated)
            free_string_option(save_cpo);
     }
index 3dfb1c43cc0ea8c312b730375c3318ac626714ba..03c733d3548991745a079ae147802d4f6447e619 100644 (file)
@@ -783,7 +783,7 @@ add_pack_dir_to_rtp(char_u *fname)
        STRCAT(new_rtp, afterdir);
     }
 
-    set_option_value((char_u *)"rtp", 0L, new_rtp, 0);
+    set_option_value_give_err((char_u *)"rtp", 0L, new_rtp, 0);
     vim_free(new_rtp);
     retval = OK;
 
@@ -1758,7 +1758,8 @@ almosttheend:
                    }
                }
        }
-       set_option_value((char_u *)"cpo", 0L, si->sn_save_cpo, OPT_NO_REDRAW);
+       set_option_value_give_err((char_u *)"cpo",
+                                          0L, si->sn_save_cpo, OPT_NO_REDRAW);
     }
     VIM_CLEAR(si->sn_save_cpo);
 
index 5145ce198ef0ffc1103a48710c7bf42073a07686..0c1890472a9a61f040d617b33c8599708ecc8792 100644 (file)
@@ -1965,7 +1965,7 @@ count_syllables(slang_T *slang, char_u *word)
 
 /*
  * Parse 'spelllang' and set w_s->b_langp accordingly.
- * Returns NULL if it's OK, an error message otherwise.
+ * Returns NULL if it's OK, an untranslated error message otherwise.
  */
     char *
 did_set_spelllang(win_T *wp)
@@ -3834,8 +3834,8 @@ ex_spelldump(exarg_T *eap)
     do_cmdline_cmd((char_u *)"new");
 
     // enable spelling locally in the new window
-    set_option_value((char_u*)"spell", TRUE, (char_u*)"", OPT_LOCAL);
-    set_option_value((char_u*)"spl",  dummy, spl, OPT_LOCAL);
+    set_option_value_give_err((char_u*)"spell", TRUE, (char_u*)"", OPT_LOCAL);
+    set_option_value_give_err((char_u*)"spl",  dummy, spl, OPT_LOCAL);
     vim_free(spl);
 
     if (!BUFEMPTY())
index aaacb2e4483ba3f701c5ae4a99245beda06efe1a..22cf82da0872e58843b0884007a71ef69538da13 100644 (file)
@@ -6414,7 +6414,8 @@ init_spellfile(void)
                        fname != NULL
                          && strstr((char *)gettail(fname), ".ascii.") != NULL
                                       ? (char_u *)"ascii" : spell_enc());
-               set_option_value((char_u *)"spellfile", 0L, buf, OPT_LOCAL);
+               set_option_value_give_err((char_u *)"spellfile",
+                                                          0L, buf, OPT_LOCAL);
                break;
            }
            aspath = FALSE;
index 1c6aadc86404058cb7aae16ac4cd006e62ec69da..8f3ee600f0cad8ddebc39993a3f6f3256e88afd6 100644 (file)
@@ -2029,7 +2029,7 @@ set_termname(char_u *term)
 # endif
        if (p != NULL)
        {
-           set_option_value((char_u *)"ttym", 0L, p, 0);
+           set_option_value_give_err((char_u *)"ttym", 0L, p, 0);
            // Reset the WAS_SET flag, 'ttymouse' can be set to "sgr" or
            // "xterm2" in check_termcode().
            reset_option_was_set((char_u *)"ttym");
@@ -4605,7 +4605,7 @@ handle_u7_response(int *arg, char_u *tp UNUSED, int csi_len UNUSED)
            // Setting the option causes a screen redraw. Do
            // that right away if possible, keeping any
            // messages.
-           set_option_value((char_u *)"ambw", 0L, (char_u *)aw, 0);
+           set_option_value_give_err((char_u *)"ambw", 0L, (char_u *)aw, 0);
 # ifdef DEBUG_TERMRESPONSE
            {
                int r = redraw_asap(CLEAR);
@@ -4816,7 +4816,7 @@ handle_version_response(int first, int *arg, int argc, char_u *tp)
                && (term_props[TPR_MOUSE].tpr_status == TPR_MOUSE_XTERM2
                    || term_props[TPR_MOUSE].tpr_status == TPR_MOUSE_SGR))
        {
-           set_option_value((char_u *)"ttym", 0L,
+           set_option_value_give_err((char_u *)"ttym", 0L,
                    term_props[TPR_MOUSE].tpr_status == TPR_MOUSE_SGR
                                    ? (char_u *)"sgr" : (char_u *)"xterm2", 0);
        }
@@ -5140,8 +5140,8 @@ handle_osc(char_u *tp, char_u *argp, int len, char_u *key_name, int *slen)
                                      && STRCMP(p_bg, new_bg_val) != 0)
                        {
                            // value differs, apply it
-                           set_option_value((char_u *)"bg", 0L,
-                                             (char_u *)new_bg_val, 0);
+                           set_option_value_give_err((char_u *)"bg",
+                                                 0L, (char_u *)new_bg_val, 0);
                            reset_option_was_set((char_u *)"bg");
                            redraw_asap(CLEAR);
                        }
index 1a4f6d06438525bc6400ac683a40f0ff9c679d12..56efb448166eaad6ebb2b2a1d2d644c38c506023 100644 (file)
@@ -3693,7 +3693,7 @@ u_undofile_reset_and_delete(buf_T *buf)
        vim_free(file_name);
     }
 
-    set_option_value((char_u *)"undofile", 0L, NULL, OPT_LOCAL);
+    set_option_value_give_err((char_u *)"undofile", 0L, NULL, OPT_LOCAL);
 }
  #endif
 
index c622f778a6cda92c919b2e97b9d7c51ae3f9a0cd..97683b459acb2cb835b1d7b829ec6038a6586519 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4753,
 /**/
     4752,
 /**/
index 68b83884c03e8579fef993f3ee6cd6d40cac905b..4f0190e4127d26cf72a058fd245c48de3b5b4f85 100644 (file)
@@ -136,7 +136,8 @@ ex_vim9script(exarg_T *eap UNUSED)
     if (STRCMP(p_cpo, CPO_VIM) != 0)
     {
        si->sn_save_cpo = vim_strsave(p_cpo);
-       set_option_value((char_u *)"cpo", 0L, (char_u *)CPO_VIM, OPT_NO_REDRAW);
+       set_option_value_give_err((char_u *)"cpo",
+                                        0L, (char_u *)CPO_VIM, OPT_NO_REDRAW);
     }
 #else
     // No check for this being the first command, it doesn't matter.