From e1ad655912f5f029687c42f0fde0f752de8468ae Mon Sep 17 00:00:00 2001 From: moculus Date: Mon, 22 Oct 2007 00:19:47 +0000 Subject: [PATCH] --HG-- branch : pmacs2 --- method.py | 56 ------------------------------------------------------- mode2.py | 3 +-- 2 files changed, 1 insertion(+), 58 deletions(-) diff --git a/method.py b/method.py index e494934..5ad6468 100644 --- a/method.py +++ b/method.py @@ -874,62 +874,6 @@ class IndentBlock(Method): w.buffer.delete(Point(0, p1.y), Point(0, p2.y)) w.buffer.insert_string(Point(0, p1.y), '\n'.join(lines) + '\n') -class CodeComplete(Method): - '''Complete based on tokenized strings''' - def execute(self, w, **vargs): - cursor = w.logical_cursor() - - if len(w.buffer.lines[cursor.y]) == 0: - return - - bounds = w.get_word_bounds() - if bounds is None: - return - - (p1, p2) = bounds - buffer = w.buffer - word = buffer.get_substring(p1, p2) - app = w.application - highlighter = buffer.highlights[w.mode.name()] - tokens = highlighter.tokens - seen = {} - sofar = None - - for group in tokens: - for token in group: - s = token.string - if s == word: - continue - elif s.startswith(word): - seen[s] = True - if sofar is None: - sofar = s - else: - l = min(len(s), len(sofar)) - i = len(word) - while i < l: - if s[i] == sofar[i]: - i += 1 - else: - break - sofar = s[:i] - - seen_keys = seen.keys() - num_seen = len(seen_keys) - if word == sofar: - w.application.set_error('No completion possible: %r' % word) - pass - elif sofar: - w.buffer.delete(p1, p2) - w.buffer.insert_string(p1, sofar) - if num_seen == 1: - w.application.set_error('Unique!') - else: - w.application.set_error('Ambiguous: %r' % seen_keys) - else: - w.application.set_error('No completion found: %r' % word) - pass - class OpenConsole(Method): '''Evaluate python expressions (for advanced use and debugging only)''' def execute(self, w, **vargs): diff --git a/mode2.py b/mode2.py index 09e0f18..8145d32 100644 --- a/mode2.py +++ b/mode2.py @@ -166,7 +166,7 @@ class Fundamental(Handler): self.add_bindings('justify-left', ('C-c b',)) self.add_bindings('indent-block', ('C-c >',)) self.add_bindings('unindent-block', ('C-c <',)) - self.add_bindings('code-complete', ('M-c',)) + self.add_bindings('token-complete', ('M-c', 'C-c c')) self.add_bindings('shell-cmd', ('C-c !',)) self.add_bindings('open-aes-file', ('C-c a',)) self.add_bindings('open-console', ('M-e',)) @@ -179,7 +179,6 @@ class Fundamental(Handler): self.add_bindings('grep', ('C-c g',)) self.add_bindings('pipe', ('C-c p',)) self.add_bindings('view-buffer-parent', ('C-c .',)) - self.add_bindings('token-complete', ('C-c c',)) # unbound actions self.add_action(method.GetToken())