I'm trying to set compilation-error-regexp-alist
but it's more fiddly than I imagined.
The error lines have two formats:
at f (/home/user/utils.js:4:16)
and
at /home/user/db.ts:74:16
I've got the first one matching okay. And I'm trying to match the second... but my rule doesn't seem to be getting used for these lines (despite being found if I use re-search-forward).
This is the rule I am using:
(list 'jest "^ *at \\w+ (\\([^:]+\\):\\([0-9]+\\):[0-9]+)\\|at \\([^:(]+\\):\\([0-9]+\\):[0-9]+" 1 2))
I think the capture group numbering "restarts" after a top-level "|" because these work.
(progn (string-match "\\(.\\).\\(.\\)\\|x\\(.\\).\\(.\\)" "xabc") (match-string 2 "abc"))
(progn (string-match "\\(.\\).\\(.\\)\\|x\\(.\\).\\(.\\)" "xabc") (match-string 2 "xabc"))
Approaches tried
Am I missing something? I'm using this answer (which I wrote today) to debug. I've got to the point of trying to patch compile - but it's getting a bit fiddly.
An obvious work around would be to define two separate rules like so
(defvar jest-function-compilation-error-regexp
(list 'jest-function "^ *at \\w+ (\\([^:]+\\):\\([0-9]+\\):[0-9]+)" 1 2))
(defvar jest-file-compilation-error-regexp
(list 'jest-file "at \\([^:(]+\\):\\([0-9]+\\):[0-9]+" 1 2))
which seems to work, but I think it'd be neater with one rule