From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: advising jde-compile -- a better way? Date: Mon, 25 Oct 2004 15:43:10 -0600 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <2u5abgF25s7dvU1@uni-berlin.de> References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1098805141 7823 80.91.229.6 (26 Oct 2004 15:39:01 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 26 Oct 2004 15:39:01 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 26 17:38:55 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CMTPT-0008Mo-00 for ; Tue, 26 Oct 2004 17:38:55 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CMTXA-0008Le-Cq for geh-help-gnu-emacs@m.gmane.org; Tue, 26 Oct 2004 11:46:52 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!syros.belnet.be!news.belnet.be!newsfeed00.sul.t-online.de!t-online.de!newsfeed.r-kom.de!fu-berlin.de!uni-berlin.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 40 Original-X-Trace: news.uni-berlin.de hjU6lAwtr39AXPzd5i/XHAyjTPlVLunCnl9h4Yrd//nUuC6LQ= User-Agent: Mozilla Thunderbird 0.8 (X11/20040916) X-Accept-Language: en-us, en In-Reply-To: Original-Xref: shelby.stanford.edu gnu.emacs.help:126051 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:21435 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:21435 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