patch 8.2.3750: error messages are everywhere

Problem:    Error messages are everywhere.
Solution:   Move more error messages to errors.h and adjust the names.
This commit is contained in:
Bram Moolenaar
2021-12-05 22:19:27 +00:00
parent 4700398e38
commit 40bcec1bac
18 changed files with 65 additions and 36 deletions

View File

@@ -209,7 +209,7 @@ write_blob(FILE *fd, blob_T *blob)
if (fwrite(blob->bv_ga.ga_data, 1, blob->bv_ga.ga_len, fd) if (fwrite(blob->bv_ga.ga_data, 1, blob->bv_ga.ga_len, fd)
< (size_t)blob->bv_ga.ga_len) < (size_t)blob->bv_ga.ga_len)
{ {
emsg(_(e_write)); emsg(_(e_error_while_writing));
return FAIL; return FAIL;
} }
return OK; return OK;

View File

@@ -193,7 +193,7 @@ open_buffer(
// This is OK, since there are no changes to lose. // This is OK, since there are no changes to lose.
if (curbuf == NULL) if (curbuf == NULL)
{ {
emsg(_("E82: Cannot allocate any buffer, exiting...")); emsg(_(e_cannot_allocate_any_buffer_exiting));
// Don't try to do any saving, with "curbuf" NULL almost nothing // Don't try to do any saving, with "curbuf" NULL almost nothing
// will work. // will work.
@@ -201,7 +201,7 @@ open_buffer(
getout(2); getout(2);
} }
emsg(_("E83: Cannot allocate buffer, using other one...")); emsg(_(e_cannot_allocate_buffer_using_other_one));
enter_buffer(curbuf); enter_buffer(curbuf);
#ifdef FEAT_SYN_HL #ifdef FEAT_SYN_HL
if (old_tw != curbuf->b_p_tw) if (old_tw != curbuf->b_p_tw)
@@ -1182,7 +1182,7 @@ empty_curbuf(
if (action == DOBUF_UNLOAD) if (action == DOBUF_UNLOAD)
{ {
emsg(_("E90: Cannot unload last buffer")); emsg(_(e_cannot_unload_last_buffer));
return FAIL; return FAIL;
} }
@@ -1255,7 +1255,7 @@ do_buffer_ext(
} }
if (!bufIsChanged(buf)) if (!bufIsChanged(buf))
{ {
emsg(_("E84: No modified buffer found")); emsg(_(e_no_modified_buffer_found));
return FAIL; return FAIL;
} }
} }
@@ -1294,7 +1294,7 @@ do_buffer_ext(
if (bp == buf) if (bp == buf)
{ {
// back where we started, didn't find anything. // back where we started, didn't find anything.
emsg(_("E85: There is no listed buffer")); emsg(_(e_there_is_no_listed_buffer));
return FAIL; return FAIL;
} }
} }
@@ -1306,12 +1306,12 @@ do_buffer_ext(
{ {
// don't warn when deleting // don't warn when deleting
if (!unload) if (!unload)
semsg(_(e_nobufnr), count); semsg(_(e_buffer_nr_does_not_exist), count);
} }
else if (dir == FORWARD) else if (dir == FORWARD)
emsg(_("E87: Cannot go beyond last buffer")); emsg(_(e_cannot_go_beyond_last_buffer));
else else
emsg(_("E88: Cannot go before first buffer")); emsg(_(e_cannot_go_before_first_buffer));
return FAIL; return FAIL;
} }
#ifdef FEAT_PROP_POPUP #ifdef FEAT_PROP_POPUP
@@ -1364,7 +1364,7 @@ do_buffer_ext(
else else
#endif #endif
{ {
semsg(_("E89: No write since last change for buffer %d (add ! to override)"), semsg(_(e_no_write_since_last_change_for_buffer_nr_add_bang_to_override),
buf->b_fnum); buf->b_fnum);
return FAIL; return FAIL;
} }

View File

@@ -1210,7 +1210,8 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
{ {
buf = buflist_findnr(opt->jo_io_buf[PART_OUT]); buf = buflist_findnr(opt->jo_io_buf[PART_OUT]);
if (buf == NULL) if (buf == NULL)
semsg(_(e_nobufnr), (long)opt->jo_io_buf[PART_OUT]); semsg(_(e_buffer_nr_does_not_exist),
(long)opt->jo_io_buf[PART_OUT]);
} }
else else
{ {
@@ -1257,7 +1258,8 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
{ {
buf = buflist_findnr(opt->jo_io_buf[PART_ERR]); buf = buflist_findnr(opt->jo_io_buf[PART_ERR]);
if (buf == NULL) if (buf == NULL)
semsg(_(e_nobufnr), (long)opt->jo_io_buf[PART_ERR]); semsg(_(e_buffer_nr_does_not_exist),
(long)opt->jo_io_buf[PART_ERR]);
} }
else else
{ {

View File

@@ -168,6 +168,34 @@ EXTERN char e_too_many_brackets[]
INIT(= N_("E76: Too many [")); INIT(= N_("E76: Too many ["));
EXTERN char e_too_many_file_names[] EXTERN char e_too_many_file_names[]
INIT(= N_("E77: Too many file names")); INIT(= N_("E77: Too many file names"));
EXTERN char e_unknown_mark[]
INIT(= N_("E78: Unknown mark"));
EXTERN char e_cannot_expand_wildcards[]
INIT(= N_("E79: Cannot expand wildcards"));
EXTERN char e_error_while_writing[]
INIT(= N_("E80: Error while writing"));
#ifdef FEAT_EVAL
EXTERN char e_using_sid_not_in_script_context[]
INIT(= N_("E81: Using <SID> not in a script context"));
#endif
EXTERN char e_cannot_allocate_any_buffer_exiting[]
INIT(= N_("E82: Cannot allocate any buffer, exiting..."));
EXTERN char e_cannot_allocate_buffer_using_other_one[]
INIT(= N_("E83: Cannot allocate buffer, using other one..."));
EXTERN char e_no_modified_buffer_found[]
INIT(= N_("E84: No modified buffer found"));
EXTERN char e_there_is_no_listed_buffer[]
INIT(= N_("E85: There is no listed buffer"));
EXTERN char e_buffer_nr_does_not_exist[]
INIT(= N_("E86: Buffer %ld does not exist"));
EXTERN char e_cannot_go_beyond_last_buffer[]
INIT(= N_("E87: Cannot go beyond last buffer"));
EXTERN char e_cannot_go_before_first_buffer[]
INIT(= N_("E88: Cannot go before first buffer"));
EXTERN char e_no_write_since_last_change_for_buffer_nr_add_bang_to_override[]
INIT(= N_("E89: No write since last change for buffer %d (add ! to override)"));
EXTERN char e_cannot_unload_last_buffer[]
INIT(= N_("E90: Cannot unload last buffer"));
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
EXTERN char e_undefined_variable_str[] EXTERN char e_undefined_variable_str[]

View File

@@ -9167,7 +9167,7 @@ eval_vars(
case SPEC_SID: case SPEC_SID:
if (current_sctx.sc_sid <= 0) if (current_sctx.sc_sid <= 0)
{ {
*errormsg = _(e_usingsid); *errormsg = _(e_using_sid_not_in_script_context);
return NULL; return NULL;
} }
sprintf((char *)strbuf, "<SNR>%d_", current_sctx.sc_sid); sprintf((char *)strbuf, "<SNR>%d_", current_sctx.sc_sid);

View File

@@ -1717,14 +1717,10 @@ EXTERN char e_signdata[] INIT(= N_("E255: Couldn't read in sign data!"));
#endif #endif
EXTERN char e_trailing[] INIT(= N_("E488: Trailing characters")); EXTERN char e_trailing[] INIT(= N_("E488: Trailing characters"));
EXTERN char e_trailing_arg[] INIT(= N_("E488: Trailing characters: %s")); EXTERN char e_trailing_arg[] INIT(= N_("E488: Trailing characters: %s"));
EXTERN char e_umark[] INIT(= N_("E78: Unknown mark"));
EXTERN char e_wildexpand[] INIT(= N_("E79: Cannot expand wildcards"));
EXTERN char e_winheight[] INIT(= N_("E591: 'winheight' cannot be smaller than 'winminheight'")); EXTERN char e_winheight[] INIT(= N_("E591: 'winheight' cannot be smaller than 'winminheight'"));
EXTERN char e_winwidth[] INIT(= N_("E592: 'winwidth' cannot be smaller than 'winminwidth'")); EXTERN char e_winwidth[] INIT(= N_("E592: 'winwidth' cannot be smaller than 'winminwidth'"));
EXTERN char e_write[] INIT(= N_("E80: Error while writing"));
EXTERN char e_zerocount[] INIT(= N_("E939: Positive count required")); EXTERN char e_zerocount[] INIT(= N_("E939: Positive count required"));
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
EXTERN char e_usingsid[] INIT(= N_("E81: Using <SID> not in a script context"));
EXTERN char e_missing_paren[] INIT(= N_("E107: Missing parentheses: %s")); EXTERN char e_missing_paren[] INIT(= N_("E107: Missing parentheses: %s"));
EXTERN char e_missing_close[] INIT(= N_("E110: Missing ')'")); EXTERN char e_missing_close[] INIT(= N_("E110: Missing ')'"));
EXTERN char e_missing_dict_colon[] INIT(= N_("E720: Missing colon in Dictionary: %s")); EXTERN char e_missing_dict_colon[] INIT(= N_("E720: Missing colon in Dictionary: %s"));
@@ -1741,7 +1737,6 @@ EXTERN char e_nbreadonly[] INIT(= N_("E744: NetBeans does not allow changes in r
#endif #endif
EXTERN char e_maxmempat[] INIT(= N_("E363: pattern uses more memory than 'maxmempattern'")); EXTERN char e_maxmempat[] INIT(= N_("E363: pattern uses more memory than 'maxmempattern'"));
EXTERN char e_emptybuf[] INIT(= N_("E749: empty buffer")); EXTERN char e_emptybuf[] INIT(= N_("E749: empty buffer"));
EXTERN char e_nobufnr[] INIT(= N_("E86: Buffer %ld does not exist"));
EXTERN char e_invalpat[] INIT(= N_("E682: Invalid search pattern or delimiter")); EXTERN char e_invalpat[] INIT(= N_("E682: Invalid search pattern or delimiter"));
EXTERN char e_bufloaded[] INIT(= N_("E139: File is loaded in another buffer")); EXTERN char e_bufloaded[] INIT(= N_("E139: File is loaded in another buffer"));

View File

@@ -225,7 +225,8 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
} }
if (buflist_findnr(opt->jo_io_buf[part]) == NULL) if (buflist_findnr(opt->jo_io_buf[part]) == NULL)
{ {
semsg(_(e_nobufnr), (long)opt->jo_io_buf[part]); semsg(_(e_buffer_nr_does_not_exist),
(long)opt->jo_io_buf[part]);
return FAIL; return FAIL;
} }
} }
@@ -475,7 +476,7 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
opt->jo_bufnr_buf = buflist_findnr(nr); opt->jo_bufnr_buf = buflist_findnr(nr);
if (opt->jo_bufnr_buf == NULL) if (opt->jo_bufnr_buf == NULL)
{ {
semsg(_(e_nobufnr), (long)nr); semsg(_(e_buffer_nr_does_not_exist), (long)nr);
return FAIL; return FAIL;
} }
if (opt->jo_bufnr_buf->b_nwindows == 0 if (opt->jo_bufnr_buf->b_nwindows == 0
@@ -1332,7 +1333,8 @@ job_start(
{ {
buf = buflist_findnr(opt.jo_io_buf[PART_IN]); buf = buflist_findnr(opt.jo_io_buf[PART_IN]);
if (buf == NULL) if (buf == NULL)
semsg(_(e_nobufnr), (long)opt.jo_io_buf[PART_IN]); semsg(_(e_buffer_nr_does_not_exist),
(long)opt.jo_io_buf[PART_IN]);
} }
else if (!(opt.jo_set & JO_IN_NAME)) else if (!(opt.jo_set & JO_IN_NAME))
{ {

View File

@@ -1603,7 +1603,7 @@ write_list(FILE *fd, list_T *list, int binary)
} }
if (ret == FAIL) if (ret == FAIL)
{ {
emsg(_(e_write)); emsg(_(e_error_while_writing));
break; break;
} }
} }

View File

@@ -578,7 +578,7 @@ check_mark(pos_T *pos)
{ {
if (pos == NULL) if (pos == NULL)
{ {
emsg(_(e_umark)); emsg(_(e_unknown_mark));
return FAIL; return FAIL;
} }
if (pos->lnum <= 0) if (pos->lnum <= 0)

View File

@@ -2403,7 +2403,7 @@ get_cmd_output_as_rettv(
buf = buflist_findnr(argvars[1].vval.v_number); buf = buflist_findnr(argvars[1].vval.v_number);
if (buf == NULL) if (buf == NULL)
{ {
semsg(_(e_nobufnr), argvars[1].vval.v_number); semsg(_(e_buffer_nr_does_not_exist), argvars[1].vval.v_number);
fclose(fd); fclose(fd);
goto errret; goto errret;
} }

View File

@@ -6797,7 +6797,7 @@ mch_expand_wildcards(
if (!(flags & EW_SILENT)) if (!(flags & EW_SILENT))
#endif #endif
{ {
msg(_(e_wildexpand)); msg(_(e_cannot_expand_wildcards));
msg_start(); // don't overwrite this message msg_start(); // don't overwrite this message
} }
} }
@@ -6817,7 +6817,7 @@ mch_expand_wildcards(
// Something went wrong, perhaps a file name with a special char. // Something went wrong, perhaps a file name with a special char.
if (!(flags & EW_SILENT)) if (!(flags & EW_SILENT))
{ {
msg(_(e_wildexpand)); msg(_(e_cannot_expand_wildcards));
msg_start(); // don't overwrite this message msg_start(); // don't overwrite this message
} }
vim_free(tempname); vim_free(tempname);

View File

@@ -1877,7 +1877,7 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type)
buf = buflist_findnr(argvars[0].vval.v_number); buf = buflist_findnr(argvars[0].vval.v_number);
if (buf == NULL) if (buf == NULL)
{ {
semsg(_(e_nobufnr), argvars[0].vval.v_number); semsg(_(e_buffer_nr_does_not_exist), argvars[0].vval.v_number);
return NULL; return NULL;
} }
#ifdef FEAT_TERMINAL #ifdef FEAT_TERMINAL

View File

@@ -2836,7 +2836,7 @@ write_reg_contents_ex(
buf = buflist_findnr(num); buf = buflist_findnr(num);
if (buf == NULL) if (buf == NULL)
semsg(_(e_nobufnr), (long)num); semsg(_(e_buffer_nr_does_not_exist), (long)num);
} }
else else
buf = buflist_findnr(buflist_findpat(str, str + STRLEN(str), buf = buflist_findnr(buflist_findpat(str, str + STRLEN(str),

View File

@@ -1331,7 +1331,7 @@ ex_mkrc(exarg_T *eap)
failed |= fclose(fd); failed |= fclose(fd);
if (failed) if (failed)
emsg(_(e_write)); emsg(_(e_error_while_writing));
#if defined(FEAT_SESSION) #if defined(FEAT_SESSION)
else if (eap->cmdidx == CMD_mksession) else if (eap->cmdidx == CMD_mksession)
{ {

View File

@@ -5259,7 +5259,7 @@ theend:
if (fwv != (size_t)1) if (fwv != (size_t)1)
retval = FAIL; retval = FAIL;
if (retval == FAIL) if (retval == FAIL)
emsg(_(e_write)); emsg(_(e_error_while_writing));
return retval; return retval;
} }
@@ -5404,7 +5404,7 @@ put_node(
if (fd != NULL) if (fd != NULL)
if (putc(np->wn_byte, fd) == EOF) // <byte> or <xbyte> if (putc(np->wn_byte, fd) == EOF) // <byte> or <xbyte>
{ {
emsg(_(e_write)); emsg(_(e_error_while_writing));
return 0; return 0;
} }
} }
@@ -5815,7 +5815,7 @@ sug_write(spellinfo_T *spin, char_u *fname)
*/ */
if (fwrite(VIMSUGMAGIC, VIMSUGMAGICL, (size_t)1, fd) != 1) // <fileID> if (fwrite(VIMSUGMAGIC, VIMSUGMAGICL, (size_t)1, fd) != 1) // <fileID>
{ {
emsg(_(e_write)); emsg(_(e_error_while_writing));
goto theend; goto theend;
} }
putc(VIMSUGVERSION, fd); // <versionnr> putc(VIMSUGVERSION, fd); // <versionnr>
@@ -5857,7 +5857,7 @@ sug_write(spellinfo_T *spin, char_u *fname)
len = (int)STRLEN(line) + 1; len = (int)STRLEN(line) + 1;
if (fwrite(line, (size_t)len, (size_t)1, fd) == 0) if (fwrite(line, (size_t)len, (size_t)1, fd) == 0)
{ {
emsg(_(e_write)); emsg(_(e_error_while_writing));
goto theend; goto theend;
} }
spin->si_memtot += len; spin->si_memtot += len;
@@ -5865,7 +5865,7 @@ sug_write(spellinfo_T *spin, char_u *fname)
// Write another byte to check for errors. // Write another byte to check for errors.
if (putc(0, fd) == EOF) if (putc(0, fd) == EOF)
emsg(_(e_write)); emsg(_(e_error_while_writing));
vim_snprintf((char *)IObuff, IOSIZE, vim_snprintf((char *)IObuff, IOSIZE,
_("Estimated runtime memory use: %d bytes"), spin->si_memtot); _("Estimated runtime memory use: %d bytes"), spin->si_memtot);

View File

@@ -6021,7 +6021,7 @@ replace_termcodes(
if (STRNICMP(src, "<SID>", 5) == 0) if (STRNICMP(src, "<SID>", 5) == 0)
{ {
if (current_sctx.sc_sid <= 0) if (current_sctx.sc_sid <= 0)
emsg(_(e_usingsid)); emsg(_(e_using_sid_not_in_script_context));
else else
{ {
src += 5; src += 5;

View File

@@ -3763,7 +3763,7 @@ trans_function_name(
// It's script-local, "s:" or "<SID>" // It's script-local, "s:" or "<SID>"
if (current_sctx.sc_sid <= 0) if (current_sctx.sc_sid <= 0)
{ {
emsg(_(e_usingsid)); emsg(_(e_using_sid_not_in_script_context));
goto theend; goto theend;
} }
sprintf((char *)sid_buf, "%ld_", (long)current_sctx.sc_sid); sprintf((char *)sid_buf, "%ld_", (long)current_sctx.sc_sid);

View File

@@ -753,6 +753,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
3750,
/**/ /**/
3749, 3749,
/**/ /**/