如何在emacs C++编译模式中跳过"包含在文件中"?

sto*_*tic 6 c++ emacs compilationmode emacs24

我喜欢使用emacs使用编译模式编译我的C++项目,并next-error跳转到源代码中的警告和错误.但是,我觉得非常烦人的是next-error把我带到编译输出中"包含在文件中"的行的每个#include.我知道您可以使用compilation-skip-threshold跳过警告,但我不想跳过警告,这些包括显示为警告的行.

对我来说这似乎是编译模式中的一个错误(这些不是警告),但这个错误被关闭为"不是错误"

具体来说,对于看起来像这样的输出:

In file included from /path/to/file1.h:linenum1:
In file included from /path/to/file2.h:linenum2:
In file included from /path/to/file3.h:linenum3:
/path/to/file4.h:linenum4:columnnum4: warning: you are bad at c++
Run Code Online (Sandbox Code Playgroud)

我想把next-error我带到file4.h,而不是在路上停在文件1到3中.

谢谢!

imm*_*rrr 5

我亲自尝试过.我们似乎有不同的gcc版本,因为我的输出看起来像这样:

g++ test.cc 
In file included from file3.h:1:0,
                 from file2.h:1,
                 from file1.h:2,
                 from test.cc:2:
file4.h:1:2: warning: #warning "you are bad at c++" [-Wcpp]
Run Code Online (Sandbox Code Playgroud)

但我仍然看到了问题.显然,这'gcc-include是破坏事物的正则表达式.在我的情况下,所有那些"从"行正确匹配,但最后一行.问题是它以冒号结束,这在某种程度上使它成为一个警告.我现在有点懒,检查可能的gcc输出消息是什么样的匹配目标(应该有它的原因,嗯?),所以我只想回答这个问题:

;; This element is what controls the matching behaviour: according to
;; `compilation-error-regexp-alist` doc, it means if subexpression 4 of the
;; regexp matches, it's a warning, if subexpression 5 matches, it's an info.
(nth 5 (assoc 'gcc-include compilation-error-regexp-alist-alist))
(4 . 5)

;; We could try and tinker with the regexp, but it's simpler to just set it as
;; "always match as info".
(setf (nth 5 (assoc 'gcc-include compilation-error-regexp-alist-alist)) 0)
Run Code Online (Sandbox Code Playgroud)

此片段停止了编辑模式,突出显示最后一行"从"行,作为对我的警告.