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

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

Re: compiling in C mode and the compilation buffer


From: Benjamin Rutt
Subject: Re: compiling in C mode and the compilation buffer
Date: Wed, 28 Jul 2004 08:57:15 -0400
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

Shug Boabie <no.spam@example.com> writes:

>> excellent, however i would still like the window to remain open upon
>> detection of warnings as well [in order to force me to write ISO C99 code
>> :-)]. i use the compile command exclusively for C code, so a grep for
>> "warning:" should be sufficient. however, my attempts to customise your
>> function have failed. any further hints?
>
> for the record, here is what i have been trying to do, but it is not
> working:
>
> (defun sam-compile (buf str)
>   (when (string-match "*compilation.*" (buffer-name buf))
>     (if (string-match "exited abnormally" str)
>       (progn
>           (message "compilation errors, press C-x ` to view"))
>       (if (string-match "warning:" str)
>           (progn
>             (message "compilation warnings, press C-x ` to view"))
>         (run-at-time 0.5 nil 'delete-windows-on buf)
>         (message "no compile errors or warnings")))))

This won't work because the `str' variable above only gets the last
line output by emacs during a compilation.  It will either look like
"Compilation exited abnormally" or "Compilation finished".

I suggest if you really want to treat warnings as errors, you can tell
your compiler to do so.  Under gcc, you would pass the -Werror flag
during compilation.

Note, also, that even during successful compilation, you can still do
C-x ` to take you to any warnings that may have occured.
-- 
Benjamin Rutt


reply via email to

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