diff --git a/IDEAS b/IDEAS index 8822eb8..9504267 100644 --- a/IDEAS +++ b/IDEAS @@ -1,3 +1,8 @@ +2007/08/11: + +Instead of storing method state in the method objects (for mode callback stuff), +we should probably store it in the buffer. + 2007/07/19: Convert all classes to subclass object. diff --git a/method.py b/method.py index fc4ce8b..7659843 100644 --- a/method.py +++ b/method.py @@ -157,7 +157,8 @@ class RegexReverseSearch(RegexSearch): class Replace(Method): '''Replace occurances of string X with string Y''' - args = [Argument('before', prompt="Replace: ", + is_literal = True + args = [Argument('before', prompt="Replace String: ", default=default.last_replace_before, load_default=True), Argument('after', prompt="Replace With: ", default=default.last_replace_after, load_default=True)] @@ -167,6 +168,19 @@ class Replace(Method): a.last_replace_after = self.after = vargs['after'] self.old_window = w a.open_mini_buffer('I-Replace: ', lambda x: None, self, None, 'replace') +class RegexReplace(Method): + '''Replace occurances of string X with string Y''' + is_literal = False + args = [Argument('before', prompt="Replace Regex: ", + default=default.last_replace_before, load_default=True), + Argument('after', prompt="Replace With: ", + default=default.last_replace_after, load_default=True)] + def _execute(self, w, **vargs): + w.application.last_replace_before = self.before = vargs['before'] + w.application.last_replace_after = self.after = vargs['after'] + self.old_window = w + f = lambda x: None + w.application.open_mini_buffer('I-RegexReplace: ', f, self, None, 'replace') # navigating between buffers class OpenFile(Method): diff --git a/mode/python.py b/mode/python.py index 1511d62..37c7bd3 100644 --- a/mode/python.py +++ b/mode/python.py @@ -133,7 +133,8 @@ class PythonTabber(tab2.StackTabber): elif self.is_rightmost_token(y, i): pass else: - self._pop() + #self._pop() + pass elif fqname == 'keyword': if token.string in self.endlevel_names: # we know we'll unindent at least once diff --git a/mode/replace.py b/mode/replace.py index ad523b2..a7a712c 100644 --- a/mode/replace.py +++ b/mode/replace.py @@ -53,11 +53,14 @@ class CancelReplace(method.Method): w.set_error("Replace cancelled") def _find_next(m, move=False): - s = m.before - w = m.old_window - c = w.logical_cursor() + s = m.before + w = m.old_window + c = w.logical_cursor() try: - r = re.compile(searchutil.escape_literal(s)) + if m.is_literal: + r = re.compile(searchutil.escape_literal(s)) + else: + r = re.compile(s) except: (m.p1, m.p2) = (None, None) return False diff --git a/mode2.py b/mode2.py index 43b21b0..cf3f027 100644 --- a/mode2.py +++ b/mode2.py @@ -126,6 +126,7 @@ class Fundamental(Handler): self.add_bindings('regex-reverse-search', ('M-C-r',)) self.add_bindings('toggle-margins', ('M-m',)) self.add_bindings('replace', ('M-%',)) + self.add_bindings('regex-replace', ('M-$',)) self.add_bindings('open-file', ('C-x C-f',)) self.add_bindings('kill-buffer', ('C-x k',)) self.add_bindings('list-buffers', ('C-x C-b',))