[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Tue, 10 Feb 2004 18:55:09 +0100
Gnus/5.1002 (Gnus v5.10.2) Emacs/21.2 (gnu/linux)
Stefan Monnier <address@hidden> writes:
> How about not adding another hook but using a function like the one below
> (defun add-hook-once (hook function append local)
> "Same as `add-hook', but FUN is only run once.
> Also contrary to `add-hook', this is not idempotent."
> ;; FIXME: need to check if `function' was already added to the hook.
> (let ((code (list 'lambda)))
> (setcdr code `(() (,function) (remove-hook ',hook ',code ',local)))
> (add-hook hook code append local)))
Ah, good. I had been looking for something like this. I was thinking
about something like
(remove-hook 'compilation-end-hook /myself/))
But didn't find any way to code /myself/.