diff options
author | Mason Larobina <mason.larobina@gmail.com> | 2009-11-25 09:22:41 +0800 |
---|---|---|
committer | Mason Larobina <mason.larobina@gmail.com> | 2009-11-25 09:22:41 +0800 |
commit | c2d23b2fbbd8a930623efa907247ce1df5b8b4ec (patch) | |
tree | b0f400ac31dc58306ce39667e8c4c6dcc91acf38 /examples/data | |
parent | 940435ccef2ac6c129b4d999cc4f1d6e210beb54 (diff) |
Set completions also complete the '='.
Diffstat (limited to 'examples/data')
-rw-r--r-- | examples/data/uzbl/plugins/completion.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/examples/data/uzbl/plugins/completion.py b/examples/data/uzbl/plugins/completion.py index ee42b1f..cfdf901 100644 --- a/examples/data/uzbl/plugins/completion.py +++ b/examples/data/uzbl/plugins/completion.py @@ -54,9 +54,9 @@ def get_incomplete_keyword(uzbl): left_segment = keylet.keycmd[:keylet.cursor] partial = (FIND_SEGMENT(left_segment) + ['',])[0].lstrip() if partial.startswith('set '): - partial = '@%s' % partial[4:].lstrip() + return ('@%s' % partial[4:].lstrip(), True) - return partial + return (partial, False) def stop_completion(uzbl, *args): @@ -67,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) @@ -87,7 +92,7 @@ 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) @@ -110,7 +115,7 @@ 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) @@ -123,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: d['lock'] = True - complete_completion(uzbl, partial, partial) + complete_completion(uzbl, partial, partial, set_completion) d['lock'] = False return |