Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using aquamacs on Mac OS X. In my .emacs file I have the following:

(setq compilation-window-height 8)
(setq compilation-finish-function
      (lambda (buf str)

        (if (string-match "exited abnormally" str)

            ;;there were errors
            (message "compilation errors, press C-x ` to visit")

          ;;no errors, make the compilation window go away in 0.5 seconds
          (run-at-time 0.5 nil 'delete-windows-on buf)
      (message "NO COMPILATION ERRORS! Thank you dear compiler..."))))

Say I have a .cpp file open alone in the frame. Then when hitting C-c C-c to compile, the frame is being split horizontally, and at the bottom I get the compilation buffer. If the compilation exits normally, then the compilation buffer is closed and the split is gone. Otherwise, it is left open and I can review the errors. So far, so good!

The problem is, that if I had in the first place a split frame, then C-c C-c resizes the lower part to 8 lines, opens the compilation buffer in the lower part (in a new tab) and compile. If the compilation is successful, then the lower part is closed, that is the buffer that was there before the C-c C-c is closed as well.

Ideally, I want that C-c C-c start a compilation buffer in a new split (always), and won't use an existing one (in case one exists). Another perfect solution, would be that the code above will be modified, such that it will close the tab containing the compilation buffer after a successful compilation. This way, if the compilation was the only tab, then the split will be gone, and otherwise, the previously opened tabs will be left intact also after the end of the compilation regardless whether it was successful or not. In this case, probably the hight of the compilation window should be equal to the one of the existing split's hight, and 8 lines otherwise.

If you read so far - thank you for that alone :)

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.