diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-05-01 12:09:22 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-05-01 12:38:40 +0200 |
| commit | 1f0858f772603f00a091321b4deb344df0e8df9a (patch) | |
| tree | a0a6afc016529605d4e236207768a557de47daec | |
| parent | ffc9062fe803b71510b1d4f6ba8d4bfa24e798fa (diff) | |
| download | vis-1f0858f772603f00a091321b4deb344df0e8df9a.tar.gz vis-1f0858f772603f00a091321b4deb344df0e8df9a.tar.xz | |
vis-lua: let vis:map override existing mappings
It now also unmaps all previously mapped prefixes of the new mapping.
See 0ef138085f885d4576a8e53d079e1f00f80799bf and #271.
| -rw-r--r-- | vis-lua.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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; |
