unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: with-url
Date: Thu, 29 Dec 2016 17:35:07 +0100	[thread overview]
Message-ID: <87mvfeg0ck.fsf@gnus.org> (raw)
In-Reply-To: <8360m2vhze.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 29 Dec 2016 18:05:09 +0200")

Eli Zaretskii <eliz@gnu.org> writes:

>>   (with-url (headers "http://fsf.org/")
>>     (message "The size of the FSF front page is %s" (buffer-size)))
>
> I'm probably missing something, but why do you need a macro?  The
> description seems to say that BODY is executed with point in a buffer
> with the response, so why not just set up that buffer and return with
> it as the current buffer?

The body is executed synchronously or as a callback later, depending on
whether you put a :wait t in the parameter list or not.  I don't see how
that's possibly without using a macro.  (I mean, without radically
rewriting the call if you want a synchronous/asynchronous execution.)

> As for the syntax, this macro looks unusual to me, certainly wrt other
> with-SOMETHING macros, in that it accepts a list of arguments of
> variable length and contents.  But that's me.

We haven't done that much in Emacs Lisp, but it's a common idiom in
Common Lisp, and I think it's kinda nice.

  (with-open-file (s "/tmp/foo"
                   :direction :output
                   :if-exists :rename)
    (princ :foo s))

> A few comments to the doc string:
>
>> :headers ALIST
>> Add ALIST to the headers sent over to the server.  This should typically
>> look like
>> 
>>   (("User-Agent" "Emacs"))
>
> What about unibyte/multibyte issue in the headers?  Should that be
> encoded by the caller?

I think that question is answered by your next comment?  :-)

>> Additional elements in this alist are interpreted as the
>> charset (defaulting to utf-8) and the encoding method (defaulting
>> to url-encode).
>
> Please don't use "charset" when you really mean "coding-system".  In
> Emacs parlance, "charset" means something very different (and "utf-8"
> is not a charset in that meaning), so this will spread confusion.

True, I'll reword that.

> Also, why should the default be UTF-8?  Isn't the system locale's
> codeset a better default?  The URL doesn't have to be on another
> machine, right?

No, but utf-8 is the normal default in network communication these days.

>> :method GET/POST/etc
>> The method to use for retrieving an HTTP(S) resource.  This defaults
>> to GET, and other popular values are POST, UPDATE and PUT.
>
> Does thus mean this macro is only for HTTP/HTTPS?

No, it'll work for file: and ftp:, too.  I should probably group the
HTTP(S)-only options.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



  reply	other threads:[~2016-12-29 16:35 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-29  0:41 with-url Lars Ingebrigtsen
2016-12-29  1:06 ` with-url Stefan Monnier
2016-12-29  1:12   ` with-url Lars Ingebrigtsen
2016-12-29 16:05 ` with-url Eli Zaretskii
2016-12-29 16:35   ` Lars Ingebrigtsen [this message]
2016-12-29 16:40     ` with-url Lars Ingebrigtsen
2016-12-29 16:58       ` with-url Eli Zaretskii
2016-12-29 18:52         ` with-url Lars Ingebrigtsen
2016-12-29 20:31           ` with-url Eli Zaretskii
2016-12-30 14:12             ` with-url Lars Ingebrigtsen
2016-12-30 15:23               ` with-url Lars Ingebrigtsen
2016-12-30 16:58               ` with-url Eli Zaretskii
2017-01-21 15:31         ` with-url Lars Ingebrigtsen
2017-01-21 15:33           ` with-url Lars Ingebrigtsen
2017-01-21 15:54           ` with-url Eli Zaretskii
2017-01-21 16:32             ` with-url Lars Ingebrigtsen
2017-01-21 16:40               ` with-url Eli Zaretskii
2017-01-22 15:55                 ` with-url Lars Ingebrigtsen
2017-01-22 16:39                   ` with-url Eli Zaretskii
2016-12-29 16:53     ` with-url Eli Zaretskii
2016-12-29 18:48       ` with-url Lars Ingebrigtsen
2017-01-01  1:07 ` with-url Dmitry Gutov
2017-01-03 17:47   ` with-url Stefan Monnier
2017-01-26 23:00     ` with-url Ted Zlatanov
2017-01-26 23:08       ` with-url Lars Ingebrigtsen
2017-01-27 13:49         ` with-url Ted Zlatanov
2017-01-21 15:44   ` with-url Lars Ingebrigtsen
2017-01-21 20:26     ` with-url Dmitry Gutov
2017-01-21 20:32       ` with-url Lars Ingebrigtsen
2017-01-21 20:36         ` with-url Dmitry Gutov
2017-01-21 20:49           ` with-url Lars Ingebrigtsen
2017-01-21 21:05             ` with-url Dmitry Gutov
2017-01-21 21:12               ` with-url Lars Ingebrigtsen
2017-01-21 21:16                 ` with-url Dmitry Gutov
2017-01-21 21:23                   ` with-url Lars Ingebrigtsen
2017-01-21 21:27                     ` with-url Dmitry Gutov
2017-01-21 21:37                       ` with-url Lars Ingebrigtsen
2017-01-21 21:54                         ` with-url Dmitry Gutov
2017-01-21 22:07                           ` with-url Lars Ingebrigtsen
2017-01-22 12:14                             ` with-url Yuri Khan
2017-01-22 14:46                               ` with-url Lars Ingebrigtsen
2017-01-22 15:13                                 ` with-url Dmitry Gutov
2017-01-22 16:36                                   ` with-url Eli Zaretskii
2017-01-22 21:27                                     ` with-url Dmitry Gutov
2017-01-22 14:22                             ` with-url Dmitry Gutov
2017-01-22 14:42                               ` with-url Lars Ingebrigtsen
2017-01-21 20:34       ` with-url Lars Ingebrigtsen
2017-01-21 20:38         ` with-url Dmitry Gutov
2017-01-21 20:48           ` with-url Lars Ingebrigtsen
2017-01-21 22:25       ` with-url John Mastro
2017-01-22 16:04 ` with-url Lars Ingebrigtsen
2017-01-22 16:42   ` with-url Eli Zaretskii
2017-01-22 16:55     ` with-url Lars Ingebrigtsen
2017-01-22 23:56   ` not with-url Richard Stallman

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=87mvfeg0ck.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=eliz@gnu.org \
    --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 public inbox

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

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).