From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.help Subject: Re: How to use http-get properly in code Date: Mon, 06 Feb 2006 23:59:49 +0100 Organization: sometimes Message-ID: <7e7j88ks9m.fsf@ada2.unipv.it> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1139266931 13321 80.91.229.2 (6 Feb 2006 23:02:11 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 6 Feb 2006 23:02:11 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Feb 07 00:02:01 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1F6FMm-0000Mb-TT for geh-help-gnu-emacs@m.gmane.org; Tue, 07 Feb 2006 00:01:53 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F6FQ7-0007dz-El for geh-help-gnu-emacs@m.gmane.org; Mon, 06 Feb 2006 18:05:19 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsfeed.berkeley.edu!ucberkeley!newsfeed.arcor.de!newsfeed01.sul.t-online.de!t-online.de!news.belwue.de!LF.net!quimby.gnus.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 31 Original-NNTP-Posting-Host: ada2.unipv.it Original-X-Trace: quimby.gnus.org 1139266788 24464 193.204.44.145 (6 Feb 2006 22:59:48 GMT) Original-X-Complaints-To: usenet@quimby.gnus.org Original-NNTP-Posting-Date: Mon, 6 Feb 2006 22:59:48 +0000 (UTC) User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:hAeFrjIC1We4C5u1q7nBgki3rzc= Original-Xref: shelby.stanford.edu gnu.emacs.help:137421 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:33045 Archived-At: Mathias Dahl 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