diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-10-24 20:49:43 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-10-24 20:49:43 +0200 |
commit | e10044015841711b989f9a898d427bcc1fdb4c32 (patch) | |
tree | 256dbf4f826bbc408bb1eca2b381c4dc4f953eb6 /src | |
parent | 5661ed6c833e05467cab33cb9b1c535e7e5cc570 (diff) |
patch 8.2.1898: command modifier parsing always uses global cmdmodv8.2.1898
Problem: Command modifier parsing always uses global cmdmod.
Solution: Pass in cmdmod_T to use. Rename struct fields consistently.
Diffstat (limited to 'src')
-rw-r--r-- | src/arglist.c | 6 | ||||
-rw-r--r-- | src/buffer.c | 16 | ||||
-rw-r--r-- | src/bufwrite.c | 4 | ||||
-rw-r--r-- | src/change.c | 2 | ||||
-rw-r--r-- | src/cmdhist.c | 2 | ||||
-rw-r--r-- | src/diff.c | 20 | ||||
-rw-r--r-- | src/edit.c | 2 | ||||
-rw-r--r-- | src/ex_cmds.c | 55 | ||||
-rw-r--r-- | src/ex_cmds2.c | 8 | ||||
-rw-r--r-- | src/ex_docmd.c | 169 | ||||
-rw-r--r-- | src/ex_getln.c | 10 | ||||
-rw-r--r-- | src/fileio.c | 2 | ||||
-rw-r--r-- | src/filepath.c | 6 | ||||
-rw-r--r-- | src/gui.c | 4 | ||||
-rw-r--r-- | src/gui_gtk_x11.c | 4 | ||||
-rw-r--r-- | src/help.c | 11 | ||||
-rw-r--r-- | src/if_cscope.c | 4 | ||||
-rw-r--r-- | src/indent.c | 2 | ||||
-rw-r--r-- | src/mark.c | 11 | ||||
-rw-r--r-- | src/memline.c | 7 | ||||
-rw-r--r-- | src/message.c | 6 | ||||
-rw-r--r-- | src/ops.c | 18 | ||||
-rw-r--r-- | src/option.c | 4 | ||||
-rw-r--r-- | src/os_unix.c | 8 | ||||
-rw-r--r-- | src/proto/ex_docmd.pro | 4 | ||||
-rw-r--r-- | src/quickfix.c | 19 | ||||
-rw-r--r-- | src/register.c | 4 | ||||
-rw-r--r-- | src/scriptfile.c | 2 | ||||
-rw-r--r-- | src/search.c | 5 | ||||
-rw-r--r-- | src/session.c | 2 | ||||
-rw-r--r-- | src/structs.h | 45 | ||||
-rw-r--r-- | src/tag.c | 2 | ||||
-rw-r--r-- | src/terminal.c | 7 | ||||
-rw-r--r-- | src/textformat.c | 4 | ||||
-rw-r--r-- | src/usercmd.c | 44 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9compile.c | 22 | ||||
-rw-r--r-- | src/window.c | 12 |
38 files changed, 284 insertions, 271 deletions
diff --git a/src/arglist.c b/src/arglist.c index ab23880a5e..dd255a64a5 100644 --- a/src/arglist.c +++ b/src/arglist.c @@ -657,7 +657,7 @@ do_argfile(exarg_T *eap, int argn) #endif // split window or create new tab page first - if (*eap->cmd == 's' || cmdmod.tab != 0) + if (*eap->cmd == 's' || cmdmod.cmod_tab != 0) { if (win_split(0, 0) == FAIL) return; @@ -878,7 +878,7 @@ do_arg_all( alist_T *alist; // argument list to be used buf_T *buf; tabpage_T *tpnext; - int had_tab = cmdmod.tab; + int had_tab = cmdmod.cmod_tab; win_T *old_curwin, *last_curwin; tabpage_T *old_curtab, *last_curtab; win_T *new_curwin = NULL; @@ -1116,7 +1116,7 @@ do_arg_all( // When ":tab" was used open a new tab for a new window repeatedly. if (had_tab > 0 && tabpage_index(NULL) <= p_tpm) - cmdmod.tab = 9999; + cmdmod.cmod_tab = 9999; } // Remove the "lock" on the argument list. diff --git a/src/buffer.c b/src/buffer.c index 8a791d4c38..a1c789abda 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1444,7 +1444,7 @@ do_buffer( if (!forceit && bufIsChanged(buf)) { #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) - if ((p_confirm || cmdmod.confirm) && p_write) + if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) && p_write) { dialog_changed(buf, FALSE); if (!bufref_valid(&bufref)) @@ -1634,7 +1634,7 @@ do_buffer( if (action == DOBUF_GOTO && !can_abandon(curbuf, forceit)) { #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) - if ((p_confirm || cmdmod.confirm) && p_write) + if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) && p_write) { bufref_T bufref; @@ -1689,7 +1689,7 @@ set_curbuf(buf_T *buf, int action) bufref_T prevbufref; setpcmark(); - if (!cmdmod.keepalt) + if ((cmdmod.cmod_flags & CMOD_KEEPALT) == 0) curwin->w_alt_fnum = curbuf->b_fnum; // remember alternate file buflist_altfpos(curwin); // remember curpos @@ -3435,7 +3435,7 @@ setaltfname( // Create a buffer. 'buflisted' is not set if it's a new buffer buf = buflist_new(ffname, sfname, lnum, 0); - if (buf != NULL && !cmdmod.keepalt) + if (buf != NULL && (cmdmod.cmod_flags & CMOD_KEEPALT) == 0) curwin->w_alt_fnum = buf->b_fnum; return buf; } @@ -5068,7 +5068,7 @@ ex_buffer_all(exarg_T *eap) int r; int count; // Maximum number of windows to open. int all; // When TRUE also load inactive buffers. - int had_tab = cmdmod.tab; + int had_tab = cmdmod.cmod_tab; tabpage_T *tpnext; if (eap->addr_count == 0) // make as many windows as possible @@ -5099,7 +5099,7 @@ ex_buffer_all(exarg_T *eap) { wpnext = wp->w_next; if ((wp->w_buffer->b_nwindows > 1 - || ((cmdmod.split & WSP_VERT) + || ((cmdmod.cmod_split & WSP_VERT) ? wp->w_height + wp->w_status_height < Rows - p_ch - tabline_height() : wp->w_width != Columns) @@ -5220,7 +5220,7 @@ ex_buffer_all(exarg_T *eap) #endif // When ":tab" was used open a new tab for a new window repeatedly. if (had_tab > 0 && tabpage_index(NULL) <= p_tpm) - cmdmod.tab = 9999; + cmdmod.cmod_tab = 9999; } --autocmd_no_enter; win_enter(firstwin, FALSE); // back to first window @@ -5547,7 +5547,7 @@ buf_hide(buf_T *buf) case 'd': return FALSE; // "delete" case 'h': return TRUE; // "hide" } - return (p_hid || cmdmod.hide); + return (p_hid || (cmdmod.cmod_flags & CMOD_HIDE)); } /* diff --git a/src/bufwrite.c b/src/bufwrite.c index 4be48e28e0..4b522465d5 100644 --- a/src/bufwrite.c +++ b/src/bufwrite.c @@ -883,7 +883,7 @@ buf_write( #endif ) { - if (buf != NULL && cmdmod.lockmarks) + if (buf != NULL && (cmdmod.cmod_flags & CMOD_LOCKMARKS)) { // restore the original '[ and '] positions buf->b_op_start = orig_start; @@ -967,7 +967,7 @@ buf_write( fname = buf->b_sfname; } - if (cmdmod.lockmarks) + if (cmdmod.cmod_flags & CMOD_LOCKMARKS) { // restore the original '[ and '] positions buf->b_op_start = orig_start; diff --git a/src/change.c b/src/change.c index 44c2f0480c..45780573dc 100644 --- a/src/change.c +++ b/src/change.c @@ -453,7 +453,7 @@ changed_common( #endif // set the '. mark - if (!cmdmod.keepjumps) + if ((cmdmod.cmod_flags & CMOD_KEEPJUMPS) == 0) { curbuf->b_last_change.lnum = lnum; curbuf->b_last_change.col = col; diff --git a/src/cmdhist.c b/src/cmdhist.c index 69c83c0b5a..1e7ae34034 100644 --- a/src/cmdhist.c +++ b/src/cmdhist.c @@ -304,7 +304,7 @@ add_to_history( if (hislen == 0) // no history return; - if (cmdmod.keeppatterns && histype == HIST_SEARCH) + if ((cmdmod.cmod_flags & CMOD_KEEPPATTERNS) && histype == HIST_SEARCH) return; // Searches inside the same mapping overwrite each other, so that only diff --git a/src/diff.c b/src/diff.c index bb95d5ed65..753d089b66 100644 --- a/src/diff.c +++ b/src/diff.c @@ -775,7 +775,7 @@ diff_write(buf_T *buf, diffin_T *din) { int r; char_u *save_ff; - int save_lockmarks; + int save_cmod_flags; if (din->din_fname == NULL) return diff_write_buffer(buf, din); @@ -783,14 +783,14 @@ diff_write(buf_T *buf, diffin_T *din) // Always use 'fileformat' set to "unix". save_ff = buf->b_p_ff; buf->b_p_ff = vim_strsave((char_u *)FF_UNIX); - save_lockmarks = cmdmod.lockmarks; + save_cmod_flags = cmdmod.cmod_flags; // Writing the buffer is an implementation detail of performing the diff, // so it shouldn't update the '[ and '] marks. - cmdmod.lockmarks = TRUE; + cmdmod.cmod_flags |= CMOD_LOCKMARKS; r = buf_write(buf, din->din_fname, NULL, (linenr_T)1, buf->b_ml.ml_line_count, NULL, FALSE, FALSE, FALSE, TRUE); - cmdmod.lockmarks = save_lockmarks; + cmdmod.cmod_flags = save_cmod_flags; free_string_option(buf->b_p_ff); buf->b_p_ff = save_ff; return r; @@ -1187,13 +1187,13 @@ ex_diffpatch(exarg_T *eap) #endif #ifdef FEAT_BROWSE char_u *browseFile = NULL; - int browse_flag = cmdmod.browse; + int save_cmod_flags = cmdmod.cmod_flags; #endif stat_T st; char_u *esc_name = NULL; #ifdef FEAT_BROWSE - if (cmdmod.browse) + if (cmdmod.cmod_flags & CMOD_BROWSE) { browseFile = do_browse(0, (char_u *)_("Patch file"), eap->arg, NULL, NULL, @@ -1201,7 +1201,7 @@ ex_diffpatch(exarg_T *eap) if (browseFile == NULL) return; // operation cancelled eap->arg = browseFile; - cmdmod.browse = FALSE; // don't let do_ecmd() browse again + cmdmod.cmod_flags &= ~CMOD_BROWSE; // don't let do_ecmd() browse again } #endif @@ -1310,7 +1310,7 @@ ex_diffpatch(exarg_T *eap) need_mouse_correct = TRUE; #endif // don't use a new tab page, each tab page has its own diffs - cmdmod.tab = 0; + cmdmod.cmod_tab = 0; if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL) { @@ -1355,7 +1355,7 @@ theend: vim_free(esc_name); #ifdef FEAT_BROWSE vim_free(browseFile); - cmdmod.browse = browse_flag; + cmdmod.cmod_flags = save_cmod_flags; #endif } @@ -1377,7 +1377,7 @@ ex_diffsplit(exarg_T *eap) set_fraction(curwin); // don't use a new tab page, each tab page has its own diffs - cmdmod.tab = 0; + cmdmod.cmod_tab = 0; if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL) { diff --git a/src/edit.c b/src/edit.c index 14a21d9573..73e8337521 100644 --- a/src/edit.c +++ b/src/edit.c @@ -3616,7 +3616,7 @@ ins_esc( curwin->w_set_curswant = TRUE; // Remember the last Insert position in the '^ mark. - if (!cmdmod.keepjumps) + if ((cmdmod.cmod_flags & CMOD_KEEPJUMPS) == 0) curbuf->b_last_insert = curwin->w_cursor; /* diff --git a/src/ex_cmds.c b/src/ex_cmds.c index 6371eceba1..1dbd01494e 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -744,7 +744,7 @@ do_move(linenr_T line1, linenr_T line2, linenr_T dest) foldMoveRange(&win->w_folds, line1, line2, dest); } #endif - if (!cmdmod.lockmarks) + if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) { curbuf->b_op_start.lnum = dest - num_lines + 1; curbuf->b_op_end.lnum = dest; @@ -759,13 +759,13 @@ do_move(linenr_T line1, linenr_T line2, linenr_T dest) foldMoveRange(&win->w_folds, dest + 1, line1 - 1, line2); } #endif - if (!cmdmod.lockmarks) + if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) { curbuf->b_op_start.lnum = dest + 1; curbuf->b_op_end.lnum = dest + num_lines; } } - if (!cmdmod.lockmarks) + if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) curbuf->b_op_start.col = curbuf->b_op_end.col = 0; mark_adjust_nofold(last_line - num_lines + 1, last_line, -(last_line - dest - extra), 0L); @@ -815,7 +815,7 @@ ex_copy(linenr_T line1, linenr_T line2, linenr_T n) char_u *p; count = line2 - line1 + 1; - if (!cmdmod.lockmarks) + if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) { curbuf->b_op_start.lnum = n + 1; curbuf->b_op_end.lnum = n + count; @@ -1062,7 +1062,7 @@ do_filter( int shell_flags = 0; pos_T orig_start = curbuf->b_op_start; pos_T orig_end = curbuf->b_op_end; - int save_lockmarks = cmdmod.lockmarks; + int save_cmod_flags = cmdmod.cmod_flags; #ifdef FEAT_FILTERPIPE int stmp = p_stmp; #endif @@ -1072,7 +1072,7 @@ do_filter( // Temporarily disable lockmarks since that's needed to propagate changed // regions of the buffer for foldUpdate(), linecount, etc. - cmdmod.lockmarks = 0; + cmdmod.cmod_flags &= ~CMOD_LOCKMARKS; cursor_save = curwin->w_cursor; linecount = line2 - line1 + 1; @@ -1241,7 +1241,8 @@ do_filter( if (do_in) { - if (cmdmod.keepmarks || vim_strchr(p_cpo, CPO_REMMARK) == NULL) + if ((cmdmod.cmod_flags & CMOD_KEEPMARKS) + || vim_strchr(p_cpo, CPO_REMMARK) == NULL) { if (read_linecount >= linecount) // move all marks from old lines to new lines @@ -1307,13 +1308,13 @@ error: filterend: - cmdmod.lockmarks = save_lockmarks; + cmdmod.cmod_flags = save_cmod_flags; if (curbuf != old_curbuf) { --no_wait_return; emsg(_("E135: *Filter* Autocommands must not change current buffer")); } - else if (cmdmod.lockmarks) + else if (cmdmod.cmod_flags & CMOD_LOCKMARKS) { curbuf->b_op_start = orig_start; curbuf->b_op_end = orig_end; @@ -1769,7 +1770,7 @@ rename_buffer(char_u *new_fname) if (xfname != NULL && *xfname != NUL) { buf = buflist_new(fname, xfname, curwin->w_cursor.lnum, 0); - if (buf != NULL && !cmdmod.keepalt) + if (buf != NULL && (cmdmod.cmod_flags & CMOD_KEEPALT) == 0) curwin->w_alt_fnum = buf->b_fnum; } vim_free(fname); @@ -1866,7 +1867,7 @@ do_write(exarg_T *eap) ffname = eap->arg; #ifdef FEAT_BROWSE - if (cmdmod.browse && !exiting) + if ((cmdmod.cmod_flags & CMOD_BROWSE) && !exiting) { browse_file = do_browse(BROWSE_SAVE, (char_u *)_("Save As"), ffname, NULL, NULL, NULL, curbuf); @@ -1942,7 +1943,7 @@ do_write(exarg_T *eap) && !p_wa) { #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) - if (p_confirm || cmdmod.confirm) + if (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) { if (vim_dialog_yesno(VIM_QUESTION, NULL, (char_u *)_("Write partial file?"), 2) != VIM_YES) @@ -2091,7 +2092,7 @@ check_overwrite( } #endif #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) - if (p_confirm || cmdmod.confirm) + if (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) { char_u buff[DIALOG_MSG_SIZE]; @@ -2142,7 +2143,7 @@ check_overwrite( if (r) { #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) - if (p_confirm || cmdmod.confirm) + if (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) { char_u buff[DIALOG_MSG_SIZE]; @@ -2229,12 +2230,13 @@ do_wqall(exarg_T *eap) } #ifdef FEAT_BROWSE // ":browse wall": ask for file name if there isn't one - if (buf->b_ffname == NULL && cmdmod.browse) + if (buf->b_ffname == NULL && (cmdmod.cmod_flags & CMOD_BROWSE)) browse_save_fname(buf); #endif if (buf->b_ffname == NULL) { - semsg(_("E141: No file name for buffer %ld"), (long)buf->b_fnum); + semsg(_("E141: No file name for buffer %ld"), + (long)buf->b_fnum); ++error; } else if (check_readonly(&eap->forceit, buf) @@ -2297,7 +2299,8 @@ check_readonly(int *forceit, buf_T *buf) && check_file_readonly(buf->b_ffname, 0777)))) { #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) - if ((p_confirm || cmdmod.confirm) && buf->b_fname != NULL) + if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) + && buf->b_fname != NULL) { char_u buff[DIALOG_MSG_SIZE]; @@ -2501,7 +2504,7 @@ do_ecmd( else { #ifdef FEAT_BROWSE - if (cmdmod.browse && !exiting) + if ((cmdmod.cmod_flags & CMOD_BROWSE) && !exiting) { if ( # ifdef FEAT_GUI @@ -2612,7 +2615,7 @@ do_ecmd( { if (!(flags & ECMD_ADDBUF)) { - if (!cmdmod.keepalt) + if ((cmdmod.cmod_flags & CMOD_KEEPALT) == 0) curwin->w_alt_fnum = curbuf->b_fnum; if (oldwin != NULL) buflist_altfpos(oldwin); @@ -3299,14 +3302,14 @@ ex_append(exarg_T *eap) // eap->line2 pointed to the end of the buffer and nothing was appended) // "end" is set to lnum when something has been appended, otherwise // it is the same than "start" -- Acevedo - if (!cmdmod.lockmarks) + if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) { curbuf->b_op_start.lnum = (eap->line2 < curbuf->b_ml.ml_line_count) ? eap->line2 + 1 : curbuf->b_ml.ml_line_count; if (eap->cmdidx != CMD_append) --curbuf->b_op_start.lnum; curbuf->b_op_end.lnum = (eap->line2 < lnum) - ? lnum : curbuf->b_op_start.lnum; + ? lnum : curbuf->b_op_start.lnum; curbuf->b_op_start.col = curbuf->b_op_end.col = 0; } curwin->w_cursor.lnum = lnum; @@ -3729,7 +3732,7 @@ ex_substitute(exarg_T *eap) ex_may_print(eap); } - if (!cmdmod.keeppatterns) + if ((cmdmod.cmod_flags & CMOD_KEEPPATTERNS) == 0) save_re_pat(RE_SUBST, pat, p_magic); // put pattern in history add_to_history(HIST_SEARCH, pat, TRUE, NUL); @@ -4619,7 +4622,7 @@ outofmem: if (sub_nsubs > start_nsubs) { - if (!cmdmod.lockmarks) + if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) { // Set the '[ and '] marks. curbuf->b_op_start.lnum = eap->line1; @@ -5108,7 +5111,7 @@ ex_drop(exarg_T *eap) if (ARGCOUNT == 0) return; - if (cmdmod.tab) + if (cmdmod.cmod_tab) { // ":tab drop file ...": open a tab for each argument that isn't // edited in a window yet. It's like ":tab all" but without closing @@ -5247,7 +5250,7 @@ ex_oldfiles(exarg_T *eap UNUSED) got_int = FALSE; # ifdef FEAT_BROWSE_CMD - if (cmdmod.browse) + if (cmdmod.cmod_flags & CMOD_BROWSE) { quit_more = FALSE; nr = prompt_for_number(FALSE); @@ -5262,7 +5265,7 @@ ex_oldfiles(exarg_T *eap UNUSED) p = expand_env_save(p); eap->arg = p; eap->cmdidx = CMD_edit; - cmdmod.browse = FALSE; + cmdmod.cmod_flags &= ~CMOD_BROWSE; do_exedit(eap, NULL); vim_free(p); } diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 738bdb11d3..04859ada7d 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -86,7 +86,7 @@ check_changed(buf_T *buf, int flags) && (!(flags & CCGD_AW) || autowrite(buf, forceit) == FAIL)) { #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) - if ((p_confirm || cmdmod.confirm) && p_write) + if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) && p_write) { buf_T *buf2; int count = 0; @@ -96,7 +96,7 @@ check_changed(buf_T *buf, int flags) if (bufIsChanged(buf2) && (buf2->b_ffname != NULL # ifdef FEAT_BROWSE - || cmdmod.browse + || (cmdmod.cmod_flags & CMOD_BROWSE) # endif )) ++count; @@ -197,7 +197,7 @@ dialog_changed( if (bufIsChanged(buf2) && (buf2->b_ffname != NULL #ifdef FEAT_BROWSE - || cmdmod.browse + || (cmdmod.cmod_flags & CMOD_BROWSE) #endif ) && !buf2->b_p_ro) @@ -347,7 +347,7 @@ check_changed_any( /* * When ":confirm" used, don't give an error message. */ - if (!(p_confirm || cmdmod.confirm)) + if (!(p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM))) #endif { // There must be a wait_return for this message, do_buffer() diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 1e1b8e3a46..5e9eeb78fe 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -1711,7 +1711,6 @@ do_one_cmd( char *errormsg = NULL; // error message char_u *after_modifier = NULL; exarg_T ea; // Ex command arguments - int save_msg_scroll = msg_scroll; cmdmod_T save_cmdmod; int save_reg_executing = reg_executing; int ni; // set when Not Implemented @@ -1762,7 +1761,7 @@ do_one_cmd( ea.cstack = cstack; starts_with_colon = *skipwhite(ea.cmd) == ':'; #endif - if (parse_command_modifiers(&ea, &errormsg, FALSE) == FAIL) + if (parse_command_modifiers(&ea, &errormsg, &cmdmod, FALSE) == FAIL) goto doend; apply_cmdmod(&cmdmod); @@ -2598,7 +2597,7 @@ doend: ? cmdnames[(int)ea.cmdidx].cmd_name : (char_u *)NULL); #endif - undo_cmdmod(save_msg_scroll); + undo_cmdmod(&cmdmod); cmdmod = save_cmdmod; reg_executing = save_reg_executing; @@ -2633,25 +2632,31 @@ ex_errmsg(char *msg, char_u *arg) /* * Parse and skip over command modifiers: * - update eap->cmd - * - store flags in "cmdmod". + * - store flags in "cmod". * - Set ex_pressedreturn for an empty command line. - * - set msg_silent for ":silent" - * - set 'eventignore' to "all" for ":noautocmd" * When "skip_only" is TRUE the global variables are not changed, except for * "cmdmod". + * When "skip_only" is FALSE then undo_cmdmod() must be called later to free + * any cmod_filter_regmatch.regprog. * Call apply_cmdmod() to get the side effects of the modifiers: * - Increment "sandbox" for ":sandbox" * - set p_verbose for ":verbose" + * - set msg_silent for ":silent" + * - set 'eventignore' to "all" for ":noautocmd" * Return FAIL when the command is not to be executed. * May set "errormsg" to an error message. */ int -parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only) +parse_command_modifiers( + exarg_T *eap, + char **errormsg, + cmdmod_T *cmod, + int skip_only) { char_u *p; int starts_with_colon = FALSE; - CLEAR_FIELD(cmdmod); + CLEAR_POINTER(cmod); // Repeat until no more command modifiers are found. for (;;) @@ -2690,51 +2695,51 @@ parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only) // When adding an entry, also modify cmd_exists(). case 'a': if (!checkforcmd(&eap->cmd, "aboveleft", 3)) break; - cmdmod.split |= WSP_ABOVE; + cmod->cmod_split |= WSP_ABOVE; continue; case 'b': if (checkforcmd(&eap->cmd, "belowright", 3)) { - cmdmod.split |= WSP_BELOW; + cmod->cmod_split |= WSP_BELOW; continue; } if (checkforcmd(&eap->cmd, "browse", 3)) { #ifdef FEAT_BROWSE_CMD - cmdmod.browse = TRUE; + cmod->cmod_flags |= CMOD_BROWSE; #endif continue; } if (!checkforcmd(&eap->cmd, "botright", 2)) break; - cmdmod.split |= WSP_BOT; + cmod->cmod_split |= WSP_BOT; continue; case 'c': if (!checkforcmd(&eap->cmd, "confirm", 4)) break; #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) - cmdmod.confirm = TRUE; + cmod->cmod_flags |= CMOD_CONFIRM; #endif continue; case 'k': if (checkforcmd(&eap->cmd, "keepmarks", 3)) { - cmdmod.keepmarks = TRUE; + cmod->cmod_flags |= CMOD_KEEPMARKS; continue; } if (checkforcmd(&eap->cmd, "keepalt", 5)) { - cmdmod.keepalt = TRUE; + cmod->cmod_flags |= CMOD_KEEPALT; continue; } if (checkforcmd(&eap->cmd, "keeppatterns", 5)) { - cmdmod.keeppatterns = TRUE; + cmod->cmod_flags |= CMOD_KEEPPATTERNS; continue; } if (!checkforcmd(&eap->cmd, "keepjumps", 5)) break; - cmdmod.keepjumps = TRUE; + cmod->cmod_flags |= CMOD_KEEPJUMPS; continue; case 'f': // only accept ":filter {pat} cmd" @@ -2746,7 +2751,7 @@ parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only) break; if (*p == '!') { - cmdmod.filter_force = TRUE; + cmod->cmod_filter_force = TRUE; p = skipwhite(p + 1); if (*p == NUL || ends_excmd(*p)) break; @@ -2765,9 +2770,9 @@ parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only) break; if (!skip_only) { - cmdmod.filter_regmatch.regprog = + cmod->cmod_filter_regmatch.regprog = vim_regcomp(reg_pat, RE_MAGIC); - if (cmdmod.filter_regmatch.regprog == NULL) + if (cmod->cmod_filter_regmatch.regprog == NULL) break; } eap->cmd = p; @@ -2779,48 +2784,48 @@ parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only) || *p == NUL || ends_excmd(*p)) break; eap->cmd = p; - cmdmod.hide = TRUE; + cmod->cmod_flags |= CMOD_HIDE; continue; case 'l': if (checkforcmd(&eap->cmd, "lockmarks", 3)) { - cmdmod.lockmarks = TRUE; + cmod->cmod_flags |= CMOD_LOCKMARKS; continue; } if (!checkforcmd(&eap->cmd, "leftabove", 5)) break; - cmdmod.split |= WSP_ABOVE; + cmod->cmod_split |= WSP_ABOVE; continue; case 'n': if (checkforcmd(&eap->cmd, "noautocmd", 3)) { - cmdmod.cmod_flags |= CMOD_NOAUTOCMD; + cmod->cmod_flags |= CMOD_NOAUTOCMD; continue; } if (!checkforcmd(&eap->cmd, "noswapfile", 3)) break; - cmdmod.noswapfile = TRUE; + cmod->cmod_flags |= CMOD_NOSWAPFILE; continue; case 'r': if (!checkforcmd(&eap->cmd, "rightbelow", 6)) break; - cmdmod.split |= WSP_BELOW; + cmod->cmod_split |= WSP_BELOW; continue; case 's': if (checkforcmd(&eap->cmd, "sandbox", 3)) { - cmdmod.cmod_flags |= CMOD_SANDBOX; + cmod->cmod_flags |= CMOD_SANDBOX; continue; } if (!checkforcmd(&eap->cmd, "silent", 3)) break; - cmdmod.cmod_flags |= CMOD_SILENT; + cmod->cmod_flags |= CMOD_SILENT; if (*eap->cmd == '!' && !VIM_ISWHITE(eap->cmd[-1])) { // ":silent!", but not "silent !cmd" eap->cmd = skipwhite(eap->cmd + 1); - cmdmod.cmod_flags |= CMOD_ERRSILENT; + cmod->cmod_flags |= CMOD_ERRSILENT; } continue; @@ -2832,7 +2837,7 @@ parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only) ADDR_TABS, eap->skip, skip_only, FALSE, 1); if (tabnr == MAXLNUM) - cmdmod.tab = tabpage_index(curtab) + 1; + cmod->cmod_tab = tabpage_index(curtab) + 1; else { if (tabnr < 0 || tabnr > LAST_TAB_NR) @@ -2840,7 +2845,7 @@ parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only) *errormsg = _(e_invrange); return FAIL; } - cmdmod.tab = tabnr + 1; + cmod->cmod_tab = tabnr + 1; } } eap->cmd = p; @@ -2848,25 +2853,25 @@ parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only) } if (!checkforcmd(&eap->cmd, "topleft", 2)) break; - cmdmod.split |= WSP_TOP; + cmod->cmod_split |= WSP_TOP; continue; case 'u': if (!checkforcmd(&eap->cmd, "unsilent", 3)) break; - cmdmod.cmod_flags |= CMOD_UNSILENT; + cmod->cmod_flags |= CMOD_UNSILENT; continue; case 'v': if (checkforcmd(&eap->cmd, "vertical", 4)) { - cmdmod.split |= WSP_VERT; + cmod->cmod_split |= WSP_VERT; continue; } if (!checkforcmd(&p, "verbose", 4)) break; if (vim_isdigit(*eap->cmd)) - cmdmod.cmod_verbose = atoi((char *)eap->cmd); + cmod->cmod_verbose = atoi((char *)eap->cmd); else - cmdmod.cmod_verbose = 1; + cmod->cmod_verbose = 1; eap->cmd = p; continue; } @@ -2899,7 +2904,10 @@ apply_cmdmod(cmdmod_T *cmod) if ((cmod->cmod_flags & (CMOD_SILENT | CMOD_UNSILENT)) && cmod->cmod_save_msg_silent == 0) + { cmod->cmod_save_msg_silent = msg_silent + |