[Top][All Lists]

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

compilation mode enhancement (compile.el): hook to process filenames

From: Gary Oberbrunner
Subject: compilation mode enhancement (compile.el): hook to process filenames
Date: Wed, 24 Oct 2001 09:43:01 -0400

Some build systems ('cons' in my case, see www.dsmit.com/cons) symlink
or copy the source files into a subdir before building them.  In this
case the error messages have extra or wrong directory components in
them.  This simple patch allows emacs users to define a hook function
to postprocess error filenames that next-error finds in the
*compilation* buffer.  It has been very useful to me and it will be
useful to other cons users and maybe others; and I don't think it has
any impact if it's not used.

This patch is against the version of compile.el in emacs 21.1, but I
think it will work against many recent versions.

# diff -u /temp/compile-{orig,new}.el
--- /temp/compile-orig.el       Wed Oct 24 13:32:44 2001
+++ /temp/compile-new.el        Wed Oct 24 13:33:14 2001
@@ -1874,6 +1874,13 @@
                         (setq filename
                               (concat comint-file-name-prefix filename)))

+                   ;; If compilation-error-filename-hook is
+                   ;; defined, use it to process the filename.
+                   (and (boundp 'compilation-error-filename-hook)
+                        (setq filename
+                              (funcall compilation-error-filename-hook
+                                       filename)))
                    ;; Some compilers (e.g. Sun's java compiler, reportedly)
                    ;; produce bogus file names like "./bar//foo.c" for file
                    ;; "bar/foo.c"; expand-file-name will collapse these into

Without this patch, users have to redefine compilation-parse-errors, which
is possible because there's a variable to switch that function to another
one, but since compilation-parse-errors is a very long and involved
function, you basically have to duplicate it if you want to modify it, which
is not good for maintainability.  Hence I think this patch is practical and

I believe the FSF already has a release on file for me so this patch can
be included in emacs under the GPL.

-- Gary Oberbrunner (address@hidden)

reply via email to

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