parent
c0ca82feef
commit
6a9e8cd470
|
@ -117,9 +117,9 @@ class Fundamental(Handler):
|
|||
app.token_colors[key] = val
|
||||
|
||||
# install configuration stuff
|
||||
for (name, val) in cls.config.iteritems():
|
||||
assert name not in app.config, "config conflict: %r" % name
|
||||
app.config[name] = val
|
||||
for (key, val) in cls.config.iteritems():
|
||||
assert key not in app.config, "config conflict: %r" % key
|
||||
app.config[key] = val
|
||||
for (key, val) in cls.lconfig.iteritems():
|
||||
app.config.setdefault(key, [])
|
||||
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: ",
|
||||
default=default.build_constant("."))]
|
||||
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):
|
||||
'''Check the syntax of a perl file'''
|
||||
def _execute(self, w, **vargs):
|
||||
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)
|
||||
if retval == 0: a.set_error("Syntax OK")
|
||||
|
||||
|
@ -214,13 +227,18 @@ class PerlViewModulePerldoc(Method):
|
|||
class PerlViewWordPerldoc(Method):
|
||||
'''View documentation about a package or function using perldoc'''
|
||||
def _try(self, w, word, asfunc=False):
|
||||
a = w.application
|
||||
if asfunc:
|
||||
cmd = "perldoc -t -T -f '%s'" % (word,)
|
||||
else:
|
||||
cmd = "perldoc -t -T '%s'" % (word,)
|
||||
perllib = w.application.config.get('perl.lib')
|
||||
if perllib:
|
||||
cmd = 'PERL5LIB=%r %s' % (perllib, cmd)
|
||||
|
||||
if a.config.get('perl.libs', None):
|
||||
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)
|
||||
if status == 0:
|
||||
return data
|
||||
|
@ -700,7 +718,8 @@ class Perl(mode.Fundamental):
|
|||
'translate.null': ('magenta', 'default', 'bold'),
|
||||
}
|
||||
config = {
|
||||
'perl.lib': 'lib',
|
||||
'perl.lib': 'lib',
|
||||
'perl.libs': ['lib'],
|
||||
}
|
||||
actions = [PerlSetLib, PerlCheckSyntax, PerlHashCleanup,
|
||||
PerlViewModulePerldoc, PerlViewWordPerldoc, PerlWrapParagraph,
|
||||
|
@ -751,11 +770,13 @@ class Perl(mode.Fundamental):
|
|||
|
||||
def get_inc(self):
|
||||
if self.perlinc is None:
|
||||
perllib = self.window.application.config.get('perl.lib')
|
||||
if perllib:
|
||||
cmd = "PERL5LIB=%r perl -e 'print join(\"\\n\", @INC);'" % perllib
|
||||
else:
|
||||
cmd = "perl -e 'print join(\"\\n\", @INC);'"
|
||||
cmd = "perl -e 'print join(\"\\n\", @INC);'"
|
||||
if a.config.get('perl.libs', None):
|
||||
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)
|
||||
if status != 0:
|
||||
raise Exception, "%r failed" % cmd
|
||||
|
|
Loading…
Reference in New Issue