[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Compilation buffer
From: |
Andrea Crotti |
Subject: |
Re: Compilation buffer |
Date: |
Fri, 26 Nov 2010 00:22:56 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (darwin) |
Thien-Thi Nguyen <ttn@gnuvola.org> writes:
> () Andrea Crotti <andrea.crotti.0@gmail.com>
> () 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 :)