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: Tue, 05 Sep 2006 13:22:17 -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 1157476985 13205 80.91.229.2 (5 Sep 2006 17:23:05 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 5 Sep 2006 17:23:05 +0000 (UTC) Cc: Emacs-Devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 05 19:23:02 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 1GKedC-0007ov-Fi for ged-emacs-devel@m.gmane.org; Tue, 05 Sep 2006 19:22:38 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GKedB-0007hf-L4 for ged-emacs-devel@m.gmane.org; Tue, 05 Sep 2006 13:22:37 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GKed1-0007hP-Ii for emacs-devel@gnu.org; Tue, 05 Sep 2006 13:22:27 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GKecz-0007hD-I2 for emacs-devel@gnu.org; Tue, 05 Sep 2006 13:22:26 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GKecz-0007hA-Dj for emacs-devel@gnu.org; Tue, 05 Sep 2006 13:22:25 -0400 Original-Received: from [132.204.24.67] (helo=mercure.iro.umontreal.ca) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GKenm-00049i-9e for emacs-devel@gnu.org; Tue, 05 Sep 2006 13:33:34 -0400 Original-Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca [132.204.27.50]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id A21BD2CEA99; Tue, 5 Sep 2006 13:22:24 -0400 (EDT) Original-Received: from faina.iro.umontreal.ca (faina.iro.umontreal.ca [132.204.26.177]) by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id 05C763FE0; Tue, 5 Sep 2006 13:22:18 -0400 (EDT) Original-Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id E860E4C6D25; Tue, 5 Sep 2006 13:22:17 -0400 (EDT) Original-To: "Drew Adams" In-Reply-To: (Drew Adams's message of "Tue, 5 Sep 2006 09:20:43 -0700") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-2.82, requis 5, autolearn=not spam, ALL_TRUSTED -2.82) X-DIRO-MailScanner-From: monnier@iro.umontreal.ca 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:59382 Archived-At: > (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)))) -- Stefan