// edited in a window yet. It's like ":tab all" but without closing
// windows or tabs.
ex_all(eap);
+ return;
}
- else
- {
- // ":drop file ...": Edit the first argument. Jump to an existing
- // window if possible, edit in current window if the current buffer
- // can be abandoned, otherwise open a new window.
- buf = buflist_findnr(ARGLIST[0].ae_fnum);
- FOR_ALL_TAB_WINDOWS(tp, wp)
+ // ":drop file ...": Edit the first argument. Jump to an existing
+ // window if possible, edit in current window if the current buffer
+ // can be abandoned, otherwise open a new window.
+ buf = buflist_findnr(ARGLIST[0].ae_fnum);
+
+ FOR_ALL_TAB_WINDOWS(tp, wp)
+ {
+ if (wp->w_buffer == buf)
{
- if (wp->w_buffer == buf)
+ goto_tabpage_win(tp, wp);
+ curwin->w_arg_idx = 0;
+ if (!bufIsChanged(curbuf))
{
- goto_tabpage_win(tp, wp);
- curwin->w_arg_idx = 0;
- if (!bufIsChanged(curbuf))
- {
- int save_ar = curbuf->b_p_ar;
+ int save_ar = curbuf->b_p_ar;
- // reload the file if it is newer
- curbuf->b_p_ar = TRUE;
- buf_check_timestamp(curbuf, FALSE);
- curbuf->b_p_ar = save_ar;
- }
- return;
+ // reload the file if it is newer
+ curbuf->b_p_ar = TRUE;
+ buf_check_timestamp(curbuf, FALSE);
+ curbuf->b_p_ar = save_ar;
}
+ return;
}
+ }
- /*
- * Check whether the current buffer is changed. If so, we will need
- * to split the current window or data could be lost.
- * Skip the check if the 'hidden' option is set, as in this case the
- * buffer won't be lost.
- */
- if (!buf_hide(curbuf))
- {
- ++emsg_off;
- split = check_changed(curbuf, CCGD_AW | CCGD_EXCMD);
- --emsg_off;
- }
+ /*
+ * Check whether the current buffer is changed. If so, we will need
+ * to split the current window or data could be lost.
+ * Skip the check if the 'hidden' option is set, as in this case the
+ * buffer won't be lost.
+ */
+ if (!buf_hide(curbuf))
+ {
+ ++emsg_off;
+ split = check_changed(curbuf, CCGD_AW | CCGD_EXCMD);
+ --emsg_off;
+ }
- // Fake a ":sfirst" or ":first" command edit the first argument.
- if (split)
- {
- eap->cmdidx = CMD_sfirst;
- eap->cmd[0] = 's';
- }
- else
- eap->cmdidx = CMD_first;
- ex_rewind(eap);
+ // Fake a ":sfirst" or ":first" command edit the first argument.
+ if (split)
+ {
+ eap->cmdidx = CMD_sfirst;
+ eap->cmd[0] = 's';
}
+ else
+ eap->cmdidx = CMD_first;
+ ex_rewind(eap);
}
/*
char_u *fname;
if (l == NULL)
+ {
msg(_("No old files"));
- else
+ return;
+ }
+
+ msg_start();
+ msg_scroll = TRUE;
+ for (li = l->lv_first; li != NULL && !got_int; li = li->li_next)
{
- msg_start();
- msg_scroll = TRUE;
- for (li = l->lv_first; li != NULL && !got_int; li = li->li_next)
+ ++nr;
+ fname = tv_get_string(&li->li_tv);
+ if (!message_filtered(fname))
{
- ++nr;
- fname = tv_get_string(&li->li_tv);
- if (!message_filtered(fname))
- {
- msg_outnum((long)nr);
- msg_puts(": ");
- msg_outtrans(fname);
- msg_clr_eos();
- msg_putchar('\n');
- out_flush(); // output one line at a time
- ui_breakcheck();
- }
+ msg_outnum((long)nr);
+ msg_puts(": ");
+ msg_outtrans(fname);
+ msg_clr_eos();
+ msg_putchar('\n');
+ out_flush(); // output one line at a time
+ ui_breakcheck();
}
+ }
- // Assume "got_int" was set to truncate the listing.
- got_int = FALSE;
+ // Assume "got_int" was set to truncate the listing.
+ got_int = FALSE;
# ifdef FEAT_BROWSE_CMD
- if (cmdmod.cmod_flags & CMOD_BROWSE)
+ if (cmdmod.cmod_flags & CMOD_BROWSE)
+ {
+ quit_more = FALSE;
+ nr = prompt_for_number(FALSE);
+ msg_starthere();
+ if (nr > 0)
{
- quit_more = FALSE;
- nr = prompt_for_number(FALSE);
- msg_starthere();
- if (nr > 0)
- {
- char_u *p = list_find_str(get_vim_var_list(VV_OLDFILES),
- (long)nr);
+ char_u *p = list_find_str(get_vim_var_list(VV_OLDFILES),
+ (long)nr);
- if (p != NULL)
- {
- p = expand_env_save(p);
- eap->arg = p;
- eap->cmdidx = CMD_edit;
- cmdmod.cmod_flags &= ~CMOD_BROWSE;
- do_exedit(eap, NULL);
- vim_free(p);
- }
+ if (p != NULL)
+ {
+ p = expand_env_save(p);
+ eap->arg = p;
+ eap->cmdidx = CMD_edit;
+ cmdmod.cmod_flags &= ~CMOD_BROWSE;
+ do_exedit(eap, NULL);
+ vim_free(p);
}
}
-# endif
}
+# endif
}
#endif
void
browse_save_fname(buf_T *buf)
{
- if (buf->b_fname == NULL)
- {
- char_u *fname;
+ if (buf->b_fname != NULL)
+ return;
- fname = do_browse(BROWSE_SAVE, (char_u *)_("Save As"),
- NULL, NULL, NULL, NULL, buf);
- if (fname != NULL)
- {
- if (setfname(buf, fname, NULL, TRUE) == OK)
- buf->b_flags |= BF_NOTEDITED;
- vim_free(fname);
- }
- }
+ char_u *fname;
+
+ fname = do_browse(BROWSE_SAVE, (char_u *)_("Save As"),
+ NULL, NULL, NULL, NULL, buf);
+ if (fname == NULL)
+ return;
+
+ if (setfname(buf, fname, NULL, TRUE) == OK)
+ buf->b_flags |= BF_NOTEDITED;
+ vim_free(fname);
}
#endif
// List all compiler scripts.
do_cmdline_cmd((char_u *)"echo globpath(&rtp, 'compiler/*.vim')");
// ) keep the indenter happy...
+ return;
+ }
+
+ buf = alloc(STRLEN(eap->arg) + 14);
+ if (buf == NULL)
+ return;
+
+ if (eap->forceit)
+ {
+ // ":compiler! {name}" sets global options
+ do_cmdline_cmd((char_u *)
+ "command -nargs=* CompilerSet set <args>");
}
else
{
- buf = alloc(STRLEN(eap->arg) + 14);
- if (buf != NULL)
- {
- if (eap->forceit)
- {
- // ":compiler! {name}" sets global options
- do_cmdline_cmd((char_u *)
- "command -nargs=* CompilerSet set <args>");
- }
- else
- {
- // ":compiler! {name}" sets local options.
- // To remain backwards compatible "current_compiler" is always
- // used. A user's compiler plugin may set it, the distributed
- // plugin will then skip the settings. Afterwards set
- // "b:current_compiler" and restore "current_compiler".
- // Explicitly prepend "g:" to make it work in a function.
- old_cur_comp = get_var_value((char_u *)"g:current_compiler");
- if (old_cur_comp != NULL)
- old_cur_comp = vim_strsave(old_cur_comp);
- do_cmdline_cmd((char_u *)
- "command -nargs=* -keepscript CompilerSet setlocal <args>");
- }
- do_unlet((char_u *)"g:current_compiler", TRUE);
- do_unlet((char_u *)"b:current_compiler", TRUE);
+ // ":compiler! {name}" sets local options.
+ // To remain backwards compatible "current_compiler" is always
+ // used. A user's compiler plugin may set it, the distributed
+ // plugin will then skip the settings. Afterwards set
+ // "b:current_compiler" and restore "current_compiler".
+ // Explicitly prepend "g:" to make it work in a function.
+ old_cur_comp = get_var_value((char_u *)"g:current_compiler");
+ if (old_cur_comp != NULL)
+ old_cur_comp = vim_strsave(old_cur_comp);
+ do_cmdline_cmd((char_u *)
+ "command -nargs=* -keepscript CompilerSet setlocal <args>");
+ }
+ do_unlet((char_u *)"g:current_compiler", TRUE);
+ do_unlet((char_u *)"b:current_compiler", TRUE);
- sprintf((char *)buf, "compiler/%s.vim", eap->arg);
- if (source_runtime(buf, DIP_ALL) == FAIL)
- semsg(_(e_compiler_not_supported_str), eap->arg);
- vim_free(buf);
+ sprintf((char *)buf, "compiler/%s.vim", eap->arg);
+ if (source_runtime(buf, DIP_ALL) == FAIL)
+ semsg(_(e_compiler_not_supported_str), eap->arg);
+ vim_free(buf);
- do_cmdline_cmd((char_u *)":delcommand CompilerSet");
+ do_cmdline_cmd((char_u *)":delcommand CompilerSet");
- // Set "b:current_compiler" from "current_compiler".
- p = get_var_value((char_u *)"g:current_compiler");
- if (p != NULL)
- set_internal_string_var((char_u *)"b:current_compiler", p);
+ // Set "b:current_compiler" from "current_compiler".
+ p = get_var_value((char_u *)"g:current_compiler");
+ if (p != NULL)
+ set_internal_string_var((char_u *)"b:current_compiler", p);
- // Restore "current_compiler" for ":compiler {name}".
- if (!eap->forceit)
- {
- if (old_cur_comp != NULL)
- {
- set_internal_string_var((char_u *)"g:current_compiler",
- old_cur_comp);
- vim_free(old_cur_comp);
- }
- else
- do_unlet((char_u *)"g:current_compiler", TRUE);
- }
+ // Restore "current_compiler" for ":compiler {name}".
+ if (!eap->forceit)
+ {
+ if (old_cur_comp != NULL)
+ {
+ set_internal_string_var((char_u *)"g:current_compiler",
+ old_cur_comp);
+ vim_free(old_cur_comp);
}
+ else
+ do_unlet((char_u *)"g:current_compiler", TRUE);
}
}
#endif
char_u *cmd;
int starts_with_colon = FALSE;
int may_have_range;
- int vim9script;
#ifdef FEAT_EVAL
int did_set_expr_line = FALSE;
#endif
// In Vim9 script a colon is required before the range. This may also be
// after command modifiers.
- vim9script = in_vim9script();
+ int vim9script = in_vim9script();
if (vim9script && (flags & DOCMD_RANGEOK) == 0)
{
may_have_range = FALSE;
int tab_number;
if (cmdwin_type != 0)
+ {
cmdwin_result = K_IGNORE;
- else if (first_tabpage->tp_next == NULL)
+ return;
+ }
+
+ if (first_tabpage->tp_next == NULL)
+ {
emsg(_(e_cannot_close_last_tab_page));
- else if (!window_layout_locked(CMD_tabclose))
+ return;
+ }
+
+ if (window_layout_locked(CMD_tabclose))
+ return;
+
+ tab_number = get_tabpage_arg(eap);
+ if (eap->errmsg != NULL)
+ return;
+
+ tp = find_tabpage(tab_number);
+ if (tp == NULL)
{
- tab_number = get_tabpage_arg(eap);
- if (eap->errmsg == NULL)
- {
- tp = find_tabpage(tab_number);
- if (tp == NULL)
- {
- beep_flush();
- return;
- }
- if (tp != curtab)
- {
- tabpage_close_other(tp, eap->forceit);
- return;
- }
- else if (!text_locked() && !curbuf_locked())
- tabpage_close(eap->forceit);
- }
+ beep_flush();
+ return;
}
+ if (tp != curtab)
+ {
+ tabpage_close_other(tp, eap->forceit);
+ return;
+ }
+ else if (!text_locked() && !curbuf_locked())
+ tabpage_close(eap->forceit);
}
/*
int tab_number;
if (cmdwin_type != 0)
+ {
cmdwin_result = K_IGNORE;
- else if (first_tabpage->tp_next == NULL)
+ return;
+ }
+
+ if (first_tabpage->tp_next == NULL)
+ {
msg(_("Already only one tab page"));
- else if (!window_layout_locked(CMD_tabonly))
+ return;
+ }
+
+ if (window_layout_locked(CMD_tabonly))
+ return;
+
+ tab_number = get_tabpage_arg(eap);
+ if (eap->errmsg != NULL)
+ return;
+
+ goto_tabpage(tab_number);
+ // Repeat this up to a 1000 times, because autocommands may
+ // mess up the lists.
+ for (done = 0; done < 1000; ++done)
{
- tab_number = get_tabpage_arg(eap);
- if (eap->errmsg == NULL)
- {
- goto_tabpage(tab_number);
- // Repeat this up to a 1000 times, because autocommands may
- // mess up the lists.
- for (done = 0; done < 1000; ++done)
+ FOR_ALL_TABPAGES(tp)
+ if (tp->tp_topframe != topframe)
{
- FOR_ALL_TABPAGES(tp)
- if (tp->tp_topframe != topframe)
- {
- tabpage_close_other(tp, eap->forceit);
- // if we failed to close it quit
- if (valid_tabpage(tp))
- done = 1000;
- // start over, "tp" is now invalid
- break;
- }
- if (first_tabpage->tp_next == NULL)
- break;
+ tabpage_close_other(tp, eap->forceit);
+ // if we failed to close it quit
+ if (valid_tabpage(tp))
+ done = 1000;
+ // start over, "tp" is now invalid
+ break;
}
- }
+ if (first_tabpage->tp_next == NULL)
+ break;
}
}
ex_hide(exarg_T *eap UNUSED)
{
// ":hide" or ":hide | cmd": hide current window
- if (!eap->skip)
- {
- if (window_layout_locked(CMD_hide))
- return;
+ if (eap->skip)
+ return;
+
+ if (window_layout_locked(CMD_hide))
+ return;
#ifdef FEAT_GUI
- need_mouse_correct = TRUE;
+ need_mouse_correct = TRUE;
#endif
- if (eap->addr_count == 0)
- win_close(curwin, FALSE); // don't free buffer
- else
- {
- int winnr = 0;
- win_T *win;
+ if (eap->addr_count == 0)
+ win_close(curwin, FALSE); // don't free buffer
+ else
+ {
+ int winnr = 0;
+ win_T *win;
- FOR_ALL_WINDOWS(win)
- {
- winnr++;
- if (winnr == eap->line2)
- break;
- }
- if (win == NULL)
- win = lastwin;
- win_close(win, FALSE);
+ FOR_ALL_WINDOWS(win)
+ {
+ winnr++;
+ if (winnr == eap->line2)
+ break;
}
+ if (win == NULL)
+ win = lastwin;
+ win_close(win, FALSE);
}
}
/*
* Disallow suspending for "rvim".
*/
- if (!check_restricted())
- {
- if (!eap->forceit)
- autowrite_all();
- apply_autocmds(EVENT_VIMSUSPEND, NULL, NULL, FALSE, NULL);
- windgoto((int)Rows - 1, 0);
- out_char('\n');
- out_flush();
- stoptermcap();
- out_flush(); // needed for SUN to restore xterm buffer
- mch_restore_title(SAVE_RESTORE_BOTH); // restore window titles
- ui_suspend(); // call machine specific function
- maketitle();
- resettitle(); // force updating the title
- starttermcap();
- scroll_start(); // scroll screen before redrawing
- redraw_later_clear();
- shell_resized(); // may have resized window
- apply_autocmds(EVENT_VIMRESUME, NULL, NULL, FALSE, NULL);
- }
+ if (check_restricted())
+ return;
+
+ if (!eap->forceit)
+ autowrite_all();
+ apply_autocmds(EVENT_VIMSUSPEND, NULL, NULL, FALSE, NULL);
+ windgoto((int)Rows - 1, 0);
+ out_char('\n');
+ out_flush();
+ stoptermcap();
+ out_flush(); // needed for SUN to restore xterm buffer
+ mch_restore_title(SAVE_RESTORE_BOTH); // restore window titles
+ ui_suspend(); // call machine specific function
+ maketitle();
+ resettitle(); // force updating the title
+ starttermcap();
+ scroll_start(); // scroll screen before redrawing
+ redraw_later_clear();
+ shell_resized(); // may have resized window
+ apply_autocmds(EVENT_VIMRESUME, NULL, NULL, FALSE, NULL);
}
/*
linenr_T lnum;
if (eap->usefilter) // :r!cmd
- do_bang(1, eap, FALSE, FALSE, TRUE);
- else
{
- if (u_save(eap->line2, (linenr_T)(eap->line2 + 1)) == FAIL)
- return;
+ do_bang(1, eap, FALSE, FALSE, TRUE);
+ return;
+ }
+
+ if (u_save(eap->line2, (linenr_T)(eap->line2 + 1)) == FAIL)
+ return;
#ifdef FEAT_BROWSE
- if (cmdmod.cmod_flags & CMOD_BROWSE)
- {
- char_u *browseFile;
+ if (cmdmod.cmod_flags & CMOD_BROWSE)
+ {
+ char_u *browseFile;
- browseFile = do_browse(0, (char_u *)_("Append File"), eap->arg,
- NULL, NULL, NULL, curbuf);
- if (browseFile != NULL)
- {
- i = readfile(browseFile, NULL,
- eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0);
- vim_free(browseFile);
- }
- else
- i = OK;
+ browseFile = do_browse(0, (char_u *)_("Append File"), eap->arg,
+ NULL, NULL, NULL, curbuf);
+ if (browseFile != NULL)
+ {
+ i = readfile(browseFile, NULL,
+ eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0);
+ vim_free(browseFile);
}
else
+ i = OK;
+ }
+ else
#endif
- if (*eap->arg == NUL)
+ if (*eap->arg == NUL)
{
if (check_fname() == FAIL) // check for no file name
return;
i = readfile(curbuf->b_ffname, curbuf->b_fname,
- eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0);
+ eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0);
}
else
{
if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL)
(void)setaltfname(eap->arg, eap->arg, (linenr_T)1);
i = readfile(eap->arg, NULL,
- eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0);
+ eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0);
}
- if (i != OK)
- {
+ if (i != OK)
+ {
#if defined(FEAT_EVAL)
- if (!aborting())
+ if (!aborting())
#endif
- semsg(_(e_cant_open_file_str), eap->arg);
- }
- else
+ semsg(_(e_cant_open_file_str), eap->arg);
+ }
+ else
+ {
+ if (empty && exmode_active)
{
- if (empty && exmode_active)
+ // Delete the empty line that remains. Historically ex does
+ // this but vi doesn't.
+ if (eap->line2 == 0)
+ lnum = curbuf->b_ml.ml_line_count;
+ else
+ lnum = 1;
+ if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK)
{
- // Delete the empty line that remains. Historically ex does
- // this but vi doesn't.
- if (eap->line2 == 0)
- lnum = curbuf->b_ml.ml_line_count;
- else
- lnum = 1;
- if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK)
- {
- ml_delete(lnum);
- if (curwin->w_cursor.lnum > 1
- && curwin->w_cursor.lnum >= lnum)
- --curwin->w_cursor.lnum;
- deleted_lines_mark(lnum, 1L);
- }
+ ml_delete(lnum);
+ if (curwin->w_cursor.lnum > 1
+ && curwin->w_cursor.lnum >= lnum)
+ --curwin->w_cursor.lnum;
+ deleted_lines_mark(lnum, 1L);
}
- redraw_curbuf_later(UPD_VALID);
}
+ redraw_curbuf_later(UPD_VALID);
}
}
#if !defined(UNIX) && !defined(VMS)
// for non-UNIX ":cd" means: print current directory unless 'cdhome' is set
if (*new_dir == NUL && !p_cdh)
+ {
ex_pwd(NULL);
- else
+ return;
+ }
#endif
- {
- cdscope_T scope = CDSCOPE_GLOBAL;
- if (eap->cmdidx == CMD_lcd || eap->cmdidx == CMD_lchdir)
- scope = CDSCOPE_WINDOW;
- else if (eap->cmdidx == CMD_tcd || eap->cmdidx == CMD_tchdir)
- scope = CDSCOPE_TABPAGE;
+ cdscope_T scope = CDSCOPE_GLOBAL;
- if (changedir_func(new_dir, eap->forceit, scope))
- {
- // Echo the new current directory if the command was typed.
- if (KeyTyped || p_verbose >= 5)
- ex_pwd(eap);
- }
+ if (eap->cmdidx == CMD_lcd || eap->cmdidx == CMD_lchdir)
+ scope = CDSCOPE_WINDOW;
+ else if (eap->cmdidx == CMD_tcd || eap->cmdidx == CMD_tchdir)
+ scope = CDSCOPE_TABPAGE;
+
+ if (changedir_func(new_dir, eap->forceit, scope))
+ {
+ // Echo the new current directory if the command was typed.
+ if (KeyTyped || p_verbose >= 5)
+ ex_pwd(eap);
}
}
== FAIL)
{
beep_flush();
+ return;
}
- else
- {
- int save_efr = exec_from_reg;
- exec_from_reg = TRUE;
+ int save_efr = exec_from_reg;
- /*
- * Execute from the typeahead buffer.
- * Continue until the stuff buffer is empty and all added characters
- * have been consumed.
- */
- while (!stuff_empty() || typebuf.tb_len > prev_len)
- (void)do_cmdline(NULL, getexline, NULL, DOCMD_NOWAIT|DOCMD_VERBOSE);
+ exec_from_reg = TRUE;
- exec_from_reg = save_efr;
- }
+ /*
+ * Execute from the typeahead buffer.
+ * Continue until the stuff buffer is empty and all added characters
+ * have been consumed.
+ */
+ while (!stuff_empty() || typebuf.tb_len > prev_len)
+ (void)do_cmdline(NULL, getexline, NULL, DOCMD_NOWAIT|DOCMD_VERBOSE);
+
+ exec_from_reg = save_efr;
}
/*
return;
#endif
if (*eap->arg == NUL) // No argument?
+ {
emsg(_(e_argument_required));
- else if (eap->arg[1] != NUL) // more than one character?
- semsg(_(e_trailing_characters_str), eap->arg);
- else
+ return;
+ }
+
+ if (eap->arg[1] != NUL) // more than one character?
{
- pos = curwin->w_cursor; // save curwin->w_cursor
- curwin->w_cursor.lnum = eap->line2;
- beginline(BL_WHITE | BL_FIX);
- if (setmark(*eap->arg) == FAIL) // set mark
- emsg(_(e_argument_must_be_letter_or_forward_backward_quote));
- curwin->w_cursor = pos; // restore curwin->w_cursor
+ semsg(_(e_trailing_characters_str), eap->arg);
+ return;
}
+
+ pos = curwin->w_cursor; // save curwin->w_cursor
+ curwin->w_cursor.lnum = eap->line2;
+ beginline(BL_WHITE | BL_FIX);
+ if (setmark(*eap->arg) == FAIL) // set mark
+ emsg(_(e_argument_must_be_letter_or_forward_backward_quote));
+ curwin->w_cursor = pos; // restore curwin->w_cursor
}
/*
static void
ex_setfiletype(exarg_T *eap)
{
- if (!did_filetype)
- {
- char_u *arg = eap->arg;
+ if (did_filetype)
+ return;
- if (STRNCMP(arg, "FALLBACK ", 9) == 0)
- arg += 9;
+ char_u *arg = eap->arg;
+ if (STRNCMP(arg, "FALLBACK ", 9) == 0)
+ arg += 9;
- set_option_value_give_err((char_u *)"filetype", 0L, arg, OPT_LOCAL);
- if (arg != eap->arg)
- did_filetype = FALSE;
- }
+ set_option_value_give_err((char_u *)"filetype", 0L, arg, OPT_LOCAL);
+ if (arg != eap->arg)
+ did_filetype = FALSE;
}
static void