all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Stuart D. Herring" <herring@lanl.gov>
Cc: emacs-devel@gnu.org
Subject: Re: Should `cancel-timer' use `delete' instead of `delq'?
Date: Tue, 5 Sep 2006 12:13:43 -0700 (PDT)	[thread overview]
Message-ID: <33709.128.165.123.18.1157483623.squirrel@webmail.lanl.gov> (raw)
In-Reply-To: <MEEKKIABFKKDFJMPIOEBAELKDEAA.drew.adams@oracle.com>

> If, on the other hand, the use of delq in `cancel-timer' is unintentional
> and is not needed, then perhaps delete should be used instead of delq, so
> that all timers with the same parameters are cancelled at once.

Others have talked about the philosophy of timers, but let me point out
that this particular idea wouldn't work anyway.  Evaluate this to see why:

(let ((ts (list (run-with-timer 1.2 1 'ignore)
                (progn (sit-for 0.2) (run-with-timer 1.2 1 'ignore)))))
  (message "%s" ts)
  (prog1 (equal (car ts) (cadr ts))
    (mapcar 'cancel-timer ts)))

Because the precise timing of a timer (especially a repeating one) depends
on when it was created and how much time has since elapsed, the internal
representation of a timer cannot be merely its invocation parameters (and
in fact loses the delay argument, because a timer delayed by 10s started
9s ago looks the same as one delayed by 1s started now).  So "similar"
timers aren't necessarily `equal', and not all timers that are `equal'
were created with a call to `run-with-timer' with the same arguments. 
(Some may have been generated with `timer-create' directly!)  In other
words, we use `eq' because using `equal' doesn't work (although there are
obviously other implementations that could support such a practice).

Perhaps what you want is `cancel-function-timers'?  Certainly for testing
it's quite useful.  You could also just store some "mundane" value of
`timer-list' somewhere and restore it instead of specifically cancelling
anything.

Hope this helps,
Davis

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.

  parent reply	other threads:[~2006-09-05 19:13 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-05  0:14 Should `cancel-timer' use `delete' instead of `delq'? Drew Adams
2006-09-05  1:44 ` Miles Bader
2006-09-05 15:38   ` Stefan Monnier
2006-09-05 16:20     ` Drew Adams
2006-09-05 17:22       ` Stefan Monnier
2006-09-05 17:36         ` Drew Adams
2006-09-05 20:46           ` Kevin Rodgers
2006-09-05 21:24             ` Drew Adams
2006-09-06  1:11               ` Miles Bader
2006-09-06  2:09                 ` Drew Adams
2006-09-06  2:38                   ` Miles Bader
2006-09-06  6:31                     ` Drew Adams
2006-09-06  6:48                       ` Miles Bader
2006-09-06  7:29                       ` David Kastrup
2006-09-06 14:00                       ` Stefan Monnier
2006-09-06 15:27                         ` Drew Adams
2006-09-06  6:38                   ` David Kastrup
2006-09-05 21:56     ` David Kastrup
2006-09-06  0:59       ` Stefan Monnier
2006-09-06 19:05     ` Richard Stallman
2006-09-05 19:13 ` Stuart D. Herring [this message]
2006-09-05 19:22   ` Drew Adams
2006-09-06  8:49 ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=33709.128.165.123.18.1157483623.squirrel@webmail.lanl.gov \
    --to=herring@lanl.gov \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.