bao*_*aol 14 c++ emacs elisp flymake
我有以下几行 ~/.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)
Run Code Online (Sandbox Code Playgroud)
当我在同一个文件夹中打开一个具有正确Makefile的C++文件时,我会得到即时编译和错误报告(Flymake将检查语法并在代码编辑期间报告错误和警告).
Makefile有一个check-syntax
目标:
.PHONY: check-syntax
check-syntax:
$(CXX) -Wall -Wextra -pedantic -fsyntax-only $(CHK_SOURCES)
Run Code Online (Sandbox Code Playgroud)
问题是,当我打开一个没有相应Makefile的.cc文件时,我得到一个恼人的对话框,警告我关于flymake被禁用.
因此,如果我emacs *.cc
在一个包含20个C++文件的文件夹中启动,我会得到20个模态对话框,其中显示的内容类似于[...]找不到构建文件.Flymake将被关闭.
我可以使用一些钩子来禁用该警告吗?你能提供样本elisp代码和解释你如何找到合适的钩子吗?
arv*_*ixx 14
最简单的方法是将自定义变量设置为true,并重新定义flymake-display-warning函数.
;; 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))
Run Code Online (Sandbox Code Playgroud)
bao*_*aol 11
有一个可以定制的变量,我忽略了.
flymake-gui-warnings-enabled
这将禁用任何GUI消息,但如果没有人会发布更好的答案,我会很好.