[comp.emacs] compile c in emacs

haozhou@acsu.buffalo.edu (Hao Zhou) (02/14/91)

My question is how do you compile c source code within emacs without
creating a shell window? I am on Sparc/SunOS.

Thanks in advance...

	- Hao 
-- 
Internet:haozhou@acsu.buffalo.edu BITNET:haozhou%acsu.buffalo.edu@UBVM.BITNET
UUCP: rutgers!ub!haozhou

Dan_Jacobson@ATT.COM (02/14/91)

>>>>> On 13 Feb 91 22:59:47 GMT, haozhou@acsu.buffalo.edu (Hao Zhou) said:

Hao> My question is how do you compile c source code within emacs without
Hao> creating a shell window? I am on Sparc/SunOS.

M-x compile:
Compile the program including the current buffer.  Default: run `make'.
Runs COMMAND, a shell command, in a separate process asynchronously
with output going to the buffer *compilation*.
You can then use the command C-x ` to find the next error message
and move to the source code that caused it.
-- 
Dan_Jacobson@ATT.COM  Naperville IL USA  +1 708-979-6364

bandu@acsu.buffalo.edu (Jagath Samarabandu) (02/15/91)

In article <59658@eerie.acsu.Buffalo.EDU> haozhou@acsu.buffalo.edu (Hao Zhou) writes:
>My question is how do you compile c source code within emacs without
>creating a shell window? I am on Sparc/SunOS.

One neat trick I found (this is probably common knowledge. But I'll say it
anyway) is to define the compile command as a 'buffer-local' variable and then 
bind the M-x compile to a key combination like C-c C-c. Then, when I type C-c
C-c, voila... It gives the correct command.

By adding this at the end of a file called boundary.c, I can define the
compile-command variable.

/* Local Variables: */
/* compile-command: "gcc boundary.c -o boundary -lm -O" */
/* End: */

Capitalization and space between '/*', '*/'  and all words are important.

Bandu

PS: All this (and more) can be found in the info section while in gnu-emacs.