help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compilation buffer


From: Andrea Crotti
Subject: Re: Compilation buffer
Date: Thu, 25 Nov 2010 17:57:18 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (darwin)

Thien-Thi Nguyen <address@hidden> writes:

> () Andrea Crotti <address@hidden>
> () Thu, 25 Nov 2010 00:17:00 +0100
>
>    I stole this nice trick somewhere
>
>      (defun kill-compile-buffer-if-successful (buffer string)
>        (if (string-match "finished" string)        ^ 
>            (run-with-timer 1 nil                   | 
>                            'kill-buffer            | 
>                            buffer)))               | 
>                                                    | 
>      (add-hook 'compilation-finish-functions 'kill | 
> ompile-buffer-if-successful)
>                                                    | 
>    And actually it's very nice, in short if the co | ilation succeeds the
>    buffer is killed, but there are two small probl | s:
>                                                    | 
>    - not just "compile" uses compilation mode, for | xample grep also does
>      but then the buffer disappears too soon.      | 
>      Is there a way to distiguish between those di | erent things?
>                                                    | 
> The first arg to the function is the buffer. ------+
> You can test that.

Ah ok thanks good, so now is
--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))
      (run-with-timer 1 nil
                      'kill-buffer
                      buffer)))
--8<---------------cut here---------------end--------------->8---

I also wanted to check for "warnings", but how from a buffer do I get
easily IF there is a string in it?

I found (buffer-string) for example but I can't pass a buffer to it...




reply via email to

[Prev in Thread] Current Thread [Next in Thread]