* how to temporarily remove a function from a hook?
@ 2009-07-09 1:40 Kevin Rodgers
0 siblings, 0 replies; 4+ messages in thread
From: Kevin Rodgers @ 2009-07-09 1:40 UTC (permalink / raw)
To: help-gnu-emacs
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)))
...)
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: how to temporarily remove a function from a hook?
[not found] <mailman.2124.1247103655.2239.help-gnu-emacs@gnu.org>
@ 2009-07-09 2:42 ` Pascal J. Bourguignon
2009-07-09 4:04 ` Barry Margolin
0 siblings, 1 reply; 4+ messages in thread
From: Pascal J. Bourguignon @ 2009-07-09 2:42 UTC (permalink / raw)
To: help-gnu-emacs
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)))
...)
--
__Pascal Bourguignon__
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: how to temporarily remove a function from a hook?
2009-07-09 2:42 ` how to temporarily remove a function from a hook? Pascal J. Bourguignon
@ 2009-07-09 4:04 ` Barry Margolin
2009-07-09 11:14 ` Johan Bockgård
0 siblings, 1 reply; 4+ messages in thread
From: Barry Margolin @ 2009-07-09 4:04 UTC (permalink / raw)
To: help-gnu-emacs
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 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: how to temporarily remove a function from a hook?
2009-07-09 4:04 ` Barry Margolin
@ 2009-07-09 11:14 ` Johan Bockgård
0 siblings, 0 replies; 4+ messages in thread
From: Johan Bockgård @ 2009-07-09 11:14 UTC (permalink / raw)
To: help-gnu-emacs
Barry Margolin <barmar@alum.mit.edu> writes:
> Or:
>
> (let ((foo-hook foo-hook))
> (remove-hook 'bar 'foo-hook)
> ...)
>
> This doesn't violate the abstraction of remove-hook.
(add-hook 'foo-hook 'global)
(add-hook 'foo-hook 'local nil t)
(list (default-value 'foo-hook)
foo-hook)
=>
((global) (local t))
(let ((foo-hook foo-hook))
(remove-hook 'foo-hook 'global))
(list (default-value 'foo-hook)
foo-hook)
=>
(nil (local t))
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-07-09 11:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.2124.1247103655.2239.help-gnu-emacs@gnu.org>
2009-07-09 2:42 ` how to temporarily remove a function from a hook? Pascal J. Bourguignon
2009-07-09 4:04 ` Barry Margolin
2009-07-09 11:14 ` Johan Bockgård
2009-07-09 1:40 Kevin Rodgers
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.