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>
diff --git a/src/optionstr.c b/src/optionstr.c
index 603d0f4..d667e53 100644
--- a/src/optionstr.c
+++ b/src/optionstr.c
@@ -2248,11 +2248,18 @@
static char_u *
get_eventignore_name(expand_T *xp, int idx)
{
+ int subtract = *xp->xp_pattern == '-';
// 'eventignore(win)' allows special keyword "all" in addition to
// all event names.
- if (idx == 0)
+ if (!subtract && idx == 0)
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