Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browsing through previous-compilation errors during a new compilation?

How to setup emacs so that I can browse through previous-compilation errors during new compilation?

Two things don't work for me:

  1. M-g M-g (next-error) function is not working when second compilation is in-progress.

  2. I have my emacs split into 5 uneven windows (split-windows-horizontally), the compilation "window" is double the size (dbl monitor setup). When I launch compilation it always appeared in the last double compilation window. Now it opens a new window for itself.

like image 862
Łukasz Lew Avatar asked Nov 07 '12 13:11

Łukasz Lew


People also ask

What kind of errors can happen during the compilation process?

Compilation Errors Compilation is where your high-level language converts into a lower-level language that the computer can understand better. A compilation or compile-time error happens when the compiler doesn't know how to turn your code into the lower-level code.

What kind of errors are mostly detected at compile-time?

Most frequent Compile-Time errors are: Missing Parenthesis (}) Printing the value of variable without declaring it. Missing semicolon (terminator)


1 Answers

Putting the following in your init file will rename the compilation buffer to *compilation-old* when the compile command terminates.

Please note that this will not work if you run the new compilation process from the old compilation buffer (since compile will in this case reuse 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)
like image 54
François Févotte Avatar answered Oct 06 '22 00:10

François Févotte