summaryrefslogtreecommitdiff
path: root/lisp/xml.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>2006-07-24 18:02:10 +0000
committerRichard M. Stallman <rms@gnu.org>2006-07-24 18:02:10 +0000
commit882cb60d1a74b752827f176ef9ec0193fbc8fd29 (patch)
tree32b20b4f2b527a74cbf8e99ffc3ce73c46fcc6dd /lisp/xml.el
parente1eed9a446f77d37232bb435d15c42550fe5d457 (diff)
downloademacs-882cb60d1a74b752827f176ef9ec0193fbc8fd29.tar.gz
(xml-parse-file): Clean up, and use with-temp-buffer.
Diffstat (limited to 'lisp/xml.el')
-rw-r--r--lisp/xml.el29
1 files changed, 13 insertions, 16 deletions
diff --git a/lisp/xml.el b/lisp/xml.el
index 2ce3ec7b4f9..ca8f5bdc81b 100644
--- a/lisp/xml.el
+++ b/lisp/xml.el
@@ -165,22 +165,19 @@ If FILE is already visited, use its buffer and don't kill it.
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)