changeset 21461:4dfd00f481fb v8.2.1281

patch 8.2.1281: the "trailing characters" error can be hard to understand Commit: https://github.com/vim/vim/commit/2d06bfde29bd3a62fc85823d2aa719ef943bd319 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jul 23 17:16:18 2020 +0200 patch 8.2.1281: the "trailing characters" error can be hard to understand Problem: The "trailing characters" error can be hard to understand. Solution: Add the trailing characters to the message.
author Bram Moolenaar <Bram@vim.org>
date Thu, 23 Jul 2020 17:30:03 +0200
parents 280fe8be34a2
children e9f60cc88fd2
files src/cmdhist.c src/eval.c src/evalfunc.c src/evalvars.c src/ex_cmds.c src/ex_docmd.c src/ex_eval.c src/json.c src/menu.c src/quickfix.c src/sign.c src/userfunc.c src/version.c
diffstat 13 files changed, 24 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/cmdhist.c
+++ b/src/cmdhist.c
@@ -705,7 +705,7 @@ ex_history(exarg_T *eap)
 	    else
 	    {
 		*end = i;
-		emsg(_(e_trailing));
+		semsg(_(e_trailing_arg), arg);
 		return;
 	    }
 	}
@@ -717,7 +717,7 @@ ex_history(exarg_T *eap)
 	end = arg;
     if (!get_list_range(&end, &hisidx1, &hisidx2) || *end != NUL)
     {
-	emsg(_(e_trailing));
+	semsg(_(e_trailing_arg), end);
 	return;
     }
 
