On Wed, 2019-09-11 at 08:44 +0200, Andreas Schwab wrote:
> On Sep 10 2019, Paul Smith <psm...@gnu.org> wrote:
> 
> > That didn't work, however, because particularly in recursive make
> > the makefile name is likely not qualified with a path, but the
> > current working directory when the build is invoked is not the same
> > as the one where make is invoked--thus "Makefile" is at best
> > ambiguous.
> 
> But isn't that the same situation as with any other error message in
> a recursive make, which Emacs already handles correctly (with the
> help of make --print-directory)?

Thanks for getting me to look into this more deeply.

The problem is not print-directory, etc.  The problem is that Emacs
compile mode doesn't have a matcher for error messages generated by GNU
make when a target fails.  As such it matches some other regex in
compilation-error-regexp-alist-alist and computes the filename
incorrectly.

I've sent a patch to Emacs for compile.el which adds a matching regex
for GNU make error messages, and assigns them the INFO level since they
are usually not needed, but sometimes is is very handy to be able to
jump to the makefile recipe.

In the meantime I've added this to my init.el:

;; Add support for GNU make error matching, if it doesn't yet exist
(with-eval-after-load 'compile
  (or (member 'gmake compilation-error-regexp-alist)
      (progn
        (setf (alist-get 'gmake compilation-error-regexp-alist-alist)
              '(": \\*\\*\\* \\[\\(\\(.+?\\):\\([0-9]+\\): .+\\)\\]"
                2 3 nil 0 1))
        (add-to-list 'compilation-error-regexp-alist 'gmake))))

I'm going to revert the change I made to GNU make to use ";" instead of
":" between the filename and line number (that was never part of any
release of GNU make) and go back to ":".


_______________________________________________
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make

Reply via email to