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.
This commit is contained in:
Gokcehan 2016-09-02 21:32:11 +03:00
parent 7fc93313bc
commit cd63dc1872

View File

@ -106,10 +106,18 @@ func (e *SetExpr) eval(app *App, args []string) {
} }
func (e *MapExpr) 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 gOpts.keys[e.keys] = e.expr
} }
func (e *CmdExpr) eval(app *App, args []string) { func (e *CmdExpr) eval(app *App, args []string) {
if e.expr == nil {
delete(gOpts.cmds, e.name)
return
}
gOpts.cmds[e.name] = e.expr gOpts.cmds[e.name] = e.expr
} }