all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / 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

* Re: How do I use compilation-transform-file-match-alist?
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Joel Reicher @ 2024-08-17 14:14 UTC (permalink / raw)
  To: Yuri Khan; +Cc: help-gnu-emacs

Yuri Khan <yuri.v.khan@gmail.com> writes:

> I have a project that I compile using a Docker container. This 
> part works.
>
> I want to have multiple working copies of the project

I am not sure, but I don't think project supports this concept. If 
you want to use project in the intended way, you might have to 
treat each working copy as its own project.

And if you want it to support the multiple-working-copy concept, 
you might have to change it.

Regards,

        - Joel



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

* Re: How do I use compilation-transform-file-match-alist?
  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
  0 siblings, 2 replies; 5+ messages in thread
From: Yuri Khan @ 2024-08-17 14:46 UTC (permalink / raw)
  To: Joel Reicher; +Cc: help-gnu-emacs

On Sat, 17 Aug 2024 at 21:14, Joel Reicher <joel.reicher@gmail.com> wrote:
>
> Yuri Khan <yuri.v.khan@gmail.com> writes:
>
> > I have a project that I compile using a Docker container. This
> > part works.
> >
> > I want to have multiple working copies of the project
>
> I am not sure, but I don't think project supports this concept.

You seem to have interpreted the word ‘project’ as related to
‘project.el’. No, I am not asking about project.el, I’m using the word
‘project’ in its plain English meaning.

I am okay treating each working copy of my code base as a separate
project{.el,ile.el} project.

My question was about customizing variables affecting
‘compilation-mode’. It does not seem to pick up directory-local
variables, which surprises me. The rest of the text was intended to
explain why I do not want to customize them globally.



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

* Re: How do I use compilation-transform-file-match-alist?
  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
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2024-08-19 19:44 UTC (permalink / raw)
  To: help-gnu-emacs

> My question was about customizing variables affecting
> ‘compilation-mode’. It does not seem to pick up directory-local
> variables,

Directory-local variables are supposed to apply to all file buffers, so
if your `compilation-mode` buffer is a file buffer, the dir-local
settings *should* definitely apply.

For non-file buffers, whether dir-local vars are applied or not is
...hmm... well it depends and we've had discussions about when it should
and when it shouldn't.  So you might want to `M-x report-emacs-bug`
explaining your circumstances so as to help us figure out when it should
and when it shouldn't.


        Stefan




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

* Re: How do I use compilation-transform-file-match-alist?
  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
  1 sibling, 0 replies; 5+ messages in thread
From: Joel Reicher @ 2024-08-21 10:28 UTC (permalink / raw)
  To: Yuri Khan; +Cc: help-gnu-emacs

Yuri Khan <yuri.v.khan@gmail.com> writes:

> On Sat, 17 Aug 2024 at 21:14, Joel Reicher 
> <joel.reicher@gmail.com> wrote:
>>
>> Yuri Khan <yuri.v.khan@gmail.com> writes:
>>
>>> I have a project that I compile using a Docker container. This 
>>> part works.
>>>
>>> I want to have multiple working copies of the project
>>
>> I am not sure, but I don't think project supports this concept.
>
> You seem to have interpreted the word ‘project’ as related to 
> ‘project.el’.

Yes I did, sorry.

> No, I am not asking about project.el, I’m using the word 
> ‘project’ in its plain English meaning.
>
> I am okay treating each working copy of my code base as a 
> separate project{.el,ile.el} project.
>
> My question was about customizing variables affecting 
> ‘compilation-mode’. It does not seem to pick up directory-local 
> variables, which surprises me. The rest of the text was intended 
> to explain why I do not want to customize them globally.

From what I can see the 'compile' command is quite opinionated 
about the environment it sets up in its buffer, so finding a good 
way to override this might not be the easiest way forward.

Can you coax your compiler to output relative paths?

Cheers,

        - Joel



^ 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

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.