From 7d91bc1a14cf09d957c32384f4259020cbbd2bd5 Mon Sep 17 00:00:00 2001 From: moculus Date: Fri, 13 Mar 2009 04:36:20 +0000 Subject: [PATCH] --HG-- branch : pmacs2 --- method/__init__.py | 3 +++ method/help.py | 44 +++++++++++++++++++++++++++++++++++++++++++- mode/__init__.py | 4 +++- mode/forth.py | 2 -- 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/method/__init__.py b/method/__init__.py index 35044e0..6a1ff82 100644 --- a/method/__init__.py +++ b/method/__init__.py @@ -939,10 +939,13 @@ class CloseTag(Method): i = len(tokens[y]) - 1 class CloseParen(CloseTag): + '''Insert ), matching if applicable''' mytag = ')' class CloseBrace(CloseTag): + '''Insert }, matching if applicable''' mytag = '}' class CloseBracket(CloseTag): + '''Insert ], matching if applicable''' mytag = ']' class RegisterSave(Method): diff --git a/method/help.py b/method/help.py index 9d72be7..54ae152 100644 --- a/method/help.py +++ b/method/help.py @@ -4,9 +4,51 @@ from subprocess import Popen, PIPE, STDOUT import buffer, buffer.about import default, dirutil, regex, util, window from point import Point - +from mode import Fundamental from method import Method, Argument +class ShowMode(Method): + '''Show helpful information for the current mode''' + + def _execute(self, w, **vargs): + a = w.application + m = w.mode + f = Fundamental(w) + + lines = ['%s mode' % m.modename, ''] + + seen = set() + triples = [] + l1, l2 = 0, 0 + for keys in m.bindings: + if f.bindings.get(keys) == m.bindings.get(keys): + continue + name = m.bindings[keys] + seen.add(name) + l1 = max(l1, len(name)) + l2 = max(l2, len(keys)) + triples.append([name, keys, a.methods[name].help]) + + for cls in m.actions: + name = cls._name() + if name in seen: + continue + triples.append([name, '', a.methods[name].help]) + + last = None + lines.append('Key Bindings:') + for triple in sorted(triples): + name, keys, _help = triple + if name == last: + name = '' + else: + last = name + lines.append(' %-*s %-*s %s' % (l1, name, l2, keys, _help)) + lines.append('') + + data = '\n'.join(lines) + w.application.data_buffer("*Mode-Help*", data, switch_to=True) + class ShowBindingsBuffer(Method): '''Dump all keybindings for current mode into a new buffer''' def _execute(self, w, **vargs): diff --git a/mode/__init__.py b/mode/__init__.py index 964da8e..6a7cd31 100644 --- a/mode/__init__.py +++ b/mode/__init__.py @@ -256,12 +256,14 @@ class Fundamental(Handler): self.add_bindings('insert-text', ('C-c i',)) self.add_bindings('insert-text2', ('C-c M-i',)) self.add_bindings('insert-multiline-text', ('C-c m',)) - self.add_bindings('increment', ('M-+',)) + self.add_bindings('increment', ('M-+', 'M-=')) self.add_bindings('decrement', ('M--',)) self.add_bindings('uppercase-word', ('M-u',)) self.add_bindings('lowercase-word', ('M-l',)) + i = 31 + # used for all word operations if not self.word_letters: self.word_letters = w.application.config['word_letters'] diff --git a/mode/forth.py b/mode/forth.py index 99a7438..92fb0bc 100644 --- a/mode/forth.py +++ b/mode/forth.py @@ -10,8 +10,6 @@ class DataGrammar(Grammar): class LineGrammar(Grammar): rules = [PatternRule(r'data', r'.+')] -#class StringGrammar1(Grammar): -# rules = [PatternRule(r'data', r'[^\']+')] class StringGrammar3(Grammar): rules = [PatternRule(r'data', r'[^)]+')]