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.) --- Test/X04zlehighlight.ztst | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'Test') diff --git a/Test/X04zlehighlight.ztst b/Test/X04zlehighlight.ztst index 475a2e309..7ab050bee 100644 --- a/Test/X04zlehighlight.ztst +++ b/Test/X04zlehighlight.ztst @@ -94,6 +94,50 @@ 0:basic region_highlight with 8 colors >0m27m24mCDE|32|trueCDE|39| + zpty_start + zpty_input 'rh_widget() { region_highlight+=( "0 4 fg=green memo=someplugin" ); typeset -p region_highlight }' + zpty_input 'zle -N rh_widget' + zpty_input 'bindkey "\C-a" rh_widget' + zpty_enable_zle + zpty_input $'\C-a' + zpty_line + zpty_stop +0:region_highlight memo information round trips +>typeset -a region_highlight=( '0 4 fg=green memo=someplugin' ) + + zpty_start + zpty_input 'rh_widget() { region_highlight+=( "0 4 fg=green memo=someplugin,futureattribute=futurevalue" ); typeset -p region_highlight }' + zpty_input 'zle -N rh_widget' + zpty_input 'bindkey "\C-a" rh_widget' + zpty_enable_zle + zpty_input $'\C-a' + zpty_line + zpty_stop +0:region_highlight memo information forward compatibility, #1 +>typeset -a region_highlight=( '0 4 fg=green memo=someplugin' ) + + zpty_start + zpty_input 'rh_widget() { region_highlight+=( "0 4 fg=green memo=someplugin futurefifthfield" ); typeset -p region_highlight }' + zpty_input 'zle -N rh_widget' + zpty_input 'bindkey "\C-a" rh_widget' + zpty_enable_zle + zpty_input $'\C-a' + zpty_line + zpty_stop +0:region_highlight memo information forward compatibility, #2 +>typeset -a region_highlight=( '0 4 fg=green memo=someplugin' ) + + zpty_start + zpty_input 'rh_widget() { region_highlight+=( "0 4 fg=green memo=some'$'\0''plugin" ); typeset -p region_highlight }' + zpty_input 'zle -N rh_widget' + zpty_input 'bindkey "\C-a" rh_widget' + zpty_enable_zle + zpty_input $'\C-a' + zpty_line + zpty_stop +0:region_highlight memo information forward compatibility, #3: NULs +>typeset -a region_highlight=( '0 4 fg=green memo=some' ) + zpty_start zpty_input 'rh_widget() { BUFFER="true"; region_highlight+=( "0 4 fg=#040810" ); }' zpty_input 'zle -N rh_widget' -- cgit 1.4.1