From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: joakim@verona.se Newsgroups: gmane.emacs.devel Subject: Re: more url-utils? Date: Mon, 16 May 2011 19:04:25 +0200 Message-ID: References: <8739khju46.fsf@lifelogs.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1305565484 23930 80.91.229.12 (16 May 2011 17:04:44 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 16 May 2011 17:04:44 +0000 (UTC) Cc: Ted Zlatanov , Stefan Monnier , emacs-devel@gnu.org To: Tom Tromey Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon May 16 19:04:40 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QM1Dj-0002v0-CF for ged-emacs-devel@m.gmane.org; Mon, 16 May 2011 19:04:39 +0200 Original-Received: from localhost ([::1]:53678 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QM1Di-0006OD-Ex for ged-emacs-devel@m.gmane.org; Mon, 16 May 2011 13:04:38 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:47932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QM1Df-0006NX-NV for emacs-devel@gnu.org; Mon, 16 May 2011 13:04:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QM1De-00058F-JG for emacs-devel@gnu.org; Mon, 16 May 2011 13:04:35 -0400 Original-Received: from batman.blixtvik.net ([87.96.254.3]:48324) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QM1De-00056l-EM for emacs-devel@gnu.org; Mon, 16 May 2011 13:04:34 -0400 Original-Received: from www.verona.se (3-208-96-87.cust.blixtvik.se [87.96.208.3]) by batman.blixtvik.net (Postfix) with ESMTP id D7E8C7F9041; Mon, 16 May 2011 19:04:25 +0200 (CEST) Original-Received: from chopper (unknown [192.168.201.6]) by www.verona.se (Postfix) with ESMTP id 83650A890C8; Mon, 16 May 2011 19:04:25 +0200 (CEST) In-Reply-To: (Tom Tromey's message of "Mon, 16 May 2011 09:19:18 -0600") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 87.96.254.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:139429 Archived-At: Tom Tromey writes: >>>>>> "Stefan" == Stefan Monnier writes: > > Stefan> While Emacs uses them a lot, dynamically-scoped variables used as > Stefan> implicit extra parameters are bad. In many cases, it's difficult to > Stefan> avoid using them, but in this case, calling a function after the > Stefan> url-retrieve call works just as well, so there's no excuse. > > IIRC, in package.el I had to special-case some URL types, because > headers are inconsistently used. E.g., I think the 'ftp' method won't > leave headers in the buffer. It would be nice if this bit were handled > by the url package rather than all the callers. Changing (url-retrieve-synchronously URL) To (url-retrieve-synchronously URL &optional remove-headers) ought to sattisfy all participants in this thread? and it could be done somewhat like this: (defun url-retrieve-synchronously (url &optional remove-headers) (let ((buffer (url-retrieve-synchronously-old-implementation url)) (if remove-headers (url-remove-headers buffer )))) (defun url-remove-headers (buffer) (with-current-buffer buffer (widen) (goto-char (point-min)) (search-forward "\n\n") (delete-region (point-min) (point)) buffer) ) but we would also need to look out for the special cases Tom mentioned. Good enough? url-remove-headers is separate so it can be re-used in a url-retrieve callback for instance. > > Tom -- Joakim Verona