From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: idledo.el v. 0.3 Date: 25 Oct 2002 11:11:59 +0200 Sender: emacs-devel-admin@gnu.org Message-ID: <5x8z0mzxuo.fsf@kfs2.cua.dk> References: <87wuobakqz.fsf@computer.localdomain> <5xfzuyqbxo.fsf@kfs2.cua.dk> <874rbduxdf.fsf@computer.localdomain> <5xbs5ljj6s.fsf@kfs2.cua.dk> <87u1jcq1ex.fsf@computer.localdomain> <5xy98ozpfj.fsf@kfs2.cua.dk> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1035533554 15084 80.91.224.249 (25 Oct 2002 08:12:34 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 25 Oct 2002 08:12:34 +0000 (UTC) Cc: deego@gnufans.org, emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 184za4-0003v2-00 for ; Fri, 25 Oct 2002 10:12:32 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 184zce-0005Fk-00 for ; Fri, 25 Oct 2002 10:15:12 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 184zZs-0004OL-00; Fri, 25 Oct 2002 04:12:20 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 184zZU-0003xR-00 for emacs-devel@gnu.org; Fri, 25 Oct 2002 04:11:56 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 184zZS-0003sX-00 for emacs-devel@gnu.org; Fri, 25 Oct 2002 04:11:55 -0400 Original-Received: from mail.filanet.dk ([195.215.206.179]) by monty-python.gnu.org with esmtp (Exim 4.10) id 184zZR-0003qe-00; Fri, 25 Oct 2002 04:11:53 -0400 Original-Received: from kfs2.cua.dk.cua.dk (kfs2.local.filanet.dk [192.168.1.182]) by mail.filanet.dk (Postfix) with SMTP id C2F467C017; Fri, 25 Oct 2002 08:11:50 +0000 (GMT) Original-To: rms@gnu.org In-Reply-To: Original-Lines: 95 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:8770 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:8770 Richard Stallman writes: > IMO, the clean enhancement to timer.el would be to allow REPEAT to be > a number for run-with-idle-timer as well. > > This requires C-level changes, e.g. using the first element of the > > I think this feature can be implemented at the Lisp level, in > timer.el. If we want this to be supported directly in the idle-timers (not having to setup an idle-timer or a pre-command-hook), it requires C level changes! But I agree that it can [and should] be done in lisp [in a way similar to what blink-cursor-mode currently does]. So I suggest the following to changes to timer.el: Change run-with-idle-timer so that: If REPEAT is non-nil, do the action each time Emacs has been idle for exactly SECS seconds. If REPEAT is a number, keep repeating the action every REPEAT seconds as long as emacs remains idle; otherwise, only do the action once for each time Emacs becomes idle. [Implementation: use a list of normal timers (one for each repeating idle hook) similar to blink-cursor-mode, and a pre-command hook which clears that list when emacs is no longer idle]. Add a new function: (timer-idle-timer-first-invocation-p TIMER) which allows an idle-timer action to check whether this is the first invocation of the timer after emacs becoming idle, or a repeated activation. [Implementation: just look at the first element of the timer vector] Add a new hooks: timer-no-longer-idle-hook where users of idle-timers may setup functions to be called when emacs is no longer idle. Functions may be added/removed to this hook once (e.g. when blink-cursor-mode is turned on or off), or it could be added by the idle-timer action (in which case the hook function would be responsible for removing the function from the hook when called). Note: Globally added functions on that hook are called independently of whether the "corresponding" idle-timer was activated or not (there is really no way to associate the function with a specific timer; however, they can use the timer-idle-timer-first-invocation-p function to check whether a specific timer has been activated) [Implementation: Run from the above mentioned pre-command hook.] Note: The pre-command hook is only setup when the first idle-timer is activated, so if no idle-timers have been activated, the timer-no-longer-idle-hook isn't run either! [This may seem a little strange, but from a practical point of view, I think it actually makes good sense, as the intended purpose of the no-longer-idle hook is to be able to clean-up things which were initiated by an idle-timer action. So if no idle-timers were run, there's no reason to run the hook either]. As an example, blink-cursor-mode could then be implemented by just three functions: (defun blink-cursor-mode (arg) ... e.g. to turn it on ...: (setq blink-cursor-idle-timer (run-with-idle-timer blink-cursor-delay blink-cursor-interval ;; OBS: New functionality!!! 'blink-cursor-blink)) (add-hook 'timer-no-longer-idle-hook 'blink-cursor-stop)) (defun blink-cursor-blink () "Toggle blinking cursor." (internal-show-cursor nil (not (internal-show-cursor-p)))) (defun blink-cursor-stop () "Stop cursor blinking." (internal-show-cursor nil t)) -- Kim F. Storm http://www.cua.dk