--- a/src/eval.c
+++ b/src/eval.c
@@ -797,7 +797,7 @@ get_lval(
 	if (unlet && !VIM_ISWHITE(*p) && !ends_excmd(*p)
 						    && *p != '[' && *p != '.')
 	{
-	    emsg(_(e_trailing));
+	    semsg(_(e_trailing_arg), p);
 	    return NULL;
 	}
 
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -2141,7 +2141,7 @@ f_eval(typval_T *argvars, typval_T *rett
 	rettv->vval.v_number = 0;
     }
     else if (*s != NUL)
-	emsg(_(e_trailing));
+	semsg(_(e_trailing_arg), s);
 }
 
 /*
@@ -5113,7 +5113,7 @@ f_islocked(typval_T *argvars, typval_T *
     if (end != NULL && lv.ll_name != NULL)
     {
 	if (*end != NUL)
-	    emsg(_(e_trailing));
+	    semsg(_(e_trailing_arg), end);
 	else
 	{
 	    if (lv.ll_tv == NULL)
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -592,7 +592,7 @@ heredoc_get(exarg_T *eap, char_u *cmd, i
 	p = skiptowhite(marker);
 	if (*skipwhite(p) != NUL && *skipwhite(p) != '"')
 	{
-	    emsg(_(e_trailing));
+	    semsg(_(e_trailing_arg), p);
 	    return NULL;
 	}
 	*p = NUL;
@@ -1113,7 +1113,7 @@ list_arg_vars(exarg_T *eap, char_u *arg,
 	    if (!VIM_ISWHITE(*arg) && !ends_excmd(*arg))
 	    {
 		emsg_severe = TRUE;
-		emsg(_(e_trailing));
+		semsg(_(e_trailing_arg), arg);
 		break;
 	    }
 	}
@@ -1489,7 +1489,7 @@ ex_unletlock(
 		if (name_end != NULL)
 		{
 		    emsg_severe = TRUE;
-		    emsg(_(e_trailing));
+		    semsg(_(e_trailing_arg), name_end);
 		}
 		if (!(eap->skip || error))
 		    clear_lval(&lv);
@@ -3431,9 +3431,9 @@ var_redir_start(char_u *name, int append
 	clear_lval(redir_lval);
 	if (redir_endp != NULL && *redir_endp != NUL)
 	    // Trailing characters are present after the variable name
-	    emsg(_(e_trailing));
+	    semsg(_(e_trailing_arg), redir_endp);
 	else
-	    emsg(_(e_invarg));
+	    semsg(_(e_invarg2), name);
 	redir_endp = NULL;  // don't store a value, only cleanup
 	var_redir_stop();
 	return FAIL;
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -3816,7 +3816,7 @@ do_sub(exarg_T *eap)
 	eap->nextcmd = check_nextcmd(cmd);
 	if (eap->nextcmd == NULL)
 	{
-	    emsg(_(e_trailing));
+	    semsg(_(e_trailing_arg), cmd);
 	    return;
 	}
     }
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -2396,7 +2396,7 @@ do_one_cmd(
 	    && *ea.arg != '"' && (*ea.arg != '|' || (ea.argt & EX_TRLBAR) == 0))
     {
 	// no arguments allowed but there is something
-	errormsg = _(e_trailing);
+	errormsg = ex_errmsg(e_trailing_arg, ea.arg);
 	goto doend;
     }
 
@@ -7725,7 +7725,7 @@ ex_mark(exarg_T *eap)
     if (*eap->arg == NUL)		// No argument?
 	emsg(_(e_argreq));
     else if (eap->arg[1] != NUL)	// more than one character?
-	emsg(_(e_trailing));
+	semsg(_(e_trailing_arg), eap->arg);
     else
     {
 	pos = curwin->w_cursor;		// save curwin->w_cursor
--- a/src/ex_eval.c
+++ b/src/ex_eval.c
@@ -1588,7 +1588,7 @@ ex_catch(exarg_T *eap)
 	    if (end != NULL && *end != NUL
 				      && !ends_excmd2(end, skipwhite(end + 1)))
 	    {
-		emsg(_(e_trailing));
+		semsg(_(e_trailing_arg), end);
 		return;
 	    }
 
--- a/src/json.c
+++ b/src/json.c
@@ -1086,7 +1086,7 @@ json_decode_all(js_read_T *reader, typva
     json_skip_white(reader);
     if (reader->js_buf[reader->js_used] != NUL)
     {
-	emsg(_(e_trailing));
+	semsg(_(e_trailing_arg), reader->js_buf + reader->js_used);
 	return FAIL;
     }
     return OK;
--- a/src/menu.c
+++ b/src/menu.c
@@ -289,7 +289,7 @@ ex_menu(
     }
     else if (*map_to != NUL && (unmenu || enable != MAYBE))
     {
-	emsg(_(e_trailing));
+	semsg(_(e_trailing_arg), map_to);
 	goto theend;
     }
 #if defined(FEAT_GUI) && !(defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON))
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -3579,7 +3579,7 @@ qf_list(exarg_T *eap)
     }
     if (!get_list_range(&arg, &idx1, &idx2) || *arg != NUL)
     {
-	emsg(_(e_trailing));
+	semsg(_(e_trailing_arg), arg);
 	return;
     }
     qfl = qf_get_curlist(qi);
--- a/src/sign.c
+++ b/src/sign.c
@@ -1577,7 +1577,7 @@ parse_sign_cmd_args(
 	    filename = arg;
 	    *buf = buflist_findnr((int)getdigits(&arg));
 	    if (*skipwhite(arg) != NUL)
-		emsg(_(e_trailing));
+		semsg(_(e_trailing_arg), arg);
 	    break;
 	}
 	else
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -2664,7 +2664,7 @@ def_function(exarg_T *eap, char_u *name_
     {
 	if (!ends_excmd(*skipwhite(p)))
 	{
-	    emsg(_(e_trailing));
+	    semsg(_(e_trailing_arg), p);
 	    goto ret_free;
 	}
 	eap->nextcmd = check_nextcmd(p);
@@ -2833,7 +2833,7 @@ def_function(exarg_T *eap, char_u *name_
 	    && !(*p == '#' && (vim9script || eap->cmdidx == CMD_def))
 	    && !eap->skip
 	    && !did_emsg)
-	emsg(_(e_trailing));
+	semsg(_(e_trailing_arg), p);
 
     /*
      * Read the body of the function, until "}", ":endfunction" or ":enddef" is
@@ -3629,7 +3629,7 @@ ex_delfunction(exarg_T *eap)
     if (!ends_excmd(*skipwhite(p)))
     {
 	vim_free(name);
-	emsg(_(e_trailing));
+	semsg(_(e_trailing_arg), p);
 	return;
     }
     eap->nextcmd = check_nextcmd(p);
@@ -3977,7 +3977,7 @@ ex_call(exarg_T *eap)
 	    if (!failed)
 	    {
 		emsg_severe = TRUE;
-		emsg(_(e_trailing));
+		semsg(_(e_trailing_arg), arg);
 	    }
 	}
 	else
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1281,
+/**/
     1280,
 /**/
     1279,