我正在使用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仅在我运行
时使用此“process-error-filename”功能M-x compile
scons
命令?
答案 0 :(得分:3)
您可以使用模式挂钩
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)