parent
27b2b3db3a
commit
1a66165dbd
|
@ -98,17 +98,16 @@ class Pipe(Method):
|
||||||
lines = data.split('\n')
|
lines = data.split('\n')
|
||||||
if lines and lines[-1] == '':
|
if lines and lines[-1] == '':
|
||||||
lines = lines[:-1]
|
lines = lines[:-1]
|
||||||
if status == 0 and len(lines) == 1:
|
|
||||||
w.set_error("%s output: %r" % (prog, lines[0]))
|
|
||||||
else:
|
|
||||||
bufname = '*%s*' % self.name.title()
|
bufname = '*%s*' % self.name.title()
|
||||||
w.application.data_buffer(bufname, data, switch_to=True)
|
b = w.application.data_buffer(bufname, data, switch_to=True, modename='error')
|
||||||
|
b.orig_path = w.buffer.path
|
||||||
w.set_error("%s exited with status %d" % (prog, status))
|
w.set_error("%s exited with status %d" % (prog, status))
|
||||||
|
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
(prog, cmd, shell) = self._parse(w, **vargs)
|
(prog, cmd, shell) = self._parse(w, **vargs)
|
||||||
if prog is None or not cmd:
|
if prog is None or not cmd:
|
||||||
return
|
return
|
||||||
|
|
||||||
self._dopipe(w, prog, cmd, shell)
|
self._dopipe(w, prog, cmd, shell)
|
||||||
|
|
||||||
def _dopipe(self, w, prog, cmd, shell):
|
def _dopipe(self, w, prog, cmd, shell):
|
||||||
|
@ -129,11 +128,12 @@ class Grep(Pipe):
|
||||||
args = [arg('pattern', dt="str", p="Pattern: ")]
|
args = [arg('pattern', dt="str", p="Pattern: ")]
|
||||||
def _parse(self, w, **vargs):
|
def _parse(self, w, **vargs):
|
||||||
return ('grep', ('grep', '-E', '-n', vargs['pattern']), False)
|
return ('grep', ('grep', '-E', '-n', vargs['pattern']), False)
|
||||||
|
|
||||||
class Sed(Pipe):
|
class Sed(Pipe):
|
||||||
'''Push the buffer's contents through a sed expression'''
|
'''Push the buffer's contents through a sed expression'''
|
||||||
args = [arg('expression', dt="str", p="Expression: ")]
|
args = [arg('expression', dt="str", p="Expression: ")]
|
||||||
def _parse(self, w, **vargs):
|
def _parse(self, w, **vargs):
|
||||||
return ('grep', ('sed', '-r', '-e', vargs['expression']), False)
|
return ('sed', ('sed', '-r', '-e', vargs['expression']), False)
|
||||||
|
|
||||||
class Interact(Method):
|
class Interact(Method):
|
||||||
'''Interact with a program via a PTY'''
|
'''Interact with a program via a PTY'''
|
||||||
|
|
|
@ -7,6 +7,7 @@ _error_regexes = [
|
||||||
r'File "(?P<file>.+?)", line (?P<line>\d+)(?:, in \S+)?$', #python
|
r'File "(?P<file>.+?)", line (?P<line>\d+)(?:, in \S+)?$', #python
|
||||||
r'^(?P<file>\S+?):(?P<line>\d+): ', #javac/gcc
|
r'^(?P<file>\S+?):(?P<line>\d+): ', #javac/gcc
|
||||||
r'at \S+\((?P<file>.+?):(?P<line>\d+)\)$', #java
|
r'at \S+\((?P<file>.+?):(?P<line>\d+)\)$', #java
|
||||||
|
r'^(?P<line>\d+):', #grep
|
||||||
]
|
]
|
||||||
error_regexes = [re.compile(s) for s in _error_regexes]
|
error_regexes = [re.compile(s) for s in _error_regexes]
|
||||||
|
|
||||||
|
@ -31,12 +32,17 @@ class ErrorGotoLine(Method):
|
||||||
w.set_error("nothing found")
|
w.set_error("nothing found")
|
||||||
return
|
return
|
||||||
errline = w.buffer.lines[y]
|
errline = w.buffer.lines[y]
|
||||||
path, line = m.group('file'), int(m.group('line'))
|
|
||||||
if path == '-':
|
d = m.groupdict()
|
||||||
|
path = d.get('file')
|
||||||
|
line = d.get('line')
|
||||||
|
if line is None:
|
||||||
|
return
|
||||||
|
elif path is None or path == '-':
|
||||||
path = w.buffer.orig_path
|
path = w.buffer.orig_path
|
||||||
b2 = a.open_path(path)
|
b2 = a.open_path(path)
|
||||||
a.switch_buffer(b2)
|
a.switch_buffer(b2)
|
||||||
a.methods['goto-line'].execute(b2.windows[0], lineno=line)
|
a.methods['goto-line'].execute(b2.windows[0], lineno=int(line))
|
||||||
w.set_error(errline)
|
w.set_error(errline)
|
||||||
|
|
||||||
class Error(Fundamental):
|
class Error(Fundamental):
|
||||||
|
|
|
@ -5,7 +5,7 @@ from point import Point
|
||||||
from render import RenderString
|
from render import RenderString
|
||||||
from lex import Grammar, PatternRule, RegionRule, OverridePatternRule
|
from lex import Grammar, PatternRule, RegionRule, OverridePatternRule
|
||||||
from parse import Any, And, Or, Optional, Name, Match, Matchs
|
from parse import Any, And, Or, Optional, Name, Match, Matchs
|
||||||
from method import Method, arg
|
from method import Method, arg, Argument
|
||||||
from method.shell import Exec
|
from method.shell import Exec
|
||||||
|
|
||||||
class StringGrammar1(Grammar):
|
class StringGrammar1(Grammar):
|
||||||
|
@ -203,7 +203,7 @@ class PythonTabber(tab.StackTabber):
|
||||||
self._append(s, currlvl + w, y)
|
self._append(s, currlvl + w, y)
|
||||||
return currlvl
|
return currlvl
|
||||||
|
|
||||||
class PythonCheckSyntax(method.Method):
|
class PythonCheckSyntax(Method):
|
||||||
'''Check the syntax of the current python file'''
|
'''Check the syntax of the current python file'''
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
pythonlib = w.application.config.get('python.lib')
|
pythonlib = w.application.config.get('python.lib')
|
||||||
|
@ -219,7 +219,7 @@ class PythonCheckSyntax(method.Method):
|
||||||
modename='error')
|
modename='error')
|
||||||
del sys.path[0]
|
del sys.path[0]
|
||||||
|
|
||||||
class PythonDictCleanup(method.Method):
|
class PythonDictCleanup(Method):
|
||||||
'''Align assignment blocks and literal dictionaries'''
|
'''Align assignment blocks and literal dictionaries'''
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
cursor = w.logical_cursor()
|
cursor = w.logical_cursor()
|
||||||
|
@ -309,7 +309,7 @@ class PythonHelp(Exec):
|
||||||
stmt = 'try:\n import %s\nexcept:\n pass\nhelp(%s)' % (name, name)
|
stmt = 'try:\n import %s\nexcept:\n pass\nhelp(%s)' % (name, name)
|
||||||
self._doit(w, None, 'python -c "%s"' % stmt)
|
self._doit(w, None, 'python -c "%s"' % stmt)
|
||||||
|
|
||||||
class PythonInsertTripleSquotes(method.Method):
|
class PythonInsertTripleSquotes(Method):
|
||||||
'''Insert a triple-quoted string using single-quotes'''
|
'''Insert a triple-quoted string using single-quotes'''
|
||||||
_q = "'''"
|
_q = "'''"
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
|
@ -321,7 +321,7 @@ class PythonInsertTripleDquotes(PythonInsertTripleSquotes):
|
||||||
'''Insert a triple-quoted string using double-quotes'''
|
'''Insert a triple-quoted string using double-quotes'''
|
||||||
_q = '"""'
|
_q = '"""'
|
||||||
|
|
||||||
class PythonInitNames(method.Method):
|
class PythonInitNames(Method):
|
||||||
'''Jump to a function defined in this module'''
|
'''Jump to a function defined in this module'''
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
w.mode.context.build_name_map()
|
w.mode.context.build_name_map()
|
||||||
|
@ -349,9 +349,9 @@ class PythonSemanticComplete(method.introspect.TokenComplete):
|
||||||
|
|
||||||
return self._prune_candidates(t, minlen, candidates)
|
return self._prune_candidates(t, minlen, candidates)
|
||||||
|
|
||||||
class PythonGotoName(method.Method):
|
class PythonGotoName(Method):
|
||||||
'''Jump to a class or function defined in this module'''
|
'''Jump to a class or function defined in this module'''
|
||||||
args = [method.Argument("name", type(""), "pythonname", "Goto Name: ")]
|
args = [Argument("name", type(""), "pythonname", "Goto Name: ")]
|
||||||
title = 'Name'
|
title = 'Name'
|
||||||
def _get_dict(self, w):
|
def _get_dict(self, w):
|
||||||
return w.mode.context.get_names()
|
return w.mode.context.get_names()
|
||||||
|
@ -365,26 +365,26 @@ class PythonGotoName(method.Method):
|
||||||
|
|
||||||
class PythonGotoFunction(PythonGotoName):
|
class PythonGotoFunction(PythonGotoName):
|
||||||
'''Jump to a function defined in this module'''
|
'''Jump to a function defined in this module'''
|
||||||
args = [method.Argument("name", type(""), "pythonfunction", "Goto Function: ")]
|
args = [Argument("name", type(""), "pythonfunction", "Goto Function: ")]
|
||||||
title = 'Function'
|
title = 'Function'
|
||||||
def _get_dict(self, w):
|
def _get_dict(self, w):
|
||||||
return w.mode.context.get_functions()
|
return w.mode.context.get_functions()
|
||||||
|
|
||||||
class PythonGotoClass(method.Method):
|
class PythonGotoClass(Method):
|
||||||
'''Jump to a class defined in this module'''
|
'''Jump to a class defined in this module'''
|
||||||
args = [method.Argument("name", type(""), "pythonclass", "Goto Class: ")]
|
args = [Argument("name", type(""), "pythonclass", "Goto Class: ")]
|
||||||
title = 'Class'
|
title = 'Class'
|
||||||
def _get_dict(self, w):
|
def _get_dict(self, w):
|
||||||
return w.mode.context.get_classes()
|
return w.mode.context.get_classes()
|
||||||
|
|
||||||
class PythonListNames(method.Method):
|
class PythonListNames(Method):
|
||||||
'''Show the user all functions defined in this module'''
|
'''Show the user all functions defined in this module'''
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
names = w.mode.context.get_names()
|
names = w.mode.context.get_names()
|
||||||
output = '\n'.join(sorted(names)) + "\n"
|
output = '\n'.join(sorted(names)) + "\n"
|
||||||
w.application.data_buffer("*Python-List-Names*", output, switch_to=True)
|
w.application.data_buffer("*Python-List-Names*", output, switch_to=True)
|
||||||
|
|
||||||
class PythonBrmFindReferences(method.Method):
|
class PythonBrmFindReferences(Method):
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
if w.mode.brm is None:
|
if w.mode.brm is None:
|
||||||
w.set_error('bicycle repairman not installed')
|
w.set_error('bicycle repairman not installed')
|
||||||
|
|
Loading…
Reference in New Issue