Here's what I would like to do: When C-c C-l is pressed, a new terminal window is launched if there is no terminal window already, then, in that terminal, gcc is invoked with some flags and the current buffer's file. How would I do that?
Try the built in:
M-x compile gcc ...
compile
isn't bound to any keys by default, but you could do something like:
(add-hook 'c-mode-common-hook
(lambda () (define-key c-mode-base-map (kbd "C-c C-l") 'compile))))
There are a bunch of packages people have written around compiling on the Emacs Wiki. Check out SmartCompile, CompileCommand, and the category Programmer Utils.
The benefit of using M-x compile ...
over just running it in a "terminal" is that you get C-x ` (aka next-error
) which will jump you to the file and line that caused the error command. And there's the command M-x recompile which does what you'd expect. And, of course, like all Emacs commands, the compile
command keeps a history of the compile calls and you can go through the history with M-p and M-n.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With