help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: compiling in C mode and the compilation buffer


From: Benjamin Rutt
Subject: Re: compiling in C mode and the compilation buffer
Date: Sun, 25 Jul 2004 18:52:26 -0400
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

Shug Boabie <no.spam@example.com> writes:

> i like to compile my code from within Emacs as i have a Makefile setup.
> however, upon compiling; even on a successful compile the compilation
> buffer needs to be closed afterward.
>
> i was wondering; is there a way to have the compilation buffer close
> automatically if there are no warnings or errors?
>
> also, is there a way to run the compile command, without having to agree
> that `make -k` is the correct command each time? that extra 'enter' is just
> annoying.

I would use the following for all of this:

(require 'compile)

;; don't prompt
(setq compilation-read-command nil)

;; close the window on successful compile
(defun my-compilation-finish-function-standard (buf str)
  ;; avoid doing this for buffers created from M-x grep
  (when (string-match "*compilation.*" (buffer-name buf))
    (if (string-match "exited abnormally" str)

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

      ;;no errors, make the compilation window go away
      (run-at-time 0.5 nil 'delete-windows-on buf)
      (message "NO COMPILATION ERRORS!"))))
(add-to-list 'compilation-finish-functions
             'my-compilation-finish-function-standard)

-- 
Benjamin Rutt


reply via email to

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