In my emacs init file, I have this:
(add-hook 'c++-mode-hook (lambda () (set (make-local-variable 'compile-command) (concat "g++ " buffer-file-name)))) Then, say I have a c++ file called: test.cpp. I just need to do M-x compile, Emacs would do : g++ test.cpp automatically.
Now, to run the executable, I would need to do: M-x shell, then ./a.out to run the program.
Is there a way to create a command that tells Emacs to do M-x compile then run the executable?
Additionally, how would one change so that M-x compile will give appropriate executable name? For example, if I have test.cpp, then I want it to do: g++ test.cpp -o test instead.
Please help and thank you
(compile "COMMAND && ./a.out")or(compile (concat compile-command " && ./.out"))