unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Thien-Thi Nguyen <ttn@glug.org>
Subject: Re: How to use http-get properly in code
Date: Mon, 06 Feb 2006 23:59:49 +0100	[thread overview]
Message-ID: <7e7j88ks9m.fsf@ada2.unipv.it> (raw)
In-Reply-To: m24q3d3axa.fsf@gmail.com

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	other threads:[~2006-02-06 22:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-05 18:41 How to use http-get properly in code Mathias Dahl
2006-02-06 22:59 ` Thien-Thi Nguyen [this message]
2006-02-06 23:23   ` Thien-Thi Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7e7j88ks9m.fsf@ada2.unipv.it \
    --to=ttn@glug.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).