From eff5bef2bb2dd220410c3a10d5f41bb9fc771ef1 Mon Sep 17 00:00:00 2001 From: moculus Date: Wed, 27 Feb 2008 07:33:24 +0000 Subject: [PATCH] new string methods --HG-- branch : pmacs2 --- method.py | 19 +++++++++++++++++++ mode/__init__.py | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/method.py b/method.py index d2cc2fb..4acb407 100644 --- a/method.py +++ b/method.py @@ -1427,6 +1427,25 @@ class SomethingCrazy(Method): def _execute(self, w, **vargs): pass +class InsertSquotes(Method): + '''Insert a pair of single-quotes into the buffer''' + def _execute(self, w, **vargs): + w.insert_string_at_cursor("''") + w.backward() +class InsertDquotes(Method): + '''Insert a pair of double-quotes into the buffer''' + def _execute(self, w, **vargs): + w.insert_string_at_cursor('""') + w.backward() +class InsertEscapedSquote(Method): + '''Insert an escaped single-quote''' + def _execute(self, w, **vargs): + w.insert_string_at_cursor("\\'") +class InsertEscapedDquote(Method): + '''Insert an escaped double-quote''' + def _execute(self, w, **vargs): + w.insert_string_at_cursor('\\"') + class CloseTag(Method): mytag = ')' def _execute(self, w, **vargs): diff --git a/mode/__init__.py b/mode/__init__.py index 6982ba3..afabbec 100644 --- a/mode/__init__.py +++ b/mode/__init__.py @@ -179,6 +179,10 @@ 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('insert-squotes', ('M-\'',)) + self.add_bindings('insert-dquotes', ('M-"',)) + self.add_bindings('insert-escaped-squote', ('C-c M-\'',)) + self.add_bindings('insert-escaped-dquote', ('C-c M-"',)) # unbound actions self.add_action(method.GetToken())