From dd6e702ee49c7292c39037843b1b1b2b080f9fda Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Thu, 25 Jun 2020 11:41:21 +0000 Subject: 46068 (tweaked) (was: github #57): region_highlight: Add memo= support. This is useful when multiple plugins add region_highlight entries and subsequently want to remove only their own entries. Without this functionality, recognizing one's region_highlight entries is not trivial because the 'start' and 'end' offsets are modified by editing of $BUFFER and the highlight specification may not be unique or distinctive. The tweaks are as follows: - Change zfree() to zsfree() per workers/46070. - Remove the mem.c hunk, as it changed the signature of only one out of two alternative definitions of zsfree(). (The definition that hunk touched is the one that's not used by default.) --- Src/prompt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Src/prompt.c') diff --git a/Src/prompt.c b/Src/prompt.c index b65bfb86b..bc9734720 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -1724,10 +1724,11 @@ match_colour(const char **teststrp, int is_fg, int colour) /* * Match a set of highlights in the given teststr. * Set *on_var to reflect the values found. + * Return a pointer to the first character not consumed. */ /**/ -mod_export void +mod_export const char * match_highlight(const char *teststr, zattr *on_var) { int found = 1; @@ -1745,7 +1746,7 @@ match_highlight(const char *teststr, zattr *on_var) atr = match_colour(&teststr, is_fg, 0); if (*teststr == ',') teststr++; - else if (*teststr) + else if (*teststr && *teststr != ' ') break; found = 1; /* skip out of range colours but keep scanning attributes */ @@ -1758,7 +1759,7 @@ match_highlight(const char *teststr, zattr *on_var) if (*val == ',') val++; - else if (*val) + else if (*val && *val != ' ') break; *on_var |= hl->mask_on; @@ -1769,6 +1770,8 @@ match_highlight(const char *teststr, zattr *on_var) } } } + + return teststr; } /* -- cgit 1.4.1