From 91ffeb9a4b6476054359f9537184ea58106137ee Mon Sep 17 00:00:00 2001 From: moculus Date: Thu, 12 Jul 2007 21:42:31 +0000 Subject: [PATCH] --HG-- branch : pmacs2 --- BUGS | 4 ++++ mode_search.py | 4 ++-- mode_sh.py | 57 +++++++++++++++++++++++++++++--------------------- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/BUGS b/BUGS index a4bb75c..37ade08 100644 --- a/BUGS +++ b/BUGS @@ -1,3 +1,7 @@ +2007/07/12: +sometimes searching seems to save the wrong cursor position, or not overwrite +the previously used one. + 2006/07/04: undo/redo should probably show you what is being undone (i.e. by jumping to that region of code). diff --git a/mode_search.py b/mode_search.py index 155cc8e..1646c8c 100644 --- a/mode_search.py +++ b/mode_search.py @@ -117,12 +117,12 @@ class InsertSearchString(method.Method): w.insert_string_at_cursor(self.string) s = w.buffer.make_string() if not s: + w.application.clear_highlighted_ranges() return else: - s = w.buffer.make_string() - w2 = w.buffer.method.old_window try: r = _make_regex(w, s) + w2 = w.buffer.method.old_window if w.buffer.method.direction == 'next': search.find_next(r, w2, move=False) else: diff --git a/mode_sh.py b/mode_sh.py index c2e7b33..1a801a0 100644 --- a/mode_sh.py +++ b/mode_sh.py @@ -3,31 +3,32 @@ from lex2 import Grammar, PatternRule, RegionRule class StringGrammar(Grammar): rules = [ - PatternRule(name=r'escaped', pattern=r'\\.'), - PatternRule(name=r'variable', pattern=r"(?:^|(?<= ))[a-zA-Z_][a-zA-Z_][a-zA-Z0-9_]*(?==)"), - PatternRule(name=r'variable', pattern=r"\${(?:[a-zA-Z0-9_]+|\?\$)}"), - PatternRule(name=r"variable", pattern=r"\$[^({][a-zA-Z0-9_]*"), - PatternRule(name=r'variable', pattern=r"\$(?=\()"), + PatternRule(r'escaped', r'\\.'), + PatternRule(r'variable', r"\${(?:[a-zA-Z0-9_]+|\?\$)}"), + PatternRule(r"variable", r"\$[^({][a-zA-Z0-9_]*"), + PatternRule(r'variable', r"\$(?=\()"), ] class ShGrammar(Grammar): rules = [ - PatternRule(name=r'function', pattern=r'[a-zA-Z_][a-zA-Z0-9_]*(?= *\(\))'), - PatternRule(name=r'reserved', pattern=r"(?:case|done|do|elif|else|esac|fi|for|function|if|in|select|then|until|while|time)(?![a-zA-Z0-9_=/])"), - PatternRule(name=r'builtin', pattern=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(name=r'operator', pattern=r"(?:-eq|-ne|-gt|-lt|-ge|-le| = | != )"), - PatternRule(name=r'delimiter', pattern=r"[][\(\);\{\}|&><]"), - RegionRule(name=r'eval2', start=r'\$\(', grammar=None, end=r'\)'), - PatternRule(name=r'variable', pattern=r"(?:^|(?<= ))[a-zA-Z_][a-zA-Z_][a-zA-Z0-9_]*(?==)"), - PatternRule(name=r'variable', pattern=r"\${(?:[a-zA-Z0-9_]+|\?\$)}"), - PatternRule(name=r"variable", pattern=r"\$[^({][a-zA-Z0-9_]*"), - PatternRule(name=r'variable', pattern=r"\$(?=\()"), - RegionRule(name=r'eval', start='`', grammar=StringGrammar(), end='`'), - RegionRule(name=r'string', start="'", grammar=Grammar(), end="'"), - RegionRule(name=r'string', start='"', grammar=StringGrammar(), end='"'), - PatternRule(name=r'continuation', pattern=r'\\(?= *$)'), - PatternRule(name=r'comment', pattern=r'#.*$'), - PatternRule(name=r'bareword', pattern=r'[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'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'operator', r"(?:-eq|-ne|-gt|-lt|-ge|-le| = | != )"), + PatternRule(r'delimiter', r"[][\(\);\{\}|&><]"), + RegionRule(r'eval', '`', StringGrammar, '`'), + #RegionRule(r'eval2', r'\$\(', None, r'\)'), + RegionRule(r'eval2', r'\$\(', StringGrammar, r'\)'), + PatternRule(r'variable', r"(?:^|(?<= ))[a-zA-Z_][a-zA-Z_][a-zA-Z0-9_]*(?==)"), + PatternRule(r'variable', r"\${(?:[a-zA-Z0-9_]+|\?\$)}"), + PatternRule(r"variable", r"\$[^({][a-zA-Z0-9_]*"), + PatternRule(r'variable', r"\$(?=\()"), + RegionRule(r'string', "'", Grammar(), "'"), + RegionRule(r'string', '"', StringGrammar, '"'), + PatternRule(r'comment', r'#.*$'), + PatternRule(r'bareword', r'[a-zA-Z0-9_-]+'), + PatternRule(r'continuation', r'\\\n$'), + PatternRule(r'eol', r'\n$'), ] class Sh(mode2.Fundamental): @@ -39,19 +40,27 @@ class Sh(mode2.Fundamental): 'function': color.build('magenta', 'default', 'bold'), 'reserved': color.build('magenta', 'default', 'bold'), 'variable': color.build('yellow', 'default', 'bold'), + 'delimiter': color.build('default', 'default', 'bold'), 'operator': color.build('magenta', 'default', 'bold'), - 'redirection': color.build('blue', 'default', 'bold'), + 'string.start': color.build('green', 'default'), 'string.variable': color.build('yellow', 'default'), 'string.null': color.build('green', 'default'), 'string.end': color.build('green', 'default'), + 'eval.start': color.build('cyan', 'default'), 'eval.variable': color.build('yellow', 'default'), 'eval.null': color.build('cyan', 'default'), 'eval.end': color.build('cyan', 'default'), - 'eval2.start': color.build('cyan', 'default'), - 'eval2.end': color.build('cyan', 'default'), + + #'eval2.start': color.build('cyan', 'default'), + #'eval2.end': color.build('cyan', 'default'), + 'eval2.start': color.build('yellow', 'default'), + 'eval2.variable': color.build('yellow', 'default'), + 'eval2.null': color.build('cyan', 'default'), + 'eval2.end': color.build('yellow', 'default'), + 'comment': color.build('red', 'default'), 'continuation': color.build('red', 'default'), }