From: Yuri Khan <yuri.v.khan@gmail.com>
To: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: How do I use compilation-transform-file-match-alist?
Date: Thu, 15 Aug 2024 21:45:15 +0700 [thread overview]
Message-ID: <CAP_d_8UoOdxoxeVLQFmT749cVX1BQfGsiozu9m+xWQu4gY_p3g@mail.gmail.com> (raw)
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’?
next reply other threads:[~2024-08-15 14:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-15 14:45 Yuri Khan [this message]
2024-08-17 14:14 ` How do I use compilation-transform-file-match-alist? Joel Reicher
2024-08-17 14:46 ` Yuri Khan
2024-08-19 19:44 ` Stefan Monnier via Users list for the GNU Emacs text editor
2024-08-21 10:28 ` Joel Reicher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAP_d_8UoOdxoxeVLQFmT749cVX1BQfGsiozu9m+xWQu4gY_p3g@mail.gmail.com \
--to=yuri.v.khan@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.