help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to temporarily remove a function from a hook?


From: Barry Margolin
Subject: Re: how to temporarily remove a function from a hook?
Date: Thu, 09 Jul 2009 00:04:02 -0400
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

In article <87ab3elgpl.fsf@galatea.local>,
 pjb@informatimago.com (Pascal J. Bourguignon) wrote:

> Kevin Rodgers <kevin.d.rodgers@gmail.com> 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 ***


reply via email to

[Prev in Thread] Current Thread [Next in Thread]