forked from aniani/vim
patch 8.2.4753: error from setting an option is silently ignored
Problem: Error from setting an option is silently ignored. Solution: Handle option value errors better. Fix uses of N_().
This commit is contained in:
parent
5dc294a7b6
commit
31e5c60a68
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
26
src/main.c
26
src/main.c
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -314,13 +314,13 @@ main(int argc, char **argv)
|
||||
params.argv = argv;
|
||||
common_init(¶ms);
|
||||
|
||||
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();
|
||||
|
58
src/option.c
58
src/option.c
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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())
|
||||
|
@ -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;
|
||||
|
10
src/term.c
10
src/term.c
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -746,6 +746,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
4753,
|
||||
/**/
|
||||
4752,
|
||||
/**/
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user