From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.devel Subject: Re: with-url Date: Thu, 29 Dec 2016 17:35:07 +0100 Message-ID: <87mvfeg0ck.fsf@gnus.org> References: <87mvffva75.fsf@gnus.org> <8360m2vhze.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1483029381 16676 195.159.176.226 (29 Dec 2016 16:36:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 29 Dec 2016 16:36:21 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 29 17:36:16 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cMdgd-0003kK-LK for ged-emacs-devel@m.gmane.org; Thu, 29 Dec 2016 17:36:15 +0100 Original-Received: from localhost ([::1]:36317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMdgi-0006Oz-CV for ged-emacs-devel@m.gmane.org; Thu, 29 Dec 2016 11:36:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMdft-0006Oi-Ew for emacs-devel@gnu.org; Thu, 29 Dec 2016 11:35:30 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cMdfq-0002Jb-BY for emacs-devel@gnu.org; Thu, 29 Dec 2016 11:35:29 -0500 Original-Received: from hermes.netfonds.no ([80.91.224.195]:45386) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cMdfq-0002HP-51; Thu, 29 Dec 2016 11:35:26 -0500 Original-Received: from 2.150.52.7.tmi.telenormobil.no ([2.150.52.7] helo=mouse) by hermes.netfonds.no with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1cMdfe-0000j2-99; Thu, 29 Dec 2016 17:35:16 +0100 In-Reply-To: <8360m2vhze.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 29 Dec 2016 18:05:09 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 80.91.224.195 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:210958 Archived-At: Eli Zaretskii 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