From cd63dc187240cd721fb68034cb7f320431b8aac7 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Fri, 2 Sep 2016 21:32:11 +0300 Subject: [PATCH] unmap a binding or delete a command when expression is empty With this commit `map`/`cmd` keywords are also used to remove a binding/command by leaving the expression part empty (e.g. `map j` removes keybinding for `j` or `cmd trash` removes `trash` command). Mentioned in #16. --- eval.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/eval.go b/eval.go index 33c5cbe..86bca8c 100644 --- a/eval.go +++ b/eval.go @@ -106,10 +106,18 @@ func (e *SetExpr) eval(app *App, args []string) { } func (e *MapExpr) eval(app *App, args []string) { + if e.expr == nil { + delete(gOpts.keys, e.keys) + return + } gOpts.keys[e.keys] = e.expr } func (e *CmdExpr) eval(app *App, args []string) { + if e.expr == nil { + delete(gOpts.cmds, e.name) + return + } gOpts.cmds[e.name] = e.expr }