reddit / emacs

Tips on managing compilation-error-regexp-alist?

[deleted] · 2022-10-04 18:02
Hi everyone! Lately, I've been defining my own regular expressions for parsing errors in the `*compilation*` buffers by adding entries to the `compilation-error-regexp-alist` and `compilation-error-regexp-alist-alist` variables. However, there's a problem. This list already contains an enormous amount of regular expressions for all kinds of languages that I don't use, however, these regular expressions also match errors of the language that I'm trying to add support to, and this results in extracting incorrect paths to files containing errors. I've set `compilation-error-regexp-alist` to `nil` and the problem disappeared, but now when I byte-compile elisp files, I get no way to jump to problems from the compilation buffer (well, duh, the regexp list now doesn't contain an entry for elisp). So this creates a problem. I want my regular expressions to be the only ones present in the list when I'm working on a project in this language, and I want other regexps to be available when I'm working on other projects. I've thought about using dir-locals.el but my regexps use [functions to get the file out of the error message](https://github.com/andreyorst/dotfiles/blob/97b4cbaea1eec5e1d1c16730c173dd3ce8545a88/.config/emacs/init.el#L1540-L1565), and I can't put that into dir-locals reliably. Another problem is that the `compilation-error-regexp-alist` contains names of the languages it supports, but for example, there's no `elisp` or `emacs-lisp` entry, yet the byte-compile warnings are highlighted correctly. And there's no way to see what regular expressions are responsible for the matches in the compilation buffer, so it's hard to debug what's overriding mine. TL;DR: Ideally, I want `compilation-error-regexp-alist` to be configurable per project but I use custom functions that can break other people's configurations who work on the same project as me and load dir-locals.el
mickeyp · 2022-10-04 18:43
There's `.dir-locals-2.el`. You can add entries to it and either either `.gitignore` or `.git/exclude` it. It's loaded in conjunction with `.dir-locals.el`. The other option is `dir-locals-set-class-variables` and defining them in your init file.
[deleted] · 2022-10-04 18:57
I don't want to exclude it from the project, as other developers in our team suffer from the same problem I'm trying to solve - incorrect filenames extracted from Clojure compilation errors. Right now we share snippets from configs, but this is not ideal. I guess I could use `eval` in `.dir-locals.el` but it also doesn't seem to be a proper option.