Add cmd-delete-word-back command (#1409)

* add `cmd-delete-word-back`

Implementation of zsh-like backwards word deletion.

* add unixwords option and evaluate, short description in doc

* remove unixwords configuration option

* remove yank, bind delete word back to alt-backspace, update docs

* minor changes to docs

* small fixes
This commit is contained in:
Jan-Peter Dhallé authored and GitHub committed 2023-09-03 19:52:07 +03:00
1 parent 439fb038e5
commit 791dfff8dc
6 files changed
+31

No files matched your search

+1
View File
@@ -101,6 +101,7 @@ var (
"cmd-delete-home",
"cmd-delete-end",
"cmd-delete-unix-word",
"cmd-delete-word-back",
"cmd-yank",
"cmd-transpose",
"cmd-transpose-word",
+5
View File
@@ -111,6 +111,7 @@ The following command line commands are provided by lf:
cmd-word (default '<a-f>')
cmd-word-back (default '<a-b>')
cmd-delete-word (default '<a-d>')
cmd-delete-word-back (default '<a-backspace>' and '<a-backspace2>')
cmd-capitalize-word (default '<a-c>')
cmd-uppercase-word (default '<a-u>')
cmd-lowercase-word (default '<a-l>')
@@ -632,6 +633,10 @@ Move the cursor by one word in forward/backward direction.
Delete the next word in forward direction.
cmd-delete-word-back (default '<a-backspace>' and '<a-backspace2>')
Delete the previous word in backward direction.
cmd-capitalize-word (default '<a-c>')
cmd-uppercase-word (default '<a-u>')
cmd-lowercase-word (default '<a-l>')
+5
View File
@@ -114,6 +114,7 @@ The following command line commands are provided by lf:
cmd-word (default '<a-f>')
cmd-word-back (default '<a-b>')
cmd-delete-word (default '<a-d>')
cmd-delete-word-back (default '<a-backspace>' and '<a-backspace2>')
cmd-capitalize-word (default '<a-c>')
cmd-uppercase-word (default '<a-u>')
cmd-lowercase-word (default '<a-l>')
@@ -661,6 +662,10 @@ Move the cursor by one word in forward/backward direction.
Delete the next word in forward direction.
cmd-delete-word-back (default '<a-backspace>' and '<a-backspace2>')
Delete the previous word in backward direction.
cmd-capitalize-word (default '<a-c>')
cmd-uppercase-word (default '<a-u>')
cmd-lowercase-word (default '<a-l>')
+11
View File
@@ -2665,6 +2665,17 @@ func (e *callExpr) eval(app *app, args []string) {
ind := loc[3]
app.ui.cmdAccRight = []rune(string(app.ui.cmdAccRight)[ind:])
update(app)
case "cmd-delete-word-back":
if len(app.ui.cmdAccLeft) == 0 {
return
}
locs := reWordBeg.FindAllStringSubmatchIndex(string(app.ui.cmdAccLeft), -1)
if locs == nil {
return
}
ind := locs[len(locs)-1][3]
app.ui.cmdAccLeft = app.ui.cmdAccLeft[:ind]
update(app)
case "cmd-uppercase-word":
if len(app.ui.cmdAccRight) == 0 {
return
+7
View File
@@ -128,6 +128,7 @@ The following command line commands are provided by lf:
cmd-word (default '<a-f>')
cmd-word-back (default '<a-b>')
cmd-delete-word (default '<a-d>')
cmd-delete-word-back (default '<a-backspace>' and '<a-backspace2>')
cmd-capitalize-word (default '<a-c>')
cmd-uppercase-word (default '<a-u>')
cmd-lowercase-word (default '<a-l>')
@@ -776,6 +777,12 @@ Move the cursor by one word in forward/backward direction.
.PP
Delete the next word in forward direction.
.PP
.EX
cmd-delete-word-back (default '<a-backspace>' and '<a-backspace2>')
.EE
.PP
Delete the previous word in backward direction.
.PP
.EX
cmd-capitalize-word (default '<a-c>')
cmd-uppercase-word (default '<a-u>')
+2
View File
@@ -351,6 +351,8 @@ func init() {
gOpts.cmdkeys["<a-b>"] = &callExpr{"cmd-word-back", nil, 1}
gOpts.cmdkeys["<a-c>"] = &callExpr{"cmd-capitalize-word", nil, 1}
gOpts.cmdkeys["<a-d>"] = &callExpr{"cmd-delete-word", nil, 1}
gOpts.cmdkeys["<a-backspace>"] = &callExpr{"cmd-delete-word-back", nil, 1}
gOpts.cmdkeys["<a-backspace2>"] = &callExpr{"cmd-delete-word-back", nil, 1}
gOpts.cmdkeys["<a-u>"] = &callExpr{"cmd-uppercase-word", nil, 1}
gOpts.cmdkeys["<a-l>"] = &callExpr{"cmd-lowercase-word", nil, 1}
gOpts.cmdkeys["<a-t>"] = &callExpr{"cmd-transpose-word", nil, 1}