我正在使用scons来构建我的c++项目
我正在使用下一个脚本来正确处理scons的错误:
34;;; SCons builds into a 'build' subdir, but we want to find the errors
35;;; in the regular source dir. So we remove build/XXX/YYY/{dbg,final}/ from the
36;;; filenames.
37(defun process-error-filename (filename)
38 (let ((case-fold-search t))
39 (setq f (replace-regexp-in-string
40 "[Ss]?[Bb]uild[\/].*\(final\|dbg\)[^\/]*[\/]" "" filename))
41 (cond ((file-exists-p f)
42 f)
43 (t filename))))
44
45(setq compilation-parse-errors-filename-function 'process-error-filename)
所以。我想使用emacs,而不仅仅是c++和scons。但也可以使用java和其他语言
如何设置emacs以仅在运行时使用此"进程错误文件名"功能
M-x compile
scons
命令?
您可以使用模式挂钩
http://www.gnu.org/software/emacs/manual/html_node/emacs/Hooks.html
http://www.gnu.org/software/emacs/manual/html_node/elisp/Creating-Buffer_002dLocal.html
(defun my-c++-mode-hook ()
(set (make-local-variable
'compilation-parse-errors-filename-function)
'process-error-filename))
(add-hook 'c++-mode-hook 'my-c++-mode-hook)