[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: advising jde-compile -- a better way?
From: |
Kevin Rodgers |
Subject: |
Re: advising jde-compile -- a better way? |
Date: |
Mon, 25 Oct 2004 15:43:10 -0600 |
User-agent: |
Mozilla Thunderbird 0.8 (X11/20040916) |
Joe Casadonte wrote:
> jde-compile prompts me to save buffers before compiling, a practice
> that I find personally annoying.
(setq compilation-ask-about-save nil)
or
(add-hook 'java-mode-hook
(lambda ()
(set (make-local-variable 'compilation-ask-about-save) nil)))
> I've come up with the following, but it seems ugly:
>
> (defadvice jde-compile (around jde-compile-no-save-prompt act)
> "Supresses the save-buffer prompting."
> (fset 'save-some-buffers-old-fn-def (symbol-function
'save-some-buffers))
> (fset 'save-some-buffers 'ignore)
> ad-do-it
> (fset 'save-some-buffers (symbol-function
'save-some-buffers-old-fn-def)))
> Is there a better or more elegant way to accomplish the same thing?
It sure is ugly. First, you should use a local variable binding instead
of a global function binding to save the original definition, and you
should make sure to restore the original binding in case of an error:
(defadvice jde-compile (around ignore-save-some-buffers activate)
"Don't call `save-some-buffers'."
(let ((save-some-buffers (symbol-function 'save-some-buffers)))
(fset 'save-some-buffers 'ignore)
(unwind-protect
ad-do-it
(fset 'save-some-buffers save-some-buffers))))
The flet Common Lisp emulation macro basically does that.
--
Kevin Rodgers