parent
250a29f97d
commit
3a731e6e29
34
mode/c.py
34
mode/c.py
|
@ -1,5 +1,5 @@
|
|||
import re
|
||||
import color, mode2, tab2
|
||||
import popen2, re
|
||||
import color, method, mode2, tab2
|
||||
from lex3 import Grammar, PatternRule, RegionRule
|
||||
from mode.python import StringGrammar
|
||||
|
||||
|
@ -237,5 +237,35 @@ class C(mode2.Fundamental):
|
|||
self.add_bindings('close-paren', (')',))
|
||||
self.add_bindings('close-brace', ('}',))
|
||||
self.add_bindings('close-bracket', (']',))
|
||||
self.add_action_and_bindings(CMake(), ('C-c C-c',))
|
||||
self.add_action_and_bindings(CSetMake(), ('C-c C-m',))
|
||||
self.makecmd = "make"
|
||||
def name(self):
|
||||
return "C"
|
||||
|
||||
class CSetMake(method.Method):
|
||||
'''Set the path(s) to find perl modules'''
|
||||
args = [method.Argument("cmd", type=type(""), prompt="Make Cmd: ",
|
||||
default=default.build_constant("make"))]
|
||||
def _execute(self, w, **vargs):
|
||||
w.mode.makecmd = vargs['cmd']
|
||||
|
||||
class CMake(method.Method):
|
||||
'''Check the syntax of the current python file'''
|
||||
def _execute(self, w, **vargs):
|
||||
p = popen2.Popen4(w.makecmd)
|
||||
p.tochild.close()
|
||||
output = p.fromchild.read()
|
||||
result = p.wait()
|
||||
|
||||
if not os.WIFEXITED(result):
|
||||
sig = os.WTERMSIG(result)
|
||||
w.application.data_buffer("*CMake*", output, switch_to=True)
|
||||
w.set_error("make: killed by signal %r" % sig)
|
||||
else:
|
||||
status = os.WEXITSTATUS(result)
|
||||
if status == 0:
|
||||
w.set_error("make: OK")
|
||||
else:
|
||||
w.application.data_buffer("*CMake*", output, switch_to=True)
|
||||
w.set_error("make: failed with status %r" % status)
|
||||
|
|
Loading…
Reference in New Issue