@@ -600,6 +600,17 @@ do_cmdline_cmd(char_u *cmd)
600600 DOCMD_VERBOSE |DOCMD_NOWAIT |DOCMD_KEYTYPED );
601601}
602602
603+ /*
604+ * Execute the "+cmd" argument of "edit +cmd fname" and the like.
605+ * This allows for using a range without ":" in Vim9 script.
606+ */
607+ int
608+ do_cmd_argument (char_u * cmd )
609+ {
610+ return do_cmdline (cmd , NULL , NULL ,
611+ DOCMD_VERBOSE |DOCMD_NOWAIT |DOCMD_KEYTYPED |DOCMD_RANGEOK );
612+ }
613+
603614/*
604615 * do_cmdline(): execute one Ex command line
605616 *
@@ -995,7 +1006,7 @@ do_cmdline(
9951006 * "cmdline_copy" can change, e.g. for '%' and '#' expansion.
9961007 */
9971008 ++ recursive ;
998- next_cmdline = do_one_cmd (& cmdline_copy , flags & DOCMD_VERBOSE ,
1009+ next_cmdline = do_one_cmd (& cmdline_copy , flags ,
9991010#ifdef FEAT_EVAL
10001011 & cstack ,
10011012#endif
@@ -1691,7 +1702,8 @@ comment_start(char_u *p, int starts_with_colon UNUSED)
16911702/*
16921703 * Execute one Ex command.
16931704 *
1694- * If 'sourcing' is TRUE, the command will be included in the error message.
1705+ * If "flags" has DOCMD_VERBOSE, the command will be included in the error
1706+ * message.
16951707 *
16961708 * 1. skip comment lines and leading space
16971709 * 2. handle command modifiers
@@ -1714,7 +1726,7 @@ comment_start(char_u *p, int starts_with_colon UNUSED)
17141726 static char_u *
17151727do_one_cmd (
17161728 char_u * * cmdlinep ,
1717- int sourcing ,
1729+ int flags ,
17181730#ifdef FEAT_EVAL
17191731 cstack_T * cstack ,
17201732#endif
@@ -1737,6 +1749,7 @@ do_one_cmd(
17371749 int vim9script = in_vim9script ();
17381750 int did_set_expr_line = FALSE;
17391751#endif
1752+ int sourcing = flags & DOCMD_VERBOSE ;
17401753
17411754 CLEAR_FIELD (ea );
17421755 ea .line1 = 1 ;
@@ -1800,7 +1813,7 @@ do_one_cmd(
18001813#ifdef FEAT_EVAL
18011814 // In Vim9 script a colon is required before the range. This may also be
18021815 // after command modifiers.
1803- if (vim9script )
1816+ if (vim9script && ( flags & DOCMD_RANGEOK ) == 0 )
18041817 {
18051818 may_have_range = FALSE;
18061819 for (p = ea .cmd ; p >= * cmdlinep ; -- p )
@@ -3325,9 +3338,13 @@ find_ex_command(
33253338
33263339 // When followed by "=" or "+=" then it is an assignment.
33273340 ++ emsg_silent ;
3328- if (skip_expr (& after , NULL ) == OK
3329- && (* after == '='
3330- || (* after != NUL && after [1 ] == '=' )))
3341+ if (skip_expr (& after , NULL ) == OK )
3342+ after = skipwhite (after );
3343+ else
3344+ after = (char_u * )"" ;
3345+ if (* after == '=' || (* after != NUL && after [1 ] == '=' )
3346+ || (after [0 ] == '.' && after [1 ] == '.'
3347+ && after [2 ] == '=' ))
33313348 eap -> cmdidx = CMD_var ;
33323349 else
33333350 eap -> cmdidx = CMD_eval ;
@@ -5015,7 +5032,7 @@ ex_buffer(exarg_T *eap)
50155032 else
50165033 goto_buffer (eap , DOBUF_FIRST , FORWARD , (int )eap -> line2 );
50175034 if (eap -> do_ecmd_cmd != NULL )
5018- do_cmdline_cmd (eap -> do_ecmd_cmd );
5035+ do_cmd_argument (eap -> do_ecmd_cmd );
50195036 }
50205037}
50215038
@@ -5028,7 +5045,7 @@ ex_bmodified(exarg_T *eap)
50285045{
50295046 goto_buffer (eap , DOBUF_MOD , FORWARD , (int )eap -> line2 );
50305047 if (eap -> do_ecmd_cmd != NULL )
5031- do_cmdline_cmd (eap -> do_ecmd_cmd );
5048+ do_cmd_argument (eap -> do_ecmd_cmd );
50325049}
50335050
50345051/*
@@ -5043,7 +5060,7 @@ ex_bnext(exarg_T *eap)
50435060
50445061 goto_buffer (eap , DOBUF_CURRENT , FORWARD , (int )eap -> line2 );
50455062 if (eap -> do_ecmd_cmd != NULL )
5046- do_cmdline_cmd (eap -> do_ecmd_cmd );
5063+ do_cmd_argument (eap -> do_ecmd_cmd );
50475064}
50485065
50495066/*
@@ -5060,7 +5077,7 @@ ex_bprevious(exarg_T *eap)
50605077
50615078 goto_buffer (eap , DOBUF_CURRENT , BACKWARD , (int )eap -> line2 );
50625079 if (eap -> do_ecmd_cmd != NULL )
5063- do_cmdline_cmd (eap -> do_ecmd_cmd );
5080+ do_cmd_argument (eap -> do_ecmd_cmd );
50645081}
50655082
50665083/*
@@ -5077,7 +5094,7 @@ ex_brewind(exarg_T *eap)
50775094
50785095 goto_buffer (eap , DOBUF_FIRST , FORWARD , 0 );
50795096 if (eap -> do_ecmd_cmd != NULL )
5080- do_cmdline_cmd (eap -> do_ecmd_cmd );
5097+ do_cmd_argument (eap -> do_ecmd_cmd );
50815098}
50825099
50835100/*
@@ -5092,7 +5109,7 @@ ex_blast(exarg_T *eap)
50925109
50935110 goto_buffer (eap , DOBUF_LAST , BACKWARD , 0 );
50945111 if (eap -> do_ecmd_cmd != NULL )
5095- do_cmdline_cmd (eap -> do_ecmd_cmd );
5112+ do_cmd_argument (eap -> do_ecmd_cmd );
50965113}
50975114
50985115/*
@@ -6631,7 +6648,8 @@ do_exedit(
66316648 else if (eap -> cmdidx == CMD_enew )
66326649 readonlymode = FALSE; // 'readonly' doesn't make sense in an
66336650 // empty buffer
6634- setpcmark ();
6651+ if (eap -> cmdidx != CMD_balt && eap -> cmdidx != CMD_badd )
6652+ setpcmark ();
66356653 if (do_ecmd (0 , (eap -> cmdidx == CMD_enew ? NULL : eap -> arg ),
66366654 NULL , eap ,
66376655 // ":edit" goes to first line if Vi compatible
@@ -6686,7 +6704,7 @@ do_exedit(
66866704 else
66876705 {
66886706 if (eap -> do_ecmd_cmd != NULL )
6689- do_cmdline_cmd (eap -> do_ecmd_cmd );
6707+ do_cmd_argument (eap -> do_ecmd_cmd );
66906708#ifdef FEAT_TITLE
66916709 n = curwin -> w_arg_idx_invalid ;
66926710#endif
0 commit comments