如何让emacs自动编译?

Vim、Emacs配置和使用
回复
testla
帖子: 9
注册时间: 2009-07-28 20:00

如何让emacs自动编译?

#1

帖子 testla » 2010-04-26 12:49

我想按F10键时对当前C源代码进行编译,例如,文件名为XXX.c的源文件怎么写配置文件,使得按F10键后执行这个命令?
gcc -o xxx -g xxx.c
davyzhu
帖子: 109
注册时间: 2009-12-06 21:23

Re: 如何让emacs自动编译?

#2

帖子 davyzhu » 2010-04-26 16:41

A general method with *nix flavor:
1. write a Makefile in the source directory like

代码: 全选

xxx: xxx.c
    gcc -o xxx -g xxx.c
2. M-x compile (I alias it to M-x cpl, or you can alias it to F10)
M-x compile will (1)run make Makefile, (2)parse the information by gcc and re-fontify it.
回复