all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Modifying a hook while it's being executed
@ 2005-08-08 15:32 PT
  2005-08-08 15:42 ` J. David Boyd
       [not found] ` <mailman.3028.1123516720.20277.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 8+ messages in thread
From: PT @ 2005-08-08 15:32 UTC (permalink / raw)


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.

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Modifying a hook while it's being executed
  2005-08-08 15:32 Modifying a hook while it's being executed PT
@ 2005-08-08 15:42 ` J. David Boyd
       [not found] ` <mailman.3028.1123516720.20277.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 8+ messages in thread
From: J. David Boyd @ 2005-08-08 15:42 UTC (permalink / raw)


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!

Dave

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Modifying a hook while it's being executed
       [not found] ` <mailman.3028.1123516720.20277.help-gnu-emacs@gnu.org>
@ 2005-08-08 18:51   ` rgb
  2005-08-08 20:21     ` kcin
  0 siblings, 1 reply; 8+ messages in thread
From: rgb @ 2005-08-08 18:51 UTC (permalink / raw)



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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Modifying a hook while it's being executed
  2005-08-08 18:51   ` rgb
@ 2005-08-08 20:21     ` kcin
  2005-08-08 20:34       ` Henrik Enberg
       [not found]       ` <mailman.3053.1123533819.20277.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 8+ messages in thread
From: kcin @ 2005-08-08 20:21 UTC (permalink / raw)


rgb wrote:
>
> 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.

Yes, it seems OK. However I wonder why it is not simply

  (setq hook-value (remove function hook-value))
 
remove also returns a copy. Is there a difference?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Modifying a hook while it's being executed
  2005-08-08 20:21     ` kcin
@ 2005-08-08 20:34       ` Henrik Enberg
       [not found]       ` <mailman.3053.1123533819.20277.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 8+ messages in thread
From: Henrik Enberg @ 2005-08-08 20:34 UTC (permalink / raw)
  Cc: help-gnu-emacs

> From: kcin@mytrashmail.com
> Date: 8 Aug 2005 13:21:13 -0700
> 
> rgb wrote:
> >
> > 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.
> 
> Yes, it seems OK. However I wonder why it is not simply
> 
>   (setq hook-value (remove function hook-value))
>  
> remove also returns a copy. Is there a difference?

`remove' is part of the cl library which isn't supposed to be used in
core Emacs.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Modifying a hook while it's being executed
       [not found]       ` <mailman.3053.1123533819.20277.help-gnu-emacs@gnu.org>
@ 2005-08-08 20:55         ` David Kastrup
  2005-08-08 21:08           ` Henrik Enberg
       [not found]           ` <mailman.3058.1123535725.20277.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 8+ messages in thread
From: David Kastrup @ 2005-08-08 20:55 UTC (permalink / raw)


Henrik Enberg <henrik.enberg@telia.com> writes:

>> From: kcin@mytrashmail.com
>> Date: 8 Aug 2005 13:21:13 -0700
>> 
>> rgb wrote:
>> >
>> > 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.
>> 
>> Yes, it seems OK. However I wonder why it is not simply
>> 
>>   (setq hook-value (remove function hook-value))
>>  
>> remove also returns a copy. Is there a difference?
>
> `remove' is part of the cl library which isn't supposed to be used in
> core Emacs.

remove is a compiled Lisp function in `subr'.
(remove ELT SEQ)

Return a copy of SEQ with all occurrences of ELT removed.
SEQ must be a list, vector, or string.  The comparison is done with `equal'.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Modifying a hook while it's being executed
  2005-08-08 20:55         ` David Kastrup
@ 2005-08-08 21:08           ` Henrik Enberg
       [not found]           ` <mailman.3058.1123535725.20277.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 8+ messages in thread
From: Henrik Enberg @ 2005-08-08 21:08 UTC (permalink / raw)


> From: David Kastrup <dak@gnu.org>
> Date: Mon, 08 Aug 2005 22:55:17 +0200
> 
> Henrik Enberg <henrik.enberg@telia.com> writes:
> 
> > `remove' is part of the cl library which isn't supposed to be used in
> > core Emacs.
> 
> remove is a compiled Lisp function in `subr'.
> (remove ELT SEQ)
> 
> Return a copy of SEQ with all occurrences of ELT removed.
> SEQ must be a list, vector, or string.  The comparison is done with `equal'.

doh, I must have been passing through a low flying crack cloud when I
wrote my previous message.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Modifying a hook while it's being executed
       [not found]           ` <mailman.3058.1123535725.20277.help-gnu-emacs@gnu.org>
@ 2005-08-08 21:32             ` David Kastrup
  0 siblings, 0 replies; 8+ messages in thread
From: David Kastrup @ 2005-08-08 21:32 UTC (permalink / raw)


Henrik Enberg <henrik.enberg@telia.com> writes:

>> From: David Kastrup <dak@gnu.org>
>> Date: Mon, 08 Aug 2005 22:55:17 +0200
>> 
>> Henrik Enberg <henrik.enberg@telia.com> writes:
>> 
>> > `remove' is part of the cl library which isn't supposed to be used in
>> > core Emacs.
>> 
>> remove is a compiled Lisp function in `subr'.
>> (remove ELT SEQ)
>> 
>> Return a copy of SEQ with all occurrences of ELT removed.
>> SEQ must be a list, vector, or string.  The comparison is done with `equal'.
>
> doh, I must have been passing through a low flying crack cloud when I
> wrote my previous message.

I would not be terribly surprised if cl had its own keyword-rich
variant of remove.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-08-08 21:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-08 15:32 Modifying a hook while it's being executed PT
2005-08-08 15:42 ` J. David Boyd
     [not found] ` <mailman.3028.1123516720.20277.help-gnu-emacs@gnu.org>
2005-08-08 18:51   ` rgb
2005-08-08 20:21     ` kcin
2005-08-08 20:34       ` Henrik Enberg
     [not found]       ` <mailman.3053.1123533819.20277.help-gnu-emacs@gnu.org>
2005-08-08 20:55         ` David Kastrup
2005-08-08 21:08           ` Henrik Enberg
     [not found]           ` <mailman.3058.1123535725.20277.help-gnu-emacs@gnu.org>
2005-08-08 21:32             ` David Kastrup

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.