代码之家  ›  专栏  ›  技术社区  ›  baol

Emacs:恼人的Flymake对话框

  •  14
  • baol  · 技术社区  · 14 年前

    我的字典里有以下几行字 ~/.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)
    

    当我打开一个C++文件,它在同一个文件夹中有一个正确的Mag文件时,我立即开始编译和错误报告(FielMew将在代码编辑期间检查语法和报告错误和警告)。

    Makefile有一个 check-syntax 目标:

    .PHONY: check-syntax
    check-syntax:
     $(CXX) -Wall -Wextra -pedantic -fsyntax-only $(CHK_SOURCES)
    

    所以如果我发射 emacs *.cc 在一个文件夹里有20个C++文件,我得到20 情态动词 对话框显示如下内容 找不到[…]的生成文件。Flymake将关闭 .

    有什么钩子我可以用来禁用那个警告吗?你能提供示例elisp代码和解释如何找到合适的钩子吗?

    2 回复  |  直到 12 年前
        1
  •  14
  •   SamB som-snytt    12 年前

    最简单的方法是将自定义变量设置为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))
    
        2
  •  11
  •   baol    14 年前

    flymake-gui-warnings-enabled

    这将禁用任何GUI消息,但如果没有人会发布更好的答案,我会很好地处理它。

    推荐文章