From 2c13e0d7d63a574c255fc754f511bcca8a0c9e44 Mon Sep 17 00:00:00 2001 From: Joe Lim <50560759+joelim-work@users.noreply.github.com> Date: Mon, 5 Jun 2023 01:56:39 +1000 Subject: [PATCH] Add `clearmaps` command (#1286) --- complete.go | 1 + doc.go | 7 +++++++ docstring.go | 8 ++++++++ eval.go | 4 ++++ lf.1 | 7 +++++++ 5 files changed, 27 insertions(+) diff --git a/complete.go b/complete.go index 125eeaca..024da3a0 100644 --- a/complete.go +++ b/complete.go @@ -43,6 +43,7 @@ var ( "glob-select", "glob-unselect", "calcdirsize", + "clearmaps", "copy", "cut", "paste", diff --git a/doc.go b/doc.go index 99e2819a..bdafebe4 100644 --- a/doc.go +++ b/doc.go @@ -41,6 +41,7 @@ The following commands are provided by lf: glob-select glob-unselect calcdirsize + clearmaps copy (default 'y') cut (default 'd') paste (default 'p') @@ -382,6 +383,12 @@ Calculate the total size for each of the selected directories. Option 'info' should include 'size' and option 'dircounts' should be disabled to show this size. If the total size of a directory is not calculated, it will be shown as '-'. + clearmaps + +Remove all keybindings associated with the `map` command. +This command can be used in the config file to remove the default keybindings. +For safety purposes, `:` is left mapped to the `read` command, and `cmap` keybindings are retained so that it is still possible to exit `lf` using `:quit`. + copy (default 'y') If there are no selections, save the path of the current file to the copy buffer, otherwise, copy the paths of selected files. diff --git a/docstring.go b/docstring.go index 759260c2..89476715 100644 --- a/docstring.go +++ b/docstring.go @@ -44,6 +44,7 @@ The following commands are provided by lf: glob-select glob-unselect calcdirsize + clearmaps copy (default 'y') cut (default 'd') paste (default 'p') @@ -398,6 +399,13 @@ should include 'size' and option 'dircounts' should be disabled to show this size. If the total size of a directory is not calculated, it will be shown as '-'. + clearmaps + +Remove all keybindings associated with the 'map' command. This command can be +used in the config file to remove the default keybindings. For safety purposes, +':' is left mapped to the 'read' command, and 'cmap' keybindings are retained so +that it is still possible to exit 'lf' using ':quit'. + copy (default 'y') If there are no selections, save the path of the current file to the copy diff --git a/eval.go b/eval.go index 1ece47bf..048ee92b 100644 --- a/eval.go +++ b/eval.go @@ -1614,6 +1614,10 @@ func (e *callExpr) eval(app *app, args []string) { app.ui.loadFileInfo(app.nav) app.nav.sort() app.ui.sort() + case "clearmaps": + // leave `:` and cmaps bound so the user can still exit using `:quit` + gOpts.keys = make(map[string]expr) + gOpts.keys[":"] = &callExpr{"read", nil, 1} case "copy": if !app.nav.init { return diff --git a/lf.1 b/lf.1 index 97f64605..7b59b1c5 100644 --- a/lf.1 +++ b/lf.1 @@ -56,6 +56,7 @@ The following commands are provided by lf: glob-select glob-unselect calcdirsize + clearmaps copy (default 'y') cut (default 'd') paste (default 'p') @@ -444,6 +445,12 @@ Select/unselect files that match the given glob. .PP Calculate the total size for each of the selected directories. Option 'info' should include 'size' and option 'dircounts' should be disabled to show this size. If the total size of a directory is not calculated, it will be shown as '-'. .PP +.EX + clearmaps +.EE +.PP +Remove all keybindings associated with the `map` command. This command can be used in the config file to remove the default keybindings. For safety purposes, `:` is left mapped to the `read` command, and `cmap` keybindings are retained so that it is still possible to exit `lf` using `:quit`. +.PP .EX copy (default 'y') .EE