From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: compilation/grep buffer advice Date: Thu, 07 Aug 2008 21:19:23 -0600 Message-ID: References: <87r6906gxj.fsf@nonospaz.fatphil.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1218165608 9973 80.91.229.12 (8 Aug 2008 03:20:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 8 Aug 2008 03:20:08 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Aug 08 05:20:59 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KRIXC-00082O-Hx for geh-help-gnu-emacs@m.gmane.org; Fri, 08 Aug 2008 05:20:58 +0200 Original-Received: from localhost ([127.0.0.1]:42381 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KRIWG-0005Si-Ts for geh-help-gnu-emacs@m.gmane.org; Thu, 07 Aug 2008 23:20:00 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KRIVx-0005SP-67 for help-gnu-emacs@gnu.org; Thu, 07 Aug 2008 23:19:41 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KRIVw-0005SD-Jn for help-gnu-emacs@gnu.org; Thu, 07 Aug 2008 23:19:40 -0400 Original-Received: from [199.232.76.173] (port=41139 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KRIVw-0005SA-CX for help-gnu-emacs@gnu.org; Thu, 07 Aug 2008 23:19:40 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:46814 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KRIVw-0002yo-5Q for help-gnu-emacs@gnu.org; Thu, 07 Aug 2008 23:19:40 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1KRIVo-0004uL-VP for help-gnu-emacs@gnu.org; Fri, 08 Aug 2008 03:19:32 +0000 Original-Received: from c-67-161-145-183.hsd1.co.comcast.net ([67.161.145.183]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 08 Aug 2008 03:19:32 +0000 Original-Received: from kevin.d.rodgers by c-67-161-145-183.hsd1.co.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 08 Aug 2008 03:19:32 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 56 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-67-161-145-183.hsd1.co.comcast.net User-Agent: Thunderbird 2.0.0.16 (Macintosh/20080707) In-Reply-To: <87r6906gxj.fsf@nonospaz.fatphil.org> X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:56268 Archived-At: Phil Carmody wrote: > I like the idea of burying the result of a successful > compilation, but keeping errors visible, and started > using the code snippet that was recently posted here > to achieve that. > > However, I got annoyed by it burying grep results too. > This quick hack overcomes that limitation, but I'm not > sure what kind of condition to include to test the buffer > name: > > (setq compilation-finish-function > (lambda (buf str) > (if (string-match "compilation" (buffer-name buf)) > (if (string-match "exited abnormally" str) > (message "compilation errors, press C-x ` to visit") > (run-at-time 1 nil 'delete-windows-on buf) > (message "NO COMPILATION ERRORS!")) > (message "didn't look like a compilation")))) Rather than testing the buffer name, you could test the major-mode variable: By default, M-x compile sets it to compilation-mode and M-x grep sets it to grep-mode. That's not comprehensive, as the compilation-start function takes a MODE argument, but at least major-mode is constrained to be a proper major mode whereas the buffer name could be anything returned by compilation-start's NAME-FUNCTION. > What other kinds of functions apart from grep use compilation > mode? Is it better to have 'compilation' a special case to be > handled by optionally burying, or 'grep' the special case that > does nothing? Compilation mode is highly generalized so that many other modes can be implemented on top of it. Such modes ought to set major-mode via compilation-start's MODE, so I think you'd be better of testing (eq major-mode 'compilation-mode). You might also consider moving the test out of the compilation-finish-function and into compilation-mode-hook: (defun my-compilation-finish-function (buffer string) (if (string-match "exited abnormally" string) (message (substitute-command-keys "Compilation errors, type \\[next-error] to visit")) (run-at-time 1 nil 'delete-windows-on buffer) (message "No compilation errors"))) (add-hook 'compilation-mode-hook (lambda () (if (eq major-mode 'compilation-mode) (set (make-local-variable 'compilation-finish-function) 'my-compilation-finish-function)))) -- Kevin Rodgers Denver, Colorado, USA