|
windows中emacs构建IDE
要在windows中构建emacs的IDE非常复杂,需要在MinGw中进行编译,我搞了一个星期,终于搞定了,可是启动速度暴慢,不得已只好去网上找一个已经优化编译好了的。想要进行C/C++编译,就只需要搞定GCC/G++就可以了,我去MinGw中编译了一个,可是却不能和emacs连起来使用。所以需要在Windows上装DevC++,大家可以sourceforg网站下载devcpp-alpha_setup.exe这个文件然后安装在D盘。然后在配置文件_emacs中加入下面这段话,就可以了。
- ;;如果当前目录有makefile则用make -k编译,否则,如果是
- ;;处于c-mode,就用gcc -Wall编译,如果是c++-mode就用 g++ -Wall编译"
- (global-set-key (kbd "<f7>") 'smart-compile)
- (defun smart-compile()
- (interactive)
- ;; 查找 Makefile
- (let ((candidate-make-file-name '("makefile" "Makefile" "GNUmakefile"))
- (command nil))
- (if (not (null
- (find t candidate-make-file-name :key
- '(lambda (f) (file-readable-p f)))))
- (setq command "make -k ")
- ;; 没有找到 Makefile ,查看当前 mode 是否是已知的可编译的模式
- (if (null (buffer-file-name (current-buffer)))
- (message "Buffer not attached to a file, won't compile!")
- (if (eq major-mode 'c-mode)
- (setq command
- (concat "D:/Dev-Cpp/bin/gcc.exe -Wall -o " ;;你要明确知道自己的编译器在哪里,
- (file-name-sans-extension ;;这样,用你的gcc.exe的地址代替这里的D:/Dev-Cpp/bin/gcc.exe
- (file-name-nondirectory buffer-file-name)) ;;注意,这里的路径的斜杠和vista的习惯相反,你要注意修改
- " "
- (file-name-nondirectory buffer-file-name)
- " -g -lm "))
- (if (eq major-mode 'c++-mode)
- (setq command
- (concat "D:/Dev-Cpp/bin/g++.exe -Wall -o " ;;还有这里的g++,也同gcc一样...
- (file-name-sans-extension
- (file-name-nondirectory buffer-file-name))
- " "
- (file-name-nondirectory buffer-file-name)
- " -g -lm "))
- (message "Unknow mode, won't compile!")))))
- (if (not (null command))
- (let ((command (read-from-minibuffer "Compile command: " command)))
- (compile command)))))
|
|
|