From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Engster Newsgroups: gmane.emacs.bugs Subject: bug#11916: 24.1.50; Making url-dav work Date: Thu, 26 Jul 2012 18:01:06 +0200 Message-ID: <87a9ymo6kd.fsf@engster.org> References: <87k3ya8146.fsf@engster.org> <87pq7tc69a.fsf@engster.org> <87hat3kbxe.fsf@engster.org> <87hat19uvy.fsf@engster.org> <87r4rz8sck.fsf@engster.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1343318548 26454 80.91.229.3 (26 Jul 2012 16:02:28 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 26 Jul 2012 16:02:28 +0000 (UTC) Cc: 11916@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 26 18:02:28 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 1SuQW9-0006qD-Jl for geb-bug-gnu-emacs@m.gmane.org; Thu, 26 Jul 2012 18:02:25 +0200 Original-Received: from localhost ([::1]:51771 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SuQW8-0006wi-Rg for geb-bug-gnu-emacs@m.gmane.org; Thu, 26 Jul 2012 12:02:24 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:38828) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SuQW2-0006wN-0o for bug-gnu-emacs@gnu.org; Thu, 26 Jul 2012 12:02:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SuQVv-0006xq-Oh for bug-gnu-emacs@gnu.org; Thu, 26 Jul 2012 12:02:17 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59896) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SuQVv-0006xE-BO for bug-gnu-emacs@gnu.org; Thu, 26 Jul 2012 12:02:11 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SuQcY-0008HS-0P for bug-gnu-emacs@gnu.org; Thu, 26 Jul 2012 12:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: David Engster Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 26 Jul 2012 16:09:01 +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.134331888631768 (code B ref 11916); Thu, 26 Jul 2012 16:09:01 +0000 Original-Received: (at 11916) by debbugs.gnu.org; 26 Jul 2012 16:08:06 +0000 Original-Received: from localhost ([127.0.0.1]:41209 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SuQbd-0008GK-HG for submit@debbugs.gnu.org; Thu, 26 Jul 2012 12:08:06 -0400 Original-Received: from randomsample.de ([83.169.19.17]:35751) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SuQba-0008Fu-2Y for 11916@debbugs.gnu.org; Thu, 26 Jul 2012 12:08:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=randomsample.de; s=a; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To:Subject:Cc:To:From; bh=k0kZ3et73/WfV2MEf8x7D/OBQV/ZCFUSh+gKyv3l7o8=; b=l73GsfIOexz5R+daX6TM4BGyxNatLLE6RLLS/NVulTp/JZ0DuFGWeOcmYzLG9bM/yNBIehJd8wr5ZOmPQmnCgVj50tp2jZt0V+vtXSfH+oINb9Q3JQmXbm/87z3sKx3B; Original-Received: from dslc-082-083-056-224.pools.arcor-ip.net ([82.83.56.224] helo=spaten) by randomsample.de with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1SuQUt-0002WV-48; Thu, 26 Jul 2012 18:01:07 +0200 In-Reply-To: (Stefan Monnier's message of "Wed, 25 Jul 2012 20:04:22 -0400") User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1.50 (gnu/linux) 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:62412 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: > No, no, don't add a symbol-qnames variable here, use the same > representation I proposed for xml-ns instead. And similarly don't add > any argument to xml-maybe-do-ns. This should result in a patch that > touches very little code (just the computation of xml-ns above and its > use in xml-maybe-do-ns, and not much else). OK, next try (only attaching diff to xml.el, since url-dav is unchanged). -David --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=xml-diff.patch === modified file 'lisp/xml.el' --- lisp/xml.el 2012-07-04 16:14:05 +0000 +++ lisp/xml.el 2012-07-26 14:55:34 +0000 @@ -126,7 +126,10 @@ would be represented by - '(\"\" . \"foo\")." + '(\"\" . \"foo\"). + +If you'd just like a plain symbol instead, use 'symbol-qnames in +the PARSE-NS argument." (car node)) @@ -313,7 +316,22 @@ "Parse the well-formed XML file FILE. Return the top node with all its children. If PARSE-DTD is non-nil, the DTD is parsed rather than skipped. -If PARSE-NS is non-nil, then QNAMES are expanded." + +If PARSE-NS is non-nil, then QNAMES are expanded. By default, +the variable `xml-default-ns' is the mapping from namespaces to +URIs, and expanded names will be returned as a cons + + (\"namespace:\" . \"foo\"). + +If PARSE-NS is an alist, it will be used as the mapping from +namespace to URIs instead. + +If it is the symbol 'symbol-qnames, expanded names will be +returned as a plain symbol 'namespace:foo instead of a cons. + +Both features can be combined by providing a cons cell + + (symbol-qnames . ALIST)." (with-temp-buffer (insert-file-contents file) (xml--parse-buffer parse-dtd parse-ns))) @@ -329,7 +347,21 @@ If BUFFER is nil, it defaults to the current buffer. If PARSE-DTD is non-nil, parse the DTD and return it as the first element of the list. -If PARSE-NS is non-nil, expand QNAMES." +If PARSE-NS is non-nil, then QNAMES are expanded. By default, +the variable `xml-default-ns' is the mapping from namespaces to +URIs, and expanded names will be returned as a cons + + (\"namespace:\" . \"foo\"). + +If PARSE-NS is an alist, it will be used as the mapping from +namespace to URIs instead. + +If it is the symbol 'symbol-qnames, expanded names will be +returned as a plain symbol 'namespace:foo instead of a cons. + +Both features can be combined by providing a cons cell + + (symbol-qnames . ALIST)." ;; Use fixed syntax table to ensure regexp char classes and syntax ;; specs DTRT. (unless buffer @@ -386,26 +418,36 @@ During namespace-aware parsing, any name without a namespace is put into the namespace identified by DEFAULT. nil is used to -specify that the name shouldn't be given a namespace." +specify that the name shouldn't be given a namespace. +Expanded names will by default be returned as a cons. If you +would like to get plain symbols instead, provide a cons cell + + (symbol-qnames . ALIST) + +in the XML-NS argument." (if (consp xml-ns) - (let* ((nsp (string-match ":" name)) + (let* ((symbol-qnames (eq (car-safe xml-ns) 'symbol-qnames)) + (nsp (string-match ":" name)) (lname (if nsp (substring name (match-end 0)) name)) (prefix (if nsp (substring name 0 (match-beginning 0)) default)) (special (and (string-equal lname "xmlns") (not prefix))) ;; Setting default to nil will insure that there is not ;; matching cons in xml-ns. In which case we (ns (or (cdr (assoc (if special "xmlns" prefix) - xml-ns)) + (if symbol-qnames (cdr xml-ns) xml-ns))) ""))) - (cons ns (if special "" lname))) + (if (and symbol-qnames + (not (string= prefix "xmlns"))) + (intern (concat ns lname)) + (cons ns (if special "" lname)))) (intern name))) (defun xml-parse-tag (&optional parse-dtd parse-ns) "Parse the tag at point. If PARSE-DTD is non-nil, the DTD of the document, if any, is parsed and returned as the first element in the list. -If PARSE-NS is non-nil, expand QNAMES; if the value of PARSE-NS -is a list, use it as an alist mapping namespaces to URIs. +If PARSE-NS is non-nil, expand QNAMES; for further details, see +`xml-parse-region'. Return one of: - a list : the matching node @@ -425,9 +467,16 @@ (defun xml-parse-tag-1 (&optional parse-dtd parse-ns) "Like `xml-parse-tag', but possibly modify the buffer while working." - (let ((xml-validating-parser (or parse-dtd xml-validating-parser)) - (xml-ns (cond ((consp parse-ns) parse-ns) - (parse-ns xml-default-ns)))) + (let* ((xml-validating-parser (or parse-dtd xml-validating-parser)) + (xml-ns + (cond ((eq parse-ns 'symbol-qnames) + (cons 'symbol-qnames xml-default-ns)) + ((or (consp (car-safe parse-ns)) + (and (eq (car-safe parse-ns) 'symbol-qnames) + (listp (cdr parse-ns)))) + parse-ns) + (parse-ns + xml-default-ns)))) (cond ;; Processing instructions, like . ((looking-at "<\\?") @@ -475,7 +524,9 @@ (equal "http://www.w3.org/2000/xmlns/" (caar attr))) (push (cons (cdar attr) (cdr attr)) - xml-ns)))) + (if (symbolp (car xml-ns)) + (cdr xml-ns) + xml-ns))))) (setq children (list attrs (xml-maybe-do-ns node-name "" xml-ns))) (cond ;; is this an empty element ? --=-=-=--