From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "rgb" Newsgroups: gmane.emacs.help Subject: Re: Defadvice use Date: 18 Apr 2005 10:11:08 -0700 Organization: http://groups.google.com Message-ID: <1113844268.703229.310830@g14g2000cwa.googlegroups.com> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1113844410 12424 80.91.229.2 (18 Apr 2005 17:13:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 18 Apr 2005 17:13:30 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Apr 18 19:13:27 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DNZmE-0004iW-NH for geh-help-gnu-emacs@m.gmane.org; Mon, 18 Apr 2005 19:11:15 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DNZqN-0001vI-Bm for geh-help-gnu-emacs@m.gmane.org; Mon, 18 Apr 2005 13:15:31 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!g14g2000cwa.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 41 Original-NNTP-Posting-Host: 198.74.20.77 Original-X-Trace: posting.google.com 1113844274 3197 127.0.0.1 (18 Apr 2005 17:11:14 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Mon, 18 Apr 2005 17:11:14 +0000 (UTC) User-Agent: G2/0.2 Complaints-To: groups-abuse@google.com Injection-Info: g14g2000cwa.googlegroups.com; posting-host=198.74.20.77; posting-account=C7LM4w0AAAD23IRuMuUUJVCLQTuHhTK8 Original-Xref: shelby.stanford.edu gnu.emacs.help:130214 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: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:25781 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:25781 Matthias wrote: > Hi, > > I have the following problem: How do I advice a function so that > within that function, the function `read-minibuffer' (for example) > calls the definition of another function, say `my-read-minibuffer'? > > I'm trying to use an advice around the function; the advice providing > a binding of the symbol `read-minibuffer' to the definition of > `my-read-minibuffer'. Like the following: > > (defadvice la-fonction > (around la-fonction-extended enable compile) > "Documentation" > (let (f1) > (fset 'f1 read-minibuffer) > (fset 'read-minibuffer my-read-minibuffer) > ad-do-it > (fset 'read-minibuffer f1))) > > Any comment? Is it silly? Is there a better way? Any idea? > I asked the 'is there a better way' question not too long ago concerning the problem below and got no response so this might be as good as it gets. I do it slightly different from your example. I think you really don't need f1 in your advice code. ; I don't like bookmark mouse-2 opening the file in another window. ; There doesn't seem to be any other way to fix the problem. The ; theory here is to temporarily re-define the function that the mouse ; handler does call giving it the definition of the function I wish it ; would call. (defadvice bookmark-bmenu-other-window-with-mouse (around my-fix first () activate) ;rgb 2004 "Changes behavior to open file in same window, not other-window." (let (bookmark-bmenu-other-window) (fset 'bookmark-bmenu-other-window (symbol-function 'bookmark-bmenu-this-window)) ad-do-it))