From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: Open compilation window only on errors?
Date: Mon, 13 Oct 2003 11:24:03 -0600 [thread overview]
Message-ID: <3F8ADFB3.7010201@yahoo.com> (raw)
In-Reply-To: mailman.1571.1066032399.21628.help-gnu-emacs@gnu.org
Matthew Calhoun wrote:
> (defun handle-compilation-window (buffer msg)
> "Gets rid of compilation window on successful compilation, otherwise
> goes to first error."
> (if (and (equal (substring msg 0 8) "finished")
> (get-buffer-window buffer)) ; Compilation window is still open
> (progn (delete-window (get-buffer-window buffer))
> (message "Compilation was clean."))
> (next-error)))
> (setq compilation-finish-function 'handle-compilation-window)
>
> It even works correctly with my unit test failures, which was a pleasant
> surprise. But it's not perfect yet. When compilation results in warnings
> but no errors, my function is closing the compilation window because it
> receives a "finished" message, but I would rather keep the window open
> and go to the first warning, just like I would if there were errors. I
> know I could tell the compiler to treat warnings as errors, but that's
> not always feasible. Should I add a regexp to
> compilation-error-regexp-alist to fix this, or is there a better way?
First, I think it would be more reliable to check the compiler's exit
status directly rather than Emacs' message:
;; process-status == (process-status (get-buffer-process buffer))
;; exit-status == (process-exit-status (get-buffer-process buffer))
(if (and (eq process-status 'exit)
(= exit-status 0)
(get-buffer-window buffer))
...)
Thtat's because Emacs doesn't parse the error or warning messages to
determine whether the compiler failed, it just looks at its exit status
so you may as well do the same.
My guess is that compilation-error-regexp-alist already matches your
compiler's warnings; you can test that by running next-error when you
only get warning messages. If that works, you could set
compile-auto-highlight to automatically parse the compiler's output and
then check compilation-error-list in your finish function to see whether
any warnings or errors were reported.
--
Kevin Rodgers
next parent reply other threads:[~2003-10-13 17:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.1571.1066032399.21628.help-gnu-emacs@gnu.org>
2003-10-13 17:24 ` Kevin Rodgers [this message]
[not found] <mailman.813.1064689050.21628.help-gnu-emacs@gnu.org>
2003-09-29 9:45 ` Open compilation window only on errors? Jens Schmidt
2003-10-13 8:05 ` Matthew Calhoun
2003-09-29 14:45 ` François Fleuret
2003-09-29 22:10 ` Kevin Rodgers
2003-09-27 18:57 Matthew Calhoun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3F8ADFB3.7010201@yahoo.com \
--to=ihs_4664@yahoo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).