From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: Open compilation window only on errors? Date: Mon, 13 Oct 2003 11:24:03 -0600 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <3F8ADFB3.7010201@yahoo.com> References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1066066552 29413 80.91.224.253 (13 Oct 2003 17:35:52 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 13 Oct 2003 17:35:52 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Oct 13 19:35: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 1A96bk-0001kE-00 for ; Mon, 13 Oct 2003 19:35: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 1A96Xa-0001D5-MN for geh-help-gnu-emacs@m.gmane.org; Mon, 13 Oct 2003 13:31:30 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fu-berlin.de!uni-berlin.de!170.207.51.80!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 47 Original-NNTP-Posting-Host: 170.207.51.80 Original-X-Trace: news.uni-berlin.de 1066065841 23215540 170.207.51.80 (16 [82742]) User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2 X-Accept-Language: en-us Original-Xref: shelby.stanford.edu gnu.emacs.help:117230 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:13159 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:13159 Matthew Calhoun wrote: > (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? First, I think it would be more reliable to check the compiler's exit status directly rather than Emacs' message: ;; process-status == (process-status (get-buffer-process buffer)) ;; exit-status == (process-exit-status (get-buffer-process buffer)) (if (and (eq process-status 'exit) (= exit-status 0) (get-buffer-window buffer)) ...) Thtat's because Emacs doesn't parse the error or warning messages to determine whether the compiler failed, it just looks at its exit status so you may as well do the same. My guess is that compilation-error-regexp-alist already matches your compiler's warnings; you can test that by running next-error when you only get warning messages. If that works, you could set compile-auto-highlight to automatically parse the compiler's output and then check compilation-error-list in your finish function to see whether any warnings or errors were reported. -- Kevin Rodgers