vim-patch:7.4.793

Problem:    Can't specify when not to ring the bell.
Solution:   Add the 'belloff' option. (Christian Brabandt)

165bc69d1b
This commit is contained in:
Johan Klokkhammer Helsing 2015-10-16 21:28:12 +02:00
parent e9de70e4ea
commit 3bb2662669
12 changed files with 195 additions and 90 deletions

View File

@ -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")

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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' */

View File

@ -193,6 +193,14 @@ return {
varname='p_bsk',
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'},

View File

@ -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 */

View File

@ -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;

View File

@ -128,7 +128,7 @@ static int included_patches[] = {
// 796 NA
// 795,
// 794 NA
// 793,
793,
// 792,
// 791,
// 790,