[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Nicer way to wake sit-for up?
From: |
David Kastrup |
Subject: |
Re: Nicer way to wake sit-for up? |
Date: |
Thu, 08 Jun 2006 17:34:04 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
no-spam@cua.dk (Kim F. Storm) writes:
> spamfilteraccount@gmail.com writes:
>
>> I have a code where the command loop executes a command which is
>> waiting for arriving data with sit-for. When the data arrives from the
>> network a callback is invoked and I wake sit-for up with a dummy event
>> like this:
>>
>> the callback:
>>
>> ...
>> (setq unread-command-events (cons 'data-arrived
>> unread-command-events))
>> ...
>>
>
> I can't think of a better way here, but you can just write
>
> (push 'data-arrived unread-command-events)
>>
>> ...
>> (sit-for 5)
>> (if (eq (car unread-command-events) 'data-arrived)
>> (setq unread-command-events (cdr unread-command-events)))
>> ...
>
> You could arrange for the data-arrived event to be ignored, e.g.
>
> (define-key global-map [data-arrived] 'ignore)
>
>
>
> Perhaps, you could use ignore instead of data-arrived, i.e.
>
> (define-key global-map [ignore] 'ignore)
>
> and
>
> (push 'ignore unread-command-events)
Maybe (push 'mouse-movement unread-command-events) would do the trick?
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum