unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How do I use compilation-transform-file-match-alist?
@ 2024-08-15 14:45 Yuri Khan
  2024-08-17 14:14 ` Joel Reicher
  0 siblings, 1 reply; 5+ messages in thread
From: Yuri Khan @ 2024-08-15 14:45 UTC (permalink / raw)
  To: help-gnu-emacs

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’?



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-08-21 10:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-15 14:45 How do I use compilation-transform-file-match-alist? Yuri Khan
2024-08-17 14:14 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).