[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

problems with idle timers

From: Phillip Lord
Subject: problems with idle timers
Date: 17 Jun 2004 10:34:25 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.93

I have a problem with getting the idle timers to work properly. I've
just written a package which runs desktop.el in the idle timer. This
is nice because it can take a long time for the desktop to open

I start a timer up like this...

(setq lazy-desktop-timer
          (run-with-idle-timer 5 t 'lazy-desktop-idle-timer))

which waits for 5 seconds into the idle cycle and then runs

This runs the following function...

(defun lazy-desktop-idle-timer()
  "Loop run in idle.
Open up some more buffers, until the user does something, then stop.
If there are no buffers left to open, then stop, kill the timer,
and thats it."
  (let ((repeat 1))
    (while (and repeat lazy-desktop-create-buffer-stack)
      (setq repeat (sit-for 0.2)))
    (unless lazy-desktop-create-buffer-stack
      (message "Lazy desktop load complete")
      (sit-for 3)
      (message "")
      (cancel-timer lazy-desktop-timer))))

which iterates through all of the buffers to be opened. Eventually
when all the buffers are open it cancels the timer. 

So good so far. This has pretty much the behaviour I want. But there
is problem. While the timer works mostly as I want, and stops when I
do anything to Emacs, I notice that it sometimes gets stuck. So I'll
go and make some tea, and the idle timer will not have started
again. If I do something with emacs and then let it idle generally the
timer will start again happily. 

Are there any circumstances which the timer will not run properly
following an idle? Are there ways in which the "(sit-for 0.2)" will
return false (which will stop the loop) but not restart the idle timer

And is there any way around this? 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]