diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2023-03-04 19:57:32 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-03-04 19:57:32 +0000 |
commit | 5284b23e148063648be0ff46c730ca574e3ca9fa (patch) | |
tree | ac68e9687c7415912f09db726e6ad8a670964164 /src | |
parent | c99cbf8f289bdda5d4a77d7ec415850a520330ba (diff) |
patch 9.0.1379: functions for handling options are not orderedv9.0.1379
Problem: Functions for handling options are not ordered.
Solution: Put functions in alphabetical order. (Yegappan Lakshmanan,
closes #12101)
Diffstat (limited to 'src')
-rw-r--r-- | src/option.c | 1858 | ||||
-rw-r--r-- | src/optiondefs.h | 4 | ||||
-rw-r--r-- | src/optionstr.c | 93 | ||||
-rw-r--r-- | src/proto/option.pro | 102 | ||||
-rw-r--r-- | src/proto/optionstr.pro | 1 | ||||
-rw-r--r-- | src/testdir/test_backspace_opt.vim | 28 | ||||
-rw-r--r-- | src/testdir/test_highlight.vim | 7 | ||||
-rw-r--r-- | src/testdir/test_python3.vim | 7 | ||||
-rw-r--r-- | src/version.c | 2 |
9 files changed, 1060 insertions, 1042 deletions
diff --git a/src/option.c b/src/option.c index 1203180fb6..743546798f 100644 --- a/src/option.c +++ b/src/option.c @@ -66,7 +66,6 @@ static void check_win_options(win_T *win); static void option_value2string(struct vimoption *, int scope); static void check_winopt(winopt_T *wop); static int wc_use_keyname(char_u *varp, long *wcp); -static void paste_option_changed(void); static void compatible_set(void); /* @@ -3111,147 +3110,130 @@ apply_optionset_autocmd( } #endif +#if defined(FEAT_ARABIC) || defined(PROTO) /* - * Process the updated 'compatible' option value. - */ - char * -did_set_compatible(optset_T *args UNUSED) -{ - compatible_set(); - return NULL; -} - -#if defined(FEAT_LANGMAP) || defined(PROTO) -/* - * Process the updated 'langremap' option value. - */ - char * -did_set_langremap(optset_T *args UNUSED) -{ - // 'langremap' -> !'langnoremap' - p_lnr = !p_lrm; - return NULL; -} - -/* - * Process the updated 'langnoremap' option value. + * Process the updated 'arabic' option value. */ char * -did_set_langnoremap(optset_T *args UNUSED) +did_set_arabic(optset_T *args UNUSED) { - // 'langnoremap' -> !'langremap' - p_lrm = !p_lnr; - return NULL; -} -#endif + char *errmsg = NULL; -#if defined(FEAT_PERSISTENT_UNDO) || defined(PROTO) -/* - * Process the updated 'undofile' option value. - */ - char * -did_set_undofile(optset_T *args) -{ - // Only take action when the option was set. - if (!curbuf->b_p_udf && !p_udf) - return NULL; + if (curwin->w_p_arab) + { + // 'arabic' is set, handle various sub-settings. + if (!p_tbidi) + { + // set rightleft mode + if (!curwin->w_p_rl) + { + curwin->w_p_rl = TRUE; + changed_window_setting(); + } - // When reset we do not delete the undo file, the option may be set again - // without making any changes in between. - char_u hash[UNDO_HASH_SIZE]; - buf_T *save_curbuf = curbuf; + // Enable Arabic shaping (major part of what Arabic requires) + if (!p_arshape) + { + p_arshape = TRUE; + redraw_later_clear(); + } + } - FOR_ALL_BUFFERS(curbuf) - { - // When 'undofile' is set globally: for every buffer, otherwise - // only for the current buffer: Try to read in the undofile, - // if one exists, the buffer wasn't changed and the buffer was - // loaded - if ((curbuf == save_curbuf - || (args->os_flags & OPT_GLOBAL) - || args->os_flags == 0) - && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL) + // Arabic requires a utf-8 encoding, inform the user if it's not + // set. + if (STRCMP(p_enc, "utf-8") != 0) { -#ifdef FEAT_CRYPT - if (crypt_get_method_nr(curbuf) == CRYPT_M_SOD) - continue; + static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"); + + msg_source(HL_ATTR(HLF_W)); + msg_attr(_(w_arabic), HL_ATTR(HLF_W)); +#ifdef FEAT_EVAL + set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1); #endif - u_compute_hash(hash); - u_read_undo(NULL, hash, curbuf->b_fname); } - } - curbuf = save_curbuf; - return NULL; -} -#endif + // set 'delcombine' + p_deco = TRUE; -/* - * Process the updated 'readonly' option value. - */ - char * -did_set_readonly(optset_T *args) -{ - // when 'readonly' is reset globally, also reset readonlymode - if (!curbuf->b_p_ro && (args->os_flags & OPT_LOCAL) == 0) - readonlymode = FALSE; +# ifdef FEAT_KEYMAP + // Force-set the necessary keymap for arabic + errmsg = set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic", + OPT_LOCAL); +# endif + } + else + { + // 'arabic' is reset, handle various sub-settings. + if (!p_tbidi) + { + // reset rightleft mode + if (curwin->w_p_rl) + { + curwin->w_p_rl = FALSE; + changed_window_setting(); + } - // when 'readonly' is set may give W10 again - if (curbuf->b_p_ro) - curbuf->b_did_warn = FALSE; + // 'arabicshape' isn't reset, it is a global option and + // another window may still need it "on". + } - redraw_titles(); + // 'delcombine' isn't reset, it is a global option and another + // window may still want it "on". - return NULL; +# ifdef FEAT_KEYMAP + // Revert to the default keymap + curbuf->b_p_iminsert = B_IMODE_NONE; + curbuf->b_p_imsearch = B_IMODE_USE_INSERT; +# endif + } + + return errmsg; } +#endif -#if defined(FEAT_GUI) || defined(PROTO) +#if defined(FEAT_AUTOCHDIR) || defined(PROTO) /* - * Process the updated 'mousehide' option value. + * Process the updated 'autochdir' option value. */ char * -did_set_mousehide(optset_T *args UNUSED) +did_set_autochdir(optset_T *args UNUSED) { - if (!p_mh) - gui_mch_mousehide(FALSE); + // Change directories when the 'acd' option is set now. + DO_AUTOCHDIR; return NULL; } #endif +#if defined(FEAT_BEVAL_GUI) || defined(PROTO) /* - * Process the updated 'modifiable' option value. + * Process the updated 'ballooneval' option value. */ char * -did_set_modifiable(optset_T *args UNUSED) +did_set_ballooneval(optset_T *args) { - // when 'modifiable' is changed, redraw the window title + if (balloonEvalForTerm) + return NULL; -# ifdef FEAT_TERMINAL - // Cannot set 'modifiable' when in Terminal mode. - if (curbuf->b_p_ma && (term_in_normal_mode() || (bt_terminal(curbuf) - && curbuf->b_term != NULL && !term_is_finished(curbuf)))) - { - curbuf->b_p_ma = FALSE; - args->os_doskip = TRUE; - return e_cannot_make_terminal_with_running_job_modifiable; - } -# endif - redraw_titles(); + if (p_beval && !args->os_oldval.boolean) + gui_mch_enable_beval_area(balloonEval); + else if (!p_beval && args->os_oldval.boolean) + gui_mch_disable_beval_area(balloonEval); return NULL; } +#endif +#if defined(FEAT_BEVAL_TERM) || defined(PROTO) /* - * Process the updated 'endoffile' or 'endofline' or 'fixendofline' or 'bomb' - * option value. + * Process the updated 'balloonevalterm' option value. */ char * -did_set_eof_eol_fixeol_bomb(optset_T *args UNUSED) +did_set_balloonevalterm(optset_T *args UNUSED) { - // redraw the window title and tab page text - redraw_titles(); + mch_bevalterm_changed(); return NULL; } +#endif /* * Process the updated 'binary' option value. @@ -3266,479 +3248,451 @@ did_set_binary(optset_T *args) return NULL; } +#if defined(FEAT_LINEBREAK) || defined(PROTO) /* - * Process the updated 'buflisted' option value. + * Called when the 'breakat' option changes value. */ char * -did_set_buflisted(optset_T *args) +did_set_breakat(optset_T *args UNUSED) { - // when 'buflisted' changes, trigger autocommands - if (args->os_oldval.boolean != curbuf->b_p_bl) - apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, - NULL, NULL, TRUE, curbuf); + char_u *p; + int i; + + for (i = 0; i < 256; i++) + breakat_flags[i] = FALSE; + + if (p_breakat != NULL) + for (p = p_breakat; *p; p++) + breakat_flags[*p] = TRUE; + return NULL; } +#endif /* - * Process the updated 'swapfile' option value. + * Process the updated 'buflisted' option value. */ char * -did_set_swapfile(optset_T *args UNUSED) +did_set_buflisted(optset_T *args) { - // when 'swf' is set, create swapfile, when reset remove swapfile - if (curbuf->b_p_swf && p_uc) - ml_open_file(curbuf); // create the swap file - else - // no need to reset curbuf->b_may_swap, ml_open_file() will check - // buf->b_p_swf - mf_close_file(curbuf, TRUE); // remove the swap file + // when 'buflisted' changes, trigger autocommands + if (args->os_oldval.boolean != curbuf->b_p_bl) + apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, + NULL, NULL, TRUE, curbuf); return NULL; } /* - * Process the updated 'terse' option value. + * Process the new 'cmdheight' option value. */ char * -did_set_terse(optset_T *args UNUSED) +did_set_cmdheight(optset_T *args) { - char_u *p; - - // when 'terse' is set change 'shortmess' - p = vim_strchr(p_shm, SHM_SEARCH); + long old_value = args->os_oldval.number; + char *errmsg = NULL; - // insert 's' in p_shm - if (p_terse && p == NULL) + // if p_ch changed value, change the command line height + if (p_ch < 1) { - STRCPY(IObuff, p_shm); - STRCAT(IObuff, "s"); - set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0); + errmsg = e_argument_must_be_positive; + p_ch = 1; } - // remove 's' from p_shm - else if (!p_terse && p != NULL) - STRMOVE(p, p + 1); - return NULL; + if (p_ch > Rows - min_rows() + 1) + p_ch = Rows - min_rows() + 1; + + // Only compute the new window layout when startup has been + // completed. Otherwise the frame sizes may be wrong. + if ((p_ch != old_value + || tabline_height() + topframe->fr_height != Rows - p_ch) + && full_screen +#ifdef FEAT_GUI + && !gui.starting +#endif + ) + command_height(); + + return errmsg; } /* - * Process the updated 'paste' option value. + * Process the updated 'compatible' option value. */ char * -did_set_paste(optset_T *args UNUSED) +did_set_compatible(optset_T *args UNUSED) { - // when 'paste' is set or reset also change other options - paste_option_changed(); + compatible_set(); return NULL; } +#if defined(FEAT_CONCEAL) || defined(PROTO) /* - * Process the updated 'insertmode' option value. + * Process the new 'conceallevel' option value. */ char * -did_set_insertmode(optset_T *args) +did_set_conceallevel(optset_T *args UNUSED) { - // when 'insertmode' is set from an autocommand need to do work here - if (p_im) + char *errmsg = NULL; + + if (curwin->w_p_cole < 0) { - if ((State & MODE_INSERT) == 0) - need_start_insertmode = TRUE; - stop_insert_mode = FALSE; + errmsg = e_argument_must_be_positive; + curwin->w_p_cole = 0; } - // only reset if it was set previously - else if (args->os_oldval.boolean) + else if (curwin->w_p_cole > 3) { - need_start_insertmode = FALSE; - stop_insert_mode = TRUE; - if (restart_edit != 0 && mode_displayed) - clear_cmdline = TRUE; // remove "(insert)" - restart_edit = 0; + errmsg = e_invalid_argument; + curwin->w_p_cole = 3; } - return NULL; + return errmsg; } +#endif +#if defined(FEAT_DIFF) || defined(PROTO) /* - * Process the updated 'ignorecase' option value. + * Process the updated 'diff' option value. */ char * -did_set_ignorecase(optset_T *args UNUSED) +did_set_diff(optset_T *args UNUSED) { - // when 'ignorecase' is set or reset and 'hlsearch' is set, redraw - if (p_hls) - redraw_all_later(UPD_SOME_VALID); + // May add or remove the buffer from the list of diff buffers. + diff_buf_adjust(curwin); +# ifdef FEAT_FOLDING + if (foldmethodIsDiff(curwin)) + foldUpdateAll(curwin); +# endif return NULL; } +#endif -#if defined(FEAT_SEARCH_EXTRA) || defined(PROTO) /* - * Process the updated 'hlsearch' option value. + * Process the updated 'endoffile' or 'endofline' or 'fixendofline' or 'bomb' + * option value. */ char * -did_set_hlsearch(optset_T *args UNUSED) +did_set_eof_eol_fixeol_bomb(optset_T *args UNUSED) { - // when 'hlsearch' is set or reset: reset no_hlsearch - set_no_hlsearch(FALSE); + // redraw the window title and tab page text + redraw_titles(); return NULL; } -#endif /* - * Process the updated 'scrollbind' option value. + * Process the updated 'equalalways' option value. */ char * -did_set_scrollbind(optset_T *args UNUSED) +did_set_equalalways(optset_T *args) { - // when 'scrollbind' is set: snapshot the current position to avoid a jump - // at the end of normal_cmd() - if (!curwin->w_p_scb) - return NULL; + if (p_ea && !args->os_oldval.boolean) + win_equal(curwin, FALSE, 0); - do_check_scrollbind(FALSE); - curwin->w_scbind_pos = curwin->w_topline; return NULL; } -#ifdef FEAT_QUICKFIX +#if defined(FEAT_FOLDING) || defined(PROTO) /* - * Process the updated 'previewwindow' option value. + * Process the new 'foldcolumn' option value. */ char * -did_set_previewwindow(optset_T *args) +did_set_foldcolumn(optset_T *args UNUSED) { - if (!curwin->w_p_pvw) - return NULL; - - // There can be only one window with 'previewwindow' set. - win_T *win; + char *errmsg = NULL; - FOR_ALL_WINDOWS(win) - if (win->w_p_pvw && win != curwin) - { - curwin->w_p_pvw = FALSE; - args->os_doskip = TRUE; - return e_preview_window_already_exists; - } + if (curwin->w_p_fdc < 0) + { + errmsg = e_argument_must_be_positive; + curwin->w_p_fdc = 0; + } + else if (curwin->w_p_fdc > 12) + { + errmsg = e_invalid_argument; + curwin->w_p_fdc = 12; + } - return NULL; + return errmsg; } -#endif /* - * Process the updated 'smoothscroll' option value. + * Process the new 'foldlevel' option value. */ char * -did_set_smoothscroll(optset_T *args UNUSED) +did_set_foldlevel(optset_T *args UNUSED) { - if (curwin->w_p_sms) - return NULL; - - curwin->w_skipcol = 0; - changed_line_abv_curs(); + if (curwin->w_p_fdl < 0) + curwin->w_p_fdl = 0; + newFoldLevel(); return NULL; } /* - * Process the updated 'textmode' option value. + * Process the new 'foldminlines' option value. */ char * -did_set_textmode(optset_T *args) +did_set_foldminlines(optset_T *args UNUSED) { - // when 'textmode' is set or reset also change 'fileformat' - set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, args->os_flags); - + foldUpdateAll(curwin); return NULL; } /* - * Process the updated 'textauto' option value. + * Process the new 'foldnestmax' option value. */ char * -did_set_textauto(optset_T *args) +did_set_foldnestmax(optset_T *args UNUSED) { - // when 'textauto' is set or reset also change 'fileformats' - set_string_option_direct((char_u *)"ffs", -1, - p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"", - OPT_FREE | args->os_flags, 0); - + if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin)) + foldUpdateAll(curwin); return NULL; } +#endif +#if defined(FEAT_SEARCH_EXTRA) || defined(PROTO) /* - * Process the updated 'lisp' option value. + * Process the updated 'hlsearch' option value. */ char * -did_set_lisp(optset_T *args UNUSED) +did_set_hlsearch(optset_T *args UNUSED) { - // When 'lisp' option changes include/exclude '-' in keyword characters. - (void)buf_init_chartab(curbuf, FALSE); // ignore errors + // when 'hlsearch' is set or reset: reset no_hlsearch + set_no_hlsearch(FALSE); return NULL; } +#endif /* - * Process the updated 'title' or the 'icon' option value. + * Process the updated 'ignorecase' option value. */ char * -did_set_title_icon(optset_T *args UNUSED) +did_set_ignorecase(optset_T *args UNUSED) { - // when 'title' changed, may need to change the title; same for 'icon' - did_set_title(); + // when 'ignorecase' is set or reset and 'hlsearch' is set, redraw + if (p_hls) + redraw_all_later(UPD_SOME_VALID); return NULL; } +#if defined(HAVE_INPUT_METHOD) || defined(PROTO) /* - * Process the updated 'modified' option value. + * Process the updated 'imdisable' option value. */ char * -did_set_modified(optset_T *args) +did_set_imdisable(optset_T *args UNUSED) { - if (!args->os_newval.boolean) - save_file_ff(curbuf); // Buffer is unchanged - redraw_titles(); - modified_was_set = args->os_newval.boolean; + // Only de-activate it here, it will be enabled when changing mode. + if (p_imdisable) + im_set_active(FALSE); + else if (State & MODE_INSERT) + // When the option is set from an autocommand, it may need to take + // effect right away. + im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); return NULL; } +#endif -#if defined(BACKSLASH_IN_FILENAME) || defined(PROTO) /* - * Process the updated 'shellslash' option value. + * Process the new 'iminsert' option value. */ char * -did_set_shellslash(optset_T *args UNUSED) +did_set_iminsert(optset_T *args UNUSED) { - if (p_ssl) - { - psepc = '/'; - psepcN = '\\'; - pseps[0] = '/'; - } - else + char *errmsg = NULL; + + if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST) { - psepc = '\\'; - psepcN = '/'; - pseps[0] = '\\'; + errmsg = e_invalid_argument; + curbuf->b_p_iminsert = B_IMODE_NONE; } + p_iminsert = curbuf->b_p_iminsert; + if (termcap_active) // don't do this in the alternate screen + showmode(); +#if defined(FEAT_KEYMAP) + // Show/unshow value of 'keymap' in status lines. + status_redraw_curbuf(); +#endif - // need to adjust the file name arguments and buffer names. - buflist_slash_adjust(); - alist_slash_adjust(); -# ifdef FEAT_EVAL - scriptnames_slash_adjust(); -# endif - return NULL; + return errmsg; } -#endif /* - * Process the updated 'wrap' option value. + * Process the new 'imsearch' option value. */ char * -did_set_wrap(optset_T *args UNUSED) +did_set_imsearch(optset_T *args UNUSED) { - // If 'wrap' is set, set w_leftcol to zero. - if (curwin->w_p_wrap) - curwin->w_leftcol = 0; - return NULL; + char *errmsg = NULL; + + if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST) + { + errmsg = e_invalid_argument; + curbuf->b_p_imsearch = B_IMODE_NONE; + } + p_imsearch = curbuf->b_p_imsearch; + + return errmsg; } +#if (defined(FEAT_XIM) && defined(FEAT_GUI_GTK)) || defined(PROTO) /* - * Process the updated 'equalalways' option value. + * Process the new 'imstyle' option value. */ char * -did_set_equalalways(optset_T *args) +did_set_imstyle(optset_T *args UNUSED) { - if (p_ea && !args->os_oldval.boolean) - win_equal(curwin, FALSE, 0); + char *errmsg = NULL; - return NULL; + if (p_imst != IM_ON_THE_SPOT && p_imst != IM_OVER_THE_SPOT) + errmsg = e_invalid_argument; + + return errmsg; } +#endif /* - * Process the updated 'weirdinvert' option value. + * Process the updated 'insertmode' option value. */ char * -did_set_weirdinvert(optset_T *args) +did_set_insertmode(optset_T *args) { - // When 'weirdinvert' changed, set/reset 't_xs'. - // Then set 'weirdinvert' according to value of 't_xs'. - if (p_wiv && !args->os_oldval.boolean) - T_XS = (char_u *)"y"; - else if (!p_wiv && args->os_oldval.boolean) - T_XS = empty_option; - p_wiv = (*T_XS != NUL); + // when 'insertmode' is set from an autocommand need to do work here + if (p_im) + { + if ((State & MODE_INSERT) == 0) + need_start_insertmode = TRUE; + stop_insert_mode = FALSE; + } + // only reset if it was set previously + else if (args->os_oldval.boolean) + { + need_start_insertmode = FALSE; + stop_insert_mode = TRUE; + if (restart_edit != 0 && mode_displayed) + clear_cmdline = TRUE; // remove "(insert)" + restart_edit = 0; + } return NULL; } -#if defined(FEAT_BEVAL_GUI) || defined(PROTO) +#if defined(FEAT_LANGMAP) || defined(PROTO) /* - * Process the updated 'ballooneval' option value. + * Process the updated 'langnoremap' option value. */ char * -did_set_ballooneval(optset_T *args) +did_set_langnoremap(optset_T *args UNUSED) { - if (balloonEvalForTerm) - return NULL; - - if (p_beval && !args->os_oldval.boolean) - gui_mch_enable_beval_area(balloonEval); - else if (!p_beval && args->os_oldval.boolean) - gui_mch_disable_beval_area(balloonEval); - + // 'langnoremap' -> !'langremap' + p_lrm = !p_lnr; return NULL; } -#endif -#if defined(FEAT_BEVAL_TERM) || defined(PROTO) /* - * Process the updated 'balloonevalterm' option value. + * Process the updated 'langremap' option value. */ char * -did_set_balloonevalterm(optset_T *args UNUSED) +did_set_langremap(optset_T *args UNUSED) { - mch_bevalterm_changed(); + // 'langremap' -> !'langnoremap' + p_lnr = !p_lrm; return NULL; } #endif -#if defined(FEAT_AUTOCHDIR) || defined(PROTO) /* - * Process the updated 'autochdir' option value. + * Process the new 'laststatus' option value. */ char * -did_set_autochdir(optset_T *args UNUSED) +did_set_laststatus(optset_T *args UNUSED) { - // Change directories when the 'acd' option is set now. - DO_AUTOCHDIR; + last_status(FALSE); // (re)set last window status line return NULL; } -#endif -#if defined(FEAT_DIFF) || defined(PROTO) +#if defined(FEAT_GUI) || defined(PROTO) /* - * Process the updated 'diff' option value. + * Process the new 'linespace' option value. */ char * -did_set_diff(optset_T *args UNUSED) +did_set_linespace(optset_T *args UNUSED) { - // May add or remove the buffer from the list of diff buffers. - diff_buf_adjust(curwin); -# ifdef FEAT_FOLDING - if (foldmethodIsDiff(curwin)) - foldUpdateAll(curwin); -# endif + // Recompute gui.char_height and resize the Vim window to keep the + // same number of lines. + if (gui.in_use && gui_mch_adjust_charheight() == OK) + gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); return NULL; } #endif -#if defined(HAVE_INPUT_METHOD) || defined(PROTO) /* - * Process the updated 'imdisable' option value. + * Process the updated 'lisp' option value. */ char * -did_set_imdisable(optset_T *args UNUSED) +did_set_lisp(optset_T *args UNUSED) { - // Only de-activate it here, it will be enabled when changing mode. - if (p_imdisable) - im_set_active(FALSE); - else if (State & MODE_INSERT) - // When the option is set from an autocommand, it may need to take - // effect right away. - im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); + // When 'lisp' option changes include/exclude '-' in keyword characters. + (void)buf_init_chartab(curbuf, FALSE); // ignore errors return NULL; } -#endif -#if defined(FEAT_SPELL) || defined(PROTO) /* - * Process the updated 'spell' option value. + * Process the new 'maxcombine' option value. */ char * -did_set_spell(optset_T *args UNUSED) +did_set_maxcombine(optset_T *args UNUSED) { - if (curwin->w_p_spell) - return parse_spelllang(curwin); - + if (p_mco > MAX_MCO) + p_mco = MAX_MCO; + else if (p_mco < 0) + p_mco = 0; + screenclear(); // will re-allocate the screen return NULL; } -#endif -#if defined(FEAT_ARABIC) || defined(PROTO) /* - * Process the updated 'arabic' option value. + * Process the updated 'modifiable' option value. */ char * -did_set_arabic(optset_T *args UNUSED) +did_set_modifiable(optset_T *args UNUSED) { - char *errmsg = NULL; + // when 'modifiable' is changed, redraw the window title - if (curwin->w_p_arab) +# ifdef FEAT_TERMINAL + // Cannot set 'modifiable' when in Terminal mode. + if (curbuf->b_p_ma && (term_in_normal_mode() || (bt_terminal(curbuf) + && curbuf->b_term != NULL && !term_is_finished(curbuf)))) { - // 'arabic' is set, handle various sub-settings. - if (!p_tbidi) - { - // set rightleft mode - if (!curwin->w_p_rl) - { - curwin->w_p_rl = TRUE; - changed_window_setting(); - } - - // Enable Arabic shaping (major part of what Arabic requires) - if (!p_arshape) - { - p_arshape = TRUE; - redraw_later_clear(); - } - } - - // Arabic requires a utf-8 encoding, inform the user if it's not - // set. - if (STRCMP(p_enc, "utf-8") != 0) - { - static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"); - - msg_source(HL_ATTR(HLF_W)); - msg_attr(_(w_arabic), HL_ATTR(HLF_W)); -#ifdef FEAT_EVAL - set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1); -#endif - } - - // set 'delcombine' - p_deco = TRUE; - -# ifdef FEAT_KEYMAP - // Force-set the necessary keymap for arabic - errmsg = set_option_value((char_u *)"keymap", - 0L, (char_u *)"arabic", OPT_LOCAL); -# endif + curbuf->b_p_ma = FALSE; + args->os_doskip = TRUE; + return e_cannot_make_terminal_with_running_job_modifiable; } - else - { - // 'arabic' is reset, handle various sub-settings. - if (!p_tbidi) - { - // reset rightleft mode - if (curwin->w_p_rl) - { - curwin->w_p_rl = FALSE; - changed_window_setting(); - } - - // 'arabicshape' isn't reset, it is a global option and - // another window may still need it "on". - } +# endif + redraw_titles(); - // 'delcombine' isn't reset, it is a global option and another - // window may still want it "on". + return NULL; +} -# ifdef FEAT_KEYMAP - // Revert to the default keymap - curbuf->b_p_iminsert = B_IMODE_NONE; - curbuf->b_p_imsearch = B_IMODE_USE_INSERT; -# endif - } +/* + * Process the updated 'modified' option value. + */ + char * +did_set_modified(optset_T *args) +{ + if (!args->os_newval.boolean) + save_file_ff(curbuf); // Buffer is unchanged + redraw_titles(); + modified_was_set = args->os_newval.boolean; + return NULL; +} - return errmsg; +#if defined(FEAT_GUI) || defined(PROTO) +/* + * Process the updated 'mousehide' option value. + */ + char * +did_set_mousehide(optset_T *args UNUSED) +{ + if (!p_mh) + gui_mch_mousehide(FALSE); + return NULL; } #endif @@ -3766,332 +3720,289 @@ did_set_number_relativenumber(optset_T *args UNUSED) return NULL; } -#ifdef FEAT_TERMGUICOLORS +#if defined(FEAT_LINEBREAK) || defined(PROTO) +/* + * Process the new 'numberwidth' option value. + */ char * -did_set_termguicolors(optset_T *args UNUSED) +did_set_numberwidth(optset_T *args UNUSED) { -# ifdef FEAT_VTP - // Do not turn on 'tgc' when 24-bit colors are not supported. - if ( -# ifdef VIMDLL - !gui.in_use && !gui.starting && -# endif - !has_vtp_working()) + char *errmsg = NULL; + + // 'numberwidth' must be positive + if (curwin->w_p_nuw < 1) { - p_tgc = 0; - args->os_doskip = TRUE; - return e_24_bit_colors_are_not_supported_on_this_environment; + errmsg = e_argument_must_be_positive; + curwin->w_p_nuw = 1; } - if (is_term_win32()) - swap_tcap(); -# endif -# ifdef FEAT_GUI - if (!gui.in_use && !gui.starting) -# endif - highlight_gui_started(); -# ifdef FEAT_VTP - // reset t_Co - if (is_term_win32()) + if (curwin->w_p_nuw > 20) { - control_console_color_rgb(); - set_termname(T_NAME); - init_highlight(TRUE, FALSE); + errmsg = e_invalid_argument; + curwin->w_p_nuw = 20; } -# endif -# ifdef FEAT_TERMINAL - term_update_colors_all(); - term_update_palette_all(); - term_update_wincolor_all(); -# endif + curwin->w_nrwidth_line_count = 0; // trigger a redraw - return NULL; + return errmsg; } #endif /* - * Set the value of a boolean option, and take care of side effects. - * Returns NULL for success, or an error message for an error. + * Process the updated 'paste' option value. Called after p_paste was set or + * reset. When 'paste' is set or reset also change other options. */ - static char * -set_bool_option( - int opt_idx, // index in options[] table - char_u *varp, // pointer to the option variable - int value, // new value - int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL + char * +did_set_paste(optset_T *args UNUSED) { - int old_value = *(int *)varp; -#if defined(FEAT_EVAL) - int old_global_value = 0; + static int old_p_paste = FALSE; + static int save_sm = 0; + static int save_sta = 0; + static int save_ru = 0; +#ifdef FEAT_RIGHTLEFT + static int save_ri = 0; + static int save_hkmap = 0; #endif - char *errmsg = NULL; + buf_T *buf; - // Disallow changing some options from secure mode - if ((secure -#ifdef HAVE_SANDBOX - || sandbox != 0 + if (p_paste) + { + // Paste switched from off to on. + // Save the current values, so they can be restored later. + if (!old_p_paste) + { + // save options for each buffer + FOR_ALL_BUFFERS(buf) + { + buf->b_p_tw_nopaste = buf->b_p_tw; + buf->b_p_wm_nopaste = buf->b_p_wm; + buf->b_p_sts_nopaste = buf->b_p_sts; + buf->b_p_ai_nopaste = buf->b_p_ai; + buf->b_p_et_nopaste = buf->b_p_et; +#ifdef FEAT_VARTABS + if (buf->b_p_vsts_nopaste) + vim_free(buf->b_p_vsts_nopaste); + buf->b_p_vsts_nopaste = + buf->b_p_vsts && buf->b_p_vsts != empty_option + ? vim_strsave(buf->b_p_vsts) : NULL; #endif - ) && (options[opt_idx].flags & P_SECURE)) - return e_not_allowed_here; + } -#if defined(FEAT_EVAL) - // Save the global value before changing anything. This is needed as for - // a global-only option setting the "local value" in fact sets the global - // value (since there is only one value). - if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) - old_global_value = *(int *)get_varp_scope(&(options[opt_idx]), - OPT_GLOBAL); + // save global options + save_sm = p_sm; + save_sta = p_sta; + save_ru = p_ru; +#ifdef FEAT_RIGHTLEFT + save_ri = p_ri; + save_hkmap = p_hkmap; #endif - - *(int *)varp = value; // set the new value -#ifdef FEAT_EVAL - // Remember where the option was set. - set_option_sctx_idx(opt_idx, opt_flags, current_sctx); + // save global values for local buffer options + p_ai_nopaste = p_ai; + p_et_nopaste = p_et; + p_sts_nopaste = p_sts; + p_tw_nopaste = p_tw; + p_wm_nopaste = p_wm; +#ifdef FEAT_VARTABS + if (p_vsts_nopaste) + vim_free(p_vsts_nopaste); + p_vsts_nopaste = p_vsts && p_vsts != empty_option + ? vim_strsave(p_vsts) : NULL; #endif + } -#ifdef FEAT_GUI - need_mouse_correct = TRUE; + // Always set the option values, also when 'paste' is set when it is + // already on. Set options for each buffer. + FOR_ALL_BUFFERS(buf) + { + buf->b_p_tw = 0; // textwidth is 0 + buf->b_p_wm = 0; // wrapmargin is 0 + buf->b_p_sts = 0; // softtabstop is 0 + buf->b_p_ai = 0; / |