From efa924f66b183d9cf2404ce91c4f009c27e0515a Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 18 Oct 2021 09:08:46 -0400 Subject: vim-patch:8.1.0743: giving error messages is not flexible Problem: Giving error messages is not flexible. Solution: Add semsg(). Change argument from "char_u *" to "char *", also for msg() and get rid of most MSG macros. (Ozaki Kiichi, closes vim/vim#3302) Also make emsg() accept a "char *" argument. Get rid of an enormous number of type casts. https://github.com/vim/vim/commit/f9e3e09fdc93be9f0d47afbc6c7df1188c2a5a0d --- src/nvim/edit.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/nvim/edit.c') diff --git a/src/nvim/edit.c b/src/nvim/edit.c index e2884c242b..60f2d0b2ec 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -1398,20 +1398,20 @@ bool edit(int cmdchar, bool startln, long count) // Don't allow inserting in the sandbox. if (sandbox != 0) { - EMSG(_(e_sandbox)); + emsg(_(e_sandbox)); return false; } // Don't allow changes in the buffer while editing the cmdline. The // caller of getcmdline() may get confused. if (textlock != 0) { - EMSG(_(e_secure)); + emsg(_(e_secure)); return false; } // Don't allow recursive insert mode when busy with completion. if (compl_started || compl_busy || pum_visible()) { - EMSG(_(e_secure)); + emsg(_(e_secure)); return false; } @@ -3974,13 +3974,13 @@ static void expand_by_function(int type, char_u *base) } if (curwin_save != curwin || curbuf_save != curbuf) { - EMSG(_(e_complwin)); + emsg(_(e_complwin)); goto theend; } curwin->w_cursor = pos; // restore the cursor position validate_cursor(); if (!equalpos(curwin->w_cursor, pos)) { - EMSG(_(e_compldel)); + emsg(_(e_compldel)); goto theend; } @@ -5220,7 +5220,7 @@ static int ins_complete(int c, bool enable_pum) funcname = ctrl_x_mode == CTRL_X_FUNCTION ? curbuf->b_p_cfu : curbuf->b_p_ofu; if (*funcname == NUL) { - EMSG2(_(e_notset), ctrl_x_mode == CTRL_X_FUNCTION + semsg(_(e_notset), ctrl_x_mode == CTRL_X_FUNCTION ? "completefunc" : "omnifunc"); // restore did_ai, so that adding comment leader works did_ai = save_did_ai; @@ -5241,13 +5241,13 @@ static int ins_complete(int c, bool enable_pum) State = save_State; if (curwin_save != curwin || curbuf_save != curbuf) { - EMSG(_(e_complwin)); + emsg(_(e_complwin)); return FAIL; } curwin->w_cursor = pos; // restore the cursor position validate_cursor(); if (!equalpos(curwin->w_cursor, pos)) { - EMSG(_(e_compldel)); + emsg(_(e_compldel)); return FAIL; } @@ -7017,7 +7017,7 @@ int stuff_inserted(int c, long count, int no_esc) ptr = get_last_insert(); if (ptr == NULL) { - EMSG(_(e_noinstext)); + emsg(_(e_noinstext)); return FAIL; } -- cgit From e6ff154be6da8bd53b604fb6e38686acae75b24f Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 23 Oct 2021 16:04:37 -0400 Subject: vim-patch:8.1.0779: argument for message functions is inconsistent Problem: Argument for message functions is inconsistent. Solution: Make first argument to msg() "char *". https://github.com/vim/vim/commit/32526b3c1846025f0e655f41efd4e5428da16b6c --- src/nvim/edit.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/nvim/edit.c') diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 60f2d0b2ec..9c333f5760 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -3005,7 +3005,7 @@ static void ins_compl_files(int count, char_u **files, int thesaurus, int flags, msg_hist_off = true; // reset in msg_trunc_attr() vim_snprintf((char *)IObuff, IOSIZE, _("Scanning dictionary: %s"), (char *)files[i]); - (void)msg_trunc_attr(IObuff, true, HL_ATTR(HLF_R)); + (void)msg_trunc_attr((char *)IObuff, true, HL_ATTR(HLF_R)); } if (fp == NULL) { @@ -4209,7 +4209,7 @@ static int ins_compl_get_exp(pos_T *ini) : ins_buf->b_sfname == NULL ? ins_buf->b_fname : ins_buf->b_sfname); - (void)msg_trunc_attr(IObuff, true, HL_ATTR(HLF_R)); + (void)msg_trunc_attr((char *)IObuff, true, HL_ATTR(HLF_R)); } else if (*e_cpt == NUL) { break; } else { @@ -4233,7 +4233,7 @@ static int ins_compl_get_exp(pos_T *ini) msg_hist_off = true; // reset in msg_trunc_attr() type = CTRL_X_TAGS; vim_snprintf((char *)IObuff, IOSIZE, "%s", _("Scanning tags.")); - (void)msg_trunc_attr(IObuff, true, HL_ATTR(HLF_R)); + (void)msg_trunc_attr((char *)IObuff, true, HL_ATTR(HLF_R)); } else { type = -1; } @@ -4836,7 +4836,7 @@ static int ins_compl_next(int allow_get_expansion, int count, int insert_match, msg_hist_off = true; vim_snprintf((char *)IObuff, IOSIZE, "%s %s%s", lead, s > compl_shown_match->cp_fname ? "<" : "", s); - msg(IObuff); + msg((char *)IObuff); msg_hist_off = false; redraw_cmdline = false; // don't overwrite! } @@ -7966,7 +7966,7 @@ static bool ins_esc(long *count, int cmdchar, bool nomove) if (reg_recording != 0 || restart_edit != NUL) { showmode(); } else if (p_smd) { - MSG(""); + msg(""); } // Exit Insert mode return true; -- cgit