aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
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
parentcbee561dbb20bd79a524b29b90802004f78e47d3 (diff)
Improved support for prompts with default values in bind plugin.
Diffstat (limited to 'examples')
-rw-r--r--examples/config/uzbl/config2
-rw-r--r--examples/data/uzbl/plugins/bind.py18
2 files changed, 13 insertions, 7 deletions
diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config
index 4b04d7a..57d1ea5 100644
--- a/examples/config/uzbl/config
+++ b/examples/config/uzbl/config
@@ -197,7 +197,7 @@ set formfiller = spawn @scripts_dir/formfiller
# Examples using multi-stage-bindings with text prompts.
@bind o<uri:>_ = uri %s
-@bind O<uri:"\@uri">_ = uri %s
+@bind O<uri:\@uri>_ = uri %s
# multi-stage binding way to write bookmarks to file from inside uzbl.
@bind <Ctrl>b<tags:>_ = sh 'echo -e "$6 %s" >> $XDG_DATA_HOME/uzbl/bookmarks'
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):