changeset 26861:df2de1e63de0 v8.2.3959

patch 8.2.3959: error messages are spread out Commit: https://github.com/vim/vim/commit/6d0570117ac86b7979bf249de5741088212d6e17 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Dec 31 18:49:43 2021 +0000 patch 8.2.3959: error messages are spread out Problem: Error messages are spread out. Solution: Move more errors to errors.h.
author Bram Moolenaar <Bram@vim.org>
date Fri, 31 Dec 2021 20:00:05 +0100
parents 07ad81bfab52
children e91b94a101d1
files src/autocmd.c src/bufwrite.c src/errors.h src/evalvars.c src/ex_docmd.c src/ex_eval.c src/ex_getln.c src/fileio.c src/getchar.c src/gui.c src/locale.c src/map.c src/version.c
diffstat 13 files changed, 122 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/src/autocmd.c
+++ b/src/autocmd.c
@@ -687,7 +687,7 @@ find_end_event(
     {
 	if (arg[1] && !VIM_ISWHITE(arg[1]))
 	{
-	    semsg(_("E215: Illegal character after *: %s"), arg);
+	    semsg(_(e_illegal_character_after_star_str), arg);
 	    return NULL;
 	}
 	pat = arg + 1;
@@ -699,9 +699,9 @@ find_end_event(
 	    if ((int)event_name2nr(pat, &p) >= NUM_EVENTS)
 	    {
 		if (have_group)
-		    semsg(_("E216: No such event: %s"), pat);
+		    semsg(_(e_no_such_event_str), pat);
 		else
-		    semsg(_("E216: No such group or event: %s"), pat);
+		    semsg(_(e_no_such_group_or_event_str), pat);
 		return NULL;
 	    }
 	}
@@ -1329,7 +1329,7 @@ do_doautocmd(
 
     if (*arg == '*')
     {
-	emsg(_("E217: Can't execute autocommands for ALL events"));
+	emsg(_(e_cant_execute_autocommands_for_all_events));
 	return FAIL;
     }
 
@@ -1942,7 +1942,7 @@ apply_autocmds_group(
      */
     if (nesting == 10)
     {
-	emsg(_("E218: autocommand nesting too deep"));
+	emsg(_(e_autocommand_nesting_too_deep));
 	goto BYPASS_AU;
     }
 
--- a/src/bufwrite.c
+++ b/src/bufwrite.c
@@ -932,7 +932,7 @@ buf_write(
 #ifdef FEAT_EVAL
 	    if (!aborting())
 #endif
-		emsg(_("E203: Autocommands deleted or unloaded buffer to be written"));
+		emsg(_(e_autocommands_deleted_or_unloaded_buffer_to_be_written));
 	    return FAIL;
 	}
 
@@ -953,7 +953,7 @@ buf_write(
 		{
 		    --no_wait_return;
 		    msg_scroll = msg_save;
-		    emsg(_("E204: Autocommand changed number of lines in unexpected way"));
+		    emsg(_(e_autocommands_changed_number_of_lines_in_unexpected_way));
 		    return FAIL;
 		}
 	    }
@@ -1746,7 +1746,7 @@ buf_write(
 		wfname = vim_tempname('w', FALSE);
 		if (wfname == NULL)	// Can't write without a tempfile!
 		{
-		    errmsg = (char_u *)_("E214: Can't find temp file for writing");
+		    errmsg = (char_u *)_(e_cant_find_temp_file_for_writing);
 		    goto restore_backup;
 		}
 	    }
@@ -1764,7 +1764,7 @@ buf_write(
     {
 	if (!forceit)
 	{
-	    errmsg = (char_u *)_("E213: Cannot convert (add ! to write without conversion)");
+	    errmsg = (char_u *)_(e_cannot_convert_add_bang_to_write_without_conversion);
 	    goto restore_backup;
 	}
 	notconverted = TRUE;
@@ -1826,7 +1826,7 @@ buf_write(
 		    else
 #endif
 		    {
-			errmsg = (char_u *)_("E212: Can't open file for writing");
+			errmsg = (char_u *)_(e_cant_open_file_for_writing);
 			if (forceit && vim_strchr(p_cpo, CPO_FWRITE) == NULL
 								  && perm >= 0)
 			{
@@ -2454,7 +2454,7 @@ restore_backup:
 	    // If the original file does not exist yet
 	    // the current backup file becomes the original file
 	    if (org == NULL)
-		emsg(_("E205: Patchmode: can't save original file"));
+		emsg(_(e_patchmode_cant_save_original_file));
 	    else if (mch_stat(org, &st) < 0)
 	    {
 		vim_rename(backup, (char_u *)org);
@@ -2474,7 +2474,7 @@ restore_backup:
 		    || (empty_fd = mch_open(org,
 				      O_CREAT | O_EXTRA | O_EXCL | O_NOFOLLOW,
 					perm < 0 ? 0666 : (perm & 0777))) < 0)
-	      emsg(_("E206: patchmode: can't touch empty original file"));
+	      emsg(_(e_patchmode_cant_touch_empty_original_file));
 	    else
 	      close(empty_fd);
 	}
@@ -2489,7 +2489,7 @@ restore_backup:
     // conversion error.
     if (!p_bk && backup != NULL && !write_info.bw_conv_error
 	    && mch_remove(backup) != 0)
-	emsg(_("E207: Can't delete backup file"));
+	emsg(_(e_cant_delete_backup_file));
 
     goto nofail;
 
--- a/src/errors.h
+++ b/src/errors.h
@@ -412,12 +412,89 @@ EXTERN char e_str_exists_add_bang_to_ove
 	INIT(= N_("E189: \"%s\" exists (add ! to override)"));
 EXTERN char e_cannot_open_str_for_writing_2[]
 	INIT(= N_("E190: Cannot open \"%s\" for writing"));
-
-
+EXTERN char e_argument_must_be_letter_or_forward_backward_quote[]
+	INIT(= N_("E191: Argument must be a letter or forward/backward quote"));
+EXTERN char e_recursive_use_of_normal_too_deep[]
+	INIT(= N_("E192: Recursive use of :normal too deep"));
+EXTERN char e_str_not_inside_function[]
+	INIT(= N_("E193: %s not inside a function"));
+EXTERN char e_no_alternate_file_name_to_substitute_for_hash[]
+	INIT(= N_("E194: No alternate file name to substitute for '#'"));
+EXTERN char e_cannot_open_viminfo_file_for_reading[]
+	INIT(= N_("E195: Cannot open viminfo file for reading"));
 #ifndef FEAT_DIGRAPHS
 EXTERN char e_no_digraphs_version[]
 	INIT(= N_("E196: No digraphs in this version"));
 #endif
+EXTERN char e_cannot_set_language_to_str[]
+	INIT(= N_("E197: Cannot set language to \"%s\""));
+// E198 unused
+EXTERN char e_active_window_or_buffer_deleted[]
+	INIT(= N_("E199: Active window or buffer deleted"));
+EXTERN char e_readpre_autocommands_made_file_unreadable[]
+	INIT(= N_("E200: *ReadPre autocommands made the file unreadable"));
+EXTERN char e_readpre_autocommands_must_not_change_current_buffer[]
+	INIT(= N_("E201: *ReadPre autocommands must not change current buffer"));
+EXTERN char e_conversion_mad_file_unreadable[]
+	INIT(= N_("E202: Conversion made file unreadable!"));
+EXTERN char e_autocommands_deleted_or_unloaded_buffer_to_be_written[]
+	INIT(= N_("E203: Autocommands deleted or unloaded buffer to be written"));
+EXTERN char e_autocommands_changed_number_of_lines_in_unexpected_way[]
+	INIT(= N_("E204: Autocommand changed number of lines in unexpected way"));
+EXTERN char e_patchmode_cant_save_original_file[]
+	INIT(= N_("E205: Patchmode: can't save original file"));
+EXTERN char e_patchmode_cant_touch_empty_original_file[]
+	INIT(= N_("E206: patchmode: can't touch empty original file"));
+EXTERN char e_cant_delete_backup_file[]
+	INIT(= N_("E207: Can't delete backup file"));
+EXTERN char e_error_writing_to_str[]
+	INIT(= N_("E208: Error writing to \"%s\""));
+EXTERN char e_error_closing_str[]
+	INIT(= N_("E209: Error closing \"%s\""));
+EXTERN char e_error_reading_str[]
+	INIT(= N_("E210: Error reading \"%s\""));
+EXTERN char e_file_str_no_longer_available[]
+	INIT(= N_("E211: File \"%s\" no longer available"));
+EXTERN char e_cant_open_file_for_writing[]
+	INIT(= N_("E212: Can't open file for writing"));
+EXTERN char e_cannot_convert_add_bang_to_write_without_conversion[]
+	INIT(= N_("E213: Cannot convert (add ! to write without conversion)"));
+EXTERN char e_cant_find_temp_file_for_writing[]
+	INIT(= N_("E214: Can't find temp file for writing"));
+EXTERN char e_illegal_character_after_star_str[]
+	INIT(= N_("E215: Illegal character after *: %s"));
+EXTERN char e_no_such_event_str[]
+	INIT(= N_("E216: No such event: %s"));
+EXTERN char e_no_such_group_or_event_str[]
+	INIT(= N_("E216: No such group or event: %s"));
+EXTERN char e_cant_execute_autocommands_for_all_events[]
+	INIT(= N_("E217: Can't execute autocommands for ALL events"));
+EXTERN char e_autocommand_nesting_too_deep[]
+	INIT(= N_("E218: autocommand nesting too deep"));
+EXTERN char e_missing_open_curly[]
+	INIT(= N_("E219: Missing {."));
+EXTERN char e_missing_close_curly[]
+	INIT(= N_("E220: Missing }."));
+EXTERN char e_marker_cannot_start_with_lower_case_letter[]
+	INIT(= N_("E221: Marker cannot start with lower case letter"));
+EXTERN char e_add_to_internal_buffer_that_was_already_read_from[]
+	INIT(= N_("E222: Add to internal buffer that was already read from"));
+EXTERN char e_recursive_mapping[]
+	INIT(= N_("E223: recursive mapping"));
+EXTERN char e_global_abbreviation_already_exists_for_str[]
+	INIT(= N_("E224: global abbreviation already exists for %s"));
+EXTERN char e_global_mapping_already_exists_for_str[]
+	INIT(= N_("E225: global mapping already exists for %s"));
+EXTERN char e_abbreviation_already_exists_for_str[]
+	INIT(= N_("E226: abbreviation already exists for %s"));
+EXTERN char e_mapping_already_exists_for_str[]
+	INIT(= N_("E227: mapping already exists for %s"));
+EXTERN char e_makemap_illegal_mode[]
+	INIT(= N_("E228: makemap: Illegal mode"));
+EXTERN char e_cannot_start_the_GUI[]
+	INIT(= N_("E229: Cannot start the GUI"));
+
+
 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
 EXTERN char e_cannot_allocate_color_str[]
 	INIT(= N_("E254: Cannot allocate color %s"));
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -626,7 +626,7 @@ heredoc_get(exarg_T *eap, char_u *cmd, i
 	*p = NUL;
 	if (!script_get && vim_islower(*marker))
 	{
-	    emsg(_("E221: Marker cannot start with lower case letter"));
+	    emsg(_(e_marker_cannot_start_with_lower_case_letter));
 	    return NULL;
 	}
     }
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -8335,7 +8335,7 @@ ex_mark(exarg_T *eap)
 	curwin->w_cursor.lnum = eap->line2;
 	beginline(BL_WHITE | BL_FIX);
 	if (setmark(*eap->arg) == FAIL)	// set mark
-	    emsg(_("E191: Argument must be a letter or forward/backward quote"));
+	    emsg(_(e_argument_must_be_letter_or_forward_backward_quote));
 	curwin->w_cursor = pos;		// restore curwin->w_cursor
     }
 }
@@ -8426,7 +8426,7 @@ ex_normal(exarg_T *eap)
     }
     if (ex_normal_busy >= p_mmd)
     {
-	emsg(_("E192: Recursive use of :normal too deep"));
+	emsg(_(e_recursive_use_of_normal_too_deep));
 	return;
     }
 
@@ -9062,7 +9062,7 @@ eval_vars(
 		    buf = buflist_findnr(i);
 		    if (buf == NULL)
 		    {
-			*errormsg = _("E194: No alternate file name to substitute for '#'");
+			*errormsg = _(e_no_alternate_file_name_to_substitute_for_hash);
 			return NULL;
 		    }
 		    if (lnump != NULL)
--- a/src/ex_eval.c
+++ b/src/ex_eval.c
@@ -2516,15 +2516,15 @@ rewind_conditionals(
 }
 
 /*
- * ":endfunction" when not after a ":function"
+ * ":endfunction" or ":enddef" when not after a ":function"
  */
     void
 ex_endfunction(exarg_T *eap)
 {
     if (eap->cmdidx == CMD_enddef)
-	emsg(_("E193: :enddef not inside a function"));
+	semsg(_(e_str_not_inside_function), ":enddef");
     else
-	emsg(_("E193: :endfunction not inside a function"));
+	semsg(_(e_str_not_inside_function), ":endfunction");
 }
 
 /*
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -4390,7 +4390,7 @@ open_cmdwin(void)
     if (!win_valid(old_curwin) || !bufref_valid(&old_curbuf))
     {
 	cmdwin_result = Ctrl_C;
-	emsg(_("E199: Active window or buffer deleted"));
+	emsg(_(e_active_window_or_buffer_deleted));
     }
     else
     {
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -727,9 +727,9 @@ readfile(
 	    --no_wait_return;
 	    msg_scroll = msg_save;
 	    if (fd < 0)
-		emsg(_("E200: *ReadPre autocommands made the file unreadable"));
+		emsg(_(e_readpre_autocommands_made_file_unreadable));
 	    else
-		emsg(_("E201: *ReadPre autocommands must not change current buffer"));
+		emsg(_(e_readpre_autocommands_must_not_change_current_buffer));
 	    curbuf->b_p_ro = TRUE;	// must use "w!" now
 	    return FAIL;
 	}
@@ -1053,7 +1053,7 @@ retry:
 		    if (fd < 0)
 		    {
 			// Re-opening the original file failed!
-			emsg(_("E202: Conversion made file unreadable!"));
+			emsg(_(e_conversion_mad_file_unreadable));
 			error = TRUE;
 			goto failed;
 		    }
@@ -3873,17 +3873,17 @@ vim_rename(char_u *from, char_u *to)
     while ((n = read_eintr(fd_in, buffer, WRITEBUFSIZE)) > 0)
 	if (write_eintr(fd_out, buffer, n) != n)
 	{
-	    errmsg = _("E208: Error writing to \"%s\"");
+	    errmsg = _(e_error_writing_to_str);
 	    break;
 	}
 
     vim_free(buffer);
     close(fd_in);
     if (close(fd_out) < 0)
-	errmsg = _("E209: Error closing \"%s\"");
+	errmsg = _(e_error_closing_str);
     if (n < 0)
     {
-	errmsg = _("E210: Error reading \"%s\"");
+	errmsg = _(e_error_reading_str);
 	to = from;
     }
 #ifndef UNIX	    // for Unix mch_open() already set the permission
@@ -4172,7 +4172,7 @@ buf_check_timestamp(
 		{
 		    // Only give the message once.
 		    if (prev_b_mtime != -1)
-			mesg = _("E211: File \"%s\" no longer available");
+			mesg = _(e_file_str_no_longer_available);
 		}
 		else
 		{
@@ -5613,9 +5613,9 @@ file_pat_to_reg_pat(
     if (nested != 0)
     {
 	if (nested < 0)
-	    emsg(_("E219: Missing {."));
+	    emsg(_(e_missing_open_curly));
 	else
-	    emsg(_("E220: Missing }."));
+	    emsg(_(e_missing_close_curly));
 	VIM_CLEAR(reg_pat);
     }
     return reg_pat;
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -208,7 +208,7 @@ add_buff(
     }
     else if (buf->bh_curr == NULL)	// buffer has already been read
     {
-	iemsg(_("E222: Add to read buffer"));
+	iemsg(_(e_add_to_internal_buffer_that_was_already_read_from));
 	return;
     }
     else if (buf->bh_index != 0)
@@ -2758,7 +2758,7 @@ handle_mapping(
 	 */
 	if (++*mapdepth >= p_mmd)
 	{
-	    emsg(_("E223: recursive mapping"));
+	    emsg(_(e_recursive_mapping));
 	    if (State & CMDLINE)
 		redrawcmdline();
 	    else
--- a/src/gui.c
+++ b/src/gui.c
@@ -388,7 +388,7 @@ gui_init_check(void)
     if (result != MAYBE)
     {
 	if (result == FAIL)
-	    emsg(_("E229: Cannot start the GUI"));
+	    emsg(_(e_cannot_start_the_GUI));
 	return result;
     }
 
--- a/src/locale.c
+++ b/src/locale.c
@@ -339,7 +339,7 @@ ex_language(exarg_T *eap)
 # endif
 	}
 	if (loc == NULL)
-	    semsg(_("E197: Cannot set language to \"%s\""), name);
+	    semsg(_(e_cannot_set_language_to_str), name);
 	else
 	{
 # ifdef HAVE_NL_MSG_CAT_CNTR
--- a/src/map.c
+++ b/src/map.c
@@ -603,12 +603,11 @@ do_map(
 			    && STRNCMP(mp->m_keys, keys, (size_t)len) == 0)
 		    {
 			if (abbrev)
-			    semsg(_(
-			    "E224: global abbreviation already exists for %s"),
+			    semsg(
+			       _(e_global_abbreviation_already_exists_for_str),
 				    mp->m_keys);
 			else
-			    semsg(_(
-				 "E225: global mapping already exists for %s"),
+			    semsg(_(e_global_mapping_already_exists_for_str),
 				    mp->m_keys);
 			retval = 5;
 			goto theend;
@@ -741,12 +740,11 @@ do_map(
 			    else if (unique)
 			    {
 				if (abbrev)
-				    semsg(_(
-				   "E226: abbreviation already exists for %s"),
+				    semsg(
+				      _(e_abbreviation_already_exists_for_str),
 					    p);
 				else
-				    semsg(_(
-					"E227: mapping already exists for %s"),
+				    semsg(_(e_mapping_already_exists_for_str),
 					    p);
 				retval = 5;
 				goto theend;
@@ -1855,7 +1853,7 @@ makemap(
 			c1 = 't';
 			break;
 		    default:
-			iemsg(_("E228: makemap: Illegal mode"));
+			iemsg(_(e_makemap_illegal_mode));
 			return FAIL;
 		}
 		do	// do this twice if c2 is set, 3 times with c3
--- a/src/version.c
+++ b/src/version.c
@@ -750,6 +750,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3959,
+/**/
     3958,
 /**/
     3957,