From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#11916: 24.1.50; Making url-dav work Date: Wed, 18 Jul 2012 08:25:27 -0400 Message-ID: References: <87k3ya8146.fsf@engster.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1342614374 30884 80.91.229.3 (18 Jul 2012 12:26:14 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 18 Jul 2012 12:26:14 +0000 (UTC) Cc: 11916@debbugs.gnu.org To: David Engster Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 18 14:26:12 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SrTKV-0008Qq-2n for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Jul 2012 14:26:11 +0200 Original-Received: from localhost ([::1]:41757 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrTKU-00040R-Bm for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Jul 2012 08:26:10 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:37361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrTKM-0003ox-By for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2012 08:26:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SrTKH-0004kI-6P for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2012 08:26:02 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38141) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrTKH-0004kE-2m for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2012 08:25:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SrTQA-0008Mt-AI for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2012 08:32:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Jul 2012 12:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11916 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 11916-submit@debbugs.gnu.org id=B11916.134261470032142 (code B ref 11916); Wed, 18 Jul 2012 12:32:02 +0000 Original-Received: (at 11916) by debbugs.gnu.org; 18 Jul 2012 12:31:40 +0000 Original-Received: from localhost ([127.0.0.1]:47687 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SrTPo-0008MM-4e for submit@debbugs.gnu.org; Wed, 18 Jul 2012 08:31:40 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:59940) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SrTPl-0008MF-C2 for 11916@debbugs.gnu.org; Wed, 18 Jul 2012 08:31:38 -0400 Original-Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id q6ICPTjU000300; Wed, 18 Jul 2012 08:25:30 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 29033AECAF; Wed, 18 Jul 2012 08:25:27 -0400 (EDT) In-Reply-To: <87k3ya8146.fsf@engster.org> (David Engster's message of "Wed, 11 Jul 2012 23:00:09 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4282=0 X-NAI-Spam-Version: 2.2.0.9309 : core <4282> : streams <786678> : uri <1168444> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:62094 Archived-At: > I started rewriting url-dav to work with the cons's returned by xml.el, > but it's tedious work and, more importantly, makes the code really > ugly. Could you show us some example of the ugliness to get a feeling for the tradeoffs? I see you'd need to change url-dav-find-parser, but that doesn't sound so terrible, so the ugliness seems to come from parts that aren't as immediately apparent. > Instead, I now just use a small function to replace the cons's in > xml.el's output with the plain symbols the package expects. Please find > the patch attached. Rather than provide a "changexml" function which traverses the XML tree and changes the cons to symbols, how 'bout changing xml-parse-region? I have the vague impression that the representation was changed from symbols to cons cells on the premise that it was more Lispy (would avoid (re)parsing the symbol names), but if it turns out to be a pain to use, maybe that was a bad call (basically, you're saying that you never need/want to parse those QNAMES). Another issue is: what does libxml-parse-xml-region do (it would be better to try and reduce the difference between the two)? Stefan > --- url-dav.el 2012-07-11 22:34:49.401721367 +0200 > +++ url-dav.el_patched 2012-07-11 22:33:34.504867729 +0200 > @@ -395,10 +395,15 @@ > url-http-content-type > (string-match "\\`\\(text\\|application\\)/xml" > url-http-content-type)) > - (setq tree (xml-parse-region (point) (point-max))))) > + (setq tree (xml-parse-region (point) (point-max) nil nil t)))) > ;; Clean up after ourselves. > (kill-buffer buffer))) > + ;; This package was initially written for a different kind of > + ;; QNAMES expansion, hence we have now to rewrite those so that > + ;; for example ("DAV:" . "foo") becomes the symbol 'DAV:foo. > + (url-dav-changexml (car tree)) > + > ;; We should now be > (if (eq (xml-node-name (car tree)) 'DAV:multistatus) > (url-dav-dispatch-node (car tree)) > @@ -411,6 +416,21 @@ > ;; nobody but us needs to know the difference. > (list (cons url properties)))))) > +(defun url-dav-changexml (node) > + "Rewrite all expanded names in NODE to plain symbols. > +That means, all cons produced from `xml-parse-region' > +like (\"DAV:\" . \"foo\") become plain symbols DAV:foo. > +This replacement happens in-place." > + (when (consp node) > + (let ((name (xml-node-name node)) > + (children (xml-node-children node))) > + (when (and (consp name) > + (equal (car name) "DAV:")) > + (setcar node (intern (concat "DAV:" (cdr name))))) > + (when children > + (dolist (cur children) > + (url-dav-changexml cur)))))) > + > (defun url-dav-request (url method tag body > &optional depth headers namespaces) > "Perform WebDAV operation METHOD on URL. Return the parsed responses.