0

I've below code

(add-to-list 'compilation-error-regexp-alist 'kbd)
(add-to-list 'compilation-error-regexp-alist-alist
             '(kbd "^kmonad: Parse error at \\([0-9]+\\):\\([0-9]+\\):" 2 3))

And I want to parse

kmonad: Parse error at 36:1:
   |
36 | jdfkj
   | ^

But it doesn't match correctly in compilation buffer, I can't go to the line and column of the error, instead it points to first column of first line, and matches first regexp block as line number. But regexp is correct re-build proof

1 Answer 1

2

The LINE and COLUMN entries (2 and 3 in your code) refers to the subgroup of the regexp. Your regexp only contains two subgroups, so they should be 1 and 2.

In addition, the first entry after the regexp is the filename (or nil), so it should be (REGEXP nil 1 2).

4
  • I tried (kbd "^kmonad: Parse error at \\([0-9]+\\):\\([0-9]+\\):" 1 2) but it doesn't work either. From their faces, I can say that 36 parsed as file name and 1 parsed as line number. paste.pics/4738cc4c3a70b7eb21e6189e146951ee Feb 12, 2022 at 19:47
  • Ah, the first number is the file name (I missed that). Since you don't have a file name to match, try (REGEXP nil 1 2). Feb 12, 2022 at 21:14
  • Thank you so much, it drove me insane! Feb 12, 2022 at 21:44
  • Glad I could help! Feb 12, 2022 at 21:54

Your Answer

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

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