more improvements for C mode, config variables
--HG-- branch : pmacs2
This commit is contained in:
parent
d49e69691c
commit
de8920d5e0
|
@ -918,9 +918,9 @@ class GetConfigVariable(Method):
|
|||
name = vargs['name']
|
||||
if name in w.application.config:
|
||||
value = w.application.config[name]
|
||||
w.set_error("param %s set to %r" % (name, value))
|
||||
w.set_error("param %r set to %r" % (name, value))
|
||||
else:
|
||||
w.set_error("param %s is not set" % (name,))
|
||||
w.set_error("param %r is not set" % (name,))
|
||||
|
||||
class ViewConfigVariables(Method):
|
||||
def _execute(self, w, **vargs):
|
||||
|
@ -936,10 +936,14 @@ class SetConfigVariable(Method):
|
|||
arg('value', t=type(''), p="Variable value: ",
|
||||
h='Configuration parameter value to use')]
|
||||
def _execute(self, w, **vargs):
|
||||
name, value = vargs['name'], vargs['value']
|
||||
name = vargs['name']
|
||||
found = name in w.application.config
|
||||
try:
|
||||
value = eval(vargs['value'])
|
||||
except:
|
||||
value = vargs['value']
|
||||
w.application.config[name] = value
|
||||
if found:
|
||||
w.set_error("param %s set to %r" % (name, value))
|
||||
w.set_error("param %r set to %r" % (name, value))
|
||||
else:
|
||||
w.set_error("previously unset param %s set to %r" % (name, value))
|
||||
w.set_error("previously unset param %r set to %r" % (name, value))
|
||||
|
|
|
@ -10,7 +10,9 @@ class Exec(Method):
|
|||
'''Execute a command in a shell and put the output in a new buffer'''
|
||||
show_success = True
|
||||
args = [Argument('cmd', prompt="Exec: ", datatype='shell')]
|
||||
def _doit(self, w, path, cmd, cmdname=None, bufname=None):
|
||||
def _doit(self, w, path, cmd, cmdname=None, bufname=None, cmddir=None):
|
||||
if cmddir:
|
||||
cmd = "cd %r && %s" % (cmddir, cmd)
|
||||
if path:
|
||||
try:
|
||||
cmd = cmd % {'path': path}
|
||||
|
|
24
mode/c.py
24
mode/c.py
|
@ -209,8 +209,10 @@ class C(mode.Fundamental):
|
|||
'enumname': ('yellow', 'default'),
|
||||
}
|
||||
config = {
|
||||
'c.syntaxcmd': "gcc -x c -fsyntax-only %(path)s",
|
||||
'c.makecmd': "make",
|
||||
'c.syntax-cmd': "gcc -x c -fsyntax-only %(path)s",
|
||||
'c.syntax-rel-dir': False,
|
||||
'c.make-cmd': "make",
|
||||
'c.make-rel-dir': True,
|
||||
}
|
||||
def __init__(self, w):
|
||||
mode.Fundamental.__init__(self, w)
|
||||
|
@ -225,15 +227,25 @@ class CCheckSyntax(method.shell.Exec):
|
|||
show_success = False
|
||||
args = []
|
||||
def _execute(self, w, **vargs):
|
||||
self._doit(w, w.buffer.path, w.application.config['c.syntaxcmd'],
|
||||
cmdname='c-check-syntax')
|
||||
if w.application.config['c.syntax-rel-dir']:
|
||||
d = os.path.dirname(w.buffer.path)
|
||||
self._doit(w, w.buffer.path, w.application.config['c.syntax-cmd'],
|
||||
cmdname='c-check-syntax', cmddir=d)
|
||||
else:
|
||||
self._doit(w, w.buffer.path, w.application.config['c.syntax-cmd'],
|
||||
cmdname='c-check-syntax')
|
||||
|
||||
class CMake(method.shell.Exec):
|
||||
'''Build this C program (using the mode's make cmd)'''
|
||||
show_success = False
|
||||
args = []
|
||||
def _execute(self, w, **vargs):
|
||||
self._doit(w, w.buffer.path, w.application.config['c.makecmd'],
|
||||
cmdname='c-make')
|
||||
if w.application.config['c.make-rel-dir']:
|
||||
d = os.path.dirname(w.buffer.path)
|
||||
self._doit(w, w.buffer.path, w.application.config['c.make-cmd'],
|
||||
cmdname='c-make', cmddir=d)
|
||||
else:
|
||||
self._doit(w, w.buffer.path, w.application.config['c.make-cmd'],
|
||||
cmdname='c-make')
|
||||
|
||||
install = C.install
|
||||
|
|
Loading…
Reference in New Issue