From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: Should `cancel-timer' use `delete' instead of `delq'? Date: Tue, 5 Sep 2006 10:36:18 -0700 Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1157477831 16179 80.91.229.2 (5 Sep 2006 17:37:11 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 5 Sep 2006 17:37:11 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 05 19:37:09 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 1GKeqs-0002dg-69 for ged-emacs-devel@m.gmane.org; Tue, 05 Sep 2006 19:36:46 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GKeqr-0005vZ-MP for ged-emacs-devel@m.gmane.org; Tue, 05 Sep 2006 13:36:45 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GKeqg-0005v3-Hp for emacs-devel@gnu.org; Tue, 05 Sep 2006 13:36:34 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GKeqe-0005uW-UV for emacs-devel@gnu.org; Tue, 05 Sep 2006 13:36:34 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GKeqe-0005uT-Pw for emacs-devel@gnu.org; Tue, 05 Sep 2006 13:36:32 -0400 Original-Received: from [148.87.113.118] (helo=rgminet01.oracle.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.52) id 1GKf1R-0005pS-LU for emacs-devel@gnu.org; Tue, 05 Sep 2006 13:47:41 -0400 Original-Received: from rgmsgw02.us.oracle.com (rgmsgw02.us.oracle.com [138.1.186.52]) by rgminet01.oracle.com (Switch-3.1.6/Switch-3.1.6) with ESMTP id k85HaTl4017988 for ; Tue, 5 Sep 2006 11:36:30 -0600 Original-Received: from dradamslap (dhcp-amer-csvpn-gw2-141-144-74-150.vpn.oracle.com [141.144.74.150]) by rgmsgw02.us.oracle.com (Switch-3.1.7/Switch-3.1.7) with SMTP id k85HaTJv004014 for ; Tue, 5 Sep 2006 11:36:29 -0600 Original-To: "Emacs-Devel" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-Reply-To: Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-Whitelist: TRUE 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:59383 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)))) 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 them?