View previous compilation errors during a new compilation?

How to configure emacs so that I can view previous compilation errors during a new compilation?

For me, two things do not work:

  • Mg Mg function (next error) does not work when the second compilation is performed.

  • I have emacs divided into 5 uneven windows (split-windows-horizontally), and the compilation window is twice as large (dbl monitor setup). When I start compilation, it always appears in the last double compilation window. Now he opens a new window for himself.

+8
c ++ compilation emacs ide
source share
3 answers

Here is a solution that seems to meet all your requirements:

  • the buffer *compilation-old* always remains in one window
  • next-error does not break
  • all subsequent compilation outputs are added at the end of *compilation-old* when the compilation process is completed
 (defun my-compilation-finish-function (buffer msg) ;; Don't do anything if we are in a derived mode (when (with-current-buffer buffer (eq major-mode 'compilation-mode)) ;; Insert the last compilation output at the end of *compilation-old* (if (get-buffer "*compilation-old*") (with-current-buffer "*compilation-old*" (save-excursion (goto-char (point-max)) (insert-buffer buffer))) (with-current-buffer buffer (rename-buffer "*compilation-old*"))))) (add-hook 'compilation-finish-functions 'my-compilation-finish-function) (defadvice compile (around my-compile-show-old activate) "Show the *compilation-old* buffer after starting the compilation" (let ((buffer (current-buffer))) (when (get-buffer "*compilation-old*") (pop-to-buffer "*compilation-old*") (switch-to-buffer "*compilation*")) ad-do-it (when (get-buffer "*compilation-old*") (switch-to-buffer "*compilation-old*") (pop-to-buffer buffer)))) 
+3
source share

As a result of executing the compilation command in the initialization file, rename the build buffer to *compilation-old* .

Note that this will not work if you start the new compilation process from the old compilation buffer (since compile in this case reuses the buffer instead of creating a new one)

 (defun my-rename-compilation-buffer (buffer message) ;; Don't do anything if we are in a derived mode (when (with-current-buffer buffer (eq major-mode 'compilation-mode)) (let* ((old-compilation-buffer-name "*compilation-old*") (old-compilation-buffer (get-buffer old-compilation-buffer-name))) ;; Kill old compilation buffer if necessary (when old-compilation-buffer (kill-buffer old-compilation-buffer)) ;; Rename the current compilation buffer (with-current-buffer buffer (rename-buffer old-compilation-buffer-name))))) (add-hook 'compilation-finish-functions 'my-rename-compilation-buffer) 
+2
source share

This is a bit of Kludge, but try the following:

Before starting a new compilation, save (write, Cx Cw) the current compilation buffer to a file. If the buffer for the new file loses the compilation-mode setting, just enable compilation mode (Mx compilation mode).

0
source share

All Articles