branch : pmacs2
This commit is contained in:
moculus 2007-07-06 22:27:52 +00:00
parent 12a4b34c58
commit a173604a57
6 changed files with 83 additions and 110 deletions

View File

@ -10,11 +10,11 @@ from point2 import Point
import mode2 import mode2
import mode_mini, mode_search, mode_replace, mode_which import mode_mini, mode_search, mode_replace, mode_which
import mode_console, mode_consolemini import mode_console, mode_consolemini
import mode_c, mode_python, mode_perl, mode_nasm, mode_sh
import mode_blame, mode_diff import mode_blame, mode_diff
import mode_c, mode_python, mode_perl, mode_nasm, mode_sh, mode_javascript, mode_sql import mode_javascript, mode_sql, mode_xml, mode_tt
import mode_xml, mode_tt import mode_text, mode_mutt
import mode_life, mode_text, mode_mutt import mode_bds, mode_life
import mode_bds
def run(buffers, jump_to_line=None, init_mode=None): def run(buffers, jump_to_line=None, init_mode=None):
# save terminal state so we can restore it when the program exits # save terminal state so we can restore it when the program exits
@ -704,12 +704,8 @@ def open_plain_file(path, nl, name=None):
return b return b
if __name__ == "__main__": if __name__ == "__main__":
ciphers = { 'none': open_plain_file, ciphers = { 'none': open_plain_file, 'aes': open_aes_file }
'aes': open_aes_file } linetypes = { 'win': '\r\n', 'mac': '\r', 'unix': '\n' }
linetypes = { 'win': '\r\n',
'mac': '\r',
'unix': '\n' }
import optparse import optparse

View File

