Use C-x h ( mark-whole-buffer ), depois 'M-| ( shell-command-on-region ), depois use a sugestão de @ Kotte acima para executar gcc -x c -o tmp_prog - && tmp_prog
Ou aqui está uma função elisp que faz isso:
(defun compile-and-run-buffer()
"Compiles the code in the buffer using gcc, run the exe and remove it."
(interactive)
(shell-command-on-region
(point-min)
(point-max)
"gcc -x c -o emacs_tmp - && ./emacs_tmp && rm emacs_tmp"))