mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 9.1.1419: It is difficult to ignore all but some events
Problem: It is difficult to ignore all but some events. Solution: Add support for a "-" prefix syntax in '(win)eventignore' that subtracts an event from the ignored set if present (Luuk van Baal). closes: #17392 Signed-off-by: Luuk van Baal <luukvbaal@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
647d7f7389
commit
8cc6d8b187
@ -1,4 +1,4 @@
|
|||||||
*options.txt* For Vim version 9.1. Last change: 2025 May 30
|
*options.txt* For Vim version 9.1. Last change: 2025 May 31
|
||||||
|
|
||||||
|
|
||||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||||
@ -3376,6 +3376,9 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
events are ignored, autocommands will not be executed.
|
events are ignored, autocommands will not be executed.
|
||||||
Otherwise this is a comma-separated list of event names. Example: >
|
Otherwise this is a comma-separated list of event names. Example: >
|
||||||
:set ei=WinEnter,WinLeave
|
:set ei=WinEnter,WinLeave
|
||||||
|
<
|
||||||
|
To ignore all but some events, a "-" prefix can be used: >
|
||||||
|
:set ei=all,-WinLeave
|
||||||
<
|
<
|
||||||
*'eventignorewin'* *'eiw'*
|
*'eventignorewin'* *'eiw'*
|
||||||
'eventignorewin' 'eiw' string (default "")
|
'eventignorewin' 'eiw' string (default "")
|
||||||
|
@ -803,16 +803,26 @@ find_end_event(
|
|||||||
int
|
int
|
||||||
event_ignored(event_T event, char_u *ei)
|
event_ignored(event_T event, char_u *ei)
|
||||||
{
|
{
|
||||||
|
int ignored = FALSE;
|
||||||
while (*ei != NUL)
|
while (*ei != NUL)
|
||||||
{
|
{
|
||||||
if (STRNICMP(ei, "all", 3) == 0 && (ei[3] == NUL || ei[3] == ',')
|
int unignore = *ei == '-';
|
||||||
&& (ei == p_ei || (event_tab[event].key <= 0)))
|
ei += unignore;
|
||||||
return TRUE;
|
if (STRNICMP(ei, "all", 3) == 0 && (ei[3] == NUL || ei[3] == ','))
|
||||||
if (event_name2nr(ei, &ei) == event)
|
{
|
||||||
return TRUE;
|
ignored = ei == p_ei || (event_tab[event].key <= 0);
|
||||||
|
ei += 3 + (ei[3] == ',');
|
||||||
|
}
|
||||||
|
else if (event_name2nr(ei, &ei) == event)
|
||||||
|
{
|
||||||
|
if (unignore)
|
||||||
|
return FALSE;
|
||||||
|
else
|
||||||
|
ignored = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return ignored;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -827,13 +837,10 @@ check_ei(char_u *ei)
|
|||||||
while (*ei)
|
while (*ei)
|
||||||
{
|
{
|
||||||
if (STRNICMP(ei, "all", 3) == 0 && (ei[3] == NUL || ei[3] == ','))
|
if (STRNICMP(ei, "all", 3) == 0 && (ei[3] == NUL || ei[3] == ','))
|
||||||
{
|
ei += 3 + (ei[3] == ',');
|
||||||
ei += 3;
|
|
||||||
if (*ei == ',')
|
|
||||||
++ei;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
ei += (*ei == '-');
|
||||||
event_T event = event_name2nr(ei, &ei);
|
event_T event = event_name2nr(ei, &ei);
|
||||||
if (event == NUM_EVENTS || (win && event_tab[event].key > 0))
|
if (event == NUM_EVENTS || (win && event_tab[event].key > 0))
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
@ -2248,11 +2248,18 @@ static int expand_eiw = FALSE;
|
|||||||
static char_u *
|
static char_u *
|
||||||
get_eventignore_name(expand_T *xp, int idx)
|
get_eventignore_name(expand_T *xp, int idx)
|
||||||
{
|
{
|
||||||
|
int subtract = *xp->xp_pattern == '-';
|
||||||
// 'eventignore(win)' allows special keyword "all" in addition to
|
// 'eventignore(win)' allows special keyword "all" in addition to
|
||||||
// all event names.
|
// all event names.
|
||||||
if (idx == 0)
|
if (!subtract && idx == 0)
|
||||||
return (char_u *)"all";
|
return (char_u *)"all";
|
||||||
return get_event_name_no_group(xp, idx - 1, expand_eiw);
|
|
||||||
|
char_u *name = get_event_name_no_group(xp, idx - 1 + subtract, expand_eiw);
|
||||||
|
if (name == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
sprintf((char *)IObuff, "%s%s", subtract ? "-" : "", name);
|
||||||
|
return IObuff;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -195,9 +195,9 @@ let test_values = {
|
|||||||
\ ['xxx']],
|
\ ['xxx']],
|
||||||
\ 'eadirection': [['', 'both', 'ver', 'hor'], ['xxx', 'ver,hor']],
|
\ 'eadirection': [['', 'both', 'ver', 'hor'], ['xxx', 'ver,hor']],
|
||||||
\ 'encoding': [['latin1'], ['xxx', '']],
|
\ 'encoding': [['latin1'], ['xxx', '']],
|
||||||
\ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter'],
|
\ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter', 'all,-WinLeave'],
|
||||||
\ ['xxx']],
|
\ ['xxx']],
|
||||||
\ 'eventignorewin': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter'],
|
\ 'eventignorewin': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter', 'all,-WinLeave'],
|
||||||
\ ['xxx', 'WinNew']],
|
\ ['xxx', 'WinNew']],
|
||||||
\ 'fileencoding': [['', 'latin1', 'xxx'], []],
|
\ 'fileencoding': [['', 'latin1', 'xxx'], []],
|
||||||
\ 'fileformat': [['', 'dos', 'unix', 'mac'], ['xxx']],
|
\ 'fileformat': [['', 'dos', 'unix', 'mac'], ['xxx']],
|
||||||
|
@ -5463,4 +5463,20 @@ func Test_reuse_curbuf_switch()
|
|||||||
%bw!
|
%bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_eventignore_subtract()
|
||||||
|
set eventignore=all,-WinEnter
|
||||||
|
augroup testing
|
||||||
|
autocmd!
|
||||||
|
autocmd WinEnter * ++once let s:triggered = 1
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
new
|
||||||
|
call assert_equal(1, s:triggered)
|
||||||
|
|
||||||
|
set eventignore&
|
||||||
|
unlet! s:triggered
|
||||||
|
call CleanUpTestAuGroup()
|
||||||
|
%bw!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@ -602,6 +602,7 @@ func Test_set_completion_string_values()
|
|||||||
|
|
||||||
" Other string options that queries the system rather than fixed enum names
|
" Other string options that queries the system rather than fixed enum names
|
||||||
call assert_equal(['all', 'BufAdd'], getcompletion('set eventignore=', 'cmdline')[0:1])
|
call assert_equal(['all', 'BufAdd'], getcompletion('set eventignore=', 'cmdline')[0:1])
|
||||||
|
call assert_equal(['-BufAdd', '-BufCreate'], getcompletion('set eventignore=all,-', 'cmdline')[0:1])
|
||||||
call assert_equal(['WinLeave', 'WinResized', 'WinScrolled'], getcompletion('set eiw=', 'cmdline')[-3:-1])
|
call assert_equal(['WinLeave', 'WinResized', 'WinScrolled'], getcompletion('set eiw=', 'cmdline')[-3:-1])
|
||||||
call assert_equal('latin1', getcompletion('set fileencodings=', 'cmdline')[1])
|
call assert_equal('latin1', getcompletion('set fileencodings=', 'cmdline')[1])
|
||||||
call assert_equal('top', getcompletion('set printoptions=', 'cmdline')[0])
|
call assert_equal('top', getcompletion('set printoptions=', 'cmdline')[0])
|
||||||
|
@ -709,6 +709,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1419,
|
||||||
/**/
|
/**/
|
||||||
1418,
|
1418,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user