From f3a9df9c23a38dba29e660aa61d72554045d6658 Mon Sep 17 00:00:00 2001 From: moculus Date: Wed, 13 Aug 2008 02:17:27 +0000 Subject: [PATCH] fixed some replace bugs --HG-- branch : pmacs2 --- BUGS | 11 ----------- code_examples/Reporting2.pm | 2 +- mode/replace.py | 13 ++++++++++--- window.py | 1 + 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/BUGS b/BUGS index e7b9374..72565ef 100644 --- a/BUGS +++ b/BUGS @@ -2,22 +2,13 @@ 2008/06/25: * when the "first" point is on a wrapping line bad things happen. - * when replace mode doesn't replace the last candidate it doesn't exit. * try implementing an "undo ID" in the application. * the "last visible" calculation doesn't handle long lines correctly. this affects page-up/page-down/etc. - * $) in perl regexes shows up as a varible. need better lists of which vars - work in perl. - * certain perl constructs are ambiguous between prototypes and vars - (e.g. "($@)"). 2008/06/06: what passes for auto-fill-mode around here still needs a lot of work. -2008/05/16: - paired delimiters in perl regexes either never worked or are broken. - dammit. (FIXED 2008/07/29) - 2007/07/15: sometimes you don't get search-as-you-type (and have to hit C-s again to see anything). @@ -34,5 +25,3 @@ known deficiencies: 1. a single action (global search and replace) may produce N actions that need to be individually "undone". This is annoying. 3. opening files larger than 5-10k lines can be very slow - 6. if you get confused in the mini buffer it can be annoying - (usually you just need to start hammering C-] to cancel whatever is happening). diff --git a/code_examples/Reporting2.pm b/code_examples/Reporting2.pm index c55059f..412b95e 100644 --- a/code_examples/Reporting2.pm +++ b/code_examples/Reporting2.pm @@ -2,7 +2,7 @@ package TBB::Reporting2; my $bar =~ s/foob/blag/g; -#@@:heredoc.string:xml +#@@:heredoc:sql sub foo { bar() unless 9 && 3; diff --git a/mode/replace.py b/mode/replace.py index 4c6318b..261fb3c 100644 --- a/mode/replace.py +++ b/mode/replace.py @@ -52,7 +52,11 @@ def _find_next(m, move=False): (m.p1, m.p2) = (None, None) return False - newc = searchutil.find_next(r, w, move, start=c.add(0, 0)) + if move: + newc = searchutil.find_next(r, w, False, start=c.add(1, 0)) + else: + newc = searchutil.find_next(r, w, False, start=c.add(0, 0)) + if newc: (m.p1, m.p2, m.match) = newc return True @@ -84,7 +88,8 @@ def _get_after(m): def _set_prompt(m): w = m.old_window if m.p1 is None: - w.application.mini_prompt = '%r was not found' % m.before + #w.application.mini_prompt = '%r was not found' % m.before + w.application.mini_prompt = '[%r] %r was not found' % (m.p1, m.before) return (x, y) = m.p1.xy() count = 0 @@ -98,8 +103,10 @@ def _set_prompt(m): if count > 1: p = 'Replace %r with %r [ynadq] (%d occurances)?' % (before, after, count) - else: + elif count == 1: p = 'Replace %r with %r [ynadq] (1 occurance)?' % (before, after) + else: + raise Exception("this can't happen") w.application.mini_prompt = p def _replace(m): diff --git a/window.py b/window.py index 2af1a57..98e2c81 100644 --- a/window.py +++ b/window.py @@ -139,6 +139,7 @@ class Window(object): # last visible point def _calc_last(self): + # POSSIBLE BUG (x, y) = self.first.xy() count = 0 while count < self.height - 1 and y < len(self.buffer.lines) - 1: