unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: David Engster <deng@randomsample.de>
To: 14411@debbugs.gnu.org
Subject: bug#14411: 24.3.50; compile.el: Better file search for parallel builds
Date: Thu, 16 May 2013 21:09:38 +0200	[thread overview]
Message-ID: <87d2sqzqq5.fsf@engster.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 703 bytes --]

When doing parallel builds using GNU Make, jumping to the location of a
warning/error from the compilation buffer often does not work. This is
because GNU Make enters different directories at the same time, and the
resulting output is intermixed. The attached patch fixes this by looking
at all directories which were entered up to the point of the
warning/error, instead of just taking the directly preceding one. I'm
aware that this is not a perfect solution, since those directories might
contain files with identical names, in which case Emacs might show the
wrong one, but IMO it's still an improvement over the current
situation. This feature can also be disabled through a new variable.

-David


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: compile-parallel-patch.diff --]
[-- Type: text/x-diff, Size: 2276 bytes --]

=== modified file 'lisp/progmodes/compile.el'
--- lisp/progmodes/compile.el	2013-04-24 13:50:22 +0000
+++ lisp/progmodes/compile.el	2013-05-16 18:49:35 +0000
@@ -611,6 +611,18 @@
 			 (string :tag "Directory")))
   :group 'compilation)
 
+(defcustom compilation-search-all-directories t
+  "Whether further upward directories should be used when searching a file.
+When doing a parallel build, several files from different
+directories can be compiled at the same time.  This makes it
+difficult to determine the base directory for a relative file
+name in a compiler error or warning.  If this variable is
+non-nil, instead of just relying on the previous directory change
+in the compilation buffer, all other directories further upwards
+will be used as well."
+  :type 'boolean
+  :group 'compilation)
+
 ;;;###autoload
 (defcustom compile-command (purecopy "make -k ")
   "Last shell command used to do a compilation; default for next compilation.
@@ -2616,6 +2628,25 @@
                           (find-file-noselect name))
               fmts (cdr fmts)))
       (setq dirs (cdr dirs)))
+    ;; If we haven't found it, this might be a parallel build.
+    ;; Search the directories further up the buffer.
+    (when (and (null buffer)
+               compilation-search-all-directories)
+      (with-current-buffer (marker-buffer marker)
+        (save-excursion
+          (goto-char (marker-position marker))
+          (goto-char (compilation--previous-directory (point)))
+          (setq dirs (cdr (or (get-text-property (1- (point)) 'compilation-directory)
+                              (get-text-property (point) 'compilation-directory))))))
+      (while (and dirs (null buffer))
+        (setq thisdir (car dirs)
+              fmts formats)
+        (while (and fmts (null buffer))
+          (setq name (expand-file-name (format (car fmts) filename) thisdir)
+                buffer (and (file-exists-p name)
+                            (find-file-noselect name))
+                fmts (cdr fmts)))
+        (setq dirs (cdr dirs))))
     (while (null buffer)    ;Repeat until the user selects an existing file.
       ;; The file doesn't exist.  Ask the user where to find it.
       (save-excursion            ;This save-excursion is probably not right.


             reply	other threads:[~2013-05-16 19:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-16 19:09 David Engster [this message]
2013-05-16 19:19 ` bug#14411: 24.3.50; compile.el: Better file search for parallel builds Eli Zaretskii
2020-09-18 14:35   ` Lars Ingebrigtsen
2020-09-18 15:36     ` Eli Zaretskii
2020-09-18 15:39       ` Lars Ingebrigtsen
2020-10-15 14:49         ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d2sqzqq5.fsf@engster.org \
    --to=deng@randomsample.de \
    --cc=14411@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).