I love using emacs to compile my C++ project using compilation mode and next-error
to jump to the warnings and errors in the source. However, I find it highly annoying that next-error
brings me to every #include for the lines "In file included from" in the compilation output. I know you can use compilation-skip-threshold
to skip warnings, but I don't want to skip warnings, and these include lines show up as warnings.
To me this seems to be a bug in compilation mode (these aren't warnings), but this bug was closed as "not a bug"
Specifically, for an output that looks like this:
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++
I want next-error
to take me right to file4.h, instead of stopping in files 1 through 3 on the way.
Thanks!
I tried it for myself. We seem to have different gcc versions, because my output looks like this:
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]
But I still see the problem. Apparently, it's the 'gcc-include
regexp that breaks things. In my situation, all those "from" lines match correctly but the last one. The problem is that it ends in a colon and this somehow makes it a warning. I'm a bit lazy now to check what possible gcc output message does such matching target (there should be a reason for it, huh?), so I'll just answer the question:
;; 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)
This snippet stopped compilation mode from highlighting last "from" line as a warning for me.
Configure compilation-skip-threshold
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With