comparison src/normal.c @ 15470:55ccc2d353bd v8.1.0743

patch 8.1.0743: giving error messages is not flexible commit https://github.com/vim/vim/commit/f9e3e09fdc93be9f0d47afbc6c7df1188c2a5a0d Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 13 23:38:42 2019 +0100 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 #3302) Also make emsg() accept a "char *" argument. Get rid of an enormous number of type casts.
author Bram Moolenaar <Bram@vim.org>
date Sun, 13 Jan 2019 23:45:08 +0100
parents 29f3d59bb6f0
children dd725a8ab112
comparison
equal deleted inserted replaced
15469:bc9b5261ed01 15470:55ccc2d353bd
2209 # ifdef FEAT_VIRTUALEDIT 2209 # ifdef FEAT_VIRTUALEDIT
2210 int save_virtual_op = virtual_op; 2210 int save_virtual_op = virtual_op;
2211 # endif 2211 # endif
2212 2212
2213 if (*p_opfunc == NUL) 2213 if (*p_opfunc == NUL)
2214 EMSG(_("E774: 'operatorfunc' is empty")); 2214 emsg(_("E774: 'operatorfunc' is empty"));
2215 else 2215 else
2216 { 2216 {
2217 /* Set '[ and '] marks to text to be operated on. */ 2217 /* Set '[ and '] marks to text to be operated on. */
2218 curbuf->b_op_start = oap->start; 2218 curbuf->b_op_start = oap->start;
2219 curbuf->b_op_end = oap->end; 2219 curbuf->b_op_end = oap->end;
2241 # ifdef FEAT_VIRTUALEDIT 2241 # ifdef FEAT_VIRTUALEDIT
2242 virtual_op = save_virtual_op; 2242 virtual_op = save_virtual_op;
2243 # endif 2243 # endif
2244 } 2244 }
2245 #else 2245 #else
2246 EMSG(_("E775: Eval feature not available")); 2246 emsg(_("E775: Eval feature not available"));
2247 #endif 2247 #endif
2248 } 2248 }
2249 2249
2250 #if defined(FEAT_MOUSE) || defined(PROTO) 2250 #if defined(FEAT_MOUSE) || defined(PROTO)
2251 /* 2251 /*
3540 { 3540 {
3541 /* 3541 /*
3542 * didn't find an identifier or string 3542 * didn't find an identifier or string
3543 */ 3543 */
3544 if (find_type & FIND_STRING) 3544 if (find_type & FIND_STRING)
3545 EMSG(_("E348: No string under cursor")); 3545 emsg(_("E348: No string under cursor"));
3546 else 3546 else
3547 EMSG(_(e_noident)); 3547 emsg(_(e_noident));
3548 return 0; 3548 return 0;
3549 } 3549 }
3550 ptr += col; 3550 ptr += col;
3551 *string = ptr; 3551 *string = ptr;
3552 3552
5014 } 5014 }
5015 else if (foldmethodIsMarker(curwin)) 5015 else if (foldmethodIsMarker(curwin))
5016 deleteFold((linenr_T)1, curbuf->b_ml.ml_line_count, 5016 deleteFold((linenr_T)1, curbuf->b_ml.ml_line_count,
5017 TRUE, FALSE); 5017 TRUE, FALSE);
5018 else 5018 else
5019 EMSG(_("E352: Cannot erase folds with current 'foldmethod'")); 5019 emsg(_("E352: Cannot erase folds with current 'foldmethod'"));
5020 break; 5020 break;
5021 5021
5022 /* "zn": fold none: reset 'foldenable' */ 5022 /* "zn": fold none: reset 'foldenable' */
5023 case 'n': curwin->w_p_fen = FALSE; 5023 case 'n': curwin->w_p_fen = FALSE;
5024 break; 5024 break;
5614 kp = (*curbuf->b_p_kp == NUL ? p_kp : curbuf->b_p_kp); 5614 kp = (*curbuf->b_p_kp == NUL ? p_kp : curbuf->b_p_kp);
5615 kp_help = (*kp == NUL || STRCMP(kp, ":he") == 0 5615 kp_help = (*kp == NUL || STRCMP(kp, ":he") == 0
5616 || STRCMP(kp, ":help") == 0); 5616 || STRCMP(kp, ":help") == 0);
5617 if (kp_help && *skipwhite(ptr) == NUL) 5617 if (kp_help && *skipwhite(ptr) == NUL)
5618 { 5618 {
5619 EMSG(_(e_noident)); /* found white space only */ 5619 emsg(_(e_noident)); /* found white space only */
5620 return; 5620 return;
5621 } 5621 }
5622 kp_ex = (*kp == ':'); 5622 kp_ex = (*kp == ':');
5623 buflen = (unsigned)(n * 2 + 30 + STRLEN(kp)); 5623 buflen = (unsigned)(n * 2 + 30 + STRLEN(kp));
5624 buf = alloc(buflen); 5624 buf = alloc(buflen);
5665 ++ptr; 5665 ++ptr;
5666 --n; 5666 --n;
5667 } 5667 }
5668 if (n == 0) 5668 if (n == 0)
5669 { 5669 {
5670 EMSG(_(e_noident)); /* found dashes only */ 5670 emsg(_(e_noident)); /* found dashes only */
5671 vim_free(buf); 5671 vim_free(buf);
5672 return; 5672 return;
5673 } 5673 }
5674 5674
5675 /* When a count is given, turn it into a range. Is this 5675 /* When a count is given, turn it into a range. Is this
7273 nv_operator(cap); 7273 nv_operator(cap);
7274 } 7274 }
7275 else if (!checkclearopq(cap->oap)) 7275 else if (!checkclearopq(cap->oap))
7276 { 7276 {
7277 if (!curbuf->b_p_ma) 7277 if (!curbuf->b_p_ma)
7278 EMSG(_(e_modifiable)); 7278 emsg(_(e_modifiable));
7279 else 7279 else
7280 { 7280 {
7281 #ifdef FEAT_VIRTUALEDIT 7281 #ifdef FEAT_VIRTUALEDIT
7282 if (virtual_active()) 7282 if (virtual_active())
7283 coladvance(getviscol()); 7283 coladvance(getviscol());
7300 nv_replace(cap); /* Do same as "r" in Visual mode for now */ 7300 nv_replace(cap); /* Do same as "r" in Visual mode for now */
7301 } 7301 }
7302 else if (!checkclearopq(cap->oap)) 7302 else if (!checkclearopq(cap->oap))
7303 { 7303 {
7304 if (!curbuf->b_p_ma) 7304 if (!curbuf->b_p_ma)
7305 EMSG(_(e_modifiable)); 7305 emsg(_(e_modifiable));
7306 else 7306 else
7307 { 7307 {
7308 if (cap->extra_char == Ctrl_V) /* get another character */ 7308 if (cap->extra_char == Ctrl_V) /* get another character */
7309 cap->extra_char = get_literal(); 7309 cap->extra_char = get_literal();
7310 stuffcharReadbuff(cap->extra_char); 7310 stuffcharReadbuff(cap->extra_char);
7627 else if (pos != NULL) /* can jump */ 7627 else if (pos != NULL) /* can jump */
7628 nv_cursormark(cap, FALSE, pos); 7628 nv_cursormark(cap, FALSE, pos);
7629 else if (cap->cmdchar == 'g') 7629 else if (cap->cmdchar == 'g')
7630 { 7630 {
7631 if (curbuf->b_changelistlen == 0) 7631 if (curbuf->b_changelistlen == 0)
7632 EMSG(_("E664: changelist is empty")); 7632 emsg(_("E664: changelist is empty"));
7633 else if (cap->count1 < 0) 7633 else if (cap->count1 < 0)
7634 EMSG(_("E662: At start of changelist")); 7634 emsg(_("E662: At start of changelist"));
7635 else 7635 else
7636 EMSG(_("E663: At end of changelist")); 7636 emsg(_("E663: At end of changelist"));
7637 } 7637 }
7638 else 7638 else
7639 clearopbeep(cap->oap); 7639 clearopbeep(cap->oap);
7640 # ifdef FEAT_FOLDING 7640 # ifdef FEAT_FOLDING
7641 if (cap->oap->op_type == OP_NOP 7641 if (cap->oap->op_type == OP_NOP
8512 { 8512 {
8513 #ifdef FEAT_CONCEAL 8513 #ifdef FEAT_CONCEAL
8514 if (curwin->w_p_cole > 0 && oldline != curwin->w_cursor.lnum) 8514 if (curwin->w_p_cole > 0 && oldline != curwin->w_cursor.lnum)
8515 redrawWinline(curwin, oldline); 8515 redrawWinline(curwin, oldline);
8516 #endif 8516 #endif
8517 /* When '#' is in 'cpoptions' ignore the count. */
8518 if (vim_strchr(p_cpo, CPO_HASH) != NULL)
8519 cap->count1 = 1;
8520 #ifdef FEAT_SYN_HL 8517 #ifdef FEAT_SYN_HL
8521 if (curwin->w_p_cul) 8518 if (curwin->w_p_cul)
8522 /* force redraw of cursorline */ 8519 /* force redraw of cursorline */
8523 curwin->w_valid &= ~VALID_CROW; 8520 curwin->w_valid &= ~VALID_CROW;
8524 #endif 8521 #endif
8522 /* When '#' is in 'cpoptions' ignore the count. */
8523 if (vim_strchr(p_cpo, CPO_HASH) != NULL)
8524 cap->count1 = 1;
8525 invoke_edit(cap, FALSE, cap->cmdchar, TRUE); 8525 invoke_edit(cap, FALSE, cap->cmdchar, TRUE);
8526 } 8526 }
8527 } 8527 }
8528 } 8528 }
8529 8529
9105 } 9105 }
9106 #endif 9106 #endif
9107 else if (!curbuf->b_p_ma && !p_im) 9107 else if (!curbuf->b_p_ma && !p_im)
9108 { 9108 {
9109 /* Only give this error when 'insertmode' is off. */ 9109 /* Only give this error when 'insertmode' is off. */
9110 EMSG(_(e_modifiable)); 9110 emsg(_(e_modifiable));
9111 clearop(cap->oap); 9111 clearop(cap->oap);
9112 if (cap->cmdchar == K_PS) 9112 if (cap->cmdchar == K_PS)
9113 /* drop the pasted text */ 9113 /* drop the pasted text */
9114 bracketed_paste(PASTE_INSERT, TRUE, NULL); 9114 bracketed_paste(PASTE_INSERT, TRUE, NULL);
9115 } 9115 }