parent
c0ca82feef
commit
6a9e8cd470
|
@ -117,9 +117,9 @@ class Fundamental(Handler):
|
||||||
app.token_colors[key] = val
|
app.token_colors[key] = val
|
||||||
|
|
||||||
# install configuration stuff
|
# install configuration stuff
|
||||||
for (name, val) in cls.config.iteritems():
|
for (key, val) in cls.config.iteritems():
|
||||||
assert name not in app.config, "config conflict: %r" % name
|
assert key not in app.config, "config conflict: %r" % key
|
||||||
app.config[name] = val
|
app.config[key] = val
|
||||||
for (key, val) in cls.lconfig.iteritems():
|
for (key, val) in cls.lconfig.iteritems():
|
||||||
app.config.setdefault(key, [])
|
app.config.setdefault(key, [])
|
||||||
for val2 in val:
|
for val2 in val:
|
||||||
|
|
43
mode/perl.py
43
mode/perl.py
|
@ -192,13 +192,26 @@ class PerlSetLib(Method):
|
||||||
args = [Argument("lib", type=type(""), prompt="Location of lib: ",
|
args = [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.application.config['perl.lib'] = vargs['lib']
|
w.application.config['perl.lib'] = vargs['lib']
|
||||||
|
w.application.config['perl.libs'] = [vargs['lib']]
|
||||||
|
class PerlAddLib(Method):
|
||||||
|
'''Set the path(s) to find perl modules'''
|
||||||
|
args = [Argument("lib", type=type(""), prompt="Location of lib: ",
|
||||||
|
default=default.build_constant("."))]
|
||||||
|
def _execute(self, w, **vargs):
|
||||||
|
w.application.config['perl.libs'].append(vargs['lib'])
|
||||||
|
|
||||||
class PerlCheckSyntax(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):
|
||||||
a = w.application
|
a = w.application
|
||||||
args = ('perl', '-I', a.config.get('perl.lib', '.'), '-c', '-')
|
if a.config.get('perl.libs', None):
|
||||||
|
args = ['perl']
|
||||||
|
for l in a.config.get('perl.libs'):
|
||||||
|
args.extend(('-I', l))
|
||||||
|
args.extend(('-c', '-'))
|
||||||
|
else:
|
||||||
|
args = ('perl', '-I', a.config.get('perl.lib', '.'), '-c', '-')
|
||||||
retval = a.run_pipe(args, w.buffer, '*Perl-Syntax*', lambda x: x != 0)
|
retval = a.run_pipe(args, w.buffer, '*Perl-Syntax*', lambda x: x != 0)
|
||||||
if retval == 0: a.set_error("Syntax OK")
|
if retval == 0: a.set_error("Syntax OK")
|
||||||
|
|
||||||
|
@ -214,13 +227,18 @@ class PerlViewModulePerldoc(Method):
|
||||||
class PerlViewWordPerldoc(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):
|
||||||
|
a = w.application
|
||||||
if asfunc:
|
if asfunc:
|
||||||
cmd = "perldoc -t -T -f '%s'" % (word,)
|
cmd = "perldoc -t -T -f '%s'" % (word,)
|
||||||
else:
|
else:
|
||||||
cmd = "perldoc -t -T '%s'" % (word,)
|
cmd = "perldoc -t -T '%s'" % (word,)
|
||||||
perllib = w.application.config.get('perl.lib')
|
|
||||||
if perllib:
|
if a.config.get('perl.libs', None):
|
||||||
cmd = 'PERL5LIB=%r %s' % (perllib, cmd)
|
s = ':'.join(['%r' % x for x in a.config.get('perl.libs')])
|
||||||
|
cmd = 'PERL5LIB=%r %s' % (s, cmd)
|
||||||
|
elif a.config.get('perl.lib', None):
|
||||||
|
cmd = 'PERL5LIB=%r %s' % (a.config.get('perl.lib'), cmd)
|
||||||
|
|
||||||
(status, data) = commands.getstatusoutput(cmd)
|
(status, data) = commands.getstatusoutput(cmd)
|
||||||
if status == 0:
|
if status == 0:
|
||||||
return data
|
return data
|
||||||
|
@ -700,7 +718,8 @@ class Perl(mode.Fundamental):
|
||||||
'translate.null': ('magenta', 'default', 'bold'),
|
'translate.null': ('magenta', 'default', 'bold'),
|
||||||
}
|
}
|
||||||
config = {
|
config = {
|
||||||
'perl.lib': 'lib',
|
'perl.lib': 'lib',
|
||||||
|
'perl.libs': ['lib'],
|
||||||
}
|
}
|
||||||
actions = [PerlSetLib, PerlCheckSyntax, PerlHashCleanup,
|
actions = [PerlSetLib, PerlCheckSyntax, PerlHashCleanup,
|
||||||
PerlViewModulePerldoc, PerlViewWordPerldoc, PerlWrapParagraph,
|
PerlViewModulePerldoc, PerlViewWordPerldoc, PerlWrapParagraph,
|
||||||
|
@ -751,11 +770,13 @@ class Perl(mode.Fundamental):
|
||||||
|
|
||||||
def get_inc(self):
|
def get_inc(self):
|
||||||
if self.perlinc is None:
|
if self.perlinc is None:
|
||||||
perllib = self.window.application.config.get('perl.lib')
|
cmd = "perl -e 'print join(\"\\n\", @INC);'"
|
||||||
if perllib:
|
if a.config.get('perl.libs', None):
|
||||||
cmd = "PERL5LIB=%r perl -e 'print join(\"\\n\", @INC);'" % perllib
|
s = ':'.join(['%r' % x for x in a.config.get('perl.libs')])
|
||||||
else:
|
cmd = 'PERL5LIB=%r %s' % (s, cmd)
|
||||||
cmd = "perl -e 'print join(\"\\n\", @INC);'"
|
elif a.config.get('perl.lib', None):
|
||||||
|
cmd = 'PERL5LIB=%r %s' % (a.config.get('perl.lib'), cmd)
|
||||||
|
|
||||||
(status, data) = commands.getstatusoutput(cmd)
|
(status, data) = commands.getstatusoutput(cmd)
|
||||||
if status != 0:
|
if status != 0:
|
||||||
raise Exception, "%r failed" % cmd
|
raise Exception, "%r failed" % cmd
|
||||||
|
|
Loading…
Reference in New Issue