From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andrea Crotti Newsgroups: gmane.emacs.help Subject: Re: Compilation buffer Date: Fri, 26 Nov 2010 00:22:56 +0100 Message-ID: References: <87eia9jwux.fsf@ambire.localdomain> <87aakxjeq5.fsf@ambire.localdomain> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1290727495 10272 80.91.229.12 (25 Nov 2010 23:24:55 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 25 Nov 2010 23:24:55 +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 Nov 26 00:24:51 2010 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.69) (envelope-from ) id 1PLlBK-0002Hu-9f for geh-help-gnu-emacs@m.gmane.org; Fri, 26 Nov 2010 00:24:50 +0100 Original-Received: from localhost ([127.0.0.1]:52512 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PLlBJ-0002rw-HF for geh-help-gnu-emacs@m.gmane.org; Thu, 25 Nov 2010 18:24:49 -0500 Original-Received: from [140.186.70.92] (port=38738 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PLlAL-0002nD-4t for help-gnu-emacs@gnu.org; Thu, 25 Nov 2010 18:24:27 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PLl9p-0007OZ-Qa for help-gnu-emacs@gnu.org; Thu, 25 Nov 2010 18:23:48 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:34076) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PLl9p-0007OI-LF for help-gnu-emacs@gnu.org; Thu, 25 Nov 2010 18:23:17 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PLl9l-0001ed-DI for help-gnu-emacs@gnu.org; Fri, 26 Nov 2010 00:23:13 +0100 Original-Received: from ip1-201.halifax.rwth-aachen.de ([137.226.108.201]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 26 Nov 2010 00:23:13 +0100 Original-Received: from andrea.crotti.0 by ip1-201.halifax.rwth-aachen.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 26 Nov 2010 00:23:13 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 30 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: ip1-201.halifax.rwth-aachen.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (darwin) Cancel-Lock: sha1:y6qSfEURjumg6S/LBqwXKSufs4M= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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:75435 Archived-At: Thien-Thi Nguyen writes: > () Andrea Crotti > () Thu, 25 Nov 2010 17:57:18 +0100 > > how from a buffer do I get > easily IF there is a string in it? > > See ‘with-current-buffer’ and ‘search-forward’. Very nic here it is then the solution: --8<---------------cut here---------------start------------->8--- (defun kill-compile-buffer-if-successful (buffer string) " kill a compilation buffer if succeeded without warnings " (if (and (string-match "compilation" (buffer-name buffer)) (string-match "finished" string) (not (with-current-buffer buffer (search-forward "warning" nil t)))) (run-with-timer 1 nil 'kill-buffer buffer))) --8<---------------cut here---------------end--------------->8--- The third argument in search-forward to "t" is important otherwise it doesn't work as expected. Now it's not the most beautiful code I've ever seen but it works pretty well :)