From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Matthew Calhoun Newsgroups: gmane.emacs.help Subject: Re: Open compilation window only on errors? Date: Mon, 13 Oct 2003 01:05:55 -0700 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <11EB670C-FD54-11D7-8605-0003930EBF00@mac.com> References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 (Apple Message framework v552) Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1066032891 23129 80.91.224.253 (13 Oct 2003 08:14:51 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 13 Oct 2003 08:14:51 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Oct 13 10:14:48 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 1A8xqq-0002SW-00 for ; Mon, 13 Oct 2003 10:14:48 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1A8xkz-000725-Pb for geh-help-gnu-emacs@m.gmane.org; Mon, 13 Oct 2003 04:08:45 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1A8xit-0006dN-Ny for help-gnu-emacs@gnu.org; Mon, 13 Oct 2003 04:06:35 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1A8xiJ-0006WV-Ie for help-gnu-emacs@gnu.org; Mon, 13 Oct 2003 04:06:30 -0400 Original-Received: from [17.250.248.88] (helo=smtpout.mac.com) by monty-python.gnu.org with esmtp (Exim 4.24) id 1A8xiI-0006WA-Gk for help-gnu-emacs@gnu.org; Mon, 13 Oct 2003 04:05:58 -0400 Original-Received: from mac.com (smtpin08-en2 [10.13.10.153]) by smtpout.mac.com (Xserve/MantshX 2.0) with ESMTP id h9D85vcW028038 for ; Mon, 13 Oct 2003 01:05:57 -0700 (PDT) Original-Received: from mac.com (12-234-253-207.client.attbi.com [12.234.253.207]) (authenticated bits=0) by mac.com (Xserve/smtpin08/MantshX 3.0) with ESMTP id h9D85ubn014182 for ; Mon, 13 Oct 2003 01:05:56 -0700 (PDT) Original-To: help-gnu-emacs@gnu.org In-Reply-To: X-Mailer: Apple Mail (2.552) 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:13149 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:13149 Thanks to the superb guidance of Jens, Francois, and Kevin, I have a compilation-finish-function that works quite well. It looks like this: (defun handle-compilation-window (buffer msg) "Gets rid of compilation window on successful compilation, otherwise goes to first error." (if (and (equal (substring msg 0 8) "finished") (get-buffer-window buffer)) ; Compilation window is still open (progn (delete-window (get-buffer-window buffer)) (message "Compilation was clean.")) (next-error))) (setq compilation-finish-function 'handle-compilation-window) It even works correctly with my unit test failures, which was a pleasant surprise. But it's not perfect yet. When compilation results in warnings but no errors, my function is closing the compilation window because it receives a "finished" message, but I would rather keep the window open and go to the first warning, just like I would if there were errors. I know I could tell the compiler to treat warnings as errors, but that's not always feasible. Should I add a regexp to compilation-error-regexp-alist to fix this, or is there a better way? Thanks, Matt