some fixes for searching bugs

--HG--
branch : pmacs2
This commit is contained in:
moculus 2007-09-26 04:32:28 +00:00
parent faf00c2db6
commit 025d142a3d
4 changed files with 8 additions and 13 deletions

1
BUGS
View File

@ -15,6 +15,7 @@ reverse search is all fucked up.
2007/07/15: 2007/07/15:
sometimes you don't get search-as-you-type (and have to hit C-s an extra time sometimes you don't get search-as-you-type (and have to hit C-s an extra time
to see anything). to see anything).
* possibly fixed (2007/09/26)
2007/07/12: 2007/07/12:
sometimes searching seems to save the wrong cursor position, or not overwrite sometimes searching seems to save the wrong cursor position, or not overwrite

View File

@ -137,8 +137,8 @@ class ForwardLines(Method):
# search and replace # search and replace
class Search(Method): class Search(Method):
'''Interactive search; finds next occurance of text in buffer''' '''Interactive search; finds next occurance of text in buffer'''
direction = 'next'
is_literal = True is_literal = True
direction = 'next'
prompt = 'I-Search: ' prompt = 'I-Search: '
def execute(self, w, **vargs): def execute(self, w, **vargs):
self.old_cursor = w.logical_cursor() self.old_cursor = w.logical_cursor()

View File

@ -36,9 +36,12 @@ def _make_regex(w, s):
try: try:
if w.buffer.method.is_literal: if w.buffer.method.is_literal:
s = searchutil.escape_literal(s) s = searchutil.escape_literal(s)
if s.islower():
return re.compile(s, re.IGNORECASE) return re.compile(s, re.IGNORECASE)
else: else:
return re.compile(s) return re.compile(s)
else:
return re.compile(s)
except: except:
raise searchutil.IllegalPatternError, "failed to compile: %r" % s raise searchutil.IllegalPatternError, "failed to compile: %r" % s
@ -53,7 +56,8 @@ class SearchNext(method.Method):
except searchutil.IllegalPatternError: except searchutil.IllegalPatternError:
w.application.clear_highlighted_ranges() w.application.clear_highlighted_ranges()
else: else:
w.buffer.set_data(w.application.last_search) action = InsertSearchString(w.application.last_search)
action.execute(w)
class SearchPrevious(method.Method): class SearchPrevious(method.Method):
def execute(self, w, **vargs): def execute(self, w, **vargs):
@ -136,5 +140,3 @@ def _end(w):
w.application.close_mini_buffer() w.application.close_mini_buffer()
w.application.clear_highlighted_ranges() w.application.clear_highlighted_ranges()
w.application.last_search = w.buffer.make_string() w.application.last_search = w.buffer.make_string()
#w.buffer.method.old_cursor = None
#w.buffer.method.old_window = None

View File

@ -38,14 +38,9 @@ class TestGrammar(Grammar):
class ShGrammar(Grammar): class ShGrammar(Grammar):
rules = [ rules = [
PatternRule(r'function', r'[a-zA-Z_][a-zA-Z0-9_]*(?= *\(\))'), 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_=/])"), 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'), 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'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'test', r'test', TestGrammar, r'\n'),
RegionRule(r'test2', r'\[', TestGrammar, r'\]'), RegionRule(r'test2', r'\[', TestGrammar, r'\]'),
PatternRule(r'delimiter', r";;|[();{}|&><]"), PatternRule(r'delimiter', r";;|[();{}|&><]"),
@ -94,7 +89,6 @@ class Sh(mode2.Fundamental):
grammar = ShGrammar grammar = ShGrammar
tabbercls = ShTabber tabbercls = ShTabber
opentokens = ('delimiter', 'reserved', 'case.start') opentokens = ('delimiter', 'reserved', 'case.start')
#opentokens = ('delimiter', 'reserved', 'start')
opentags = {'(': ')', '[': ']', '{': '}', opentags = {'(': ')', '[': ']', '{': '}',
'do': 'done', 'then': 'fi', 'case': 'esac'} 'do': 'done', 'then': 'fi', 'case': 'esac'}
closetokens = ('delimiter', 'reserved', 'case.end') closetokens = ('delimiter', 'reserved', 'case.end')
@ -127,8 +121,6 @@ class Sh(mode2.Fundamental):
'eval.null': ('cyan', 'default'), 'eval.null': ('cyan', 'default'),
'eval.end': ('cyan', 'default'), 'eval.end': ('cyan', 'default'),
#'neval.start': ('cyan', 'default'),
#'neval.end': ('cyan', 'default'),
'neval.start': ('yellow', 'default'), 'neval.start': ('yellow', 'default'),
'neval.variable': ('yellow', 'default'), 'neval.variable': ('yellow', 'default'),
'neval.null': ('cyan', 'default'), 'neval.null': ('cyan', 'default'),