emacs-devel
[Top][All Lists]
Advanced

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

Re: Delayed warnings


From: martin rudalics
Subject: Re: Delayed warnings
Date: Tue, 22 Mar 2011 08:59:23 +0100
User-agent: Thunderbird 2.0.0.21 (Windows/20090302)

> Or you could have your C code all `add-hook-once' on post-command-hook
> which would be a new function that adds a function onto a hook such that
> the function is only run once and then automatically removed.
> Something like:
>
>    (defun add-hook-once (hook function &optional 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)))

When there's a bug in `post-command-hook' and that hook gets cleared we
won't be able to display any warnings.  In particular, those about what
just happened in the `post-command-hook'.

The idea of `add-hook-once' itself sounds good but could be also done -
symmetrically to `run-with-idle-timer' - with an optional REPEAT
argument for `add-hook'.  Obviously, any function called in a hook could
easily remove itself in the call.

martin



reply via email to

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