all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ted Zlatanov <tzz@lifelogs.com>
To: emacs-devel@gnu.org
Subject: Re: more url-utils?
Date: Tue, 17 May 2011 17:26:15 -0500	[thread overview]
Message-ID: <87mxilezg8.fsf@lifelogs.com> (raw)
In-Reply-To: 87fwogaxzb.fsf@stupidchicken.com

On Tue, 17 May 2011 00:04:50 -0300 Stefan Monnier <monnier@iro.umontreal.ca> wrote: 

>> Ah, OK.  So my proposal does not fit because you want backwards
>> compatibility.

SM> I think that's right, although I'm not completely clear on what is
SM> exactly your proposal.

This is my proposal, after thinking about it for a bit.

Current top-level API:

Dynamic binding: `url-request-data', `url-request-method' and
`url-request-extra-headers' according to the docstring; also according
to a comment: url-standalone-mode, url-gateway-unplugged,
w3-honor-stylesheets, url-confirmation-func, url-cookie-multiple-line,
url-cookie-{{,secure-}storage,confirmation}.

(defun url-retrieve (url callback &optional cbargs silent) ...)
(defun url-retrieve-synchronously (url) ...)

Both of these result in a buffer containing

"[HEADERS]

[BODY]"

Proposed API (based on code review throughout Emacs and my feeling for
what would be "natural" in ELisp):

;;; buffer-local variables: url-retrieved-ok url-headers-alist url-headers-as-string
(defmacro with-url-contents-buffer (url url-options-alist callback-closure &rest body)
...)

1) Synchronous usage with errors:

(with-url-contents-buffer "http://host" '((url-request-method "POST")) nil
  (message "this will run SYNCHRONOUSLY since the callback-closure is nil")
  (message "this could throw an error")
  (message "Header x is %s" (assq 'x url-headers-alist))
  (message "Header y is %s" (assoc "y" url-headers-alist))
  (message "The headers as a string are %s" url-headers-as-string)
  (when url-retrieved-ok (message "The retrieval went fine"))
  (message "data is %s" (buffer-string))

2) Synchronous usage without errors:

(with-url-contents-buffer "http://host" '((url-request-method "POST")) 'noerror
  (message "this will run SYNCHRONOUSLY since the callback-closure is nil")
  (message "this will not throw an error"))

3) Asynchronous usage with a callback (`url-headers-alist',
`url-headers-as-string', and `url-retrieved-ok' are still available):

(with-url-contents-buffer "http://host" '((url-request-method "POST")) callback-closure
  (message "this will run AFTER the retrieval and the callback-closure are done"))

4) Asynchronous usage with no callback (`url-headers-alist',
`url-headers-as-string', and `url-retrieved-ok' are still available):

(with-url-contents-buffer "http://host" '((url-request-method "POST")) t
  (message "this will run AFTER the retrieval is done, there is no callback"))

Implicitly we don't have an asynchronous mode that throws errors.

