all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* compilation/grep buffer advice
@ 2008-08-07 14:25 Phil Carmody
  2008-08-08  3:19 ` Kevin Rodgers
       [not found] ` <mailman.16056.1218165582.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 3+ messages in thread
From: Phil Carmody @ 2008-08-07 14:25 UTC (permalink / raw
  To: help-gnu-emacs

I like the idea of burying the result of a successful 
compilation, but keeping errors visible, and started 
using the code snippet that was recently posted here 
to achieve that.

However, I got annoyed by it burying grep results too.
This quick hack overcomes that limitation, but I'm not
sure what kind of condition to include to test the buffer
name:

(setq compilation-finish-function
      (lambda (buf str)
        (if (string-match "compilation" (buffer-name buf))
            (if (string-match "exited abnormally" str)
                (message "compilation errors, press C-x ` to visit")
              (run-at-time 1 nil 'delete-windows-on buf)
              (message "NO COMPILATION ERRORS!"))
          (message "didn't look like a compilation"))))


What other kinds of functions apart from grep use compilation 
mode? Is it better to have 'compilation' a special case to be
handled by optionally burying, or 'grep' the special case that
does nothing? 

Phil
-- 
Dear aunt, let's set so double the killer delete select all.
-- Microsoft voice recognition live demonstration


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: compilation/grep buffer advice
  2008-08-07 14:25 compilation/grep buffer advice Phil Carmody
@ 2008-08-08  3:19 ` Kevin Rodgers
       [not found] ` <mailman.16056.1218165582.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 3+ messages in thread
From: Kevin Rodgers @ 2008-08-08  3:19 UTC (permalink / raw
  To: help-gnu-emacs

Phil Carmody wrote:
> I like the idea of burying the result of a successful 
> compilation, but keeping errors visible, and started 
> using the code snippet that was recently posted here 
> to achieve that.
> 
> However, I got annoyed by it burying grep results too.
> This quick hack overcomes that limitation, but I'm not
> sure what kind of condition to include to test the buffer
> name:
> 
> (setq compilation-finish-function
>       (lambda (buf str)
>         (if (string-match "compilation" (buffer-name buf))
>             (if (string-match "exited abnormally" str)
>                 (message "compilation errors, press C-x ` to visit")
>               (run-at-time 1 nil 'delete-windows-on buf)
>               (message "NO COMPILATION ERRORS!"))
>           (message "didn't look like a compilation"))))

Rather than testing the buffer name, you could test the major-mode
variable: By default, M-x compile sets it to compilation-mode and
M-x grep sets it to grep-mode.  That's not comprehensive, as the
compilation-start function takes a MODE argument, but at least
major-mode is constrained to be a proper major mode whereas the buffer
name could be anything returned by compilation-start's NAME-FUNCTION.

> What other kinds of functions apart from grep use compilation 
> mode? Is it better to have 'compilation' a special case to be
> handled by optionally burying, or 'grep' the special case that
> does nothing? 

Compilation mode is highly generalized so that many other modes
can be implemented on top of it.  Such modes ought to set major-mode
via compilation-start's MODE, so I think you'd be better of testing
(eq major-mode 'compilation-mode).

You might also consider moving the test out of the
compilation-finish-function and into compilation-mode-hook:

(defun my-compilation-finish-function (buffer string)
   (if (string-match "exited abnormally" string)
       (message (substitute-command-keys
		"Compilation errors, type \\[next-error] to visit"))
     (run-at-time 1 nil 'delete-windows-on buffer)
     (message "No compilation errors")))

(add-hook 'compilation-mode-hook
	  (lambda ()
	    (if (eq major-mode 'compilation-mode)
		(set (make-local-variable 'compilation-finish-function)
		     'my-compilation-finish-function))))

-- 
Kevin Rodgers
Denver, Colorado, USA





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: compilation/grep buffer advice
       [not found] ` <mailman.16056.1218165582.18990.help-gnu-emacs@gnu.org>
@ 2008-08-08 10:20   ` Phil Carmody
  0 siblings, 0 replies; 3+ messages in thread
From: Phil Carmody @ 2008-08-08 10:20 UTC (permalink / raw
  To: help-gnu-emacs

Kevin Rodgers <kevin.d.rodgers@gmail.com> writes:
>> What other kinds of functions apart from grep use compilation mode?
>
> Compilation mode is highly generalized so that many other modes
> can be implemented on top of it.  Such modes ought to set major-mode
> via compilation-start's MODE, so I think you'd be better of testing
> (eq major-mode 'compilation-mode).
>
> You might also consider moving the test out of the
> compilation-finish-function and into compilation-mode-hook:
>
> (defun my-compilation-finish-function (buffer string)
>   (if (string-match "exited abnormally" string)
>       (message (substitute-command-keys
> 		"Compilation errors, type \\[next-error] to visit"))
>     (run-at-time 1 nil 'delete-windows-on buffer)
>     (message "No compilation errors")))
>
> (add-hook 'compilation-mode-hook
> 	  (lambda ()
> 	    (if (eq major-mode 'compilation-mode)
> 		(set (make-local-variable 'compilation-finish-function)
> 		     'my-compilation-finish-function))))

Nice. Many thanks Kevin, I'm running with the above now.
Phil
-- 
Dear aunt, let's set so double the killer delete select all.
-- Microsoft voice recognition live demonstration


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-08-08 10:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-07 14:25 compilation/grep buffer advice Phil Carmody
2008-08-08  3:19 ` Kevin Rodgers
     [not found] ` <mailman.16056.1218165582.18990.help-gnu-emacs@gnu.org>
2008-08-08 10:20   ` Phil Carmody

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.