From: Robert Pluim Date: Tue, 3 Dec 2024 14:20:04 +0000 (+0100) Subject: Improve 'compilation-transform-file-match-alist' documentation X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9c58a11825691fbe51d94e694ba138659b38b205;p=emacs.git 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. (cherry picked from commit 7c50e4cc8cc19ad1ab10121ece894409a72a8af9) --- diff --git a/doc/emacs/building.texi b/doc/emacs/building.texi index a135991c749..d25213ad793 100644 --- a/doc/emacs/building.texi +++ b/doc/emacs/building.texi @@ -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 diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index 659b89971bb..7a11cfd453b 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -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")