I also think we should have an incremental mode where each retrieved
chunk is given to the callback in the buffer as it arrives.  That would
let us handle large downloads better.  The API would not change, though,
only the `url-options-alist' would have a `url-incremental' key and the
callback would look at the buffer-local variable
`url-incremental-byte-offset'.

SM> If you can provide a patch that give us a clean new API together with
SM> some backward compatibility layer, that would be great.

After we've settled on the API, please.  I think the above may be too
different for many :)

Ted




  reply	other threads:[~2011-05-17 22:26 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-14 10:32 more url-utils? joakim
2011-05-14 11:21 ` Lars Magne Ingebrigtsen
2011-05-14 11:42   ` joakim
2011-05-15  1:59     ` Lars Magne Ingebrigtsen
2011-05-14 20:42   ` Dimitri Fontaine
2011-05-15 14:26   ` Jason Rumney
2011-05-16 18:25     ` Ted Zlatanov
2011-05-16 19:03       ` Stefan Monnier
2011-05-16 19:17         ` Ted Zlatanov
2011-05-16 19:22           ` Lennart Borgman
2011-05-16 19:32             ` Ted Zlatanov
2011-05-16 19:33               ` Lennart Borgman
2011-05-16 19:55                 ` Ted Zlatanov
2011-05-16 19:52               ` Julien Danjou
2011-05-16 20:18                 ` Ted Zlatanov
2011-05-17  3:04                   ` Stefan Monnier
2011-05-17  8:13                   ` Julien Danjou
2011-05-16 19:53           ` Stefan Monnier
2011-05-16 21:07             ` joakim
2011-05-16 21:18               ` Ted Zlatanov
2011-05-16 21:21                 ` Lennart Borgman
2011-05-16 21:58                 ` joakim
2011-05-17 11:40             ` Lars Magne Ingebrigtsen
2011-05-17 13:34               ` Stefan Monnier
2011-05-14 13:21 ` Ted Zlatanov
2011-05-16 13:15   ` Stefan Monnier
2011-05-16 15:19     ` Tom Tromey
2011-05-16 15:45       ` Stefan Monnier
2011-05-16 17:04       ` joakim
2011-05-16 17:17         ` Lennart Borgman
2011-05-16 17:30         ` Stefan Monnier
2011-05-16 18:39         ` Julien Danjou
2011-05-15 13:34 ` Chong Yidong
2011-05-17 22:26   ` Ted Zlatanov [this message]
2011-05-18  0:11     ` Stefan Monnier
2011-05-18  2:14       ` Ted Zlatanov
2011-05-18 12:16         ` Stefan Monnier
2011-05-18 13:44           ` Ted Zlatanov
2011-05-18 14:09             ` Stefan Monnier
2011-05-18 14:43               ` Ted Zlatanov
2011-05-18 22:05                 ` Stefan Monnier
2011-05-19  1:57                   ` Ted Zlatanov
2011-05-19  2:28                     ` Stefan Monnier
2011-05-19 10:28                       ` Ted Zlatanov
2011-05-19 11:53                         ` Stefan Monnier
2011-05-19 12:43                           ` Ted Zlatanov
2011-05-19 13:28                             ` Stefan Monnier
2011-05-19 13:35                               ` Ted Zlatanov
2011-05-30 17:31                               ` Lars Magne Ingebrigtsen
2011-05-30 19:09                                 ` Stefan Monnier
2011-05-30 19:38                                   ` Lars Magne Ingebrigtsen
2011-05-30 22:17                                     ` Stefan Monnier
2011-05-30 23:11                                       ` Lars Magne Ingebrigtsen
2011-05-31  1:26                                         ` Stefan Monnier
2011-05-31 10:15                                           ` Lars Magne Ingebrigtsen
2011-05-31 12:45                                             ` Stefan Monnier
2011-05-31 18:38                                               ` Lars Magne Ingebrigtsen
2011-05-19 14:11                             ` joakim
2011-05-19 14:40                               ` Stefan Monnier
2011-05-19 13:46                   ` ELisp futures and continuations/coroutines (was: more url-utils?) Ted Zlatanov
2011-05-19 14:15                     ` ELisp futures and continuations/coroutines Stefan Monnier
2011-05-19 14:16                     ` joakim
2011-05-19 15:24                       ` Ted Zlatanov
2011-05-19 15:09                     ` Thien-Thi Nguyen
2011-05-19 15:31                       ` Ted Zlatanov
2011-05-19 16:40                         ` Thien-Thi Nguyen
2011-05-19 23:48                           ` Ted Zlatanov
2011-05-20  1:23                             ` Thien-Thi Nguyen
2011-05-20  4:18                               ` Mohsen BANAN
2011-05-20 15:30                                 ` Ted Zlatanov
2011-05-20 15:29                               ` Ted Zlatanov
2011-05-22 13:17                                 ` Thien-Thi Nguyen
2011-05-23 14:24                                   ` Ted Zlatanov
2011-05-23 14:59                                     ` Stefan Monnier
2011-05-23 15:10                                       ` Ted Zlatanov
2011-05-23 15:42                                         ` SAKURAI Masashi
2011-05-25  2:07                                           ` Ted Zlatanov
2011-05-26  0:23                                             ` SAKURAI Masashi
2011-06-03 13:59                                             ` SAKURAI Masashi
2011-06-03 16:06                                               ` Ted Zlatanov
2011-06-04  6:21                                                 ` SAKURAI Masashi
2011-06-29  5:31                                                 ` SAKURAI Masashi
2011-06-29 12:01                                                   ` Ted Zlatanov
2011-06-29 17:33                                                     ` SAKURAI Masashi
2011-06-29 16:09                                                   ` Chong Yidong
2011-05-23 15:45                                         ` Stefan Monnier
2011-05-25  2:02                                           ` Ted Zlatanov
2011-05-31 10:53                                             ` Ted Zlatanov
2011-05-31 16:55                                               ` Ted Zlatanov
2011-05-19 17:03                     ` ELisp futures and continuations/coroutines (was: more url-utils?) SAKURAI Masashi
2011-05-19 22:51                       ` ELisp futures and continuations/coroutines Ted Zlatanov
2011-05-20 15:49                         ` SAKURAI Masashi
2011-05-25  2:17                           ` Ted Zlatanov

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

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

  git send-email \
    --in-reply-to=87mxilezg8.fsf@lifelogs.com \
    --to=tzz@lifelogs.com \
    --cc=emacs-devel@gnu.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.