In the compile buffer of Emacs 25.3.1, I am getting the following compilation error using Clang (the error message is given as it appears in the compile buffer line by line) :

src/platform/linux/linux.c:668:70: error: no member named 'buffer_size_' in 'struct
      OpenGL_State::(anonymous at src/platform/linux/opengl.c:8:5)'
        init_data->render_command_buffer_size_in_bytes = gl->command.buffer_size_;

Emacs correctly matches src/platform/linux/linux.c:668:70 to be a filepath in the first line; however, in the second line, it matches with OpenGL_State::(anonymous at src/platform/linux/opengl.c:8:5)' instead of src/platform/linux/opengl.c:8:5 which means that when I click on the error, Emacs can not find the file.

How can I make Emacs not start matching the file name from the beginning of the line?

1 Answer 1


A variable called compilation-error-regexp-alist-alist (I will call c-e-r-a-a) is a list of (<name> <regexp> <list of regexp match numbers...>).

From the output of `M-x describe-variable compilation-error-regexp-alist':

HIGHLIGHT...]).  If REGEXP matches, the FILE’th subexpression
gives the file name, and the LINE’th subexpression gives the line
number.  The COLUMN’th subexpression gives the column number on
that line.

A variable called compilation-error-regexp-alist (I will call c-e-r-a) contains a list of entries which are names of entries in the above c-e-r-a-a variable.

So, to solve your problem, we need to create an entry in c-e-r-a-a to match OpenGL_State::(anonymous at src/platform/linux/opengl.c:8:5)'

(add-to-list 'compilation-error-regexp-alist-alist
               "^.* at \\(\\([^\n:/]+/\\)+[^\n:/]+\\):\\([0-9]+\\):\\([0-9]+\\)"
               1 3 4))

and add a reference to c-e-r-a:

(add-to-list 'compilation-error-regexp-alist 'clang-anonymous)

For more information of Emacs' regular expressions, see here.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.