aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Brendan Taylor <whateley@gmail.com>2011-04-13 07:03:11 -0600
committerGravatar Brendan Taylor <whateley@gmail.com>2011-04-13 07:03:11 -0600
commit89e95533d8e973b92a6217c9824ff595f6b37278 (patch)
tree8d19e5604a7625974475e96e08a6487d5fdb1d32
parent9bbff45ac31eee6458d2c20fc7a15d18c58aca19 (diff)
parentba7117ab362062f7cb0abdf6d0ee212f42d580ae (diff)
Merge remote-tracking branch 'mathstuf/dev/better-word-delete' into experimental
-rw-r--r--README2
-rw-r--r--examples/config/config2
-rw-r--r--examples/data/plugins/keycmd.py14
3 files changed, 13 insertions, 5 deletions
diff --git a/README b/README
index cfc9a87..57c7397 100644
--- a/README
+++ b/README
@@ -773,6 +773,8 @@ Events/requests which the EM and its plugins listens for
keycmd.
* `KEYCMD_STRIP_WORD`: Removes the last word from the keycmd, similar to
readline `^W`.
+ - `request KEYCMD_STRIP_WORD <seps>`: The `<seps>` argument is a list of
+ characters that are considered to separate words.
* `KEYCMD_EXEC_CURRENT`: (tries to) execute whatever is in the keycmd.
* `SET_KEYCMD`: Allow setting of the keycmd externally.
- `request SET_KEYCMD <string>`: Set the keycmd to `<string>`.
diff --git a/examples/config/config b/examples/config/config
index a690aec..ab789f9 100644
--- a/examples/config/config
+++ b/examples/config/config
@@ -200,7 +200,7 @@ set ebind = @mode_bind global,-insert
@ebind <Delete> = event KEYCMD_DELETE
@ebind <Tab> = event START_COMPLETION
# Readline-ish bindings.
-@ebind <Ctrl>w = event KEYCMD_STRIP_WORD
+@ebind <Ctrl>w = event KEYCMD_STRIP_WORD \ -./&?=
@ebind <Ctrl>u = event SET_KEYCMD
@ebind <Ctrl>a = event SET_CURSOR_POS 0
@ebind <Ctrl>e = event SET_CURSOR_POS -1
diff --git a/examples/data/plugins/keycmd.py b/examples/data/plugins/keycmd.py
index 928c597..76e2d75 100644
--- a/examples/data/plugins/keycmd.py
+++ b/examples/data/plugins/keycmd.py
@@ -406,16 +406,22 @@ def append_keycmd(uzbl, keycmd):
update_event(uzbl, k, False)
-def keycmd_strip_word(uzbl, sep):
+def keycmd_strip_word(uzbl, seps):
''' Removes the last word from the keycmd, similar to readline ^W '''
- sep = sep or ' '
+ seps = seps or ' '
k = uzbl.keylet
if not k.keycmd:
return
- head, tail = k.keycmd[:k.cursor].rstrip(sep), k.keycmd[k.cursor:]
- rfind = head.rfind(sep)
+ head, tail = k.keycmd[:k.cursor].rstrip(seps), k.keycmd[k.cursor:]
+ rfind = -1
+ for sep in seps:
+ p = head.rfind(sep)
+ if p >= 0 and rfind < p + 1:
+ rfind = p + 1
+ if rfind == len(head) and head[-1] in seps:
+ rfind -= 1
head = head[:rfind] if rfind + 1 else ''
k.keycmd = head + tail
k.cursor = len(head)