parent
318d35c436
commit
2726b9edef
|
@ -144,10 +144,8 @@ class Interact(Method):
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
bname = vargs['bname']
|
bname = vargs['bname']
|
||||||
cmd = vargs['cmd']
|
cmd = vargs['cmd']
|
||||||
|
|
||||||
a = w.application
|
a = w.application
|
||||||
a.close_buffer_by_name(bname)
|
a.close_buffer_by_name(bname)
|
||||||
#b = buffer.emul.XTermBuffer(a, cmd, [], name=bname)
|
|
||||||
b = buffer.emul.XTermBuffer(a, 'bash', ['-c', cmd], name=bname)
|
b = buffer.emul.XTermBuffer(a, 'bash', ['-c', cmd], name=bname)
|
||||||
a.add_buffer(b)
|
a.add_buffer(b)
|
||||||
window.Window(b, a)
|
window.Window(b, a)
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import commands, os.path, string, sys, traceback
|
import commands, os.path, string, sys, traceback
|
||||||
import color, completer, default, mode, method, regex, tab
|
import color, completer, default, mode, regex, tab
|
||||||
from point import Point
|
from point import Point
|
||||||
from lex import Grammar, PatternRule, RegionRule, OverridePatternRule, NocasePatternRule
|
from lex import Grammar, PatternRule, RegionRule, OverridePatternRule, NocasePatternRule
|
||||||
|
from method.shell import Interact
|
||||||
|
|
||||||
class AtomGrammar(Grammar):
|
class AtomGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
|
@ -76,6 +77,12 @@ class ErlangTabber(tab.StackTabber):
|
||||||
currlvl = self.get_curr_level()
|
currlvl = self.get_curr_level()
|
||||||
return currlvl
|
return currlvl
|
||||||
|
|
||||||
|
## this shit doesn't work... hmmm
|
||||||
|
#class ErlStart(Interact):
|
||||||
|
# args = []
|
||||||
|
# def _execute(self, w, **vargs):
|
||||||
|
# Interact._execute(self, w, bname='*Erl*', cmd='erl')
|
||||||
|
|
||||||
class Erlang(mode.Fundamental):
|
class Erlang(mode.Fundamental):
|
||||||
modename = 'Erlang'
|
modename = 'Erlang'
|
||||||
extensions = ['.erl']
|
extensions = ['.erl']
|
||||||
|
@ -101,6 +108,9 @@ class Erlang(mode.Fundamental):
|
||||||
'erl_atom.null': ('magenta', 'default', 'bold'),
|
'erl_atom.null': ('magenta', 'default', 'bold'),
|
||||||
'erl_atom.end': ('magenta', 'default', 'bold'),
|
'erl_atom.end': ('magenta', 'default', 'bold'),
|
||||||
}
|
}
|
||||||
|
actions = [
|
||||||
|
#ErlStart,
|
||||||
|
]
|
||||||
_bindings = {
|
_bindings = {
|
||||||
'close-paren': (')',),
|
'close-paren': (')',),
|
||||||
'close-brace': ('}',),
|
'close-brace': ('}',),
|
||||||
|
|
65
mode/perl.py
65
mode/perl.py
|
@ -230,14 +230,37 @@ class PerlViewModulePerldoc(Method):
|
||||||
args = ('perl', '-e', self.prog)
|
args = ('perl', '-e', self.prog)
|
||||||
app.run_pipe(args, w.buffer, '*Perldoc*', True)
|
app.run_pipe(args, w.buffer, '*Perldoc*', True)
|
||||||
|
|
||||||
class PerlViewWordPerldoc(Method):
|
class PerlViewPerldoc(Method):
|
||||||
'''View documentation about a package or function using perldoc'''
|
name_re = re.compile('(?:[a-zA-Z_][a-zA-Z0-9_]*::)*[a-zA-Z_][a-zA-Z0-9_]*')
|
||||||
def _try(self, w, word, asfunc=False):
|
args = [Argument("name", type(""), "", "Perldoc: ")]
|
||||||
|
def _execute(self, w, **vargs):
|
||||||
|
name = vargs['name']
|
||||||
|
if not self.name_re.match(name):
|
||||||
|
w.set_error("name %r is invalid" % name)
|
||||||
|
return
|
||||||
|
|
||||||
|
# try it as a module first
|
||||||
|
parts = name.split('::')
|
||||||
|
while len(parts) > 0:
|
||||||
|
newname = '::'.join(parts)
|
||||||
|
data = self._try(w, newname, asfunc=False)
|
||||||
|
if data:
|
||||||
|
self._show(w, data, newname)
|
||||||
|
return
|
||||||
|
parts.pop(-1)
|
||||||
|
|
||||||
|
# then try it as a function
|
||||||
|
data = self._try(w, name, asfunc=True)
|
||||||
|
if data:
|
||||||
|
self._show(w, data, name)
|
||||||
|
else:
|
||||||
|
w.application.set_error('nothing found for %r' % name)
|
||||||
|
def _try(self, w, name, asfunc=False):
|
||||||
a = w.application
|
a = w.application
|
||||||
if asfunc:
|
if asfunc:
|
||||||
cmd = "perldoc -t -T -f '%s'" % (word,)
|
cmd = "perldoc -t -T -f '%s'" % (name,)
|
||||||
else:
|
else:
|
||||||
cmd = "perldoc -t -T '%s'" % (word,)
|
cmd = "perldoc -t -T '%s'" % (name,)
|
||||||
|
|
||||||
if a.config.get('perl.libs', None):
|
if a.config.get('perl.libs', None):
|
||||||
s = ':'.join(['%r' % x for x in a.config.get('perl.libs')])
|
s = ':'.join(['%r' % x for x in a.config.get('perl.libs')])
|
||||||
|
@ -250,12 +273,16 @@ class PerlViewWordPerldoc(Method):
|
||||||
return data
|
return data
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
def _show(self, w, data, word):
|
def _show(self, w, data, name):
|
||||||
w.application.data_buffer("*Perldoc*", data, switch_to=True)
|
w.application.data_buffer("*Perldoc*", data, switch_to=True)
|
||||||
w.application.set_error('displaying documentation for %r' % word)
|
w.application.set_error('displaying documentation for %r' % name)
|
||||||
|
|
||||||
|
class PerlViewWordPerldoc(PerlViewPerldoc):
|
||||||
|
'''View documentation about a package or function using perldoc'''
|
||||||
|
args = []
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
token = w.get_token()
|
token = w.get_token()
|
||||||
word = token.string
|
word = token.string
|
||||||
|
|
||||||
# make sure that the name is (mostly) valid
|
# make sure that the name is (mostly) valid
|
||||||
if word is None:
|
if word is None:
|
||||||
|
@ -264,24 +291,7 @@ class PerlViewWordPerldoc(Method):
|
||||||
elif ':' in word and '::' not in word:
|
elif ':' in word and '::' not in word:
|
||||||
w.application.set_error('invalid word: %r' % word)
|
w.application.set_error('invalid word: %r' % word)
|
||||||
return
|
return
|
||||||
|
return PerlViewPerldoc._execute(self, w, name=word)
|
||||||
# first try it is a package, unless it's a builtin
|
|
||||||
if not token.name == "perl_builtin":
|
|
||||||
parts = word.split('::')
|
|
||||||
while len(parts) > 0:
|
|
||||||
newword = '::'.join(parts)
|
|
||||||
data = self._try(w, newword, asfunc=False)
|
|
||||||
if data:
|
|
||||||
self._show(w, data, newword)
|
|
||||||
return
|
|
||||||
parts.pop(-1)
|
|
||||||
|
|
||||||
# then try it as a function
|
|
||||||
data = self._try(w, word, asfunc=True)
|
|
||||||
if data:
|
|
||||||
self._show(w, data, word)
|
|
||||||
else:
|
|
||||||
w.application.set_error('nothing found for %r' % word)
|
|
||||||
|
|
||||||
class PerlInitFunctions(Method):
|
class PerlInitFunctions(Method):
|
||||||
'''Jump to a function defined in this module'''
|
'''Jump to a function defined in this module'''
|
||||||
|
@ -723,7 +733,8 @@ class Perl(mode.Fundamental):
|
||||||
'perl.libs': ['lib'],
|
'perl.libs': ['lib'],
|
||||||
}
|
}
|
||||||
actions = [PerlSetLib, PerlCheckSyntax, PerlHashCleanup,
|
actions = [PerlSetLib, PerlCheckSyntax, PerlHashCleanup,
|
||||||
PerlViewModulePerldoc, PerlViewWordPerldoc, PerlWrapParagraph,
|
PerlViewModulePerldoc, PerlViewWordPerldoc, PerlViewPerldoc,
|
||||||
|
PerlWrapParagraph,
|
||||||
PerlInitFunctions, PerlGotoFunction, PerlWhichFunction,
|
PerlInitFunctions, PerlGotoFunction, PerlWhichFunction,
|
||||||
PerlListFunctions, PerlOpenModule, PerlOpenModuleWord,
|
PerlListFunctions, PerlOpenModule, PerlOpenModuleWord,
|
||||||
PerlSemanticComplete]
|
PerlSemanticComplete]
|
||||||
|
|
|
@ -4,7 +4,8 @@ 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
|
from method import Method, arg
|
||||||
|
from method.shell import Exec
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import bike
|
import bike
|
||||||
|
@ -303,6 +304,14 @@ class PythonDictCleanup(method.Method):
|
||||||
w.delete(start_p, end_p)
|
w.delete(start_p, end_p)
|
||||||
w.insert_string(start_p, data)
|
w.insert_string(start_p, data)
|
||||||
|
|
||||||
|
class PythonHelp(Exec):
|
||||||
|
'''Generate a help page on a python object'''
|
||||||
|
args = [arg('name', t="string", p="Name: ", h='name to get help on')]
|
||||||
|
def _execute(self, w, **vargs):
|
||||||
|
name = vargs['name']
|
||||||
|
stmt = '"try:\n import %s\nexcept:\n pass\nhelp(%s)"' % (name, name)
|
||||||
|
self._doit(w, None, 'python -c %s' % stmt)
|
||||||
|
|
||||||
class PythonInsertTripleSquotes(method.Method):
|
class PythonInsertTripleSquotes(method.Method):
|
||||||
'''Insert a triple-quoted string using single-quotes'''
|
'''Insert a triple-quoted string using single-quotes'''
|
||||||
_q = "'''"
|
_q = "'''"
|
||||||
|
@ -310,6 +319,7 @@ class PythonInsertTripleSquotes(method.Method):
|
||||||
w.insert_string_at_cursor('%s%s' % (self._q, self._q))
|
w.insert_string_at_cursor('%s%s' % (self._q, self._q))
|
||||||
for i in range(0, 3):
|
for i in range(0, 3):
|
||||||
w.backward()
|
w.backward()
|
||||||
|
|
||||||
class PythonInsertTripleDquotes(PythonInsertTripleSquotes):
|
class PythonInsertTripleDquotes(PythonInsertTripleSquotes):
|
||||||
'''Insert a triple-quoted string using double-quotes'''
|
'''Insert a triple-quoted string using double-quotes'''
|
||||||
_q = '"""'
|
_q = '"""'
|
||||||
|
@ -355,12 +365,14 @@ class PythonGotoName(method.Method):
|
||||||
w.goto(Point(0, d[name]))
|
w.goto(Point(0, d[name]))
|
||||||
else:
|
else:
|
||||||
w.application.set_error("%r %r was not found" % (title, name))
|
w.application.set_error("%r %r was not found" % (title, name))
|
||||||
|
|
||||||
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 = [method.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.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 = [method.Argument("name", type(""), "pythonclass", "Goto Class: ")]
|
||||||
|
@ -558,7 +570,7 @@ class Python(mode.Fundamental):
|
||||||
lconfig = {
|
lconfig = {
|
||||||
'ignore-suffix': ['.pyc', '.pyo'],
|
'ignore-suffix': ['.pyc', '.pyo'],
|
||||||
}
|
}
|
||||||
actions = [PythonInitNames, PythonListNames, PythonGotoName,
|
actions = [PythonInitNames, PythonListNames, PythonGotoName, PythonHelp,
|
||||||
PythonGotoFunction, PythonGotoClass, PythonCheckSyntax,
|
PythonGotoFunction, PythonGotoClass, PythonCheckSyntax,
|
||||||
PythonDictCleanup, PythonSemanticComplete, PythonBrmFindReferences,
|
PythonDictCleanup, PythonSemanticComplete, PythonBrmFindReferences,
|
||||||
PythonInsertTripleSquotes, PythonInsertTripleDquotes]
|
PythonInsertTripleSquotes, PythonInsertTripleDquotes]
|
||||||
|
|
Loading…
Reference in New Issue