diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2015-10-19 09:39:51 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2015-10-19 09:39:51 -0400 |
commit | ea01c40f520dd532401c1d92c4c78295911943b1 (patch) | |
tree | 305b7e72e04b30be2ed052df262ab6b771e7469d | |
parent | e9de70e4ea53cd7ab70eba0757309004c61c3c62 (diff) | |
parent | 3bb266266935e9bf95f4a776b33800b9303d4607 (diff) | |
download | rneovim-ea01c40f520dd532401c1d92c4c78295911943b1.tar.gz rneovim-ea01c40f520dd532401c1d92c4c78295911943b1.tar.bz2 rneovim-ea01c40f520dd532401c1d92c4c78295911943b1.zip |
Merge pull request #3466 from johanhelsing/vim-7.4.793
vim-patch:7.4.793
-rw-r--r-- | runtime/doc/options.txt | 44 | ||||
-rw-r--r-- | src/nvim/edit.c | 109 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 13 | ||||
-rw-r--r-- | src/nvim/message.c | 16 | ||||
-rw-r--r-- | src/nvim/misc1.c | 21 | ||||
-rw-r--r-- | src/nvim/normal.c | 24 | ||||
-rw-r--r-- | src/nvim/option.c | 5 | ||||
-rw-r--r-- | src/nvim/option_defs.h | 31 | ||||
-rw-r--r-- | src/nvim/options.lua | 8 | ||||
-rw-r--r-- | src/nvim/search.c | 10 | ||||
-rw-r--r-- | src/nvim/spell.c | 2 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
12 files changed, 195 insertions, 90 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 4b3dbb8a15..a97dbbd898 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1036,6 +1036,47 @@ A jump table for the options with a short description can be found at |Q_op|. expression evaluates to a |List| this is equal to using each List item as a string and putting "\n" in between them. + *'belloff'* *'bo'* +'belloff' 'bo' string (default "") + global + {not in Vi} + Specifies for which events the bell will not be rung. It is a comma + separated list of items. For each item that is present, the bell + will be silenced. This is most useful to specify specific events in + insert mode to be silenced. + + item meaning when present ~ + all All events. + backspace When hitting <BS> or <Del> and deleting results in an + error. + cursor Fail to move around using the cursor keys or + <PageUp>/<PageDown> in |Insert-mode|. + complete Error occurred when using |i_CTRL-X_CTRL-K| or + |i_CTRL-X_CTRL-T|. + copy Cannot copy char from insert mode using |i_CTRL-Y| or + |i_CTRL-E|. + ctrlg Unknown Char after <C-G> in Insert mode. + error Other Error occurred (e.g. try to join last line) + (mostly used in |Normal-mode| or |Cmdline-mode|). + esc hitting <Esc> in |Normal-mode|. + ex In |Visual-mode|, hitting |Q| results in an error. + hangul Error occurred when using hangul input. + insertmode Pressing <Esc> in 'insertmode'. + lang Calling the beep module for Lua/Mzscheme/TCL. + mess No output available for |g<|. + showmatch Error occurred for 'showmatch' function. + operator Empty region error |cpo-E|. + register Unknown register after <C-R> in |Insert-mode|. + shell Bell from shell output |:!|. + spell Error happened on spell suggest. + wildmode More matches in |cmdline-completion| available + (depends on the 'wildmode' setting). + + This is most useful, to fine tune when in insert mode the bell should + be rung. For normal mode and ex commands, the bell is often rung to + indicate that an error occurred. It can be silenced by adding the + "error" keyword. + *'binary'* *'bin'* *'nobinary'* *'nobin'* 'binary' 'bin' boolean (default off) local to buffer @@ -2253,7 +2294,8 @@ A jump table for the options with a short description can be found at |Q_op|. makes a difference for error messages, the bell will be used always for a lot of errors without a message (e.g., hitting <Esc> in Normal mode). See 'visualbell' on how to make the bell behave like a beep, - screen flash or do nothing. + screen flash or do nothing. See 'belloff' to finetune when to ring the + bell. *'errorfile'* *'ef'* 'errorfile' 'ef' string (default: "errors.err") diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 310191ba06..2d6dcf4f80 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -789,9 +789,10 @@ do_intr: if (goto_im()) { if (got_int) { (void)vgetc(); /* flush all buffers */ - got_int = FALSE; - } else - vim_beep(); + got_int = false; + } else { + vim_beep(BO_IM); + } break; } doESCkey: @@ -1770,7 +1771,7 @@ static int has_compl_option(int dict_opt) : (char_u *)_("'thesaurus' option is empty"), hl_attr(HLF_E)); if (emsg_silent == 0) { - vim_beep(); + vim_beep(BO_COMPL); setcursor(); ui_flush(); os_delay(2000L, false); @@ -6826,8 +6827,8 @@ static void ins_reg(void) regname = get_expr_register(); } if (regname == NUL || !valid_yank_reg(regname, false)) { - vim_beep(); - need_redraw = TRUE; /* remove the '"' */ + vim_beep(BO_REG); + need_redraw = true; // remove the '"' } else { if (literally == Ctrl_O || literally == Ctrl_P) { /* Append the command to the redo buffer. */ @@ -6838,14 +6839,14 @@ static void ins_reg(void) do_put(regname, NULL, BACKWARD, 1L, (literally == Ctrl_P ? PUT_FIXINDENT : 0) | PUT_CURSEND); } else if (insert_reg(regname, literally) == FAIL) { - vim_beep(); - need_redraw = TRUE; /* remove the '"' */ - } else if (stop_insert_mode) - /* When the '=' register was used and a function was invoked that - * did ":stopinsert" then stuff_empty() returns FALSE but we won't - * insert anything, need to remove the '"' */ - need_redraw = TRUE; - + vim_beep(BO_REG); + need_redraw = true; // remove the '"' + } else if (stop_insert_mode) { + // When the '=' register was used and a function was invoked that + // did ":stopinsert" then stuff_empty() returns FALSE but we won't + // insert anything, need to remove the '"' + need_redraw = true; + } } --no_u_sync; if (u_sync_once == 1) @@ -6903,7 +6904,7 @@ static void ins_ctrl_g(void) break; /* Unknown CTRL-G command, reserved for future expansion. */ - default: vim_beep(); + default: vim_beep(BO_CTRLG); } } @@ -7211,13 +7212,14 @@ static void ins_del(void) if (gchar_cursor() == NUL) { /* delete newline */ temp = curwin->w_cursor.col; if (!can_bs(BS_EOL) // only if "eol" included - || do_join(2, FALSE, TRUE, FALSE, false) == FAIL) { - vim_beep(); + || do_join(2, false, true, false, false) == FAIL) { + vim_beep(BO_BS); } else { curwin->w_cursor.col = temp; } - } else if (del_char(FALSE) == FAIL) /* delete char under cursor */ - vim_beep(); + } else if (del_char(false) == FAIL) { // delete char under cursor + vim_beep(BO_BS); + } did_ai = FALSE; did_si = FALSE; can_si = FALSE; @@ -7276,8 +7278,8 @@ static int ins_bs(int c, int mode, int *inserted_space_p) || (!can_bs(BS_INDENT) && !arrow_used && ai_col > 0 && curwin->w_cursor.col <= ai_col) || (!can_bs(BS_EOL) && curwin->w_cursor.col == 0)))) { - vim_beep(); - return FALSE; + vim_beep(BO_BS); + return false; } if (stop_arrow() == FAIL) @@ -7670,9 +7672,10 @@ static void ins_left(void) start_arrow(&tpos); --(curwin->w_cursor.lnum); coladvance((colnr_T)MAXCOL); - curwin->w_set_curswant = TRUE; /* so we stay at the end */ - } else - vim_beep(); + curwin->w_set_curswant = true; // so we stay at the end + } else { + vim_beep(BO_CRSR); + } } static void ins_home(int c) @@ -7714,10 +7717,11 @@ static void ins_s_left(void) undisplay_dollar(); if (curwin->w_cursor.lnum > 1 || curwin->w_cursor.col > 0) { start_arrow(&curwin->w_cursor); - (void)bck_word(1L, FALSE, FALSE); - curwin->w_set_curswant = TRUE; - } else - vim_beep(); + (void)bck_word(1L, false, false); + curwin->w_set_curswant = true; + } else { + vim_beep(BO_CRSR); + } } static void ins_right(void) @@ -7751,8 +7755,9 @@ static void ins_right(void) curwin->w_set_curswant = TRUE; ++curwin->w_cursor.lnum; curwin->w_cursor.col = 0; - } else - vim_beep(); + } else { + vim_beep(BO_CRSR); + } } static void ins_s_right(void) @@ -7763,10 +7768,11 @@ static void ins_s_right(void) if (curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count || gchar_cursor() != NUL) { start_arrow(&curwin->w_cursor); - (void)fwd_word(1L, FALSE, 0); - curwin->w_set_curswant = TRUE; - } else - vim_beep(); + (void)fwd_word(1L, false, 0); + curwin->w_set_curswant = true; + } else { + vim_beep(BO_CRSR); + } } static void @@ -7788,9 +7794,10 @@ ins_up ( ) redraw_later(VALID); start_arrow(&tpos); - can_cindent = TRUE; - } else - vim_beep(); + can_cindent = true; + } else { + vim_beep(BO_CRSR); + } } static void ins_pageup(void) @@ -7811,9 +7818,10 @@ static void ins_pageup(void) tpos = curwin->w_cursor; if (onepage(BACKWARD, 1L) == OK) { start_arrow(&tpos); - can_cindent = TRUE; - } else - vim_beep(); + can_cindent = true; + } else { + vim_beep(BO_CRSR); + } } static void @@ -7835,9 +7843,10 @@ ins_down ( ) redraw_later(VALID); start_arrow(&tpos); - can_cindent = TRUE; - } else - vim_beep(); + can_cindent = true; + } else { + vim_beep(BO_CRSR); + } } static void ins_pagedown(void) @@ -7858,9 +7867,10 @@ static void ins_pagedown(void) tpos = curwin->w_cursor; if (onepage(FORWARD, 1L) == OK) { start_arrow(&tpos); - can_cindent = TRUE; - } else - vim_beep(); + can_cindent = true; + } else { + vim_beep(BO_CRSR); + } } /* @@ -8186,7 +8196,7 @@ int ins_copychar(linenr_T lnum) char_u *line; if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count) { - vim_beep(); + vim_beep(BO_COPY); return NUL; } @@ -8203,8 +8213,9 @@ int ins_copychar(linenr_T lnum) ptr = prev_ptr; c = (*mb_ptr2char)(ptr); - if (c == NUL) - vim_beep(); + if (c == NUL) { + vim_beep(BO_COPY); + } return c; } diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 24e31b1ed7..50e9ce7c17 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -729,10 +729,12 @@ getcmdline ( else if (wim_flags[wim_index] & WIM_FULL) nextwild(&xpc, WILD_NEXT, WILD_NO_BEEP, firstc != '@'); - } else - vim_beep(); - } else if (xpc.xp_numfiles == -1) + } else { + vim_beep(BO_WILD); + } + } else if (xpc.xp_numfiles == -1) { xpc.xp_context = EXPAND_NOTHING; + } } if (wim_index < 3) ++wim_index; @@ -2854,8 +2856,9 @@ ExpandOne ( break; } if (i < xp->xp_numfiles) { - if (!(options & WILD_NO_BEEP)) - vim_beep(); + if (!(options & WILD_NO_BEEP)) { + vim_beep(BO_WILD); + } break; } } diff --git a/src/nvim/message.c b/src/nvim/message.c index 8263ff4896..5f06506a31 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1731,12 +1731,12 @@ static void msg_puts_display(char_u *str, int maxlen, int attr, int recurse) if (msg_col) --msg_col; } else if (*s == TAB) { /* translate Tab into spaces */ - do + do { msg_screen_putchar(' ', attr); - while (msg_col & 7); - } else if (*s == BELL) /* beep (from ":sh") */ - vim_beep(); - else { + } while (msg_col & 7); + } else if (*s == BELL) { // beep (from ":sh") + vim_beep(BO_SH); + } else { if (has_mbyte) { cw = (*mb_ptr2cells)(s); if (enc_utf8 && maxlen >= 0) @@ -1897,9 +1897,9 @@ void show_sb_text(void) /* Only show something if there is more than one line, otherwise it looks * weird, typing a command without output results in one line. */ mp = msg_sb_start(last_msgchunk); - if (mp == NULL || mp->sb_prev == NULL) - vim_beep(); - else { + if (mp == NULL || mp->sb_prev == NULL) { + vim_beep(BO_MESS); + } else { do_more_prompt('G'); wait_return(FALSE); } diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index 1f1b5c2aa9..6829e4988c 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -2582,21 +2582,22 @@ void msgmore(long n) void beep_flush(void) { if (emsg_silent == 0) { - flush_buffers(FALSE); - vim_beep(); + flush_buffers(false); + vim_beep(BO_ERROR); } } -/* - * give a warning for an error - */ -void vim_beep(void) +// Give a warning for an error +// val is one of the BO_ values, e.g., BO_OPER +void vim_beep(unsigned val) { if (emsg_silent == 0) { - if (p_vb) { - ui_visual_bell(); - } else { - ui_putc(BELL); + if (!((bo_flags & val) || (bo_flags & BO_ALL))) { + if (p_vb) { + ui_visual_bell(); + } else { + ui_putc(BELL); + } } /* When 'verbose' is set and we are sourcing a script or executing a diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 5354fb20ad..713aa55500 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1534,7 +1534,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) case OP_DELETE: VIsual_reselect = false; /* don't reselect now */ if (empty_region_error) { - vim_beep(); + vim_beep(BO_OPER); CancelRedo(); } else { (void)op_delete(oap); @@ -1547,7 +1547,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) case OP_YANK: if (empty_region_error) { if (!gui_yank) { - vim_beep(); + vim_beep(BO_OPER); CancelRedo(); } } else { @@ -1560,7 +1560,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) case OP_CHANGE: VIsual_reselect = false; /* don't reselect now */ if (empty_region_error) { - vim_beep(); + vim_beep(BO_OPER); CancelRedo(); } else { /* This is a new edit command, not a restart. Need to @@ -1614,7 +1614,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) case OP_LOWER: case OP_ROT13: if (empty_region_error) { - vim_beep(); + vim_beep(BO_OPER); CancelRedo(); } else op_tilde(oap); @@ -1642,7 +1642,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) case OP_APPEND: VIsual_reselect = false; /* don't reselect now */ if (empty_region_error) { - vim_beep(); + vim_beep(BO_OPER); CancelRedo(); } else { /* This is a new edit command, not a restart. Need to @@ -1671,7 +1671,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) case OP_REPLACE: VIsual_reselect = false; /* don't reselect now */ if (empty_region_error) { - vim_beep(); + vim_beep(BO_OPER); CancelRedo(); } else { // Restore linebreak, so that when the user edits it looks as before. @@ -4040,10 +4040,11 @@ static void nv_exmode(cmdarg_T *cap) /* * Ignore 'Q' in Visual mode, just give a beep. */ - if (VIsual_active) - vim_beep(); - else if (!checkclearop(cap->oap)) + if (VIsual_active) { + vim_beep(BO_EX); + } else if (!checkclearop(cap->oap)) { do_exmode(false); + } } /* @@ -6972,8 +6973,9 @@ static void nv_esc(cmdarg_T *cap) check_cursor_col(); /* make sure cursor is not beyond EOL */ curwin->w_set_curswant = true; redraw_curbuf_later(INVERTED); - } else if (no_reason) - vim_beep(); + } else if (no_reason) { + vim_beep(BO_ESC); + } clearop(cap->oap); /* A CTRL-C is often used at the start of a menu. When 'insertmode' is diff --git a/src/nvim/option.c b/src/nvim/option.c index cbb22a0546..a578f2bb01 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1821,6 +1821,7 @@ static void didset_options(void) (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, true); (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, true); + (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, true); (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, true); (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, true); (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, true); @@ -2719,6 +2720,10 @@ did_set_string_option ( errmsg = e_invarg; } else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK) errmsg = e_invarg; + } else if (varp == &p_bo) { + if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, true) != OK) { + errmsg = e_invarg; + } } else if (varp == &p_cmp) { // 'casemap' if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, true) != OK) errmsg = e_invarg; diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index ab3169bff6..d4d3410d5c 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -287,6 +287,37 @@ static char *(p_bkc_values[]) = # define BKC_BREAKHARDLINK 0x010 EXTERN char_u *p_bdir; /* 'backupdir' */ EXTERN char_u *p_bex; /* 'backupext' */ +EXTERN char_u *p_bo; // 'belloff' +EXTERN unsigned bo_flags; +# ifdef IN_OPTION_C +static char *(p_bo_values[]) = {"all", "backspace", "cursor", "complete", + "copy", "ctrlg", "error", "esc", "ex", + "hangul", "insertmode", "lang", "mess", + "showmatch", "operator", "register", "shell", + "spell", "wildmode", NULL}; +# endif + +// values for the 'belloff' option +#define BO_ALL 0x0001 +#define BO_BS 0x0002 +#define BO_CRSR 0x0004 +#define BO_COMPL 0x0008 +#define BO_COPY 0x0010 +#define BO_CTRLG 0x0020 +#define BO_ERROR 0x0040 +#define BO_ESC 0x0080 +#define BO_EX 0x0100 +#define BO_HANGUL 0x0200 +#define BO_IM 0x0400 +#define BO_LANG 0x0800 +#define BO_MESS 0x1000 +#define BO_MATCH 0x2000 +#define BO_OPER 0x4000 +#define BO_REG 0x8000 +#define BO_SH 0x10000 +#define BO_SPELL 0x20000 +#define BO_WILD 0x40000 + EXTERN char_u *p_bsk; /* 'backupskip' */ EXTERN char_u *p_breakat; /* 'breakat' */ EXTERN char_u *p_cmp; /* 'casemap' */ diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 5973e4b938..842b0a7c82 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -194,6 +194,14 @@ return { defaults={if_true={vi=""}} }, { + full_name='belloff', abbreviation='bo', + deny_duplicates=true, + type='string', list='comma', scope={'global'}, + vi_def=true, + varname='p_bo', + defaults={if_true={vi=""}} + }, + { full_name='binary', abbreviation='bin', type='bool', scope={'buffer'}, vi_def=true, diff --git a/src/nvim/search.c b/src/nvim/search.c index 8ba888841c..a44b0e00c7 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -2052,11 +2052,13 @@ showmatch ( return; } - if ((lpos = findmatch(NULL, NUL)) == NULL) /* no match, so beep */ - vim_beep(); - else if (lpos->lnum >= curwin->w_topline && lpos->lnum < curwin->w_botline) { - if (!curwin->w_p_wrap) + if ((lpos = findmatch(NULL, NUL)) == NULL) { // no match, so beep + vim_beep(BO_MATCH); + } else if (lpos->lnum >= curwin->w_topline + && lpos->lnum < curwin->w_botline) { + if (!curwin->w_p_wrap) { getvcol(curwin, lpos, NULL, &vcol, NULL); + } if (curwin->w_p_wrap || (vcol >= curwin->w_leftcol && vcol < curwin->w_leftcol + curwin->w_width)) { mpos = *lpos; /* save the pos, update_screen() may change it */ diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 88f64bdf73..7d9257141a 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -8406,7 +8406,7 @@ void spell_suggest(int count) // Use the Visually selected text as the bad word. But reject // a multi-line selection. if (curwin->w_cursor.lnum != VIsual.lnum) { - vim_beep(); + vim_beep(BO_SPELL); return; } badlen = (int)curwin->w_cursor.col - (int)VIsual.col; diff --git a/src/nvim/version.c b/src/nvim/version.c index 072084de40..961c017bd5 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -128,7 +128,7 @@ static int included_patches[] = { // 796 NA // 795, // 794 NA - // 793, + 793, // 792, // 791, // 790, |