@ -68,10 +68,10 @@ class Argument:
class Method: class Method:
_is_method = True _is_method = True
args = []
def __init__(self): def __init__(self):
self.name = self._name() self.name = self._name()
self.help = self._help() self.help = self.__doc__
self.args = self._args()
def _name(cls): def _name(cls):
s = cls.__name__ s = cls.__name__
@ -86,12 +86,6 @@ class Method:
return s2 return s2
_name = classmethod(_name) _name = classmethod(_name)
def _help(self):
return self.__doc__
def _args(self):
return []
def _pre_execute(self, w, **vargs): def _pre_execute(self, w, **vargs):
pass pass
@ -113,21 +107,18 @@ class Method:
class GotoChar(Method): class GotoChar(Method):
'''Jump to the specified character''' '''Jump to the specified character'''
def _args(self): args = [Argument("charno", type=type(0), prompt="Goto char: ")]
return [Argument("charno", type=type(0), prompt="Goto char: ")]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
w.goto_char(vargs["charno"]) w.goto_char(vargs["charno"])
class ForwardChars(Method): class ForwardChars(Method):
'''Move forward the specified number of characters''' '''Move forward the specified number of characters'''
def _args(self): args = [Argument("charno", type=type(0), prompt="Forward chars: ")]
return [Argument("charno", type=type(0), prompt="Forward chars: ")]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
w.forward_chars(vargs["charno"]) w.forward_chars(vargs["charno"])
class GotoLine(Method): class GotoLine(Method):
'''Jump to the specified line number''' '''Jump to the specified line number'''
def _args(self): args = [Argument("lineno", type=type(0), prompt="Goto line: ")]
return [Argument("lineno", type=type(0), prompt="Goto line: ")]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
n = vargs["lineno"] n = vargs["lineno"]
if n < 0: if n < 0:
@ -139,8 +130,7 @@ class GotoLine(Method):
w.goto_line(n) w.goto_line(n)
class ForwardLines(Method): class ForwardLines(Method):
'''Move forward the specified number of characters''' '''Move forward the specified number of characters'''
def _args(self): args = [Argument("lineno", type=type(0), prompt="Forward lines: ")]
return [Argument("lineno", type=type(0), prompt="Forward lines: ")]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
w.forward_lines(vargs["lineno"]) w.forward_lines(vargs["lineno"])
@ -161,13 +151,10 @@ class ReverseSearch(Method):
w.application.open_mini_buffer('I-Search: ', lambda x: None, self, None, 'search') w.application.open_mini_buffer('I-Search: ', lambda x: None, self, None, 'search')
class Replace(Method): class Replace(Method):
'''Replace occurances of string X with string Y''' '''Replace occurances of string X with string Y'''
def _args(self): args = [Argument('before', prompt="Replace: ",
return [Argument('before', prompt="Replace: ", default=default.last_replace_before, load_default=True),
default=default.last_replace_before, Argument('after', prompt="Replace With: ",
load_default=True), default=default.last_replace_after, load_default=True)]
Argument('after', prompt="Replace With: ",
default=default.last_replace_after,
load_default=True)]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
a = w.application a = w.application
a.last_replace_before = self.before = vargs['before'] a.last_replace_before = self.before = vargs['before']
@ -178,8 +165,7 @@ class Replace(Method):
# navigating between buffers # navigating between buffers
class OpenFile(Method): class OpenFile(Method):
'''Open file in a new buffer, or go to file's open buffer''' '''Open file in a new buffer, or go to file's open buffer'''
def _args(self): args = [Argument('filename', datatype="path", prompt="Open File: ")]
return [Argument('filename', datatype="path", prompt="Open File: ")]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
path = vargs['filename'] path = vargs['filename']
path = os.path.abspath(os.path.realpath(util.expand_tilde(path))) path = os.path.abspath(os.path.realpath(util.expand_tilde(path)))
@ -201,9 +187,8 @@ class OpenFile(Method):
SwitchBuffer().execute(w, buffername=b.name()) SwitchBuffer().execute(w, buffername=b.name())
class OpenAesFile(Method): class OpenAesFile(Method):
'''Open AES encrypted file in a new buffer, or go to file's open buffer''' '''Open AES encrypted file in a new buffer, or go to file's open buffer'''
def _args(self): args = [Argument('filename', datatype="path", prompt="Open AES File: "),
return [Argument('filename', datatype="path", prompt="Open AES File: "), Argument('password', prompt="Use AES Password: ")]
Argument('password', prompt="Use AES Password: ")]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
path = vargs['filename'] path = vargs['filename']
password = vargs['password'] password = vargs['password']
@ -217,10 +202,8 @@ class OpenAesFile(Method):
SwitchBuffer().execute(w, buffername=path) SwitchBuffer().execute(w, buffername=path)
class SwitchBuffer(Method): class SwitchBuffer(Method):
'''Switch to a different''' '''Switch to a different'''
def _args(self): args = [Argument('buffername', datatype="buffer", prompt="Switch To Buffer: ",
return [Argument('buffername', datatype="buffer", default=default.last_buffer)]
prompt="Switch To Buffer: ",
default=default.last_buffer)]
def _pre_execute(self, w, **vargs): def _pre_execute(self, w, **vargs):
a = w.application a = w.application
if len(a.bufferlist.buffers) < 1: if len(a.bufferlist.buffers) < 1:
@ -236,10 +219,8 @@ class SwitchBuffer(Method):
class KillBuffer(Method): class KillBuffer(Method):
'''Close the current buffer''' '''Close the current buffer'''
force=False force=False
def _args(self): args = [Argument('buffername', datatype="buffer", prompt="Kill Buffer: ",
return [Argument('buffername', datatype="buffer", default=default.current_buffer)]
prompt="Kill Buffer: ",
default=default.current_buffer)]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
name = vargs['buffername'] name = vargs['buffername']
app = w.application app = w.application
@ -254,10 +235,8 @@ class KillBuffer(Method):
b.close() b.close()
class ForceKillBuffer(KillBuffer): class ForceKillBuffer(KillBuffer):
force=True force=True
def _args(self): args = [Argument('buffername', datatype="buffer", prompt="Force Kill Buffer: ",
return [Argument('buffername', datatype="buffer", default=default.current_buffer)]
prompt="Force Kill Buffer: ",
default=default.current_buffer)]
class ListBuffers(Method): class ListBuffers(Method):
'''List all open buffers in a new buffer''' '''List all open buffers in a new buffer'''
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
@ -268,9 +247,8 @@ class ListBuffers(Method):
w.application.data_buffer("*Buffers*", data, switch_to=True) w.application.data_buffer("*Buffers*", data, switch_to=True)
class SaveBufferAs(Method): class SaveBufferAs(Method):
'''Save the contents of a buffer to the specified path''' '''Save the contents of a buffer to the specified path'''
def _args(self): args = [Argument('path', datatype="path", prompt="Write file: ",
return [Argument('path', datatype="path", prompt="Write file: ", default=default.current_working_dir, load_default=True)]
default=default.current_working_dir, load_default=True)]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
curr_buffer = w.buffer curr_buffer = w.buffer
curr_buffer_name = curr_buffer.name() curr_buffer_name = curr_buffer.name()
@ -492,8 +470,7 @@ class DumpTokens(Method):
w.application.data_buffer("token-dump", output, switch_to=True) w.application.data_buffer("token-dump", output, switch_to=True)
class MetaX(Method): class MetaX(Method):
'''Invoke commands by name''' '''Invoke commands by name'''
def _args(self): args = [Argument('method', datatype="method", prompt="M-x ")]
return [Argument('method', datatype="method", prompt="M-x ")]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
name = vargs['method'] name = vargs['method']
if name in w.application.methods: if name in w.application.methods:
@ -907,8 +884,7 @@ class OpenConsole(Method):
class ShellCmd(Method): class ShellCmd(Method):
'''Run a command in a shell and put the output in a new buffer''' '''Run a command in a shell and put the output in a new buffer'''
def _args(self): args = [Argument("cmd", type=type(""), prompt="$ ", datatype='shell')]
return [Argument("cmd", type=type(""), prompt="$ ", datatype='shell')]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
cmd = "PBUF='%s'; %s" % (w.buffer.name(), vargs['cmd']) cmd = "PBUF='%s'; %s" % (w.buffer.name(), vargs['cmd'])
(status, data) = commands.getstatusoutput(cmd) (status, data) = commands.getstatusoutput(cmd)
@ -920,8 +896,7 @@ class ShellCmd(Method):
w.application.data_buffer("*Shell*", data, switch_to=True) w.application.data_buffer("*Shell*", data, switch_to=True)
class FileDiff(Method): class FileDiff(Method):
'''diff the buffer's contents with the given file''' '''diff the buffer's contents with the given file'''
def _args(self): args = [Argument("path", type=type(""), prompt="Filename: ", datatype='path')]
return [Argument("path", type=type(""), prompt="Filename: ", datatype='path')]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
cmd = ("/usr/bin/diff", '-u', '-', vargs['path']) cmd = ("/usr/bin/diff", '-u', '-', vargs['path'])
pipe = popen2.Popen3(cmd, capturestderr=True) pipe = popen2.Popen3(cmd, capturestderr=True)
@ -1072,8 +1047,7 @@ class CvsDiff(Method):
class CvsDiff2(Method): class CvsDiff2(Method):
'''diff the current file with the version in CVS''' '''diff the current file with the version in CVS'''
rev_regex = re.compile('^[0-9]+\.[0-9]+$') rev_regex = re.compile('^[0-9]+\.[0-9]+$')
def _args(self): args = [Argument("revision", type=type(""), prompt="Old Revision: ")]
return [Argument("revision", type=type(""), prompt="Old Revision: ")]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
if not hasattr(w.buffer, 'path'): if not hasattr(w.buffer, 'path'):
w.application.set_error("Buffer has no corresponding file") w.application.set_error("Buffer has no corresponding file")
@ -1101,9 +1075,8 @@ class CvsDiff2(Method):
class CvsDiff3(Method): class CvsDiff3(Method):
'''diff the current file with the version in CVS''' '''diff the current file with the version in CVS'''
rev_regex = re.compile('^[0-9]+\.[0-9]+$') rev_regex = re.compile('^[0-9]+\.[0-9]+$')
def _args(self): args = [Argument("revision1", type=type(""), prompt="Old Revision: "),
return [Argument("revision1", type=type(""), prompt="Old Revision: "), Argument("revision2", type=type(""), prompt="New Revision: ")]
Argument("revision2", type=type(""), prompt="New Revision: ")]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
if not hasattr(w.buffer, 'path'): if not hasattr(w.buffer, 'path'):
w.application.set_error("Buffer has no corresponding file") w.application.set_error("Buffer has no corresponding file")
@ -1225,8 +1198,7 @@ class ShowBindingsBuffer(Method):
class CmdHelpBuffer(Method): class CmdHelpBuffer(Method):
'''Get help with the specified command''' '''Get help with the specified command'''
def _args(self): args = [Argument('method', datatype="method", prompt="Help for command: ")]
return [Argument('method', datatype="method", prompt="Help for command: ")]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
lines = [] lines = []
name = vargs['method'] name = vargs['method']
@ -1281,8 +1253,7 @@ class CmdHelpBuffer(Method):
class SetMode(Method): class SetMode(Method):
'''Set the mode of the current buffer''' '''Set the mode of the current buffer'''
def _args(self): args = [Argument('mode', datatype='mode', prompt="Enter new mode: ")]
return [Argument('mode', datatype='mode', prompt="Enter new mode: ")]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
mode_name = vargs['mode'] mode_name = vargs['mode']
m = w.application.modes[mode_name](w) m = w.application.modes[mode_name](w)
@ -1396,8 +1367,7 @@ class RegisterSave(Method):
MAX_TXT = 30 MAX_TXT = 30
MAX_REG = 20 MAX_REG = 20
'''help here''' '''help here'''
def _args(self): args = [Argument('name', datatype="str", prompt="Register name: ")]
return [Argument('name', datatype="str", prompt="Register name: ")]
def _pre_execute(self, w, **vargs): def _pre_execute(self, w, **vargs):
if not w.has_kill(): if not w.has_kill():
raise MethodError, "No text on the kill stack" raise MethodError, "No text on the kill stack"
@ -1415,8 +1385,7 @@ class RegisterRestore(Method):
MAX_TXT = 30 MAX_TXT = 30
MAX_REG = 18 MAX_REG = 18
'''help here''' '''help here'''
def _args(self): args = [Argument('name', datatype="str", prompt="Register name: ")]
return [Argument('name', datatype="str", prompt="Register name: ")]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
name = vargs['name'] name = vargs['name']
if name not in w.application.registers: if name not in w.application.registers:

