I have used compilation-error-regexp-alist
a lot so I am familiar with the syntax. However for this particular error I need to use a function to get the file because I need wildcards. Here is the function I want to use:
(defun find-generic-log (file)
(car (file-expand-wildcards (format "results/log/*.%s.log" file))))
the documentation for compilation-error-regexp-alist
says:
Each elt has the form (REGEXP FILE [LINE COLUMN TYPE HYPERLINK 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.
If FILE, LINE or COLUMN are nil or that index didn't match, that information is not present on the matched line. In that case the file name is assumed to be the same as the previous one in the buffer, line number defaults to 1 and column defaults to beginning of line's indentation.
FILE can also have the form (FILE FORMAT...), where the FORMATs (e.g. "%s.c") will be applied in turn to the recognized file name, until a file of that name is found. Or FILE can also be a function that returns (FILENAME) or (RELATIVE-FILENAME . DIRNAME). In the former case, FILENAME may be relative or absolute.
I am trying to use the section that says Or FILE can also be a
function that returns (FILENAME)
. However every way I have tried to format the alist has failed. For example I have tried:
'("<regexp>" find-generic-log)
'("<regexp>" 1 find-generic-log)
'("<regexp>" 'find-generic-log)
'("<regexp>" . find-generic-log)
'("<regexp>" (find-generic-log))
'("<regexp>" (1 find-generic-log))
If I just use '("<regexp>" 1)
it will match the error, but the file path is not correct.
So my question is, how do I use a function to get the filename as it says I can in the documentation?