DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED);
}
+/*
+ * Execute the "+cmd" argument of "edit +cmd fname" and the like.
+ * This allows for using a range without ":" in Vim9 script.
+ */
+ int
+do_cmd_argument(char_u *cmd)
+{
+ return do_cmdline(cmd, NULL, NULL,
+ DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED|DOCMD_RANGEOK);
+}
+
/*
* do_cmdline(): execute one Ex command line
*
* "cmdline_copy" can change, e.g. for '%' and '#' expansion.
*/
++recursive;
- next_cmdline = do_one_cmd(&cmdline_copy, flags & DOCMD_VERBOSE,
+ next_cmdline = do_one_cmd(&cmdline_copy, flags,
#ifdef FEAT_EVAL
&cstack,
#endif
/*
* Execute one Ex command.
*
- * If 'sourcing' is TRUE, the command will be included in the error message.
+ * If "flags" has DOCMD_VERBOSE, the command will be included in the error
+ * message.
*
* 1. skip comment lines and leading space
* 2. handle command modifiers
static char_u *
do_one_cmd(
char_u **cmdlinep,
- int sourcing,
+ int flags,
#ifdef FEAT_EVAL
cstack_T *cstack,
#endif
int vim9script = in_vim9script();
int did_set_expr_line = FALSE;
#endif
+ int sourcing = flags & DOCMD_VERBOSE;
CLEAR_FIELD(ea);
ea.line1 = 1;
#ifdef FEAT_EVAL
// In Vim9 script a colon is required before the range. This may also be
// after command modifiers.
- if (vim9script)
+ if (vim9script && (flags & DOCMD_RANGEOK) == 0)
{
may_have_range = FALSE;
for (p = ea.cmd; p >= *cmdlinep; --p)
else
goto_buffer(eap, DOBUF_FIRST, FORWARD, (int)eap->line2);
if (eap->do_ecmd_cmd != NULL)
- do_cmdline_cmd(eap->do_ecmd_cmd);
+ do_cmd_argument(eap->do_ecmd_cmd);
}
}
{
goto_buffer(eap, DOBUF_MOD, FORWARD, (int)eap->line2);
if (eap->do_ecmd_cmd != NULL)
- do_cmdline_cmd(eap->do_ecmd_cmd);
+ do_cmd_argument(eap->do_ecmd_cmd);
}
/*
goto_buffer(eap, DOBUF_CURRENT, FORWARD, (int)eap->line2);
if (eap->do_ecmd_cmd != NULL)
- do_cmdline_cmd(eap->do_ecmd_cmd);
+ do_cmd_argument(eap->do_ecmd_cmd);
}
/*
goto_buffer(eap, DOBUF_CURRENT, BACKWARD, (int)eap->line2);
if (eap->do_ecmd_cmd != NULL)
- do_cmdline_cmd(eap->do_ecmd_cmd);
+ do_cmd_argument(eap->do_ecmd_cmd);
}
/*
goto_buffer(eap, DOBUF_FIRST, FORWARD, 0);
if (eap->do_ecmd_cmd != NULL)
- do_cmdline_cmd(eap->do_ecmd_cmd);
+ do_cmd_argument(eap->do_ecmd_cmd);
}
/*
goto_buffer(eap, DOBUF_LAST, BACKWARD, 0);
if (eap->do_ecmd_cmd != NULL)
- do_cmdline_cmd(eap->do_ecmd_cmd);
+ do_cmd_argument(eap->do_ecmd_cmd);
}
/*
else
{
if (eap->do_ecmd_cmd != NULL)
- do_cmdline_cmd(eap->do_ecmd_cmd);
+ do_cmd_argument(eap->do_ecmd_cmd);
#ifdef FEAT_TITLE
n = curwin->w_arg_idx_invalid;
#endif
/* ex_docmd.c */
void do_exmode(int improved);
int do_cmdline_cmd(char_u *cmd);
+int do_cmd_argument(char_u *cmd);
int do_cmdline(char_u *cmdline, char_u *(*fgetline)(int, void *, int, getline_opt_T), void *cookie, int flags);
int getline_equal(char_u *(*fgetline)(int, void *, int, getline_opt_T), void *cookie, char_u *(*func)(int, void *, int, getline_opt_T));
void *getline_cookie(char_u *(*fgetline)(int, void *, int, getline_opt_T), void *cookie);