Skip to content

Commit e29a27f

Browse files
committed
patch 8.2.3190: error messages are spread out
Problem: Error messages are spread out. Solution: Move error messages to errors.h and give them a clear name.
1 parent 9fa5dab commit e29a27f

29 files changed

Lines changed: 127 additions & 98 deletions

src/buffer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,7 +1942,7 @@ no_write_message(void)
19421942
emsg(_("E948: Job still running (add ! to end the job)"));
19431943
else
19441944
#endif
1945-
emsg(_("E37: No write since last change (add ! to override)"));
1945+
emsg(_(e_no_write_since_last_change_add_bang_to_override));
19461946
}
19471947

19481948
void
@@ -1953,7 +1953,7 @@ no_write_message_nobang(buf_T *buf UNUSED)
19531953
emsg(_("E948: Job still running"));
19541954
else
19551955
#endif
1956-
emsg(_("E37: No write since last change"));
1956+
emsg(_(e_no_write_since_last_change));
19571957
}
19581958

19591959
/*

src/debugger.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ dbg_parsearg(
562562
{
563563
if (curbuf->b_ffname == NULL)
564564
{
565-
emsg(_(e_noname));
565+
emsg(_(e_no_file_name));
566566
return FAIL;
567567
}
568568
bp->dbg_type = DBG_FILE;

src/digraph.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,7 +2074,7 @@ putdigraph(char_u *str)
20742074
str = skipwhite(str);
20752075
if (!VIM_ISDIGIT(*str))
20762076
{
2077-
emsg(_(e_number_exp));
2077+
emsg(_(e_number_expected));
20782078
return;
20792079
}
20802080
n = getdigits(&str);
@@ -2571,7 +2571,7 @@ keymap_init(void)
25712571
buflen = STRLEN(curbuf->b_p_keymap) + STRLEN(p_enc) + 14;
25722572
buf = alloc(buflen);
25732573
if (buf == NULL)
2574-
return e_outofmem;
2574+
return e_out_of_memory;
25752575

25762576
// try finding "keymap/'keymap'_'encoding'.vim" in 'runtimepath'
25772577
vim_snprintf((char *)buf, buflen, "keymap/%s_%s.vim",

src/edit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2874,7 +2874,7 @@ stuff_inserted(
28742874
ptr = get_last_insert();
28752875
if (ptr == NULL)
28762876
{
2877-
emsg(_(e_noinstext));
2877+
emsg(_(e_no_inserted_text_yet));
28782878
return FAIL;
28792879
}
28802880

src/errors.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,63 @@ EXTERN char e_no_alternate_file[]
4848
INIT(= N_("E23: No alternate file"));
4949
EXTERN char e_no_such_abbreviation[]
5050
INIT(= N_("E24: No such abbreviation"));
51+
#if !defined(FEAT_GUI) || defined(VIMDLL)
52+
EXTERN char e_gui_cannot_be_used_not_enabled_at_compile_time[]
53+
INIT(= N_("E25: GUI cannot be used: Not enabled at compile time"));
54+
#endif
55+
#ifndef FEAT_RIGHTLEFT
56+
EXTERN char e_hebrew_cannot_be_used_not_enabled_at_compile_time[]
57+
INIT(= N_("E26: Hebrew cannot be used: Not enabled at compile time\n"));
58+
#endif
59+
EXTERN char e_farsi_support_has_been_removed[]
60+
INIT(= N_("E27: Farsi support has been removed\n"));
5161
#ifdef FEAT_EVAL
62+
#if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_SYN_HL)
63+
EXTERN char e_no_such_highlight_group_name_str[]
64+
INIT(= N_("E28: No such highlight group name: %s"));
65+
#endif
66+
EXTERN char e_no_inserted_text_yet[]
67+
INIT(= N_("E29: No inserted text yet"));
68+
EXTERN char e_no_previous_command_line[]
69+
INIT(= N_("E30: No previous command line"));
70+
EXTERN char e_no_such_mapping[]
71+
INIT(= N_("E31: No such mapping"));
72+
EXTERN char e_no_file_name[]
73+
INIT(= N_("E32: No file name"));
74+
EXTERN char e_no_previous_substitute_regular_expression[]
75+
INIT(= N_("E33: No previous substitute regular expression"));
76+
EXTERN char e_no_previous_command[]
77+
INIT(= N_("E34: No previous command"));
78+
EXTERN char e_no_previous_regular_expression[]
79+
INIT(= N_("E35: No previous regular expression"));
80+
EXTERN char e_not_enough_room[]
81+
INIT(= N_("E36: Not enough room"));
82+
EXTERN char e_no_write_since_last_change[]
83+
INIT(= N_("E37: No write since last change"));
84+
EXTERN char e_no_write_since_last_change_add_bang_to_override[]
85+
INIT(= N_("E37: No write since last change (add ! to override)"));
86+
EXTERN char e_null_argument[]
87+
INIT(= N_("E38: Null argument"));
88+
#if defined(FEAT_DIGRAPHS) || defined(FEAT_TIMERS) || defined(FEAT_EVAL)
89+
EXTERN char e_number_expected[]
90+
INIT(= N_("E39: Number expected"));
91+
#endif
92+
#ifdef FEAT_QUICKFIX
93+
EXTERN char e_cant_open_errorfile_str[]
94+
INIT(= N_("E40: Can't open errorfile %s"));
95+
#endif
96+
EXTERN char e_out_of_memory[]
97+
INIT(= N_("E41: Out of memory!"));
98+
#ifdef FEAT_QUICKFIX
99+
EXTERN char e_no_errors[]
100+
INIT(= N_("E42: No Errors"));
101+
#endif
102+
EXTERN char e_damaged_match_string[]
103+
INIT(= N_("E43: Damaged match string"));
104+
EXTERN char e_corrupted_regexp_program[]
105+
INIT(= N_("E44: Corrupted regexp program"));
106+
EXTERN char e_readonly_option_is_set_add_bang_to_override[]
107+
INIT(= N_("E45: 'readonly' option is set (add ! to override)"));
52108
EXTERN char e_undefined_variable_str[]
53109
INIT(= N_("E121: Undefined variable: %s"));
54110
EXTERN char e_undefined_variable_char_str[]

src/ex_cmds.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ ex_sort(exarg_T *eap)
466466
{
467467
if (last_search_pat() == NULL)
468468
{
469-
emsg(_(e_noprevre));
469+
emsg(_(e_no_previous_regular_expression));
470470
goto sortend;
471471
}
472472
regmatch.regprog = vim_regcomp(last_search_pat(), RE_MAGIC);
@@ -935,7 +935,7 @@ do_bang(
935935
{
936936
if (prevcmd == NULL)
937937
{
938-
emsg(_(e_noprev));
938+
emsg(_(e_no_previous_command));
939939
vim_free(newcmd);
940940
return;
941941
}
@@ -2356,7 +2356,7 @@ check_readonly(int *forceit, buf_T *buf)
23562356
else
23572357
#endif
23582358
if (buf->b_p_ro)
2359-
emsg(_(e_readonly));
2359+
emsg(_(e_readonly_option_is_set_add_bang_to_override));
23602360
else
23612361
semsg(_("E505: \"%s\" is read-only (add ! to override)"),
23622362
buf->b_fname);
@@ -3763,7 +3763,7 @@ ex_substitute(exarg_T *eap)
37633763
{
37643764
if (old_sub == NULL) // there is no previous command
37653765
{
3766-
emsg(_(e_nopresub));
3766+
emsg(_(e_no_previous_substitute_regular_expression));
37673767
return;
37683768
}
37693769
sub = old_sub;
@@ -3779,7 +3779,7 @@ ex_substitute(exarg_T *eap)
37793779
{
37803780
if (old_sub == NULL) // there is no previous command
37813781
{
3782-
emsg(_(e_nopresub));
3782+
emsg(_(e_no_previous_substitute_regular_expression));
37833783
return;
37843784
}
37853785
pat = NULL; // search_regcomp() will use previous pattern

src/ex_cmds2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ check_fname(void)
413413
{
414414
if (curbuf->b_ffname == NULL)
415415
{
416-
emsg(_(e_noname));
416+
emsg(_(e_no_file_name));
417417
return FAIL;
418418
}
419419
return OK;

src/ex_docmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ do_cmdline(
919919
next_cmdline = vim_strsave(next_cmdline);
920920
if (next_cmdline == NULL)
921921
{
922-
emsg(_(e_outofmem));
922+
emsg(_(e_out_of_memory));
923923
retval = FAIL;
924924
break;
925925
}
@@ -6959,7 +6959,7 @@ do_exedit(
69596959
static void
69606960
ex_nogui(exarg_T *eap)
69616961
{
6962-
eap->errmsg = _(e_nogvim);
6962+
eap->errmsg = _(e_gui_cannot_be_used_not_enabled_at_compile_time);
69636963
}
69646964
#endif
69656965

src/ex_eval.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ cause_errthrow(
255255
if (elem == NULL)
256256
{
257257
suppress_errthrow = TRUE;
258-
emsg(_(e_outofmem));
258+
emsg(_(e_out_of_memory));
259259
}
260260
else
261261
{
@@ -264,7 +264,7 @@ cause_errthrow(
264264
{
265265
vim_free(elem);
266266
suppress_errthrow = TRUE;
267-
emsg(_(e_outofmem));
267+
emsg(_(e_out_of_memory));
268268
}
269269
else
270270
{
@@ -592,7 +592,7 @@ throw_exception(void *value, except_type_T type, char_u *cmdname)
592592
nomem:
593593
vim_free(excp);
594594
suppress_errthrow = TRUE;
595-
emsg(_(e_outofmem));
595+
emsg(_(e_out_of_memory));
596596
fail:
597597
current_exception = NULL;
598598
return FAIL;
@@ -1639,7 +1639,7 @@ ex_try(exarg_T *eap)
16391639

16401640
elem = ALLOC_ONE(struct eslist_elem);
16411641
if (elem == NULL)
1642-
emsg(_(e_outofmem));
1642+
emsg(_(e_out_of_memory));
16431643
else
16441644
{
16451645
elem->saved_emsg_silent = emsg_silent;

src/globals.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,48 +1636,22 @@ EXTERN char e_loadlib[] INIT(= N_("E370: Could not load library %s"));
16361636
EXTERN char e_loadfunc[] INIT(= N_("E448: Could not load library function %s"));
16371637
#endif
16381638
EXTERN char e_nobang[] INIT(= N_("E477: No ! allowed"));
1639-
#if !defined(FEAT_GUI) || defined(VIMDLL)
1640-
EXTERN char e_nogvim[] INIT(= N_("E25: GUI cannot be used: Not enabled at compile time"));
1641-
#endif
1642-
#ifndef FEAT_RIGHTLEFT
1643-
EXTERN char e_nohebrew[] INIT(= N_("E26: Hebrew cannot be used: Not enabled at compile time\n"));
1644-
#endif
1645-
EXTERN char e_nofarsi[] INIT(= N_("E27: Farsi support has been removed\n"));
16461639
#ifndef FEAT_ARABIC
16471640
EXTERN char e_noarabic[] INIT(= N_("E800: Arabic cannot be used: Not enabled at compile time\n"));
16481641
#endif
1649-
#if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_SYN_HL)
1650-
EXTERN char e_nogroup[] INIT(= N_("E28: No such highlight group name: %s"));
1651-
#endif
1652-
EXTERN char e_noinstext[] INIT(= N_("E29: No inserted text yet"));
1653-
EXTERN char e_nolastcmd[] INIT(= N_("E30: No previous command line"));
1654-
EXTERN char e_nomap[] INIT(= N_("E31: No such mapping"));
16551642
EXTERN char e_nomatch[] INIT(= N_("E479: No match"));
16561643
EXTERN char e_nomatch2[] INIT(= N_("E480: No match: %s"));
1657-
EXTERN char e_noname[] INIT(= N_("E32: No file name"));
1658-
EXTERN char e_nopresub[] INIT(= N_("E33: No previous substitute regular expression"));
1659-
EXTERN char e_noprev[] INIT(= N_("E34: No previous command"));
1660-
EXTERN char e_noprevre[] INIT(= N_("E35: No previous regular expression"));
16611644
EXTERN char e_norange[] INIT(= N_("E481: No range allowed"));
1662-
EXTERN char e_noroom[] INIT(= N_("E36: Not enough room"));
16631645
#ifdef FEAT_CLIENTSERVER
16641646
EXTERN char e_noserver[] INIT(= N_("E247: no registered server named \"%s\""));
16651647
#endif
16661648
EXTERN char e_notcreate[] INIT(= N_("E482: Can't create file %s"));
16671649
EXTERN char e_notmp[] INIT(= N_("E483: Can't get temp file name"));
16681650
EXTERN char e_notopen[] INIT(= N_("E484: Can't open file %s"));
16691651
EXTERN char e_notread[] INIT(= N_("E485: Can't read file %s"));
1670-
EXTERN char e_null[] INIT(= N_("E38: Null argument"));
1671-
#if defined(FEAT_DIGRAPHS) || defined(FEAT_TIMERS) || defined(FEAT_EVAL)
1672-
EXTERN char e_number_exp[] INIT(= N_("E39: Number expected"));
1673-
#endif
1674-
#ifdef FEAT_QUICKFIX
1675-
EXTERN char e_openerrf[] INIT(= N_("E40: Can't open errorfile %s"));
1676-
#endif
16771652
#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
16781653
EXTERN char e_opendisp[] INIT(= N_("E233: cannot open display"));
16791654
#endif
1680-
EXTERN char e_outofmem[] INIT(= N_("E41: Out of memory!"));
16811655
EXTERN char e_patnotf[] INIT(= N_("Pattern not found"));
16821656
EXTERN char e_patnotf2[] INIT(= N_("E486: Pattern not found: %s"));
16831657
EXTERN char e_positive[] INIT(= N_("E487: Argument must be positive"));
@@ -1686,12 +1660,8 @@ EXTERN char e_prev_dir[] INIT(= N_("E459: Cannot go back to previous directory")
16861660
#endif
16871661

16881662
#ifdef FEAT_QUICKFIX
1689-
EXTERN char e_quickfix[] INIT(= N_("E42: No Errors"));
16901663
EXTERN char e_loclist[] INIT(= N_("E776: No location list"));
16911664
#endif
1692-
EXTERN char e_re_damg[] INIT(= N_("E43: Damaged match string"));
1693-
EXTERN char e_re_corr[] INIT(= N_("E44: Corrupted regexp program"));
1694-
EXTERN char e_readonly[] INIT(= N_("E45: 'readonly' option is set (add ! to override)"));
16951665
#ifdef FEAT_EVAL
16961666
EXTERN char e_letwrong[] INIT(= N_("E734: Wrong variable type for %s="));
16971667
EXTERN char e_illvar[] INIT(= N_("E461: Illegal variable name: %s"));

0 commit comments

Comments
 (0)