branch : pmacs2
This commit is contained in:
moculus 2008-12-02 20:21:28 +00:00
parent c0ca82feef
commit 6a9e8cd470
2 changed files with 35 additions and 14 deletions

View File

@ -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:

View File

@ -193,11 +193,24 @@ class PerlSetLib(Method):
default=default.build_constant("."))]
def _execute(self, w, **vargs):
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
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
@ -701,6 +719,7 @@ class Perl(mode.Fundamental):
}
config = {
'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);'"
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