Skip to content

Commit

Permalink
Merge pull request #3466 from johanhelsing/vim-7.4.793
Browse files Browse the repository at this point in the history
vim-patch:7.4.793
  • Loading branch information
justinmk committed Oct 19, 2015
2 parents e9de70e + 3bb2662 commit ea01c40
Show file tree
Hide file tree
Showing 12 changed files with 195 additions and 90 deletions.
44 changes: 43 additions & 1 deletion runtime/doc/options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
109 changes: 60 additions & 49 deletions src/nvim/edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,9 +789,10 @@ edit (
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:
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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. */
Expand All @@ -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)
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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);
}
}

/*
Expand Down Expand Up @@ -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;
}

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

Expand Down
13 changes: 8 additions & 5 deletions src/nvim/ex_getln.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/nvim/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
Expand Down
21 changes: 11 additions & 10 deletions src/nvim/misc1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit ea01c40

Please sign in to comment.