View File

@ -3,6 +3,9 @@ import color, lex2, method
DEBUG = False DEBUG = False
class ActionError(Exception):
pass
class Handler: class Handler:
def __init__(self): def __init__(self):
self.prefixes = sets.Set(["C-x", "C-c", "C-u"]) self.prefixes = sets.Set(["C-x", "C-c", "C-u"])
@ -14,16 +17,16 @@ class Handler:
def add_action(self, action): def add_action(self, action):
if action.name in self.window.application.methods: if action.name in self.window.application.methods:
return return
assert action.name not in self.window.application.methods, \ if action.name in self.window.application.methods:
"Action %r already found" % action.name raise Exception, "Action %r already found" % action.name
self.window.application.methods[action.name] = action self.window.application.methods[action.name] = action
def del_action(self, name): def del_action(self, name):
for binding in self.bindings.keys(): for binding in self.bindings.keys():
if self.bindings[binding] == name: if self.bindings[binding] == name:
del self.bindings[binding] del self.bindings[binding]
def add_binding(self, name, sequence): def add_binding(self, name, sequence):
assert name in self.window.application.methods, \ if name not in self.window.application.methods:
"No action called %r found" % name raise Exception, "No action called %r found" % name
self.bindings[sequence] = name self.bindings[sequence] = name
def add_bindings(self, name, sequences): def add_bindings(self, name, sequences):
for sequence in sequences: for sequence in sequences:
@ -51,7 +54,7 @@ class Handler:
return None return None
self.curr_tokens = [] self.curr_tokens = []
self.last_sequence = sequence self.last_sequence = sequence
raise Exception, "no action defined for %r" % (sequence) raise ActionError, "no action defined for %r" % (sequence)
class Fundamental(Handler): class Fundamental(Handler):
'''This is the default mode''' '''This is the default mode'''
@ -165,20 +168,27 @@ class Fundamental(Handler):
def handle_token(self, t): def handle_token(self, t):
'''self.handle_token(token): handles input "token"''' '''self.handle_token(token): handles input "token"'''
self.window.active_point = None self.window.active_point = None
#self.window.application.clear_error()
self.window.clear_error()
try: try:
act = Handler.handle_token(self, t) act = Handler.handle_token(self, t)
if act is None: if act is None:
self.window.set_error(' '.join(self.curr_tokens))
return return
else: else:
self.window.application.clear_error()
act.execute(self.window) act.execute(self.window)
self.window.application.last_action = act.name self.window.application.last_action = act.name
except ActionError, e:
if t != 'C-]':
self.window.set_error(str(e))
else:
self.window.set_error('Cancelled')
except Exception, e: except Exception, e:
if DEBUG: if DEBUG:
raise raise
else: else:
err = "%s in mode '%s'" % (e, self.name()) err = "%s in mode '%s'" % (e, self.name())
self.window.application.set_error(err) self.window.set_error(err)
def region_added(self, p, newlines): def region_added(self, p, newlines):
if self.tabber is not None: if self.tabber is not None:

