我的~/.emacs.d/init.el中有以下几行
(custom-set-variables
  '(flymake-allowed-file-name-masks 
    (quote 
      (
        ("\\.cc\\'" flymake-simple-make-init) 
        ("\\.cpp\\'" flymake-simple-make-init)))))
(add-hook 'find-file-hook 'flymake-find-file-hook)当我打开一个在同一个文件夹中有一个适当的Makefile的C++文件时,我会立即进行编译和错误报告(Flymake将检查语法,并在代码编辑期间报告错误和警告)。
Makefile有一个check-syntax目标:
.PHONY: check-syntax
check-syntax:
 $(CXX) -Wall -Wextra -pedantic -fsyntax-only $(CHK_SOURCES)问题是,当我打开一个没有相应Makefile的.cc文件时,我会得到一个令人讨厌的对话框,该对话框警告我应该禁用flymake。
因此,如果我在一个包含20个emacs *.cc文件的文件夹中启动C++,就会看到20个模式对话框,上面写着“无构建文件”.会关机的。
我能用什么钩子来禁用这个警告吗?您能提供示例elisp代码并解释如何找到合适的钩子吗?
发布于 2010-04-04 13:12:16
要做到这一点,并且仍然接收消息,最简单的方法是将定制变量设置为true,并重新定义函数。
;; Overwrite flymake-display-warning so that no annoying dialog box is
;; used.
;; This version uses lwarn instead of message-box in the original version. 
;; lwarn will open another window, and display the warning in there.
(defun flymake-display-warning (warning) 
  "Display a warning to the user, using lwarn"
  (lwarn 'flymake :warning warning))
;; Using lwarn might be kind of annoying on its own, popping up windows and
;; what not. If you prefer to recieve the warnings in the mini-buffer, use:
(defun flymake-display-warning (warning) 
  "Display a warning to the user, using lwarn"
  (message warning))发布于 2010-04-03 19:58:21
有一个变量可以自定义,而我忽略了这个变量。
flymake-gui-warnings-enabled
这将禁用任何GUI消息,但如果没有人会发布更好的答案,我将对此没有意见。
https://stackoverflow.com/questions/2571436
复制相似问题