aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/data/uzbl/plugins/bind.py
diff options
context:
space:
mode:
authorGravatar Mason Larobina <mason.larobina@gmail.com>2009-11-03 22:42:57 +0800
committerGravatar Mason Larobina <mason.larobina@gmail.com>2009-11-03 22:42:57 +0800
commit2dcf30f60e9e8381fc7ccca92dbf4490e33d55ed (patch)
tree2c1639a8654055aa0b5988870b50ffd4e51be9a3 /examples/data/uzbl/plugins/bind.py
parentcbee561dbb20bd79a524b29b90802004f78e47d3 (diff)
Improved support for prompts with default values in bind plugin.
Diffstat (limited to 'examples/data/uzbl/plugins/bind.py')
-rw-r--r--examples/data/uzbl/plugins/bind.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/examples/data/uzbl/plugins/bind.py b/examples/data/uzbl/plugins/bind.py
index 356b6bd..b8494fe 100644
--- a/examples/data/uzbl/plugins/bind.py
+++ b/examples/data/uzbl/plugins/bind.py
@@ -21,7 +21,7 @@ UZBLS = {}
# Commonly used regular expressions.
starts_with_mod = re.compile('^<([A-Z][A-Za-z0-9-_]*)>')
-find_prompts = re.compile('<([^:>]*):(\"[^>]*\"|)>').split
+find_prompts = re.compile('<([^:>]*):(\"[^\"]*\"|\'[^\']*\'|[^>]*)>').split
# For accessing a bind glob stack.
MOD_CMD, ON_EXEC, HAS_ARGS, GLOB, MORE = range(5)
@@ -159,7 +159,13 @@ class Bind(object):
self.bid = self.nextbid()
self.split = split = find_prompts(glob)
- self.prompts = zip(split[1::3],[x.strip('"') for x in split[2::3]])
+ self.prompts = []
+ for (prompt, set) in zip(split[1::3], split[2::3]):
+ if set and set[0] == set[-1] and set[0] in ['"', "'"]:
+ # Remove quotes around set.
+ set = set[1:-1]
+
+ self.prompts.append((prompt, set))
# Check that there is nothing like: fl*<int:>*
for glob in split[:-1:3]:
@@ -282,7 +288,7 @@ def parse_bind_event(uzbl, args):
def set_stack_mode(uzbl, prompt):
- prompt,data = prompt
+ prompt, set = prompt
if uzbl.get_mode() != 'stack':
uzbl.set_mode('stack')
@@ -291,9 +297,9 @@ def set_stack_mode(uzbl, prompt):
uzbl.set('keycmd_prompt', prompt)
- if data:
- # go through uzbl-core to expand potential @-variables
- uzbl.send('event SET_KEYCMD %s' % data)
+ if set:
+ # Go through uzbl-core to expand potential @-variables
+ uzbl.send('event SET_KEYCMD %s' % set)
def clear_stack(uzbl, mode):