help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Transforming paths in compilation output (containerized builds)


From: Yuri Khan
Subject: Re: Transforming paths in compilation output (containerized builds)
Date: Sun, 8 Dec 2024 13:24:11 +0700

On Sun, 8 Dec 2024 at 02:59, Björn Bidar <bjorn.bidar@thaodan.de> wrote:

> I'm looking how to transform the output in the compilation buffer or
> just make Emacs open the correct paths inside builds happen inside
> containerized builds.
>
> The output of the programs ran inside these environments relates
> to the environment they are build in e.g. container in
> /var/tmp/build-root/<name> and output as if /var/tmp/build-root/<name>
> is /.

I’m using this for containerized builds.

    (defvar yk-compilation-filter-alist nil
      "List of (REGEXP REPLACEMENT) to apply to compilation messages.")

    (defun yk-compilation-filter ()
      "Apply replacements to compilation messages."
      (save-excursion
        (pcase-dolist (`(,regexp ,replacement) yk-compilation-filter-alist)
          (goto-char compilation-filter-start)
          (beginning-of-line)
          (while (re-search-forward regexp nil t)
            (replace-match replacement nil nil)))))

The variable is set directory-locally on the project root:

    ((nil . ((yk-compilation-filter-alist
              . (("/my/container/root/" "/home/myself/project/"))))))

The filter function is permanently added to the
‘compilation-filter-hook’ variable.

I may have had to work around the bug where a ‘compilation-mode’
buffer that is not visiting a file does not pick up directory-local
variables, by adding ‘hack-local-variables’ to
‘compilation-mode-hook’. I did not file a proper bug report at the
time.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]