From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: =?iso-8859-1?q?Fran=E7ois_Fleuret?= Newsgroups: gmane.emacs.help Subject: Re: Open compilation window only on errors? Date: 29 Sep 2003 16:45:15 +0200 Organization: I.N.R.I.A Rocquencourt Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1064849380 15756 80.91.224.253 (29 Sep 2003 15:29:40 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 29 Sep 2003 15:29:40 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Sep 29 17:29:38 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1A3zxx-0002n4-00 for ; Mon, 29 Sep 2003 17:29:37 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.22) id 1A3zkq-0004uL-MW for geh-help-gnu-emacs@m.gmane.org; Mon, 29 Sep 2003 11:16:04 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsmi-us.news.garr.it!NewsITBone-GARR!news.mailgate.org!newsfeed.stueberl.de!teaser.fr!news.cs.univ-paris8.fr!unice.fr!news.cma.fr!news-sop.inria.fr!news-rocq.inria.fr!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 61 Original-NNTP-Posting-Host: wasabi.inria.fr Original-X-Trace: news-rocq.inria.fr 1064846715 2805 128.93.23.201 (29 Sep 2003 14:45:15 GMT) Original-X-Complaints-To: usenet@inria.fr Original-NNTP-Posting-Date: Mon, 29 Sep 2003 14:45:15 +0000 (UTC) X-Attribution: FF X-Url: http://www-rocq.inria.fr/~fleuret User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 Original-Xref: shelby.stanford.edu gnu.emacs.help:116939 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:12866 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:12866 Matthew Calhoun wrote on 27 Sep 2003 19:57:18 MET: > When I compile using M-x compile, Emacs opens a new window for the > compilation buffer when it's finished. This is great when there are > warnings or errors, but when there aren't I would like to prevent > Emacs from opening the new window, and instead maybe just put a > message in the minibuffer indicating that compilation was > successful. Is there a variable I can set for this, or does anyone > have elisp code that does something similar? This is my own recipe (sort of dirty, but has been working for months here), maybe it can help: ;; runs the compilation according to the compile-command (and ;; thus does not ask any confirmation), shows the compilation buffer ;; during compilation AND removes it if the compilation ends with no ;; error (i.e. it restores the window configuration as it was before ;; was pressed) ;; asks for a compilation command and runs the compilation ;; but does not restore the window configuration (i.e. the compilation ;; buffer's window will still be visible, as usual) ;; goes to the next compilation error (as C-x ` does on the ;; standard configuration) (defun restore-windows-if-no-error (buffer msg) "Restores the window configuration according to `window-configuration-before-compilation' if msg matches \"^finished\". This function can be used by adding in your .emacs \(setq compilation-finish-function \'restore-windows-if-no-error\)." (if (string-match "^finished" msg) (when (boundp 'window-configuration-before-compilation) (progn (set-window-configuration window-configuration-before-compilation) (message (concat "Compilation '" compile-command "' finished with no error (compilation window removed)")) ))) (makunbound 'window-configuration-before-compilation) ) (setq compilation-finish-function 'restore-windows-if-no-error) (defun fast-compile () "Compiles without asking anything" (interactive) (let ((compilation-read-command nil)) (setq window-configuration-before-compilation (current-window-configuration)) (compile compile-command))) (define-key global-map [f1] 'fast-compile) (define-key global-map [(shift f1)] 'compile) (define-key global-map [f2] 'next-error) -- François Fleuret IMEDIA Research Group Tel +33 1 39 63 55 83 INRIA, France Fax +33 1 39 63 59 95