unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* problems with idle timers
@ 2004-06-17  9:34 Phillip Lord
  2004-07-01 10:31 ` Kai Grossjohann
  0 siblings, 1 reply; 3+ messages in thread
From: Phillip Lord @ 2004-06-17  9:34 UTC (permalink / raw)






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
sometimes. 


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
repeatedly. 


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)
      (save-window-excursion
        (lazy-desktop-open-next-buffer))
      (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
count? 

And is there any way around this? 

Cheers

Phil

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: problems with idle timers
  2004-06-17  9:34 problems with idle timers Phillip Lord
@ 2004-07-01 10:31 ` Kai Grossjohann
  2004-07-01 11:49   ` Kai Grossjohann
  0 siblings, 1 reply; 3+ messages in thread
From: Kai Grossjohann @ 2004-07-01 10:31 UTC (permalink / raw)


Phillip Lord <p.lord@russet.org.uk> writes:

> 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. 

This appears to be the result of passing t for REPEAT: it will run
the idle timer only once for each time Emacs is idle.

But I don't grok the docs, so I don't know what happens when passing
nil.

Kai

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: problems with idle timers
  2004-07-01 10:31 ` Kai Grossjohann
@ 2004-07-01 11:49   ` Kai Grossjohann
  0 siblings, 0 replies; 3+ messages in thread
From: Kai Grossjohann @ 2004-07-01 11:49 UTC (permalink / raw)


Kai Grossjohann <kai@emptydomain.de> writes:

> Phillip Lord <p.lord@russet.org.uk> writes:
>
>> 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. 
>
> This appears to be the result of passing t for REPEAT: it will run
> the idle timer only once for each time Emacs is idle.
>
> But I don't grok the docs, so I don't know what happens when passing
> nil.

Ah, now I understand.  Hm.  Passing nil for REPEAT is even worse, as
it will run the function only once.  Hm.

Kai

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-07-01 11:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-17  9:34 problems with idle timers Phillip Lord
2004-07-01 10:31 ` Kai Grossjohann
2004-07-01 11:49   ` Kai Grossjohann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).