From 025d142a3de79bd4665ebcab9c37347b1496b96a Mon Sep 17 00:00:00 2001 From: moculus Date: Wed, 26 Sep 2007 04:32:28 +0000 Subject: [PATCH] some fixes for searching bugs --HG-- branch : pmacs2 --- BUGS | 1 + method.py | 2 +- mode/search.py | 10 ++++++---- mode/sh.py | 8 -------- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/BUGS b/BUGS index 75cabd0..2556fca 100644 --- a/BUGS +++ b/BUGS @@ -15,6 +15,7 @@ reverse search is all fucked up. 2007/07/15: sometimes you don't get search-as-you-type (and have to hit C-s an extra time to see anything). +* possibly fixed (2007/09/26) 2007/07/12: sometimes searching seems to save the wrong cursor position, or not overwrite diff --git a/method.py b/method.py index 2c10db6..706a682 100644 --- a/method.py +++ b/method.py @@ -137,8 +137,8 @@ class ForwardLines(Method): # search and replace class Search(Method): '''Interactive search; finds next occurance of text in buffer''' - direction = 'next' is_literal = True + direction = 'next' prompt = 'I-Search: ' def execute(self, w, **vargs): self.old_cursor = w.logical_cursor() diff --git a/mode/search.py b/mode/search.py index cfdc898..cf5cce7 100644 --- a/mode/search.py +++ b/mode/search.py @@ -36,7 +36,10 @@ def _make_regex(w, s): try: if w.buffer.method.is_literal: s = searchutil.escape_literal(s) - return re.compile(s, re.IGNORECASE) + if s.islower(): + return re.compile(s, re.IGNORECASE) + else: + return re.compile(s) else: return re.compile(s) except: @@ -53,7 +56,8 @@ class SearchNext(method.Method): except searchutil.IllegalPatternError: w.application.clear_highlighted_ranges() else: - w.buffer.set_data(w.application.last_search) + action = InsertSearchString(w.application.last_search) + action.execute(w) class SearchPrevious(method.Method): def execute(self, w, **vargs): @@ -136,5 +140,3 @@ def _end(w): w.application.close_mini_buffer() w.application.clear_highlighted_ranges() w.application.last_search = w.buffer.make_string() - #w.buffer.method.old_cursor = None - #w.buffer.method.old_window = None diff --git a/mode/sh.py b/mode/sh.py index 2f2c33b..781fb35 100644 --- a/mode/sh.py +++ b/mode/sh.py @@ -38,14 +38,9 @@ class TestGrammar(Grammar): class ShGrammar(Grammar): rules = [ PatternRule(r'function', r'[a-zA-Z_][a-zA-Z0-9_]*(?= *\(\))'), - #PatternRule(r'reserved', r"(?:case|done|do|elif|else|esac|fi|for|function|if|in|select|then|until|while|time)(?![a-zA-Z0-9_=/])"), PatternRule(r'reserved', r"(?:done|do|elif|else|esac|fi|for|function|if|in|select|then|until|while|time)(?![a-zA-Z0-9_=/])"), RegionRule(r'case', r'case', Grammar, 'in', CaseGrammar, r'esac'), - #PatternRule(r'builtin', r"(?:source|alias|bg|bind|break|builtin|cd|command|compgen|complete|declare|dirs|disown|echo|enable|eval|exec|exit|export|fc|fg|getops|hash|help|history|jobs|kill|let|local|logout|popd|printf|pushd|pwd|readonly|read|return|set|shift|shopt|suspend|test|times|trap|type|ulimit|umask|unalias|unset|wait)(?![a-zA-Z0-9_=/])"), PatternRule(r'builtin', r"(?:source|alias|bg|bind|break|builtin|cd|command|compgen|complete|declare|dirs|disown|echo|enable|eval|exec|exit|export|fc|fg|getops|hash|help|history|jobs|kill|let|local|logout|popd|printf|pushd|pwd|readonly|read|return|set|shift|shopt|suspend|times|trap|type|ulimit|umask|unalias|unset|wait)(?![a-zA-Z0-9_=/])"), - #PatternRule(r'operator', r"(?:-eq|-ne|-gt|-lt|-ge|-le| = | != )(?![a-zA-Z0-9_])"), - #PatternRule(r'delimiter', r";;|[\[\]\(\);\{\}|&><]"), - #RegionRule(r'test', r'\[', TestGrammar, r'\]'), RegionRule(r'test', r'test', TestGrammar, r'\n'), RegionRule(r'test2', r'\[', TestGrammar, r'\]'), PatternRule(r'delimiter', r";;|[();{}|&><]"), @@ -94,7 +89,6 @@ class Sh(mode2.Fundamental): grammar = ShGrammar tabbercls = ShTabber opentokens = ('delimiter', 'reserved', 'case.start') - #opentokens = ('delimiter', 'reserved', 'start') opentags = {'(': ')', '[': ']', '{': '}', 'do': 'done', 'then': 'fi', 'case': 'esac'} closetokens = ('delimiter', 'reserved', 'case.end') @@ -127,8 +121,6 @@ class Sh(mode2.Fundamental): 'eval.null': ('cyan', 'default'), 'eval.end': ('cyan', 'default'), - #'neval.start': ('cyan', 'default'), - #'neval.end': ('cyan', 'default'), 'neval.start': ('yellow', 'default'), 'neval.variable': ('yellow', 'default'), 'neval.null': ('cyan', 'default'),