[Top][All Lists]

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

RE: Should `cancel-timer' use `delete' instead of `delq'?

From: Drew Adams
Subject: RE: Should `cancel-timer' use `delete' instead of `delq'?
Date: Tue, 5 Sep 2006 10:36:18 -0700

    > (defvar foo-timer
    >   (progn ; Cancel to prevent ~duplication.
    >     (when (boundp 'foo-timer) (cancel-timer foo-timer))
    >     (run-with-idle-timer 2 t 'foo))
    >   "Timer used to foo whenever Emacs is idle.")

    The traditional way to do something like the above is:

      (defvar foo-timer nil)
      (define-minor-mode foo "blala" :toto 1 :titi 0
        (when foo-timer
          (cancel foo-timer)
          (setq foo-timer nil))
        (when foo-mode
          (setq foo-timer (run-with-idle-timer 5 t 'foo-fun))))

OK. I'm not sure why that's better, but it does seem to move a little toward
the direction I was suggesting with a `define-idle-timer' macro.

If we expect users to do this kind of thing (either my defvar or your
define-minor-mode), then don't we need to suggest it to them? IOW, wouldn't
it be worth documenting your "traditional" way? Better yet, wouldn't it be
worth creating a specific macro like `define-idle-timer' to do that for

reply via email to

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