Mycroft-l · 2022-06-09 12:46
Hi guys. I'm studying the language C in the moment in I use other terminal to run and compile. I know It is possible to to add in the .emacs (global-set-key \[f4\] 'compile) to compile, but I want to compile and run with only one shortcut. For example in the Geany, You can compile and run, after the compile, it is created a new window to run the file, it is possible to do anything similar in Emacs? Only to run, compile it is good start to me.
Sorry for the English, English it is not my native language.
diamondnbond · 2022-06-09 13:46
Compile and run for Emacs: https://pastebin.com/cFieMstR
mickeyp · 2022-06-09 14:18
You could do that with `M-x compile`. Something like `gcc .... && ./myprogram`. Now you can type `M-x recompile` to re-run the whole thing.
The benefit of this approach is that it works in a shell like bash as well as Emacs.
Mycroft-l · 2022-06-09 15:29
Thanks, I can compile and execute. I have more one question, how I can execute in another window?
Mycroft-l · 2022-06-09 15:33
Thanks, how I can execute the code after compile in other frame/window?
diamondnbond · 2022-06-09 16:11
Change (split-window-vertically) to (split-window-horizontally) if you want;
[https://pastebin.com/T0JQEc2D](https://pastebin.com/T0JQEc2D)
​
img: https://i.ibb.co/q1mN8h2/test.png
tomratboy · 2022-06-09 17:38
`M-!` lets you execute a shell command so you can then run the compiled program like usual
Mycroft-l · 2022-06-09 20:39
Sorry to ask, but I can't do it, It is my code in .emacs:
[https://i.imgur.com/RfSHykO.png](https://i.imgur.com/RfSHykO.png)
My code in c with split-window-horizontally :
[https://ibb.co/4sCprxD](https://ibb.co/4sCprxD)
When I try to run to the shortcut now, I receive this message.
Mycroft-l · 2022-06-09 20:39
It is a good solution too, thank you