[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How do I use compilation-transform-file-match-alist?
From: |
Yuri Khan |
Subject: |
How do I use compilation-transform-file-match-alist? |
Date: |
Thu, 15 Aug 2024 21:45:15 +0700 |
Hello,
I have a project that I compile using a Docker container. This part works.
I want to have multiple working copies of the project lying on my file
system, so that I could work on several branches at the same time
without losing context when switching.
Each working copy is naturally located under a different directory.
I want the working copy on the host to be mounted into a fixed
directory name in the container. This greatly simplifies efficient use
of ccache.
/home/me/work/PROJECT/
master/ -> /home/me/work/PROJECT/_branch
foo-branch/
bar-branch/
Compilation will sometimes output warnings and error messages. These
refer to files by their full absolute name in the container:
/home/me/work/PROJECT/_branch/some/source.cpp:42: error:
some_identifier undefined
By default, compilation-mode will display those as is, and when I try
to visit the offending file, Emacs will not find it, because the
directory is different.
I have found a variable, compilation-transform-file-match-alist, that
looks like it will instruct Emacs to map file names according to a
list of regexp/replacement pairs. So I could, in theory, put
PROJECT/_branch on the left and PROJECT/master on the right, to get:
/home/me/work/PROJECT/master/some/source.cpp:42: error:
some_identifier undefined
However, I seem to be unable to easily set it for compilation-mode
buffers. I cannot set it globally because I want different
replacements in PROJECT/master, PROJECT/foo-branch and
PROJECT/bar-branch. I naturally try to put it in
PROJECT/master/.dir-locals.el:
((nil . ((compilation-transform-file-match-alist .
(("/PROJECT/_branch/" . "/PROJECT/master/"))))))
But it looks like compilation-mode buffers do not apply
directory-local variables.
How is the feature intended to be used?
I guess I can hook ‘compilation-mode-hook’ to invoke ‘hack-local-variables’?
- How do I use compilation-transform-file-match-alist?,
Yuri Khan <=