help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How to use http-get properly in code


From: Thien-Thi Nguyen
Subject: Re: How to use http-get properly in code
Date: Mon, 06 Feb 2006 23:59:49 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Mathias Dahl <brakjoller@gmail.com> writes:

> ;; The sentinel
> (defun ef-http-get-sentinel (proc message)
>   (save-excursion
>     (set-buffer (process-buffer proc))
>     (setq ef-response-xml
>           (xml-parse-region (point-min) (point-max)))))

you are confusing a sentinel and a process output filter.
the former is called on changes to process state (e.g., hangup).
this function (above) is an example of the latter.

> How do I get around this? I have been thinking about adding a
> loop that waits for some flag that the sentinel sets when it has
> fetched the data, and then when the flag is found to be true,
> continue with the code, but that feels ugly.

that approach makes the code behave synchronously, which is what
you want.  (it's ok to want "ugly" yet useful things, sometimes.)
see `gnugo-synchronous-send/return' in gnugo.el, somewhere under:

  http://www.glug.org/people/ttn/software/personal-elisp/

for an example.  there are lots of synchronous examples, but fewer
asynchronous ones, because doing asynchronous right is more hairy.
see the page beginning with "GNU Go vs GNU Go" in gnugo-extra.el
(also under the aforementioned directory) for an example of
classic(ish) asynchronous design.

thi


reply via email to

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