[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: moy-compilation-schedule-execute.el
From: |
Matthieu Moy |
Subject: |
Re: moy-compilation-schedule-execute.el |
Date: |
Tue, 10 Feb 2004 18:55:09 +0100 |
User-agent: |
Gnus/5.1002 (Gnus v5.10.2) Emacs/21.2 (gnu/linux) |
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> How about not adding another hook but using a function like the one below
> instead?
>
> (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
(defun f()
(do something)
(remove-hook 'compilation-end-hook /myself/))
But didn't find any way to code /myself/.
--
Matthieu