To: vim_dev@googlegroups.com Subject: Patch 8.2.3959 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3959 Problem: Error messages are spread out. Solution: Move more errors to errors.h. Files: src/errors.h, src/autocmd.c, src/bufwrite.c, 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 *** ../vim-8.2.3958/src/errors.h 2021-12-31 17:25:44.040304835 +0000 --- src/errors.h 2021-12-31 18:46:29.921538891 +0000 *************** *** 412,423 **** 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")); ! ! #ifndef FEAT_DIGRAPHS EXTERN char e_no_digraphs_version[] INIT(= N_("E196: No digraphs in this version")); #endif #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) EXTERN char e_cannot_allocate_color_str[] INIT(= N_("E254: Cannot allocate color %s")); --- 412,500 ---- 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")); *** ../vim-8.2.3958/src/autocmd.c 2021-12-24 19:24:39.619189424 +0000 --- src/autocmd.c 2021-12-31 18:31:08.762949955 +0000 *************** *** 687,693 **** { if (arg[1] && !VIM_ISWHITE(arg[1])) { ! semsg(_("E215: Illegal character after *: %s"), arg); return NULL; } pat = arg + 1; --- 687,693 ---- { if (arg[1] && !VIM_ISWHITE(arg[1])) { ! semsg(_(e_illegal_character_after_star_str), arg); return NULL; } pat = arg + 1; *************** *** 699,707 **** if ((int)event_name2nr(pat, &p) >= NUM_EVENTS) { if (have_group) ! semsg(_("E216: No such event: %s"), pat); else ! semsg(_("E216: No such group or event: %s"), pat); return NULL; } } --- 699,707 ---- if ((int)event_name2nr(pat, &p) >= NUM_EVENTS) { if (have_group) ! semsg(_(e_no_such_event_str), pat); else ! semsg(_(e_no_such_group_or_event_str), pat); return NULL; } } *************** *** 1329,1335 **** if (*arg == '*') { ! emsg(_("E217: Can't execute autocommands for ALL events")); return FAIL; } --- 1329,1335 ---- if (*arg == '*') { ! emsg(_(e_cant_execute_autocommands_for_all_events)); return FAIL; } *************** *** 1942,1948 **** */ if (nesting == 10) { ! emsg(_("E218: autocommand nesting too deep")); goto BYPASS_AU; } --- 1942,1948 ---- */ if (nesting == 10) { ! emsg(_(e_autocommand_nesting_too_deep)); goto BYPASS_AU; } *** ../vim-8.2.3958/src/bufwrite.c 2021-12-31 17:25:44.040304835 +0000 --- src/bufwrite.c 2021-12-31 18:33:09.138760889 +0000 *************** *** 932,938 **** #ifdef FEAT_EVAL if (!aborting()) #endif ! emsg(_("E203: Autocommands deleted or unloaded buffer to be written")); return FAIL; } --- 932,938 ---- #ifdef FEAT_EVAL if (!aborting()) #endif ! emsg(_(e_autocommands_deleted_or_unloaded_buffer_to_be_written)); return FAIL; } *************** *** 953,959 **** { --no_wait_return; msg_scroll = msg_save; ! emsg(_("E204: Autocommand changed number of lines in unexpected way")); return FAIL; } } --- 953,959 ---- { --no_wait_return; msg_scroll = msg_save; ! emsg(_(e_autocommands_changed_number_of_lines_in_unexpected_way)); return FAIL; } } *************** *** 1746,1752 **** 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"); goto restore_backup; } } --- 1746,1752 ---- wfname = vim_tempname('w', FALSE); if (wfname == NULL) // Can't write without a tempfile! { ! errmsg = (char_u *)_(e_cant_find_temp_file_for_writing); goto restore_backup; } } *************** *** 1764,1770 **** { if (!forceit) { ! errmsg = (char_u *)_("E213: Cannot convert (add ! to write without conversion)"); goto restore_backup; } notconverted = TRUE; --- 1764,1770 ---- { if (!forceit) { ! errmsg = (char_u *)_(e_cannot_convert_add_bang_to_write_without_conversion); goto restore_backup; } notconverted = TRUE; *************** *** 1826,1832 **** else #endif { ! errmsg = (char_u *)_("E212: Can't open file for writing"); if (forceit && vim_strchr(p_cpo, CPO_FWRITE) == NULL && perm >= 0) { --- 1826,1832 ---- else #endif { ! errmsg = (char_u *)_(e_cant_open_file_for_writing); if (forceit && vim_strchr(p_cpo, CPO_FWRITE) == NULL && perm >= 0) { *************** *** 2454,2460 **** // 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")); else if (mch_stat(org, &st) < 0) { vim_rename(backup, (char_u *)org); --- 2454,2460 ---- // If the original file does not exist yet // the current backup file becomes the original file if (org == NULL) ! emsg(_(e_patchmode_cant_save_original_file)); else if (mch_stat(org, &st) < 0) { vim_rename(backup, (char_u *)org); *************** *** 2474,2480 **** || (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")); else close(empty_fd); } --- 2474,2480 ---- || (empty_fd = mch_open(org, O_CREAT | O_EXTRA | O_EXCL | O_NOFOLLOW, perm < 0 ? 0666 : (perm & 0777))) < 0) ! emsg(_(e_patchmode_cant_touch_empty_original_file)); else close(empty_fd); } *************** *** 2489,2495 **** // conversion error. if (!p_bk && backup != NULL && !write_info.bw_conv_error && mch_remove(backup) != 0) ! emsg(_("E207: Can't delete backup file")); goto nofail; --- 2489,2495 ---- // conversion error. if (!p_bk && backup != NULL && !write_info.bw_conv_error && mch_remove(backup) != 0) ! emsg(_(e_cant_delete_backup_file)); goto nofail; *** ../vim-8.2.3958/src/evalvars.c 2021-12-31 17:25:44.040304835 +0000 --- src/evalvars.c 2021-12-31 18:38:19.394274883 +0000 *************** *** 626,632 **** *p = NUL; if (!script_get && vim_islower(*marker)) { ! emsg(_("E221: Marker cannot start with lower case letter")); return NULL; } } --- 626,632 ---- *p = NUL; if (!script_get && vim_islower(*marker)) { ! emsg(_(e_marker_cannot_start_with_lower_case_letter)); return NULL; } } *** ../vim-8.2.3958/src/ex_docmd.c 2021-12-31 17:25:44.044304828 +0000 --- src/ex_docmd.c 2021-12-31 17:56:22.178174562 +0000 *************** *** 8335,8341 **** 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")); curwin->w_cursor = pos; // restore curwin->w_cursor } } --- 8335,8341 ---- curwin->w_cursor.lnum = eap->line2; beginline(BL_WHITE | BL_FIX); if (setmark(*eap->arg) == FAIL) // set mark ! emsg(_(e_argument_must_be_letter_or_forward_backward_quote)); curwin->w_cursor = pos; // restore curwin->w_cursor } } *************** *** 8426,8432 **** } if (ex_normal_busy >= p_mmd) { ! emsg(_("E192: Recursive use of :normal too deep")); return; } --- 8426,8432 ---- } if (ex_normal_busy >= p_mmd) { ! emsg(_(e_recursive_use_of_normal_too_deep)); return; } *************** *** 9062,9068 **** buf = buflist_findnr(i); if (buf == NULL) { ! *errormsg = _("E194: No alternate file name to substitute for '#'"); return NULL; } if (lnump != NULL) --- 9062,9068 ---- buf = buflist_findnr(i); if (buf == NULL) { ! *errormsg = _(e_no_alternate_file_name_to_substitute_for_hash); return NULL; } if (lnump != NULL) *** ../vim-8.2.3958/src/ex_eval.c 2021-12-31 17:25:44.044304828 +0000 --- src/ex_eval.c 2021-12-31 17:55:08.210273578 +0000 *************** *** 2516,2530 **** } /* ! * ":endfunction" when not after a ":function" */ void ex_endfunction(exarg_T *eap) { if (eap->cmdidx == CMD_enddef) ! emsg(_("E193: :enddef not inside a function")); else ! emsg(_("E193: :endfunction not inside a function")); } /* --- 2516,2530 ---- } /* ! * ":endfunction" or ":enddef" when not after a ":function" */ void ex_endfunction(exarg_T *eap) { if (eap->cmdidx == CMD_enddef) ! semsg(_(e_str_not_inside_function), ":enddef"); else ! semsg(_(e_str_not_inside_function), ":endfunction"); } /* *** ../vim-8.2.3958/src/ex_getln.c 2021-12-28 20:59:51.975937080 +0000 --- src/ex_getln.c 2021-12-31 17:59:07.781946050 +0000 *************** *** 4390,4396 **** if (!win_valid(old_curwin) || !bufref_valid(&old_curbuf)) { cmdwin_result = Ctrl_C; ! emsg(_("E199: Active window or buffer deleted")); } else { --- 4390,4396 ---- if (!win_valid(old_curwin) || !bufref_valid(&old_curbuf)) { cmdwin_result = Ctrl_C; ! emsg(_(e_active_window_or_buffer_deleted)); } else { *** ../vim-8.2.3958/src/fileio.c 2021-10-15 17:23:08.755565587 +0100 --- src/fileio.c 2021-12-31 18:36:39.930430513 +0000 *************** *** 727,735 **** --no_wait_return; msg_scroll = msg_save; if (fd < 0) ! emsg(_("E200: *ReadPre autocommands made the file unreadable")); else ! emsg(_("E201: *ReadPre autocommands must not change current buffer")); curbuf->b_p_ro = TRUE; // must use "w!" now return FAIL; } --- 727,735 ---- --no_wait_return; msg_scroll = msg_save; if (fd < 0) ! emsg(_(e_readpre_autocommands_made_file_unreadable)); else ! emsg(_(e_readpre_autocommands_must_not_change_current_buffer)); curbuf->b_p_ro = TRUE; // must use "w!" now return FAIL; } *************** *** 1053,1059 **** if (fd < 0) { // Re-opening the original file failed! ! emsg(_("E202: Conversion made file unreadable!")); error = TRUE; goto failed; } --- 1053,1059 ---- if (fd < 0) { // Re-opening the original file failed! ! emsg(_(e_conversion_mad_file_unreadable)); error = TRUE; goto failed; } *************** *** 3873,3889 **** while ((n = read_eintr(fd_in, buffer, WRITEBUFSIZE)) > 0) if (write_eintr(fd_out, buffer, n) != n) { ! errmsg = _("E208: Error writing to \"%s\""); break; } vim_free(buffer); close(fd_in); if (close(fd_out) < 0) ! errmsg = _("E209: Error closing \"%s\""); if (n < 0) { ! errmsg = _("E210: Error reading \"%s\""); to = from; } #ifndef UNIX // for Unix mch_open() already set the permission --- 3873,3889 ---- while ((n = read_eintr(fd_in, buffer, WRITEBUFSIZE)) > 0) if (write_eintr(fd_out, buffer, n) != n) { ! errmsg = _(e_error_writing_to_str); break; } vim_free(buffer); close(fd_in); if (close(fd_out) < 0) ! errmsg = _(e_error_closing_str); if (n < 0) { ! errmsg = _(e_error_reading_str); to = from; } #ifndef UNIX // for Unix mch_open() already set the permission *************** *** 4172,4178 **** { // Only give the message once. if (prev_b_mtime != -1) ! mesg = _("E211: File \"%s\" no longer available"); } else { --- 4172,4178 ---- { // Only give the message once. if (prev_b_mtime != -1) ! mesg = _(e_file_str_no_longer_available); } else { *************** *** 5613,5621 **** if (nested != 0) { if (nested < 0) ! emsg(_("E219: Missing {.")); else ! emsg(_("E220: Missing }.")); VIM_CLEAR(reg_pat); } return reg_pat; --- 5613,5621 ---- if (nested != 0) { if (nested < 0) ! emsg(_(e_missing_open_curly)); else ! emsg(_(e_missing_close_curly)); VIM_CLEAR(reg_pat); } return reg_pat; *** ../vim-8.2.3958/src/getchar.c 2021-12-27 17:21:38.008449130 +0000 --- src/getchar.c 2021-12-31 18:42:04.961922449 +0000 *************** *** 208,214 **** } else if (buf->bh_curr == NULL) // buffer has already been read { ! iemsg(_("E222: Add to read buffer")); return; } else if (buf->bh_index != 0) --- 208,214 ---- } else if (buf->bh_curr == NULL) // buffer has already been read { ! iemsg(_(e_add_to_internal_buffer_that_was_already_read_from)); return; } else if (buf->bh_index != 0) *************** *** 2758,2764 **** */ if (++*mapdepth >= p_mmd) { ! emsg(_("E223: recursive mapping")); if (State & CMDLINE) redrawcmdline(); else --- 2758,2764 ---- */ if (++*mapdepth >= p_mmd) { ! emsg(_(e_recursive_mapping)); if (State & CMDLINE) redrawcmdline(); else *** ../vim-8.2.3958/src/gui.c 2021-12-27 17:21:38.008449130 +0000 --- src/gui.c 2021-12-31 18:42:37.265872047 +0000 *************** *** 388,394 **** if (result != MAYBE) { if (result == FAIL) ! emsg(_("E229: Cannot start the GUI")); return result; } --- 388,394 ---- if (result != MAYBE) { if (result == FAIL) ! emsg(_(e_cannot_start_the_GUI)); return result; } *** ../vim-8.2.3958/src/locale.c 2021-11-29 20:39:06.674101624 +0000 --- src/locale.c 2021-12-31 17:58:13.562021798 +0000 *************** *** 339,345 **** # endif } if (loc == NULL) ! semsg(_("E197: Cannot set language to \"%s\""), name); else { # ifdef HAVE_NL_MSG_CAT_CNTR --- 339,345 ---- # endif } if (loc == NULL) ! semsg(_(e_cannot_set_language_to_str), name); else { # ifdef HAVE_NL_MSG_CAT_CNTR *** ../vim-8.2.3958/src/map.c 2021-11-22 12:47:36.319593278 +0000 --- src/map.c 2021-12-31 18:46:32.681535595 +0000 *************** *** 603,614 **** && STRNCMP(mp->m_keys, keys, (size_t)len) == 0) { if (abbrev) ! semsg(_( ! "E224: global abbreviation already exists for %s"), mp->m_keys); else ! semsg(_( ! "E225: global mapping already exists for %s"), mp->m_keys); retval = 5; goto theend; --- 603,613 ---- && STRNCMP(mp->m_keys, keys, (size_t)len) == 0) { if (abbrev) ! semsg( ! _(e_global_abbreviation_already_exists_for_str), mp->m_keys); else ! semsg(_(e_global_mapping_already_exists_for_str), mp->m_keys); retval = 5; goto theend; *************** *** 741,752 **** else if (unique) { if (abbrev) ! semsg(_( ! "E226: abbreviation already exists for %s"), p); else ! semsg(_( ! "E227: mapping already exists for %s"), p); retval = 5; goto theend; --- 740,750 ---- else if (unique) { if (abbrev) ! semsg( ! _(e_abbreviation_already_exists_for_str), p); else ! semsg(_(e_mapping_already_exists_for_str), p); retval = 5; goto theend; *************** *** 1855,1861 **** c1 = 't'; break; default: ! iemsg(_("E228: makemap: Illegal mode")); return FAIL; } do // do this twice if c2 is set, 3 times with c3 --- 1853,1859 ---- c1 = 't'; break; default: ! iemsg(_(e_makemap_illegal_mode)); return FAIL; } do // do this twice if c2 is set, 3 times with c3 *** ../vim-8.2.3958/src/version.c 2021-12-31 17:33:43.031473720 +0000 --- src/version.c 2021-12-31 18:48:34.205386151 +0000 *************** *** 751,752 **** --- 751,754 ---- { /* Add new patch number below this line */ + /**/ + 3959, /**/ -- Did you ever see a "Hit any key to continue" message in a music piece? /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///