vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 02c1eae1d52261a8aa6424aeba36445fd1d20ae9
parent 5ef854b5c76c6d74647391210b2c19f6815f788e
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Sun,  1 May 2016 12:09:22 +0200

vis-lua: let vis:map override existing mappings

It now also unmaps all previously mapped prefixes of the new mapping.
See fb4498e7413d87fbe88fb020853a319d1497144b and #271.

Diffstat:
Mvis-lua.c | 14++++++++++++++
1 file changed, 14 insertions(+), 0 deletions(-)

diff --git a/vis-lua.c b/vis-lua.c @@ -403,6 +403,20 @@ static int map(lua_State *L) { binding->action = action; + char *lhs = strdup(key), *next = lhs; + while (next) { + char tmp; + next = (char*)vis_keys_next(vis, next); + if (next) { + tmp = *next; + *next = '\0'; + } + vis_mode_unmap(vis, mode, lhs); + if (next) + *next = tmp; + } + free(lhs); + if (!vis_mode_map(vis, mode, key, binding)) goto err;