aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/data/plugins/keycmd.py
diff options
context:
space:
mode:
authorGravatar Ben Boeckel <MathStuf@gmail.com>2011-03-24 18:53:12 -0400
committerGravatar Ben Boeckel <MathStuf@gmail.com>2011-03-24 18:55:26 -0400
commit7c0d66962b044bf0001005e911aefe78bb10c95f (patch)
tree7f53211c6f98f73a781c379f59e40a79d935986b /examples/data/plugins/keycmd.py
parent37fe833febdb26a03816e7a82c5b649fdc0984f3 (diff)
Allow for multiple characters to bound words
Word deletion in URLs is a lot better when characters such as: \ -./&?= are considered to separate words.
Diffstat (limited to 'examples/data/plugins/keycmd.py')
-rw-r--r--examples/data/plugins/keycmd.py14
1 files changed, 10 insertions, 4 deletions
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)