aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Rob <rob.manea@gmail.com>2009-11-25 07:21:19 +0100
committerGravatar Rob <rob.manea@gmail.com>2009-11-25 07:21:19 +0100
commit7ec390a3b67e6d4f704fb804e6d08027bddf6ab0 (patch)
tree27871bcd7ac284a33a8bc66215c7dea746ae6e13
parent16ca0d7785002bc3e90530c4c720d8d1274da943 (diff)
parentc8c56da8799c25e787bcdcd1fdd7bdc33db6d204 (diff)
Merge branch 'experimental' of git://github.com/mason-larobina/uzbl into experimental
-rw-r--r--examples/config/uzbl/config8
-rw-r--r--examples/data/uzbl/plugins/completion.py33
-rw-r--r--examples/data/uzbl/plugins/on_event.py8
3 files changed, 30 insertions, 19 deletions
diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config
index 5945985..ed522cc 100644
--- a/examples/config/uzbl/config
+++ b/examples/config/uzbl/config
@@ -125,8 +125,10 @@ set socket_dir = /tmp
# Middle click
# if clicked on a link open the link in a new uzbl window
-# otherwise open the selection in the current window
-@bind <Button2> = sh 'if [ "\@SELECTED_URI" ]; then uzbl-browser -u \@SELECTED_URI; else echo "uri $(xclip -o)" > $4; fi'
+# otherwise open the selection in the current window1
+set load_from_xclip = sh 'echo "uri $(xclip -o)" > $4'
+set open_new_window = sh 'uzbl-browser -u \@SELECTED_URI'
+@bind <Button2> = js if("\@SELECTED_URI") { Uzbl.run("\@open_new_window"); } else { Uzbl.run("\\\@load_from_xclip"); }
@bind j = scroll vertical 20
@bind <Page_Down> = scroll vertical 100%
@@ -157,7 +159,7 @@ set socket_dir = /tmp
@bind gh = uri http://www.uzbl.org
# shortcut to set variables
@bind s _ = set %s
-@bind \wiki _ = uri http://wiki.archlinux.org/index.php/Special:Search?search=%s&go=Go
+@bind \\wiki _ = uri http://wiki.archlinux.org/index.php/Special:Search?search=%s&go=Go
@bind gg _ = uri http://www.google.com/search?q=%s
# Enclose the executable in quotes if it has spaces. Any additional parameters you use will
# appear AFTER the default parameters
diff --git a/examples/data/uzbl/plugins/completion.py b/examples/data/uzbl/plugins/completion.py
index 2da42ba..42e7e17 100644
--- a/examples/data/uzbl/plugins/completion.py
+++ b/examples/data/uzbl/plugins/completion.py
@@ -9,13 +9,13 @@ import re
UZBLS = {}
# Completion level
-NONE, ONCE, LIST = range(3)
+NONE, ONCE, LIST, COMPLETE = range(4)
# Default instance dict.
DEFAULTS = {'completions': [], 'level': NONE, 'lock': False}
# The reverse keyword finding re.
-FIND_SEGMENT = re.compile("(\@[\w_]+|[\w_]+)$").findall
+FIND_SEGMENT = re.compile("(\@[\w_]+|set[\s]+[\w_]+|[\w_]+)$").findall
# Formats
LIST_FORMAT = "<span> %s </span>"
@@ -52,7 +52,11 @@ def get_incomplete_keyword(uzbl):
keylet = uzbl.get_keylet()
left_segment = keylet.keycmd[:keylet.cursor]
- return (FIND_SEGMENT(left_segment) + ['',])[0].lstrip()
+ partial = (FIND_SEGMENT(left_segment) + ['',])[0].lstrip()
+ if partial.startswith('set '):
+ return ('@%s' % partial[4:].lstrip(), True)
+
+ return (partial, False)
def stop_completion(uzbl, *args):
@@ -63,11 +67,16 @@ def stop_completion(uzbl, *args):
uzbl.set('completion_list')
-def complete_completion(uzbl, partial, hint):
+def complete_completion(uzbl, partial, hint, set_completion=False):
'''Inject the remaining porition of the keyword into the keycmd then stop
the completioning.'''
- remainder = "%s " % hint[len(partial):]
+ if set_completion:
+ remainder = "%s = " % hint[len(partial):]
+
+ else:
+ remainder = "%s " % hint[len(partial):]
+
uzbl.inject_keycmd(remainder)
stop_completion(uzbl)
@@ -83,12 +92,12 @@ def update_completion_list(uzbl, *args):
'''Checks if the user still has a partially completed keyword under his
cursor then update the completion hints list.'''
- partial = get_incomplete_keyword(uzbl)
+ partial = get_incomplete_keyword(uzbl)[0]
if not partial:
return stop_completion(uzbl)
d = get_completion_dict(uzbl)
- if d['level'] != LIST:
+ if d['level'] < LIST:
return
hints = [h for h in d['completions'] if h.startswith(partial)]
@@ -106,11 +115,11 @@ def start_completion(uzbl, *args):
if d['lock']:
return
- partial = get_incomplete_keyword(uzbl)
+ (partial, set_completion) = get_incomplete_keyword(uzbl)
if not partial:
return stop_completion(uzbl)
- if d['level'] < LIST:
+ if d['level'] < COMPLETE:
d['level'] += 1
hints = [h for h in d['completions'] if h.startswith(partial)]
@@ -119,13 +128,13 @@ def start_completion(uzbl, *args):
elif len(hints) == 1:
d['lock'] = True
- complete_completion(uzbl, partial, hints[0])
+ complete_completion(uzbl, partial, hints[0], set_completion)
d['lock'] = False
return
- elif partial in hints:
+ elif partial in hints and d['level'] == COMPLETE:
d['lock'] = True
- complete_completion(uzbl, partial, partial)
+ complete_completion(uzbl, partial, partial, set_completion)
d['lock'] = False
return
diff --git a/examples/data/uzbl/plugins/on_event.py b/examples/data/uzbl/plugins/on_event.py
index 3dfc3fa..afee4e6 100644
--- a/examples/data/uzbl/plugins/on_event.py
+++ b/examples/data/uzbl/plugins/on_event.py
@@ -1,7 +1,7 @@
'''Plugin provides arbitrary binding of uzbl events to uzbl commands.
Formatting options:
- %@ = space separated string of the arguments
+ %s = space separated string of the arguments
%1 = argument 1
%2 = argument 2
%n = argument n
@@ -45,10 +45,10 @@ def get_on_events(uzbl):
def expand(cmd, args):
- '''Replaces "%@ %1 %2 %3..." with "<all args> <arg 0> <arg 1>...".'''
+ '''Replaces "%s %1 %2 %3..." with "<all args> <arg 0> <arg 1>...".'''
- if '%@' in cmd:
- cmd = cmd.replace('%@', ' '.join(map(unicode, args)))
+ if '%s' in cmd:
+ cmd = cmd.replace('%s', ' '.join(map(unicode, args)))
for (index, arg) in enumerate(args):
index += 1