Improve 'compilation-transform-file-match-alist' documentation

* doc/emacs/building.texi (Compilation Mode): Document
'compilation-transform-file-match-alist'.
* lisp/progmodes/compile.el
(compilation-transform-file-match-alist):
Expand docstring and add some examples.
This commit is contained in:
Robert Pluim 2024-12-03 15:20:04 +01:00
parent a73d08bb67
commit 7c50e4cc8c
2 changed files with 23 additions and 3 deletions

View file

@ -310,6 +310,14 @@ error message formats and tells Emacs how to extract the locus from
each. A similar variable, @code{grep-regexp-alist}, tells Emacs how
to parse output from a @code{grep} command (@pxref{Grep Searching}).
@vindex compilation-transform-file-match-alist
@cindex compilation transform file
@cindex compilation find file
Sometimes @code{compilation-error-regexp-alist} doesn't correctly
determine the filename that is the source of the error. Use user option
@code{compilation-transform-file-match-alist} to make any necessary
adjustments, such as adding or changing a directory component.
@findex compilation-next-error
@findex compilation-previous-error
@findex compilation-next-file

View file

@ -62,9 +62,21 @@ If nil, use Emacs default."
(defcustom compilation-transform-file-match-alist
'(("/bin/[a-z]*sh\\'" nil))
"Alist of regexp/replacements to alter file names in compilation errors.
If the replacement is nil, the file will not be considered an
error after all. If not nil, it should be a regexp replacement
string."
If the replacement is nil, the file will not be considered an error
after all. If not nil, it should be a regexp replacement string.
When a replacement regexp is specified, the value of the file name used
to locate the error is changed, but the compilation buffer still
displays the original value.
For example, to prepend a subdirectory \"bar/\" to all file names, add
an entry matching \"\\\\=`\" and a replacement regexp of \"bar/\", i.e.:
(\"\\\\=`\" \"bar/\")
Similarly, to remove a prefix \"bar/\", use:
(\"\\\\=`bar/\" \"\")"
:type '(repeat (list regexp (choice (const :tag "No replacement" nil)
string)))
:version "27.1")