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

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

Re: Modifying a hook while it's being executed


From: rgb
Subject: Re: Modifying a hook while it's being executed
Date: 8 Aug 2005 11:51:47 -0700
User-agent: G2/0.2

J. David Boyd wrote:
> PT <mailshield.gg@mailnull.com> writes:
>
> > Is it safe? I haven't seen it anywhere stated explicitly.
> >
> > For example, I add a hook function to pre-command-hook or
> > post-command-hook which removes itself from the hook when invoked.
> >
>
> Does it blow up emacs?  If not, then it is probably safe!

At first I thought something similar, but that's not really
a valid way to view the problem.  If something else runs a
hook that would normally execute after the one you are removing
there is a potential for other hooks not to run on that command.
Something like that would not likely manifest itself in a
catastrophic way but could cause unusual behaviors that a
conscientious coder would want to avoid.

This line appears in remove-hook.

(setq hook-value (delete function (copy-sequence hook-value)))

It makes me think that a change to the hook's value will not
be visible to the present execution of the run-hooks command.
So I'd say it appears to be perfectly safe.



reply via email to

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