From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: how to temporarily remove a function from a hook? Date: Thu, 09 Jul 2009 00:04:02 -0400 Organization: A noiseless patient Spider Message-ID: References: <87ab3elgpl.fsf@galatea.local> NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1247114471 3332 80.91.229.12 (9 Jul 2009 04:41:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 9 Jul 2009 04:41:11 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 09 06:41:04 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MOlRP-0001kW-Fb for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Jul 2009 06:41:03 +0200 Original-Received: from localhost ([127.0.0.1]:38495 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MOlRP-0004bk-0V for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Jul 2009 00:41:03 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news1.google.com!news.glorb.com!feeder.erje.net!feeder.eternal-september.org!eternal-september.org!news.eternal-september.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 36 Original-X-Trace: news.eternal-september.org U2FsdGVkX1/fTSF8DnQWZcCqwyM/c4omcnePDiN+8PRxezXSF39bMOjHbH1Llcet3BfqWJi07KU+E4p52N8A0U4XVfu+YBnb2Yl+gi2Te0Z1Dxq9/MNWaaoaEoFYCpRtFLd0EA6t+Z4= Original-X-Complaints-To: abuse@eternal-september.org Original-NNTP-Posting-Date: Thu, 9 Jul 2009 04:08:38 +0000 (UTC) X-Auth-Sender: U2FsdGVkX1+2HXTlpAtVXQqY3iQWSOglfbp5kV9RE80= Cancel-Lock: sha1:/JcRtKxebAw1IlJEEhsbAG00UgQ= User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Mail-Copies-To: nobody Original-Xref: news.stanford.edu gnu.emacs.help:170678 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:65878 Archived-At: In article <87ab3elgpl.fsf@galatea.local>, pjb@informatimago.com (Pascal J. Bourguignon) wrote: > Kevin Rodgers writes: > > > What is the right way to temporarily remove a function from a hook? > > > > > > My best guess is: > > > > (let ((foo-hook (progn (remove-hook 'bar 'foo-hook) foo-hook))) > > ...) > > > This won't work, because remove-hook actually modifies the outside > variable foo-hook. > > > Write simply: > > (let ((foo-hook (remove 'bar foo-hook))) > ...) Or: (let ((foo-hook foo-hook)) (remove-hook 'bar 'foo-hook) ...) This doesn't violate the abstraction of remove-hook. -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** *** PLEASE don't copy me on replies, I'll read them in the group ***