View File

@ -1,7 +1,8 @@
import re, sets, string, sys import re, sets, string, sys
import color, commands, default, lex2, method, mode2, regex, tab2 import color, commands, default, lex2, method, mode2, regex, tab2
from point2 import Point from point2 import Point
from lex2 import Grammar, ConstantRule, PatternRule, ContextPatternRule, RegionRule, DualRegionRule from lex2 import Grammar, PatternRule, ContextPatternRule, RegionRule, DualRegionRule
from method import Argument, Method
class PodGrammar(Grammar): class PodGrammar(Grammar):
rules = [ rules = [
@ -228,43 +229,43 @@ class Perl(mode2.Fundamental):
'eval_heredoc.start': color.build('cyan', 'default'), 'eval_heredoc.start': color.build('cyan', 'default'),
'eval_heredoc.null': color.build('cyan', 'default'), 'eval_heredoc.null': color.build('cyan', 'default'),
'eval_heredoc.end': color.build('cyan', 'default'), 'eval_heredoc.end': color.build('cyan', 'default'),
# pod # pod
'pod.start': color.build('red', 'default'), 'pod.start': color.build('red', 'default'),
'pod.null': color.build('red', 'default'), 'pod.null': color.build('red', 'default'),
'pod.entry': color.build('magenta', 'default'), 'pod.entry': color.build('magenta', 'default'),
'pod.end': color.build('red', 'default'), 'pod.end': color.build('red', 'default'),
# "" strings # "" strings
'string1.start': color.build('green', 'default'), 'string1.start': color.build('green', 'default'),
'string1.null': color.build('green', 'default'), 'string1.null': color.build('green', 'default'),
'string1.escaped': color.build('magenta', 'default'), 'string1.escaped': color.build('magenta', 'default'),
'string1.deref': color.build('yellow', 'default'), 'string1.deref': color.build('yellow', 'default'),
'string1.end': color.build('green', 'default'), 'string1.end': color.build('green', 'default'),
# '' strings # '' strings
'string2.start': color.build('green', 'default'), 'string2.start': color.build('green', 'default'),
'string2.null': color.build('green', 'default'), 'string2.null': color.build('green', 'default'),
'string2.end': color.build('green', 'default'), 'string2.end': color.build('green', 'default'),
# `` strings # `` strings
'evalstring.start': color.build('cyan', 'default'), 'evalstring.start': color.build('cyan', 'default'),
'evalstring.null': color.build('cyan', 'default'), 'evalstring.null': color.build('cyan', 'default'),
'string1.escaped': color.build('magenta', 'default'), 'string1.escaped': color.build('magenta', 'default'),
'string1.deref': color.build('yellow', 'default'), 'string1.deref': color.build('yellow', 'default'),
'evalstring.end': color.build('cyan', 'default'), 'evalstring.end': color.build('cyan', 'default'),
# quoted region # quoted region
'quoted': color.build('cyan', 'default'), 'quoted': color.build('cyan', 'default'),
'quoted.start': color.build('cyan', 'default'), 'quoted.start': color.build('cyan', 'default'),
'quoted.null': color.build('cyan', 'default'), 'quoted.null': color.build('cyan', 'default'),
'quoted.end': color.build('cyan', 'default'), 'quoted.end': color.build('cyan', 'default'),
# match regex # match regex
'match.start': color.build('cyan', 'default'), 'match.start': color.build('cyan', 'default'),
'match.end': color.build('cyan', 'default'), 'match.end': color.build('cyan', 'default'),
'match.null': color.build('cyan', 'default'), 'match.null': color.build('cyan', 'default'),
# replace regex # replace regex
'replace.start': color.build('cyan', 'default'), 'replace.start': color.build('cyan', 'default'),
'replace.middle': color.build('cyan', 'default'), 'replace.middle': color.build('cyan', 'default'),
@ -276,14 +277,14 @@ class Perl(mode2.Fundamental):
'replace.scalar': color.build('yellow', 'default'), 'replace.scalar': color.build('yellow', 'default'),
'replace.hash': color.build('yellow', 'default'), 'replace.hash': color.build('yellow', 'default'),
'replace.cast': color.build('yellow', 'default'), 'replace.cast': color.build('yellow', 'default'),
# translate regex # translate regex
'translate.start': color.build('magenta', 'default'), 'translate.start': color.build('magenta', 'default'),
'translate.middle': color.build('magenta', 'default'), 'translate.middle': color.build('magenta', 'default'),
'translate.end': color.build('magenta', 'default'), 'translate.end': color.build('magenta', 'default'),
'translate.null': color.build('magenta', 'default'), 'translate.null': color.build('magenta', 'default'),
} }
# perl-specific # perl-specific
self.functions = None self.functions = None
self.perllib = 'lib' self.perllib = 'lib'
@ -309,15 +310,14 @@ class Perl(mode2.Fundamental):
names = [x[1] for x in pairs] names = [x[1] for x in pairs]
return names return names
class PerlSetLib(method.Method): class PerlSetLib(Method):
'''Set the path(s) to find perl modules''' '''Set the path(s) to find perl modules'''
def _args(self): args = [Argument("lib", type=type(""), prompt="Location of lib: ",
return [method.Argument("lib", type=type(""), prompt="Location of lib: ", default=default.build_constant("."))]
default=default.build_constant("."))]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
w.mode.perllib = vargs['lib'] w.mode.perllib = vargs['lib']
class PerlCheckSyntax(method.Method): class PerlCheckSyntax(Method):
'''Check the syntax of a perl file''' '''Check the syntax of a perl file'''
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
app = w.application app = w.application
@ -329,14 +329,14 @@ class PerlCheckSyntax(method.Method):
else: else:
app.data_buffer("*Perl-Check-Syntax*", output) app.data_buffer("*Perl-Check-Syntax*", output)
class PerlViewModulePerldoc(method.Method): class PerlViewModulePerldoc(Method):
'''View documentation about this file using perldoc''' '''View documentation about this file using perldoc'''
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
cmd = "perldoc -t -T '%s'" % w.buffer.path cmd = "perldoc -t -T '%s'" % w.buffer.path
(status, output) = commands.getstatusoutput(cmd) (status, output) = commands.getstatusoutput(cmd)
w.application.data_buffer("*Perldoc*", output, switch_to=True) w.application.data_buffer("*Perldoc*", output, switch_to=True)
class PerlViewWordPerldoc(method.Method): class PerlViewWordPerldoc(Method):
'''View documentation about a package or function using perldoc''' '''View documentation about a package or function using perldoc'''
def _try(self, w, word, asfunc=False): def _try(self, w, word, asfunc=False):
if asfunc: if asfunc:
@ -381,11 +381,9 @@ class PerlViewWordPerldoc(method.Method):
else: else:
w.application.set_error('nothing found for %r' % word) w.application.set_error('nothing found for %r' % word)
class PerlGotoFunction(method.Method): class PerlGotoFunction(Method):
'''Jump to a function defined in this module''' '''Jump to a function defined in this module'''
def _args(self): args = [Argument("name", type(""), "perlfunction", "Goto Function: ")]
return [method.Argument("name", type=type(""), datatype="perlfunction",
prompt="Goto Function: ")]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
name = vargs['name'] name = vargs['name']
functions = w.mode.get_functions() functions = w.mode.get_functions()
@ -394,14 +392,14 @@ class PerlGotoFunction(method.Method):
else: else:
w.application.set_error("Function %r was not found" % name) w.application.set_error("Function %r was not found" % name)
class PerlListFunctions(method.Method): class PerlListFunctions(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.get_function_names() names = w.mode.get_function_names()
output = "\n".join(names) + "\n" output = "\n".join(names) + "\n"
w.application.data_buffer("*Perl-List-Functions*", output, switch_to=True) w.application.data_buffer("*Perl-List-Functions*", output, switch_to=True)
class PerlWhichFunction(method.Method): class PerlWhichFunction(Method):
'''Show the user what function they are in''' '''Show the user what function they are in'''
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
cursor = w.logical_cursor() cursor = w.logical_cursor()
@ -419,7 +417,7 @@ class PerlWhichFunction(method.Method):
else: else:
w.application.set_error("line %d: %s" % (i, name)) w.application.set_error("line %d: %s" % (i, name))
class PerlHashCleanup(method.Method): class PerlHashCleanup(Method):
'''Correctly align assignment blocks and literal hashes''' '''Correctly align assignment blocks and literal hashes'''
def _execute(self, window, **vargs): def _execute(self, window, **vargs):
cursor = window.logical_cursor() cursor = window.logical_cursor()
@ -494,7 +492,7 @@ class PerlHashCleanup(method.Method):
window.kill(start_p, end_p) window.kill(start_p, end_p)
window.insert_string(start_p, data) window.insert_string(start_p, data)
#class PerlWrapLine(method.Method): #class PerlWrapLine(Method):
# '''Wrap lines, comments, POD''' # '''Wrap lines, comments, POD'''
# margin = 80 # margin = 80
# comment_re = re.compile('^( *)(#+)( *)([^ ].*)$') # comment_re = re.compile('^( *)(#+)( *)([^ ].*)$')

View File

@ -207,9 +207,8 @@ class Python(mode2.Fundamental):
class PythonSetLib(method.Method): class PythonSetLib(method.Method):
'''Set the path(s) to find perl modules''' '''Set the path(s) to find perl modules'''
def _args(self): args = [method.Argument("lib", type=type(""), prompt="Python Path: ",
return [method.Argument("lib", type=type(""), prompt="Python Path: ", default=default.build_constant("."))]
default=default.build_constant("."))]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
w.mode.pythonlib = vargs['lib'] w.mode.pythonlib = vargs['lib']
@ -228,9 +227,8 @@ class PythonCheckSyntax(method.Method):
class PythonUpdateTags(method.Method): class PythonUpdateTags(method.Method):
'''Update the CTag data associated with a python buffer''' '''Update the CTag data associated with a python buffer'''
def _args(self): args = [method.Argument("lib", prompt="Module Base: ", datatype='path',
return [method.Argument("lib", prompt="Module Base: ", datatype='path', default=default.build_constant("."))]
default=default.build_constant("."))]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
w.mode.ctagger = ctag_python.PythonCTagger() w.mode.ctagger = ctag_python.PythonCTagger()
w.mode.ctagger.process_paths([vargs['lib']]) w.mode.ctagger.process_paths([vargs['lib']])

View File

@ -73,6 +73,8 @@ class Window(object):
# some useful pass-through to application # some useful pass-through to application
def set_error(self, s): def set_error(self, s):
self.application.set_error(s) self.application.set_error(s)
def clear_error(self):
self.application.clear_error()
# mode stuff # mode stuff
def set_mode(self, m): def set_mode(self, m):