emacs插件flymake快速检查语法错误(C/C++,python,java,perl等语言)

先看段我演示:

怎么样? 是不是有IDE的感觉? 进入配置过程.其实配置不复杂.

首先需要Makefile的支持(这里只拿C/C++作例子).

在Makefile中添加下面两行:

check-syntax: gcc -o nul -S ${CHK_SOURCES}

gcc可以相应改成g++ 然后 进入要编写的代码启用flymake-mode即可

flymake目前支持一下语言:

LanguageCompilerOSC/C++Microsoft Visual C++ 6.0Windows 2000C/C++gcc 2.9Windows 2000/XP/LinuxMS IDLmidl 5.01Windows 2000JavaIBM Jikes 1.17Windows 2000LatexMikTeX 2.2Windows 2000HTMLHTML TidyWindows 2000/XPXMLXMLStarlet Command Line XML Toolkit 0.7.0Windows 2000/XPPerlPerl 5.8Windows 2000/XP

当然这里有一些有用的函数(ahei编写),可以把错误显示在minibuffer上:

;Code by ahei(defun flymake-display-current-error () “Display errors/warnings under cursor.” (interactive) (let ((ovs (overlays-in (point) (1+ (point))))) (catch ‘found (dolist (ov ovs) (when (flymake-overlay-p ov) (message (overlay-get ov ‘help-echo)) (throw ‘found t)))))) (defun flymake-goto-next-error-disp () “Go to next error in err ring, then display error/warning.” (interactive) (flymake-goto-next-error) (flymake-display-current-error)) (defun flymake-goto-prev-error-disp () “Go to previous error in err ring, then display error/warning.” (interactive) (flymake-goto-prev-error) (flymake-display-current-error))

flymake-display-current-error是显示当前的光标所在错误!

flymake-goto-next-error-disp显示下一个错误!

flymake-goto-prev-error-disp显示上一个错误!

是不是很给力?

当然这里有个性能问题,因为flymake是调用gcc的 大工程的话 会相对比较慢. 看你选择了!


比丘资源网 » emacs插件flymake快速检查语法错误(C/C++,python,java,perl等语言)

发表回复

提供最优质的资源集合

立即查看 了解详情