From 5e3cb7e8699f855193179a8cb799d1087f4a2ac9 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 27 Feb 2006 23:58:35 +0000 Subject: updated for version 7.0209 --- src/diff.c | 10 +- src/edit.c | 41 ++++- src/eval.c | 58 ++++-- src/ex_cmds.c | 10 +- src/ex_docmd.c | 5 +- src/fileio.c | 20 +-- src/globals.h | 3 - src/gui.c | 20 +-- src/main.c | 8 +- src/mbyte.c | 8 +- src/misc1.c | 6 + src/misc2.c | 8 +- src/option.c | 479 ++++++++++++++++++++++++++++++-------------------- src/option.h | 187 ++++++++++++++++++++ src/os_riscos.c | 2 +- src/os_vms.c | 43 +++-- src/proto/option.pro | 2 +- src/quickfix.c | 7 +- src/screen.c | 21 +-- src/structs.h | 9 + src/syntax.c | 12 +- src/term.c | 13 +- src/testdir/test51.ok | 5 + src/version.h | 4 +- src/vim.h | 1 + 25 files changed, 641 insertions(+), 341 deletions(-) (limited to 'src') diff --git a/src/diff.c b/src/diff.c index d5cb97c4e..82be8b9ae 100644 --- a/src/diff.c +++ b/src/diff.c @@ -1083,10 +1083,7 @@ diff_win_options(wp, addbuf) curwin = wp; curbuf = curwin->w_buffer; set_string_option_direct((char_u *)"fdm", -1, (char_u *)"diff", - OPT_LOCAL|OPT_FREE); -# ifdef FEAT_EVAL - set_option_scriptID((char_u *)"fdm", current_SID); -# endif + OPT_LOCAL|OPT_FREE, 0); curwin = old_curwin; curbuf = curwin->w_buffer; wp->w_p_fdc = 2; @@ -1133,10 +1130,7 @@ ex_diffoff(eap) curwin = wp; curbuf = curwin->w_buffer; set_string_option_direct((char_u *)"fdm", -1, - (char_u *)"manual", OPT_LOCAL|OPT_FREE); -# ifdef FEAT_EVAL - set_option_scriptID((char_u *)"fdm", current_SID); -# endif + (char_u *)"manual", OPT_LOCAL|OPT_FREE, 0); curwin = old_curwin; curbuf = curwin->w_buffer; wp->w_p_fdc = 0; diff --git a/src/edit.c b/src/edit.c index bfd27cec2..25a10be2a 100644 --- a/src/edit.c +++ b/src/edit.c @@ -136,6 +136,7 @@ static void ins_compl_free __ARGS((void)); static void ins_compl_clear __ARGS((void)); static int ins_compl_bs __ARGS((void)); static void ins_compl_addleader __ARGS((int c)); +static void ins_compl_set_original_text __ARGS((char_u *str)); static void ins_compl_addfrommatch __ARGS((void)); static int ins_compl_prep __ARGS((int c)); static buf_T *ins_compl_next_buf __ARGS((buf_T *buf, int flag)); @@ -1387,7 +1388,7 @@ ins_redraw(ready) if (!char_avail()) { #ifdef FEAT_AUTOCMD - /* Trigger CursorMoved if the cursor moved. */ + /* Trigger CursorMoved if the cursor moved. */ if (ready && has_cursormovedI() && !equalpos(last_cursormoved, curwin->w_cursor)) { @@ -2109,11 +2110,8 @@ ins_compl_add(str, len, icase, fname, extra, cdir, flags) return FAIL; match->cp_number = -1; if (flags & ORIGINAL_TEXT) - { match->cp_number = 0; - match->cp_str = compl_orig_text; - } - else if ((match->cp_str = vim_strnsave(str, len)) == NULL) + if ((match->cp_str = vim_strnsave(str, len)) == NULL) { vim_free(match); return FAIL; @@ -2818,7 +2816,9 @@ ins_compl_bs() ins_compl_delete(); ins_bytes(compl_leader + curwin->w_cursor.col - compl_col); - if (!compl_started) + if (compl_started) + ins_compl_set_original_text(compl_leader); + else { /* Matches were cleared, need to search for them now. */ if (ins_complete(Ctrl_N) == FAIL) @@ -2872,6 +2872,28 @@ ins_compl_addleader(c) ins_compl_del_pum(); ins_compl_show_pum(); compl_used_match = FALSE; + ins_compl_set_original_text(compl_leader); + } +} + +/* + * Set the first match, the original text. + */ + static void +ins_compl_set_original_text(str) + char_u *str; +{ + char_u *p; + + /* Replace the original text entry. */ + if (compl_first_match->cp_flags & ORIGINAL_TEXT) /* safety check */ + { + p = vim_strsave(str); + if (p != NULL) + { + vim_free(compl_first_match->cp_str); + compl_first_match->cp_str = p; + } } } @@ -4328,9 +4350,8 @@ ins_complete(c) else edit_submode = (char_u *)_(CTRL_X_MSG(ctrl_x_mode)); - /* Always add completion for the original text. Note that - * "compl_orig_text" itself (not a copy) is added, it will be freed - * when the list of matches is freed. */ + /* Always add completion for the original text. */ + vim_free(compl_orig_text); compl_orig_text = vim_strnsave(line + compl_col, compl_length); if (compl_orig_text == NULL || ins_compl_add(compl_orig_text, -1, FALSE, NULL, NULL, 0, ORIGINAL_TEXT) != OK) @@ -5779,6 +5800,8 @@ free_last_insert() { vim_free(last_insert); last_insert = NULL; + vim_free(compl_orig_text); + compl_orig_text = NULL; } #endif diff --git a/src/eval.c b/src/eval.c index 9f79560b4..ee5f0c9e7 100644 --- a/src/eval.c +++ b/src/eval.c @@ -11731,6 +11731,7 @@ find_some_match(argvars, rettv, type) char_u *save_cpo; long start = 0; long nth = 1; + colnr_T startcol = 0; int match = 0; list_T *l = NULL; listitem_T *li = NULL; @@ -11811,12 +11812,12 @@ find_some_match(argvars, rettv, type) break; } vim_free(tofree); - str = echo_string(&li->li_tv, &tofree, strbuf,0); + str = echo_string(&li->li_tv, &tofree, strbuf, 0); if (str == NULL) break; } - match = vim_regexec_nl(®match, str, (colnr_T)0); + match = vim_regexec_nl(®match, str, (colnr_T)startcol); if (match && --nth <= 0) break; @@ -11832,9 +11833,10 @@ find_some_match(argvars, rettv, type) else { #ifdef FEAT_MBYTE - str = regmatch.startp[0] + (*mb_ptr2len)(regmatch.startp[0]); + startcol = regmatch.startp[0] + + (*mb_ptr2len)(regmatch.startp[0]) - str; #else - str = regmatch.startp[0] + 1; + startcol = regmatch.startp[0] + 1 - str; #endif } } @@ -17400,6 +17402,7 @@ ex_function(eap) hashtab_T *ht; int todo; hashitem_T *hi; + int sourcing_lnum_off; /* * ":function" without argument: list functions. @@ -17522,6 +17525,8 @@ ex_function(eap) list_func_head(fp, TRUE); for (j = 0; j < fp->uf_lines.ga_len && !got_int; ++j) { + if (FUNCLINE(fp, j) == NULL) + continue; msg_putchar('\n'); msg_outnum((long)(j + 1)); if (j < 9) @@ -17693,6 +17698,8 @@ ex_function(eap) { msg_scroll = TRUE; need_wait_return = FALSE; + sourcing_lnum_off = sourcing_lnum; + if (line_arg != NULL) { /* Use eap->arg, split up in parts by line breaks. */ @@ -17718,6 +17725,12 @@ ex_function(eap) goto erret; } + /* Detect line continuation: sourcing_lnum increased more than one. */ + if (sourcing_lnum > sourcing_lnum_off + 1) + sourcing_lnum_off = sourcing_lnum - sourcing_lnum_off - 1; + else + sourcing_lnum_off = 0; + if (skip_until != NULL) { /* between ":append" and "." and between ":python < 0) + ((char_u **)(newlines.ga_data))[newlines.ga_len++] = NULL; /* Check for end of eap->arg. */ if (line_arg != NULL && *line_arg == NUL) @@ -18362,6 +18379,8 @@ func_dump_profile(fd) for (i = 0; i < fp->uf_lines.ga_len; ++i) { + if (FUNCLINE(fp, i) == NULL) + continue; prof_func_line(fd, fp->uf_tml_count[i], &fp->uf_tml_total[i], &fp->uf_tml_self[i], TRUE); fprintf(fd, "%s\n", FUNCLINE(fp, i)); @@ -19270,18 +19289,26 @@ get_func_line(c, cookie, indent) #endif gap = &fp->uf_lines; - if ((fp->uf_flags & FC_ABORT) && did_emsg && !aborted_in_try()) - retval = NULL; - else if (fcp->returned || fcp->linenr >= gap->ga_len) + if (((fp->uf_flags & FC_ABORT) && did_emsg && !aborted_in_try()) + || fcp->returned) retval = NULL; else { - retval = vim_strsave(((char_u **)(gap->ga_data))[fcp->linenr++]); - sourcing_lnum = fcp->linenr; + /* Skip NULL lines (continuation lines). */ + while (fcp->linenr < gap->ga_len + && ((char_u **)(gap->ga_data))[fcp->linenr] == NULL) + ++fcp->linenr; + if (fcp->linenr >= gap->ga_len) + retval = NULL; + else + { + retval = vim_strsave(((char_u **)(gap->ga_data))[fcp->linenr++]); + sourcing_lnum = fcp->linenr; #ifdef FEAT_PROFILE - if (do_profiling) - func_line_start(cookie); + if (do_profiling) + func_line_start(cookie); #endif + } } /* Did we encounter a breakpoint? */ @@ -19315,6 +19342,9 @@ func_line_start(cookie) && sourcing_lnum <= fp->uf_lines.ga_len) { fp->uf_tml_idx = sourcing_lnum - 1; + /* Skip continuation lines. */ + while (fp->uf_tml_idx > 0 && FUNCLINE(fp, fp->uf_tml_idx) == NULL) + --fp->uf_tml_idx; fp->uf_tml_execed = FALSE; profile_start(&fp->uf_tml_start); profile_zero(&fp->uf_tml_children); diff --git a/src/ex_cmds.c b/src/ex_cmds.c index fa8cb2ce6..71766b910 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -3265,10 +3265,7 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags) curbuf->b_help = TRUE; #ifdef FEAT_QUICKFIX set_string_option_direct((char_u *)"buftype", -1, - (char_u *)"help", OPT_FREE|OPT_LOCAL); -# ifdef FEAT_EVAL - set_option_scriptID((char_u *)"buftype", current_SID); -# endif + (char_u *)"help", OPT_FREE|OPT_LOCAL, 0); #endif /* @@ -3287,10 +3284,7 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags) if (STRCMP(curbuf->b_p_isk, p) != 0) { set_string_option_direct((char_u *)"isk", -1, p, - OPT_FREE|OPT_LOCAL); -# ifdef FEAT_EVAL - set_option_scriptID((char_u *)"isk", current_SID); -# endif + OPT_FREE|OPT_LOCAL, 0); check_buf_options(curbuf); (void)buf_init_chartab(curbuf, FALSE); } diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 743cc7737..97cb91c41 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -1825,7 +1825,7 @@ do_one_cmd(cmdlinep, sourcing, * existing option value, we restore it later. */ cmdmod.save_ei = vim_strsave(p_ei); set_string_option_direct((char_u *)"ei", -1, - (char_u *)"all", OPT_FREE); + (char_u *)"all", OPT_FREE, SID_NONE); } #endif continue; @@ -2649,7 +2649,8 @@ doend: if (cmdmod.save_ei != NULL) { /* Restore 'eventignore' to the value before ":noautocmd". */ - set_string_option_direct((char_u *)"ei", -1, cmdmod.save_ei, OPT_FREE); + set_string_option_direct((char_u *)"ei", -1, cmdmod.save_ei, + OPT_FREE, SID_NONE); free_string_option(cmdmod.save_ei); } #endif diff --git a/src/fileio.c b/src/fileio.c index 60c62d579..c3ff07c47 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -583,13 +583,8 @@ readfile(fname, sfname, from, lines_to_skip, lines_to_read, eap, flags) /* set forced 'fileencoding' */ fenc = enc_canonize(eap->cmd + eap->force_enc); if (fenc != NULL) - { set_string_option_direct((char_u *)"fenc", -1, - fenc, OPT_FREE|OPT_LOCAL); -# ifdef FEAT_EVAL - set_option_scriptID((char_u *)"fenc", current_SID); -# endif - } + fenc, OPT_FREE|OPT_LOCAL, 0); vim_free(fenc); } #endif @@ -2113,13 +2108,8 @@ failed: #ifdef FEAT_MBYTE /* If editing a new file: set 'fenc' for the current buffer. */ if (newfile) - { set_string_option_direct((char_u *)"fenc", -1, fenc, - OPT_FREE|OPT_LOCAL); -# ifdef FEAT_EVAL - set_option_scriptID((char_u *)"fenc", current_SID); -# endif - } + OPT_FREE|OPT_LOCAL, 0); if (fenc_alloced) vim_free(fenc); # ifdef USE_ICONV @@ -7503,7 +7493,8 @@ au_event_disable(what) if (new_ei != NULL) { STRCAT(new_ei, what); - set_string_option_direct((char_u *)"ei", -1, new_ei, OPT_FREE); + set_string_option_direct((char_u *)"ei", -1, new_ei, + OPT_FREE, SID_NONE); vim_free(new_ei); } } @@ -7516,7 +7507,8 @@ au_event_restore(old_ei) { if (old_ei != NULL) { - set_string_option_direct((char_u *)"ei", -1, old_ei, OPT_FREE); + set_string_option_direct((char_u *)"ei", -1, old_ei, + OPT_FREE, SID_NONE); vim_free(old_ei); } } diff --git a/src/globals.h b/src/globals.h index e77e08ffd..f13b369eb 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1472,10 +1472,7 @@ EXTERN char_u e_invexprmsg[] INIT(= N_("E449: Invalid expression received")); EXTERN char_u e_guarded[] INIT(= N_("E463: Region is guarded, cannot modify")); EXTERN char_u e_nbreadonly[] INIT(= N_("E744: NetBeans does not allow changes in read-only files")); #endif -#if defined(FEAT_INS_EXPAND) || defined(FEAT_EVAL) || defined(FEAT_SYN_HL) \ - || defined(FEAT_WINDOWS) EXTERN char_u e_intern2[] INIT(= N_("E685: Internal error: %s")); -#endif EXTERN char_u e_maxmempat[] INIT(= N_("E363: pattern uses more memory than 'maxmempattern'")); EXTERN char_u e_emptybuf[] INIT(= N_("E749: empty buffer")); diff --git a/src/gui.c b/src/gui.c index 88d97a326..7b6e38bdb 100644 --- a/src/gui.c +++ b/src/gui.c @@ -346,7 +346,7 @@ gui_init() */ if (!option_was_set((char_u *)"mouse")) set_string_option_direct((char_u *)"mouse", -1, - (char_u *)"a", OPT_FREE); + (char_u *)"a", OPT_FREE, SID_NONE); /* * If -U option given, use only the initializations from that file and @@ -788,10 +788,7 @@ set_guifontwide(name) gui_mch_free_font(gui.wide_font); gui.wide_font = font; set_string_option_direct((char_u *)"gfw", -1, - wide_name, OPT_FREE); -# ifdef FEAT_EVAL - set_option_scriptID((char_u *)"gfw", current_SID); -# endif + wide_name, OPT_FREE, 0); } } break; @@ -3387,13 +3384,8 @@ get_tabline_label(tp) STRCPY(NameBuff, res); if (called_emsg) - { set_string_option_direct((char_u *)"guitablabel", -1, - (char_u *)"", OPT_FREE); -# ifdef FEAT_EVAL - set_option_scriptID((char_u *)"guitablabel", SID_ERROR); -# endif - } + (char_u *)"", OPT_FREE, SID_ERROR); called_emsg |= save_called_emsg; } else @@ -4809,7 +4801,11 @@ gui_do_findrepl(flags, find_text, repl_text, down) if (type == FRD_REPLACEALL) { ga_concat(&ga, (char_u *)"/"); - concat_esc(&ga, repl_text, '/'); /* escape slashes */ + /* escape / and \ */ + p = vim_strsave_escaped(repl_text, (char_u *)"/\\"); + if (p != NULL) + ga_concat(&ga, p); + vim_free(p); ga_concat(&ga, (char_u *)"/g"); } ga_append(&ga, NUL); diff --git a/src/main.c b/src/main.c index 413ca1f5c..1a16f443c 100644 --- a/src/main.c +++ b/src/main.c @@ -635,13 +635,8 @@ main if (params.edit_type == EDIT_QF) { if (params.use_ef != NULL) - { set_string_option_direct((char_u *)"ef", -1, - params.use_ef, OPT_FREE); -# ifdef FEAT_EVAL - set_option_scriptID((char_u *)"ef", SID_CARG); -# endif - } + params.use_ef, OPT_FREE, SID_CARG); if (qf_init(NULL, p_ef, p_efm, TRUE) < 0) { out_char('\n'); @@ -1010,7 +1005,6 @@ main_loop(cmdwin, noexmode) /* Trigger CursorMoved if the cursor moved. */ if (!finish_op && has_cursormoved() && !equalpos(last_cursormoved, curwin->w_cursor)) - { apply_autocmds(EVENT_CURSORMOVED, NULL, NULL, FALSE, curbuf); last_cursormoved = curwin->w_cursor; diff --git a/src/mbyte.c b/src/mbyte.c index 323f1a007..062d5842f 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -731,13 +731,9 @@ codepage_invalid: /* When using Unicode, set default for 'fileencodings'. */ if (enc_utf8 && !option_was_set((char_u *)"fencs")) - { set_string_option_direct((char_u *)"fencs", -1, - (char_u *)"ucs-bom,utf-8,default,latin1", OPT_FREE); -# ifdef FEAT_EVAL - set_option_scriptID((char_u *)"fencs", current_SID); -# endif - } + (char_u *)"ucs-bom,utf-8,default,latin1", OPT_FREE, 0); + #if defined(HAVE_BIND_TEXTDOMAIN_CODESET) && defined(FEAT_GETTEXT) /* GNU gettext 0.10.37 supports this feature: set the codeset used for * translated messages independently from the current locale. */ diff --git a/src/misc1.c b/src/misc1.c index 09b9ab1dc..c9deb85fe 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -2833,6 +2833,12 @@ changed_common(lnum, col, lnume, xtra) * since it notices b_mod_set and then uses b_mod_*. */ if (must_redraw < VALID) must_redraw = VALID; + +#ifdef FEAT_AUTOCMD + /* when the cursor line is changed always trigger CursorMoved */ + if (lnum <= curwin->w_cursor.lnum && lnume > curwin->w_cursor.lnum) + last_cursormoved.lnum = 0; +#endif } /* diff --git a/src/misc2.c b/src/misc2.c index 9a2f06d01..dddbc5fb0 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -2793,13 +2793,9 @@ set_fileformat(t, opt_flags) break; } if (p != NULL) - { set_string_option_direct((char_u *)"ff", -1, (char_u *)p, - OPT_FREE | opt_flags); -# ifdef FEAT_EVAL - set_option_scriptID((char_u *)"ff", current_SID); -# endif - } + OPT_FREE | opt_flags, 0); + #ifdef FEAT_WINDOWS /* This may cause the buffer to become (un)modified. */ check_status(curbuf); diff --git a/src/option.c b/src/option.c index 4d575ab21..e67586bbf 100644 --- a/src/option.c +++ b/src/option.c @@ -45,142 +45,193 @@ #define PV_BOTH 0x1000 #define PV_WIN 0x2000 #define PV_BUF 0x4000 +#define PV_MASK 0x0fff #define OPT_WIN(x) (idopt_T)(PV_WIN + (int)(x)) #define OPT_BUF(x) (idopt_T)(PV_BUF + (int)(x)) #define OPT_BOTH(x) (idopt_T)(PV_BOTH + (int)(x)) /* - * "indir" values for buffer-local opions + * Definition of the PV_ values for buffer-local options. + * The BV_ values are defined in option.h. */ -enum -{ - BV_AI = 0 - , BV_AR -#if defined(FEAT_QUICKFIX) - , BV_BH -#endif - , BV_BIN - , BV_BL - , BV_COUNT /* must be the last one */ -}; - #define PV_AI OPT_BUF(BV_AI) #define PV_AR OPT_BOTH(OPT_BUF(BV_AR)) -#if defined(FEAT_QUICKFIX) +#ifdef FEAT_QUICKFIX # define PV_BH OPT_BUF(BV_BH) +# define PV_BT OPT_BUF(BV_BT) +# define PV_EFM OPT_BOTH(OPT_BUF(BV_EFM)) +# define PV_GP OPT_BOTH(OPT_BUF(BV_GP)) +# define PV_MP OPT_BOTH(OPT_BUF(BV_MP)) #endif #define PV_BIN OPT_BUF(BV_BIN) #define PV_BL OPT_BUF(BV_BL) +#ifdef FEAT_MBYTE +# define PV_BOMB OPT_BUF(BV_BOMB) +#endif +#define PV_CI OPT_BUF(BV_CI) +#ifdef FEAT_CINDENT +# define PV_CIN OPT_BUF(BV_CIN) +# define PV_CINK OPT_BUF(BV_CINK) +# define PV_CINO OPT_BUF(BV_CINO) +#endif +#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) +# define PV_CINW OPT_BUF(BV_CINW) +#endif +#ifdef FEAT_FOLDING +# define PV_CMS OPT_BUF(BV_CMS) +#endif +#ifdef FEAT_COMMENTS +# define PV_COM OPT_BUF(BV_COM) +#endif +#ifdef FEAT_INS_EXPAND +# define PV_CPT OPT_BUF(BV_CPT) +# define PV_DICT OPT_BOTH(OPT_BUF(BV_DICT)) +# define PV_TSR OPT_BOTH(OPT_BUF(BV_TSR)) +#endif +#ifdef FEAT_COMPL_FUNC +# define PV_CFU OPT_BUF(BV_CFU) +#endif +#ifdef FEAT_FIND_ID +# define PV_DEF OPT_BOTH(OPT_BUF(BV_DEF)) +# define PV_INC OPT_BOTH(OPT_BUF(BV_INC)) +#endif +#define PV_EOL OPT_BUF(BV_EOL) +#define PV_EP OPT_BOTH(OPT_BUF(BV_EP)) +#define PV_ET OPT_BUF(BV_ET) +#ifdef FEAT_MBYTE +# define PV_FENC OPT_BUF(BV_FENC) +#endif +#ifdef FEAT_EVAL +# define PV_FEX OPT_BUF(BV_FEX) +#endif +#define PV_FF OPT_BUF(BV_FF) +#define PV_FLP OPT_BUF(BV_FLP) +#define PV_FO OPT_BUF(BV_FO) +#ifdef FEAT_AUTOCMD +# define PV_FT OPT_BUF(BV_FT) +#endif +#define PV_IMI OPT_BUF(BV_IMI) +#define PV_IMS OPT_BUF(BV_IMS) +#if defined(FEAT_CINDENT) && defined(FEAT_EVAL) +# define PV_INDE OPT_BUF(BV_INDE) +# define PV_INDK OPT_BUF(BV_INDK) +#endif +#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) +# define PV_INEX OPT_BUF(BV_INEX) +#endif +#define PV_INF OPT_BUF(BV_INF) +#define PV_ISK OPT_BUF(BV_ISK) +#ifdef FEAT_CRYPT +# define PV_KEY OPT_BUF(BV_KEY) +#endif +#ifdef FEAT_KEYMAP +# define PV_KMAP OPT_BUF(BV_KMAP) +#endif +#define PV_KP OPT_BOTH(OPT_BUF(BV_KP)) +#ifdef FEAT_LISP +# define PV_LISP OPT_BUF(BV_LISP) +#endif +#define PV_MA OPT_BUF(BV_MA) +#define PV_ML OPT_BUF(BV_ML) +#define PV_MOD OPT_BUF(BV_MOD) +#define PV_MPS OPT_BUF(BV_MPS) +#define PV_NF OPT_BUF(BV_NF) +#ifdef FEAT_OSFILETYPE +# define PV_OFT OPT_BUF(BV_OFT) +#endif +#ifdef FEAT_COMPL_FUNC +# define PV_OFU OPT_BUF(BV_OFU) +#endif +#define PV_PATH OPT_BOTH(OPT_BUF(BV_PATH)) +#define PV_PI OPT_BUF(BV_PI) +#ifdef FEAT_TEXTOBJ +# define PV_QE OPT_BUF(BV_QE) +#endif +#define PV_RO OPT_BUF(BV_RO) +#ifdef FEAT_SMARTINDENT +# define PV_SI OPT_BUF(BV_SI) +#endif +#ifndef SHORT_FNAME +# define PV_SN OPT_BUF(BV_SN) +#endif +#ifdef FEAT_SYN_HL +# define PV_SMC OPT_BUF(BV_SMC) +# define PV_SPC OPT_BUF(BV_SPC) +# define PV_SPF OPT_BUF(BV_SPF) +# define PV_SPL OPT_BUF(BV_SPL) +# define PV_SYN OPT_BUF(BV_SYN) +#endif +#define PV_STS OPT_BUF(BV_STS) +#ifdef FEAT_SEARCHPATH +# define PV_SUA OPT_BUF(BV_SUA) +#endif +#define PV_SW OPT_BUF(BV_SW) +#define PV_SWF OPT_BUF(BV_SWF) +#define PV_TAGS OPT_BOTH(OPT_BUF(BV_TAGS)) +#define PV_TS OPT_BUF(BV_TS) +#define PV_TW OPT_BUF(BV_TW) +#define PV_TX OPT_BUF(BV_TX) +#define PV_WM OPT_BUF(BV_WM) /* - * "indir" values for window-local options + * Definition of the PV_ values for window-local options. + * The WV_ values are defined in option.h. */ -enum -{ - WV_LIST = 0 -#ifdef FEAT_ARABIC - , WV_ARAB -#endif - , WV_COUNT /* must be the last one */ -}; - #define PV_LIST OPT_WIN(WV_LIST) #ifdef FEAT_ARABIC # define PV_ARAB OPT_WIN(WV_ARAB) #endif +#ifdef FEAT_DIFF +# define PV_DIFF OPT_WIN(WV_DIFF) +#endif +#ifdef FEAT_FOLDING +# define PV_FDC OPT_WIN(WV_FDC) +# define PV_FEN OPT_WIN(WV_FEN) +# define PV_FDI OPT_WIN(WV_FDI) +# define PV_FDL OPT_WIN(WV_FDL) +# define PV_FDM OPT_WIN(WV_FDM) +# define PV_FML OPT_WIN(WV_FML) +# define PV_FDN OPT_WIN(WV_FDN) +# ifdef FEAT_EVAL +# define PV_FDE OPT_WIN(WV_FDE) +# define PV_FDT OPT_WIN(WV_FDT) +# endif +# define PV_FMR OPT_WIN(WV_FMR) +#endif +#ifdef FEAT_LINEBREAK +# define PV_LBR OPT_WIN(WV_LBR) +#endif +#define PV_NU OPT_WIN(WV_NU) +#ifdef FEAT_LINEBREAK +# define PV_NUW OPT_WIN(WV_NUW) +#endif +#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) +# define PV_PVW OPT_WIN(WV_PVW) +#endif +#ifdef FEAT_RIGHTLEFT +# define PV_RL OPT_WIN(WV_RL) +# define PV_RLC OPT_WIN(WV_RLC) +#endif +#ifdef FEAT_SCROLLBIND +# define PV_SCBIND OPT_WIN(WV_SCBIND) +#endif +#define PV_SCROLL OPT_WIN(WV_SCROLL) +#ifdef FEAT_SYN_HL +# define PV_SPELL OPT_WIN(WV_SPELL) +#endif +#ifdef FEAT_STL_OPT +# define PV_STL OPT_BOTH(OPT_WIN(WV_STL)) +#endif +#ifdef FEAT_WINDOWS +# define PV_WFH OPT_WIN(WV_WFH) +#endif +#define PV_WRAP OPT_WIN(WV_WRAP) -/* TODO: "indir" values for the rest */ + +/* WV_ and BV_ values get typecasted to this for the "indir" field */ typedef enum { PV_NONE = 0 - , PV_BOMB - , PV_BT - , PV_CI - , PV_CIN - , PV_CINK - , PV_CINO - , PV_CINW - , PV_CMS - , PV_COM - , PV_CPT - , PV_CFU - , PV_DEF - , PV_DICT - , PV_DIFF - , PV_EFM - , PV_EOL - , PV_EP - , PV_ET - , PV_FDC - , PV_FDE - , PV_FDI - , PV_FDL - , PV_FDM - , PV_FDN - , PV_FDT - , PV_FEN - , PV_FENC - , PV_FEX - , PV_FF - , PV_FML - , PV_FMR - , PV_FLP - , PV_FO - , PV_FT - , PV_GP - , PV_IMI - , PV_IMS - , PV_INC - , PV_INDE - , PV_INDK - , PV_INEX - , PV_INF - , PV_ISK - , PV_KEY - , PV_KMAP - , PV_KP - , PV_LBR - , PV_LISP - , PV_MA - , PV_ML - , PV_MOD - , PV_MP - , PV_MPS - , PV_NF - , PV_NU - , PV_NUW - , PV_OFT - , PV_OFU - , PV_PATH - , PV_PI - , PV_PVW - , PV_QE - , PV_RL - , PV_RLC - , PV_RO - , PV_SCBIND - , PV_SCROLL - , PV_SI - , PV_SN - , PV_SPELL - , PV_SPC - , PV_SPF - , PV_SPL - , PV_STL - , PV_STS - , PV_SUA - , PV_SW - , PV_SWF - , PV_SMC - , PV_SYN - , PV_TAGS - , PV_TS - , PV_TSR - , PV_TW - , PV_TX - , PV_WFH - , PV_WM - , PV_WRAP } idopt_T; /* @@ -784,7 +835,7 @@ static struct vimoption {(char_u *)"", (char_u *)0L}}, {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF, #ifdef FEAT_FIND_ID - (char_u *)&p_def, OPT_BOTH(PV_DEF), + (char_u *)&p_def, PV_DEF, {(char_u *)"^\\s*#\\s*define", (char_u *)0L} #else (char_u *)NULL, PV_NONE, @@ -801,7 +852,7 @@ static struct vimoption }, {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, #ifdef FEAT_INS_EXPAND - (char_u *)&p_dict, OPT_BOTH(PV_DICT), + (char_u *)&p_dict, PV_DICT, #else (char_u *)NULL, PV_NONE, #endif @@ -872,7 +923,7 @@ static struct vimoption (char_u *)&p_ea, PV_NONE, {(char_u *)TRUE, (char_u *)0L}}, {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, - (char_u *)&p_ep, OPT_BOTH(PV_EP), + (char_u *)&p_ep, PV_EP, {(char_u *)"", (char_u *)0L}}, {"errorbells", "eb", P_BOOL|P_VI_DEF, (char_u *)&p_eb, PV_NONE, @@ -888,7 +939,7 @@ static struct vimoption }, {"errorformat", "efm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, #ifdef FEAT_QUICKFIX - (char_u *)&p_efm, OPT_BOTH(PV_EFM), + (char_u *)&p_efm, PV_EFM, {(char_u *)DFLT_EFM, (char_u *)0L}, #else (char_u *)NULL, PV_NONE, @@ -1019,7 +1070,7 @@ static struct vimoption }, #endif {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM, -#if defined(FEAT_EVAL) +#ifdef FEAT_EVAL (char_u *)&p_fex, PV_FEX, {(char_u *)"", (char_u *)0L} #else @@ -1062,7 +1113,7 @@ static struct vimoption }, {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, #ifdef FEAT_QUICKFIX - (char_u *)&p_gp, OPT_BOTH(PV_GP), + (char_u *)&p_gp, PV_GP, { # ifdef WIN3264 /* may be changed to "grep -n" in os_win32.c */ @@ -1274,7 +1325,7 @@ static struct vimoption }, {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF, #ifdef FEAT_FIND_ID - (char_u *)&p_inc, OPT_BOTH(PV_INC), + (char_u *)&p_inc, PV_INC, {(char_u *)"^\\s*#\\s*include", (char_u *)0L} #else (char_u *)NULL, PV_NONE, @@ -1421,7 +1472,7 @@ static struct vimoption #endif {(char_u *)"", (char_u *)0L}}, {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, - (char_u *)&p_kp, OPT_BOTH(PV_KP), + (char_u *)&p_kp, PV_KP, { #if defined(MSDOS) || defined(MSWIN) (char_u *)":help", @@ -1534,7 +1585,7 @@ static struct vimoption }, {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, #ifdef FEAT_QUICKFIX - (char_u *)&p_mp, OPT_BOTH(PV_MP), + (char_u *)&p_mp, PV_MP, # ifdef VMS {(char_u *)"MMS", (char_u *)0L} # else @@ -1724,7 +1775,7 @@ static struct vimoption (char_u *)&p_pm, PV_NONE, {(char_u *)"", (char_u *)0L}}, {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, - (char_u *)&p_path, OPT_BOTH(PV_PATH), + (char_u *)&p_path, PV_PATH, { #if defined AMIGA || defined MSDOS || defined MSWIN (char_u *)".,,", @@ -2192,7 +2243,7 @@ static struct vimoption {(char_u *)TRUE, (char_u *)0L}}, {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT, #ifdef FEAT_STL_OPT - (char_u *)&p_stl, OPT_BOTH(PV_STL), + (char_u *)&p_stl, PV_STL, #else (char_u *)NULL, PV_NONE, #endif @@ -2202,7 +2253,7 @@ static struct vimoption {(char_u *)".bak,~,.o,.h,.info,.swp,.obj", (char_u *)0L}}, {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_COMMA|P_NODUP, -#if defined(FEAT_SEARCHPATH) +#ifdef FEAT_SEARCHPATH (char_u *)&p_sua, PV_SUA, {(char_u *)"", (char_u *)0L} #else @@ -2262,7 +2313,7 @@ static struct vimoption (char_u *)&p_tr, PV_NONE, {(char_u *)FALSE, (char_u *)TRUE}}, {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, - (char_u *)&p_tags, OPT_BOTH(PV_TAGS), + (char_u *)&p_tags, PV_TAGS, { #if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME) (char_u *)"./tags,./TAGS,tags,TAGS", @@ -2312,7 +2363,7 @@ static struct vimoption {(char_u *)0L, (char_u *)0L}}, {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, #ifdef FEAT_INS_EXPAND - (char_u *)&p_tsr, OPT_BOTH(PV_TSR), + (char_u *)&p_tsr, PV_TSR, #else (char_u *)NULL, PV_NONE, #endif @@ -2531,7 +2582,7 @@ static struct vimoption #endif {(char_u *)1L, (char_u *)0L}}, {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT, -#if defined(FEAT_WINDOWS) +#ifdef FEAT_WINDOWS (char_u *)VAR_WIN, PV_WFH, #else (char_u *)NULL, PV_NONE, @@ -2737,6 +2788,9 @@ static char_u *check_clipboard_option __ARGS((void)); #ifdef FEAT_SYN_HL static char_u *compile_cap_prog __ARGS((buf_T *buf)); #endif +#ifdef FEAT_EVAL +static void set_option_scriptID_idx __ARGS((int opt_idx, int opt_flags, int id)); +#endif static char_u *set_bool_option __ARGS((int opt_idx, char_u *varp, int value, int opt_flags)); static char_u *set_num_option __ARGS((int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags)); static void check_redraw __ARGS((long_u flags)); @@ -3139,7 +3193,7 @@ set_init_1() { /* Adjust the default for 'isprint' to match latin1. */ set_string_option_direct((char_u *)"isp", -1, - (char_u *)"@,161-255", OPT_FREE); + (char_u *)"@,161-255", OPT_FREE, SID_NONE); (void)init_chartab(); } #endif @@ -3211,7 +3265,7 @@ set_option_default(opt_idx, opt_flags, compatible) * freeing and allocating the value. */ if (options[opt_idx].indir != PV_NONE) set_string_option_direct(NULL, opt_idx, - options[opt_idx].def_val[dvi], opt_flags); + options[opt_idx].def_val[dvi], opt_flags, 0); else { if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED)) @@ -3249,8 +3303,7 @@ set_option_default(opt_idx, opt_flags, compatible) } #ifdef FEAT_EVAL - /* Remember where the option was set. */ - options[opt_idx].scriptID = current_SID; + set_option_scriptID_idx(opt_idx, opt_flags, current_SID); #endif } @@ -3381,7 +3434,7 @@ set_init_2() idx = findoption((char_u *)"bg"); if (!(options[idx].flags & P_WAS_SET) && *term_bg_default() == 'd') { - set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE); + set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0); /* don't mark it as set, when starting the GUI it may be * changed again */ options[idx].flags &= ~P_WAS_SET; @@ -3966,7 +4019,17 @@ do_set(arg, opt_flags) showoneopt(&options[opt_idx], opt_flags); #ifdef FEAT_EVAL if (p_verbose > 0) - last_set_msg(options[opt_idx].scriptID); + { + /* Mention where the option was last set. */ + if (varp == options[opt_idx].var) + last_set_msg(options[opt_idx].scriptID); + else if ((int)options[opt_idx].indir & PV_WIN) + last_set_msg(curwin->w_p_scriptID[ + (int)options[opt_idx].indir & PV_MASK]); + else if ((int)options[opt_idx].indir & PV_BUF) + last_set_msg(curbuf->b_p_scriptID[ + (int)options[opt_idx].indir & PV_MASK]); + } #endif } else @@ -5010,19 +5073,19 @@ insecure_flag(opt_idx, opt_flags) switch ((int)options[opt_idx].indir) { #ifdef FEAT_STL_OPT - case OPT_BOTH(PV_STL): return &curwin->w_p_stl_flags; + case PV_STL: return &curwin->w_p_stl_flags; #endif #ifdef FEAT_EVAL - case PV_FDE: return &curwin->w_p_fde_flags; - case PV_FDT: return &curwin->w_p_fdt_flags; + case PV_FDE: return &curwin->w_p_fde_flags; + case PV_FDT: return &curwin->w_p_fdt_flags; #endif #if defined(FEAT_EVAL) # if defined(FEAT_CINDENT) - case PV_INDE: return &curbuf->b_p_inde_flags; + case PV_INDE: return &curbuf->b_p_inde_flags; # endif - case PV_FEX: return &curbuf->b_p_fex_flags; + case PV_FEX: return &curbuf->b_p_fex_flags; # ifdef FEAT_FIND_ID - case PV_INEX: return &curbuf->b_p_inex_flags; + case PV_INEX: return &curbuf->b_p_inex_flags; # endif #endif } @@ -5036,13 +5099,17 @@ insecure_flag(opt_idx, opt_flags) * Set a string option to a new value (without checking the effect). * The string is copied into allocated memory. * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used. + * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is + * SID_NONE don't set the scriptID. Otherwose set the scriptID to "set_sid". */ +/*ARGSUSED*/ void -set_string_option_direct(name, opt_idx, val, opt_flags) +set_string_option_direct(name, opt_idx, val, opt_flags, set_sid) char_u *name; int opt_idx; char_u *val; int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ + int set_sid; { char_u *s; char_u **varp; @@ -5052,7 +5119,10 @@ set_string_option_direct(name, opt_idx, val, opt_flags) { opt_idx = findoption(name); if (opt_idx == -1) /* not found (should not happen) */ + { + EMSG2(_(e_intern2), "set_string_option_direct()"); return; + } } if (options[opt_idx].var == NULL) /* can't set hidden option */ @@ -5080,6 +5150,11 @@ set_string_option_direct(name, opt_idx, val, opt_flags) free_string_option(*varp); *varp = empty_option; } +# ifdef FEAT_EVAL + if (set_sid != SID_NONE) + set_option_scriptID_idx(opt_idx, opt_flags, + set_sid == 0 ? current_SID : set_sid); +# endif } } @@ -6376,7 +6451,7 @@ did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf, { #ifdef FEAT_EVAL /* Remember where the option was set. */ - options[opt_idx].scriptID = current_SID; + set_option_scriptID_idx(opt_idx, opt_flags, current_SID); #endif /* * Free string options that are in allocated memory. @@ -6761,19 +6836,29 @@ compile_cap_prog(buf) #if defined(FEAT_EVAL) || defined(PROTO) /* - * Set the script ID of option "name" to "id". + * Set the scriptID for an option, taking care of setting the buffer- or + * window-local value. */ - void -set_option_scriptID(name, id) - char_u *name; - int id; + static void +set_option_scriptID_idx(opt_idx, opt_flags, id) + int opt_idx; + int opt_flags; + int id; { - int opt_idx = findoption(name); + int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; + int indir = (int)options[opt_idx].indir; - if (opt_idx == -1) /* not found (should not happen) */ - EMSG2(_(e_intern2), "set_option_scriptID()"); - else + /* Remember where the option was set. For local options need to do that + * in the buffer or window structure. */ + if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0) options[opt_idx].scriptID = id; + if (both || (opt_flags & OPT_LOCAL)) + { + if (indir & PV_BUF) + curbuf->b_p_scriptID[indir & PV_MASK] = id; + else if (indir & PV_WIN) + curwin->w_p_scriptID[indir & PV_MASK] = id; + } } #endif @@ -6801,7 +6886,7 @@ set_bool_option(opt_idx, varp, value, opt_flags) *(int *)varp = value; /* set the new value */ #ifdef FEAT_EVAL /* Remember where the option was set. */ - options[opt_idx].scriptID = current_SID; + set_option_scriptID_idx(opt_idx, opt_flags, current_SID); #endif #ifdef FEAT_GUI @@ -6885,10 +6970,7 @@ set_bool_option(opt_idx, varp, value, opt_flags) { STRCPY(IObuff, p_shm); STRCAT(IObuff, "s"); - set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE); -# ifdef FEAT_EVAL - set_option_scriptID((char_u *)"shm", current_SID); -# endif + set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0); } /* remove 's' from p_shm */ else if (!p_terse && p != NULL) @@ -6970,14 +7052,9 @@ set_bool_option(opt_idx, varp, value, opt_flags) /* when 'textauto' is set or reset also change 'fileformats' */ else if ((int *)varp == &p_ta) - { set_string_option_direct((char_u *)"ffs", -1, p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"", - OPT_FREE | opt_flags); -# ifdef FEAT_EVAL - set_option_scriptID((char_u *)"ffs", current_SID); -# endif - } + OPT_FREE | opt_flags, 0); /* * When 'lisp' option changes include/exclude '-' in @@ -7313,7 +7390,7 @@ set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags) *pp = value; #ifdef FEAT_EVAL /* Remember where the option was set. */ - options[opt_idx].scriptID = current_SID; + set_option_scriptID_idx(opt_idx, opt_flags, current_SID); #endif #ifdef FEAT_GUI need_mouse_correct = TRUE; @@ -8297,23 +8374,39 @@ makeset(fd, opt_flags, local_only) } else /* P_STRING */ { +#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD) + int do_endif = FALSE; + /* Don't set 'syntax' and 'filetype' again if the value is * already right, avoids reloading the syntax file. */ - if (p->indir == PV_SYN || p->indir == PV_FT) + if ( +# if defined(FEAT_SYN_HL) + p->indir == PV_SYN +# if defined(FEAT_AUTOCMD) + || +# endif +# endif +# if defined(FEAT_AUTOCMD) + p->indir == PV_FT) +# endif { if (fprintf(fd, "if &%s != '%s'", p->fullname, *(char_u **)(varp)) < 0 || put_eol(fd) < 0) return FAIL; + do_endif = TRUE; } +#endif if (put_setstring(fd, cmd, p->fullname, (char_u **)varp, (p->flags & P_EXPAND) != 0) == FAIL) return FAIL; - if (p->indir == PV_SYN || p->indir == PV_FT) +#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD) + if (do_endif) { if (put_line(fd, "endif") == FAIL) return FAIL; } +#endif } } } @@ -8583,25 +8676,25 @@ get_varp_scope(p, opt_flags) switch ((int)p->indir) { #ifdef FEAT_QUICKFIX - case OPT_BOTH(PV_GP): return (char_u *)&(curbuf->b_p_gp); - case OPT_BOTH(PV_MP): return (char_u *)&(curbuf->b_p_mp); - case OPT_BOTH(PV_EFM): return (char_u *)&(curbuf->b_p_efm); + case PV_EFM: return (char_u *)&(curbuf->b_p_efm); + case PV_GP: return (char_u *)&(curbuf->b_p_gp); + case PV_MP: return (char_u *)&(curbuf->b_p_mp); #endif - case OPT_BOTH(PV_EP): return (char_u *)&(curbuf->b_p_ep); - case OPT_BOTH(PV_KP): return (char_u *)&(curbuf->b_p_kp); - case OPT_BOTH(PV_PATH): return (char_u *)&(curbuf->b_p_path); + case PV_EP: return (char_u *)&(curbuf->b_p_ep); + case PV_KP: return (char_u *)&(curbuf->b_p_kp); + case PV_PATH: return (char_u *)&(curbuf->b_p_path); case PV_AR: return (char_u *)&(curbuf->b_p_ar); - case OPT_BOTH(PV_TAGS): return (char_u *)&(curbuf->b_p_tags); + case PV_TAGS: return (char_u *)&(curbuf->b_p_tags); #ifdef FEAT_FIND_ID - case OPT_BOTH(PV_DEF): return (char_u *)&(curbuf->b_p_def); - case OPT_BOTH(PV_INC): return (char_u *)&(curbuf->b_p_inc); + case PV_DEF: return (char_u *)&(curbuf->b_p_def); + case PV_INC: return (char_u *)&(curbuf->b_p_inc); #endif #ifdef FEAT_INS_EXPAND - case OPT_BOTH(PV_DICT): return (char_u *)&(curbuf->b_p_dict); - case OPT_BOTH(PV_TSR): return (char_u *)&(curbuf->b_p_tsr); + case PV_DICT: return (char_u *)&(curbuf->b_p_dict); + case PV_TSR: return (char_u *)&(curbuf->b_p_tsr); #endif #ifdef FEAT_STL_OPT - case OPT_BOTH(PV_STL): return (char_u *)&(curwin->w_p_stl); + case PV_STL: return (char_u *)&(curwin->w_p_stl); #endif } return NULL; /* "cannot happen" */ @@ -8625,38 +8718,38 @@ get_varp(p) case PV_NONE: return p->var; /* global option with local value: use local value if it's been set */ - case OPT_BOTH(PV_EP): return *curbuf->b_p_ep != NUL + case PV_EP: return *curbuf->b_p_ep != NUL ? (char_u *)&curbuf->b_p_ep : p->var; - case OPT_BOTH(PV_KP): return *curbuf->b_p_kp != NUL + case PV_KP: return *curbuf->b_p_kp != NUL ? (char_u *)&curbuf->b_p_kp : p->var; - case OPT_BOTH(PV_PATH): return *curbuf->b_p_path != NUL + case PV_PATH: return *curbuf->b_p_path != NUL ? (char_u *)&(curbuf->b_p_path) : p->var; case PV_AR: return curbuf->b_p_ar >= 0 ? (char_u *)&(curbuf->b_p_ar) : p->var; - case OPT_BOTH(PV_TAGS): return *curbuf->b_p_tags != NUL + case PV_TAGS: return *curbuf->b_p_tags != NUL ? (char_u *)&(curbuf->b_p_tags) : p->var; #ifdef FEAT_FIND_ID - case OPT_BOTH(PV_DEF): return *curbuf->b_p_def != NUL + case PV_DEF: return *curbuf->b_p_def != NUL ? (char_u *)&(curbuf->b_p_def) : p->var; - case OPT_BOTH(PV_INC): return *curbuf->b_p_inc != NUL + case PV_INC: return *curbuf->b_p_inc != NUL ? (char_u *)&(curbuf->b_p_inc) : p->var; #endif #ifdef FEAT_INS_EXPAND - case OPT_BOTH(PV_DICT): return *curbuf->b_p_dict != NUL + case PV_DICT: return *curbuf->b_p_dict != NUL ? (char_u *)&(curbuf->b_p_dict) : p->var; - case OPT_BOTH(PV_TSR): return *curbuf->b_p_tsr != NUL + case PV_TSR: return *curbuf->b_p_tsr != NUL ? (char_u *)&(curbuf->b_p_tsr) : p->var; #endif #ifdef FEAT_QUICKFIX - case OPT_BOTH(PV_GP): return *curbuf->b_p_gp != NUL + case PV_EFM: return *curbuf->b_p_efm != NUL + ? (char_u *)&(curbuf->b_p_efm) : p->var; + case PV_GP: return *curbuf->b_p_gp != NUL ? (char_u *)&(curbuf->b_p_gp) : p->var; - case OPT_BOTH(PV_MP): return *curbuf->b_p_mp != NUL + case PV_MP: return *curbuf->b_p_mp != NUL ? (char_u *)&(curbuf->b_p_mp) : p->var; - case OPT_BOTH(PV_EFM): return *curbuf->b_p_efm != NUL - ? (char_u *)&(curbuf->b_p_efm) : p->var; #endif #ifdef FEAT_STL_OPT - case OPT_BOTH(PV_STL): return *curwin->w_p_stl != NUL + case PV_STL: return *curwin->w_p_stl != NUL ? (char_u *)&(curwin->w_p_stl) : p->var; #endif @@ -8688,7 +8781,7 @@ get_varp(p) #ifdef FEAT_LINEBREAK case PV_NUW: return (char_u *)&(curwin->w_p_nuw); #endif -#if defined(FEAT_WINDOWS) +#ifdef FEAT_WINDOWS case PV_WFH: return (char_u *)&(curwin->w_p_wfh); #endif #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) @@ -8763,7 +8856,7 @@ get_varp(p) case PV_INDE: return (char_u *)&(curbuf->b_p_inde); case PV_INDK: return (char_u *)&(curbuf->b_p_indk); #endif -#if defined(FEAT_EVAL) +#ifdef FEAT_EVAL case PV_FEX: return (char_u *)&(curbuf->b_p_fex); #endif #ifdef FEAT_CRYPT @@ -8798,10 +8891,10 @@ get_varp(p) case PV_SWF: return (char_u *)&(curbuf->b_p_swf); #ifdef FEAT_SYN_HL case PV_SMC: return (char_u *)&(curbuf->b_p_smc); - case PV_SYN: return (char_u *)&(curbuf->b_p_syn); case PV_SPC: return (char_u *)&(curbuf->b_p_spc); case PV_SPF: return (char_u *)&(curbuf->b_p_spf); case PV_SPL: return (char_u *)&(curbuf->b_p_spl); + case PV_SYN: return (char_u *)&(curbuf->b_p_syn); #endif case PV_SW: return (char_u *)&(curbuf->b_p_sw); case PV_TS: return (char_u *)&(curbuf->b_p_ts); diff --git a/src/option.h b/src/option.h index 4aeacd513..7f70b1509 100644 --- a/src/option.h +++ b/src/option.h @@ -850,3 +850,190 @@ EXTERN int p_write; /* 'write' */ EXTERN int p_wa; /* 'writeany' */ EXTERN int p_wb; /* 'writebackup' */ EXTERN long p_wd; /* 'writedelay' */ + +/* + * "indir" values for buffer-local opions. + * These need to be defined globally, so that the BV_COUNT can be used with + * b_p_scriptID[]. + */ +enum +{ + BV_AI = 0 + , BV_AR +#ifdef FEAT_QUICKFIX + , BV_BH + , BV_BT + , BV_EFM + , BV_GP + , BV_MP +#endif + , BV_BIN + , BV_BL +#ifdef FEAT_MBYTE + , BV_BOMB +#endif + , BV_CI +#ifdef FEAT_CINDENT + , BV_CIN + , BV_CINK + , BV_CINO +#endif +#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) + , BV_CINW +#endif +#ifdef FEAT_FOLDING + , BV_CMS +#endif +#ifdef FEAT_COMMENTS + , BV_COM +#endif +#ifdef FEAT_INS_EXPAND + , BV_CPT + , BV_DICT + , BV_TSR +#endif +#ifdef FEAT_COMPL_FUNC + , BV_CFU +#endif +#ifdef FEAT_FIND_ID + , BV_DEF + , BV_INC +#endif + , BV_EOL + , BV_EP + , BV_ET + , BV_FENC +#ifdef FEAT_EVAL + , BV_FEX +#endif + , BV_FF + , BV_FLP + , BV_FO +#ifdef FEAT_AUTOCMD + , BV_FT +#endif + , BV_IMI + , BV_IMS +#if defined(FEAT_CINDENT) && defined(FEAT_EVAL) + , BV_INDE + , BV_INDK +#endif +#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) + , BV_INEX +#endif + , BV_INF + , BV_ISK +#ifdef FEAT_CRYPT + , BV_KEY +#endif +#ifdef FEAT_KEYMAP + , BV_KMAP +#endif + , BV_KP +#ifdef FEAT_LISP + , BV_LISP +#endif + , BV_MA + , BV_ML + , BV_MOD + , BV_MPS + , BV_NF +#ifdef FEAT_OSFILETYPE + , BV_OFT +#endif +#ifdef FEAT_COMPL_FUNC + , BV_OFU +#endif + , BV_PATH + , BV_PI +#ifdef FEAT_TEXTOBJ + , BV_QE +#endif + , BV_RO +#ifdef FEAT_SMARTINDENT + , BV_SI +#endif +#ifndef SHORT_FNAME + , BV_SN +#endif +#ifdef FEAT_SYN_HL + , BV_SMC + , BV_SPC + , BV_SPF + , BV_SPL + , BV_SYN +#endif + , BV_STS +#ifdef FEAT_SEARCHPATH + , BV_SUA +#endif + , BV_SW + , BV_SWF + , BV_TAGS + , BV_TS + , BV_TW + , BV_TX + , BV_WM + , BV_COUNT /* must be the last one */ +}; + +/* + * "indir" values for window-local options. + * These need to be defined globally, so that the WV_COUNT can be used in the + * window structure. + */ +enum +{ + WV_LIST = 0 +#ifdef FEAT_ARABIC + , WV_ARAB +#endif +#ifdef FEAT_DIFF + , WV_DIFF +#endif +#ifdef FEAT_FOLDING + , WV_FDC + , WV_FEN + , WV_FDI + , WV_FDL + , WV_FDM + , WV_FML + , WV_FDN +# ifdef FEAT_EVAL + , WV_FDE + , WV_FDT +# endif + , WV_FMR +#endif +#ifdef FEAT_LINEBREAK + , WV_LBR +#endif + , WV_NU +#ifdef FEAT_LINEBREAK + , WV_NUW +#endif +#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) + , WV_PVW +#endif +#ifdef FEAT_RIGHTLEFT + , WV_RL + , WV_RLC +#endif +#ifdef FEAT_SCROLLBIND + , WV_SCBIND +#endif + , WV_SCROLL +#ifdef FEAT_SYN_HL + , WV_SPELL + , WV_SPC + , WV_SYN +#endif +#ifdef FEAT_STL_OPT + , WV_STL +#endif +#ifdef FEAT_WINDOWS + , WV_WFH +#endif + , WV_WRAP + , WV_COUNT /* must be the last one */ +}; diff --git a/src/os_riscos.c b/src/os_riscos.c index 39a03cc36..cc52d85a6 100644 --- a/src/os_riscos.c +++ b/src/os_riscos.c @@ -1245,7 +1245,7 @@ mch_read_filetype(file) ; type_string[i] = 0; - set_string_option_direct("osfiletype", -1, type_string, OPT_FREE); + set_string_option_direct("osfiletype", -1, type_string, OPT_FREE, 0); return; } diff --git a/src/os_vms.c b/src/os_vms.c index ff3bf2c16..b1706fea3 100644 --- a/src/os_vms.c +++ b/src/os_vms.c @@ -298,33 +298,38 @@ vms_sys_status(int status) int vms_read(char *inbuf, size_t nbytes) { - int status, function, len; - TT_MODE tt_mode; - ITEM itmlst[3]; + int status, function, len; + TT_MODE tt_mode; + ITEM itmlst[2]; /* terminates on everything */ static long trm_mask[8] = {-1, -1, -1, -1, -1, -1, -1, -1}; /* whatever happened earlier we need an iochan here */ if (!iochan) - tt_mode = get_tty(); + tt_mode = get_tty(); + + /* important: clean the inbuf */ + memset(inbuf, 0, nbytes); + /* set up the itemlist for the first read */ vul_item(&itmlst[0], 0, TRM$_MODIFIERS, - (char *)( TRM$M_TM_ESCAPE | TRM$M_TM_TIMED | TRM$M_TM_NOECHO | - TRM$M_TM_NOEDIT | TRM$M_TM_NOFILTR | - TRM$M_TM_NORECALL| TRM$M_TM_TRMNOECHO), 0); - vul_item(&itmlst[1], 0, TRM$_TIMEOUT, (char *) 1, 0 ); - vul_item(&itmlst[2], sizeof(trm_mask), TRM$_TERM, (char *)&trm_mask, 0); + (char *)( TRM$M_TM_NOECHO | TRM$M_TM_NOEDIT | + TRM$M_TM_NOFILTR | TRM$M_TM_TRMNOECHO | + TRM$M_TM_NORECALL) , 0); + vul_item(&itmlst[1], sizeof(trm_mask), TRM$_TERM, (char *)&trm_mask, 0); + /* wait forever for a char */ function = (IO$_READLBLK | IO$M_EXTEND); - memset(inbuf, 0, nbytes); + status = sys$qiow(0, iochan, function, &iosb, 0, 0, + inbuf, nbytes-1, 0, 0, &itmlst, sizeof(itmlst)); + len = strlen(inbuf); /* how many chars we got? */ + + /* read immedatelly the rest in the IO queue */ + function = (IO$_READLBLK | IO$M_TIMED | IO$M_ESCAPE | IO$M_NOECHO | IO$M_NOFILTR); + status = sys$qiow(0, iochan, function, &iosb, 0, 0, + inbuf+len, nbytes-1-len, 0, 0, 0, 0); + + len = strlen(inbuf); /* return the total length */ - for (;;) - { - status = sys$qiow(0, iochan, function, &iosb, 0, 0, inbuf, nbytes - 1, - 0, 0, &itmlst, sizeof(itmlst)); - len = strlen(inbuf); - if (len > 0) - break; - } return len; } @@ -510,7 +515,7 @@ vms_unix_mixed_filespec(char *in, char *out) /* start of directory portion */ ch = *in; - if ((ch == '[') || (ch == '/') || (ch == '<') ) { /* start of directory(s) ? */ + if ((ch == '[') || (ch == '/') || (ch == '<')) { /* start of directory(s) ? */ ch = '['; SKIP_FOLLOWING_SLASHES(in); } else if (EQN(in, "../", 3)) { /* Unix parent directory? */ diff --git a/src/proto/option.pro b/src/proto/option.pro index fbe2f095a..faeec632f 100644 --- a/src/proto/option.pro +++ b/src/proto/option.pro @@ -18,7 +18,7 @@ void free_string_option __ARGS((char_u *p)); void clear_string_option __ARGS((char_u **pp)); void set_term_option_alloced __ARGS((char_u **p)); int was_set_insecurely __ARGS((char_u *opt, int opt_flags)); -void set_string_option_direct __ARGS((char_u *name, int opt_idx, char_u *val, int opt_flags)); +void set_string_option_direct __ARGS((char_u *name, int opt_idx, char_u *val, int opt_flags, int set_sid)); char_u *check_stl_option __ARGS((char_u *s)); void set_option_scriptID __ARGS((char_u *name, int id)); int get_option_value __ARGS((char_u *name, long *numval, char_u **stringval, int opt_flags)); diff --git a/src/quickfix.c b/src/quickfix.c index 7319e8077..2d83f1fcf 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -2846,12 +2846,7 @@ ex_cfile(eap) wp = curwin; if (*eap->arg != NUL) - { - set_string_option_direct((char_u *)"ef", -1, eap->arg, OPT_FREE); -# ifdef FEAT_EVAL - set_option_scriptID((char_u *)"ef", current_SID); -# endif - } + set_string_option_direct((char_u *)"ef", -1, eap->arg, OPT_FREE, 0); /* * This function is used by the :cfile, :cgetfile and :caddfile diff --git a/src/screen.c b/src/screen.c index adedce9ed..391fe0ad4 100644 --- a/src/screen.c +++ b/src/screen.c @@ -5469,14 +5469,9 @@ redraw_custum_statusline(wp) called_emsg = FALSE; win_redr_custom(wp, FALSE); if (called_emsg) - { set_string_option_direct((char_u *)"statusline", -1, (char_u *)"", OPT_FREE | (*wp->w_p_stl != NUL - ? OPT_LOCAL : OPT_GLOBAL)); -# ifdef FEAT_EVAL - set_option_scriptID((char_u *)"statusline", SID_ERROR); -# endif - } + ? OPT_LOCAL : OPT_GLOBAL), SID_ERROR); called_emsg |= save_called_emsg; } #endif @@ -8610,13 +8605,8 @@ draw_tabline() called_emsg = FALSE; win_redr_custom(NULL, FALSE); if (called_emsg) - { set_string_option_direct((char_u *)"tabline", -1, - (char_u *)"", OPT_FREE); -# ifdef FEAT_EVAL - set_option_scriptID((char_u *)"tabline", SID_ERROR); -# endif - } + (char_u *)"", OPT_FREE, SID_ERROR); called_emsg |= save_called_emsg; } else @@ -8915,13 +8905,8 @@ win_redr_ruler(wp, always) called_emsg = FALSE; win_redr_custom(wp, TRUE); if (called_emsg) - { set_string_option_direct((char_u *)"rulerformat", -1, - (char_u *)"", OPT_FREE); -# ifdef FEAT_EVAL - set_option_scriptID((char_u *)"rulerformat", SID_ERROR); -# endif - } + (char_u *)"", OPT_FREE, SID_ERROR); called_emsg |= save_called_emsg; return; } diff --git a/src/structs.h b/src/structs.h index e4d58f13b..0d6e497da 100644 --- a/src/structs.h +++ b/src/structs.h @@ -203,6 +203,11 @@ typedef struct #endif int wo_wrap; #define w_p_wrap w_onebuf_opt.wo_wrap /* 'wrap' */ + +#ifdef FEAT_EVAL + int wo_scriptID[WV_COUNT]; /* SIDs for window-local options */ +# define w_p_scriptID w_onebuf_opt.wo_scriptID +#endif } winopt_T; /* @@ -1283,6 +1288,10 @@ struct file_buffer */ int b_p_initialized; /* set when options initialized */ +#ifdef FEAT_EVAL + int b_p_scriptID[BV_COUNT]; /* SIDs for buffer-local options */ +#endif + int b_p_ai; /* 'autoindent' */ int b_p_ai_nopaste; /* b_p_ai saved for paste mode */ int b_p_ci; /* 'copyindent' */ diff --git a/src/syntax.c b/src/syntax.c index b5c346465..5a50b590f 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -6081,6 +6081,7 @@ static char *(highlight_init_both[]) = "PmenuSbar ctermbg=Grey guibg=Grey", "TabLineSel term=bold cterm=bold gui=bold", "TabLineFill term=reverse cterm=reverse gui=reverse", + "MatchParen term=reverse ctermbg=Cyan guibg=Cyan", NULL }; @@ -7925,8 +7926,10 @@ highlight_list_one(id) msg_outtrans(HL_TABLE()[HL_TABLE()[id - 1].sg_link - 1].sg_name); } + if (!didh) + highlight_list_arg(id, didh, LIST_STRING, 0, (char_u *)"cleared", ""); #ifdef FEAT_EVAL - if (didh && p_verbose > 0) + if (p_verbose > 0) last_set_msg(sgp->sg_scriptID); #endif } @@ -7973,8 +7976,11 @@ highlight_list_arg(id, didh, type, iarg, sarg, name) didh = TRUE; if (!got_int) { - MSG_PUTS_ATTR(name, hl_attr(HLF_D)); - MSG_PUTS_ATTR("=", hl_attr(HLF_D)); + if (*name != NUL) + { + MSG_PUTS_ATTR(name, hl_attr(HLF_D)); + MSG_PUTS_ATTR("=", hl_attr(HLF_D)); + } msg_outtrans(ts); } } diff --git a/src/term.c b/src/term.c index 69b0c6cb7..c3c5979ec 100644 --- a/src/term.c +++ b/src/term.c @@ -1561,10 +1561,7 @@ set_color_count(nr) sprintf((char *)nr_colors, "%d", t_colors); else *nr_colors = NUL; - set_string_option_direct((char_u *)"t_Co", -1, nr_colors, OPT_FREE); -# ifdef FEAT_EVAL - set_option_scriptID((char_u *)"t_Co", current_SID); -# endif + set_string_option_direct((char_u *)"t_Co", -1, nr_colors, OPT_FREE, 0); } #endif @@ -1825,7 +1822,8 @@ set_termname(term) out_flush(); ui_delay(2000L, TRUE); } - set_string_option_direct((char_u *)"term", -1, term, OPT_FREE); + set_string_option_direct((char_u *)"term", -1, term, + OPT_FREE, 0); display_errors(); } out_flush(); @@ -2503,10 +2501,7 @@ termcapinit(name) #endif if (term == NULL || *term == NUL) term = DEFAULT_TERM; - set_string_option_direct((char_u *)"term", -1, term, OPT_FREE); -# ifdef FEAT_EVAL - set_option_scriptID((char_u *)"term", current_SID); -# endif + set_string_option_direct((char_u *)"term", -1, term, OPT_FREE, 0); /* Set the default terminal name. */ set_string_default("term", term); diff --git a/src/testdir/test51.ok b/src/testdir/test51.ok index fae83936c..be9ff7862 100644 --- a/src/testdir/test51.ok +++ b/src/testdir/test51.ok @@ -2,14 +2,19 @@ NewGroup xxx term=bold cterm=italic ctermfg=2 ctermbg=3 +Group2 xxx cleared Group3 xxx term=underline cterm=bold +NewGroup xxx cleared +Group2 xxx cleared +Group2 xxx cleared +Group3 xxx cleared E475: term='asdf diff --git a/src/version.h b/src/version.h index 0e4105fe3..0869768c3 100644 --- a/src/version.h +++ b/src/version.h @@ -36,5 +36,5 @@ #define VIM_VERSION_NODOT "vim70aa" #define VIM_VERSION_SHORT "7.0aa" #define VIM_VERSION_MEDIUM "7.0aa ALPHA" -#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2006 Feb 26)" -#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2006 Feb 26, compiled " +#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2006 Feb 27)" +#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2006 Feb 27, compiled " diff --git a/src/vim.h b/src/vim.h index 2333e6404..3abd65956 100644 --- a/src/vim.h +++ b/src/vim.h @@ -1036,6 +1036,7 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname); #define SID_CARG -3 /* for "-c" argument */ #define SID_ENV -4 /* for sourcing environment variable */ #define SID_ERROR -5 /* option was reset because of an error */ +#define SID_NONE -6 /* don't set scriptID */ /* * Events for autocommands. -- cgit v1.2.3