From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Should `cancel-timer' use `delete' instead of `delq'? Date: Wed, 06 Sep 2006 10:00:44 -0400 Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1157551297 10168 80.91.229.2 (6 Sep 2006 14:01:37 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 6 Sep 2006 14:01:37 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 06 16:01:35 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GKxxb-00014I-SQ for ged-emacs-devel@m.gmane.org; Wed, 06 Sep 2006 16:01:00 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GKxxb-0004S4-JK for ged-emacs-devel@m.gmane.org; Wed, 06 Sep 2006 10:00:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GKxxO-0004P4-Oo for emacs-devel@gnu.org; Wed, 06 Sep 2006 10:00:46 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GKxxO-0004NC-0h for emacs-devel@gnu.org; Wed, 06 Sep 2006 10:00:46 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GKxxN-0004MW-Q5 for emacs-devel@gnu.org; Wed, 06 Sep 2006 10:00:45 -0400 Original-Received: from [209.226.175.93] (helo=tomts36-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GKxxX-0005x1-En for emacs-devel@gnu.org; Wed, 06 Sep 2006 10:00:55 -0400 Original-Received: from localhost ([70.55.145.157]) by tomts36-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20060906140044.HMJV13653.tomts36-srv.bellnexxia.net@localhost>; Wed, 6 Sep 2006 10:00:44 -0400 Original-Received: by localhost (Postfix, from userid 20848) id 8F8A28CFC; Wed, 6 Sep 2006 10:00:44 -0400 (EDT) Original-To: "Drew Adams" In-Reply-To: (Drew Adams's message of "Tue, 5 Sep 2006 23:31:10 -0700") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:59446 Archived-At: > Well, I think that's exactly what I used in my defvar (after having been > bitten once), so I could henceforth re-eval it ("abnormally") without worry > or forethought. In any case, the "traditional" way to do that is apparently > to use `define-minor-mode'... The traditional example I showed is not exempt from the OP. When you re-evaluate the defvar with C-M-x, the timer var is forcefully reset to nil, thus potentially forgetting a running timer, which then becomes again difficult to stop. Maybe you did realize that, but I got the feeling that you thought it didn't suffer from this problem. And the same thing could/would happen if you use `timer-create'. The problem is not how you define/create your timer, but simply the fact that if you "forget" your timer object, it'll still be active as long as it's in the timer-list. One way to "solve" this problem is to change C-M-x so that in the case the variable's current value is a timer, it first cancels it, before resetting the var. Similarly to my "recent" patch which cancels timers when unloading a package. Stefan