Mercurial > emacs
changeset 72108:ee72501a64b4
(xml-parse-file): Clean up, and use with-temp-buffer.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 24 Jul 2006 18:02:10 +0000 |
parents | 659c58677dff |
children | f6cd6558bd8e |
files | lisp/xml.el |
diffstat | 1 files changed, 13 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/xml.el Mon Jul 24 17:59:15 2006 +0000 +++ b/lisp/xml.el Mon Jul 24 18:02:10 2006 +0000 @@ -165,22 +165,19 @@ Returns 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." - (let ((keep)) - (if (get-file-buffer file) - (progn - (set-buffer (get-file-buffer file)) - (setq keep (point))) - (let (auto-mode-alist) ; no need for xml-mode - (find-file file))) - - (let ((xml (xml-parse-region (point-min) - (point-max) - (current-buffer) - parse-dtd parse-ns))) - (if keep - (goto-char keep) - (kill-buffer (current-buffer))) - xml))) + (if (get-file-buffer file) + (with-current-buffer (get-file-buffer file) + (save-excursion + (xml-parse-region (point-min) + (point-max) + (current-buffer) + parse-dtd parse-ns))) + (with-temp-buffer + (insert-file-contents file) + (xml-parse-region (point-min) + (point-max) + (current-buffer) + parse-dtd parse-ns)))) (defvar xml-name-re)