diff options
| author | Richard M. Stallman | 2006-07-24 18:02:10 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2006-07-24 18:02:10 +0000 |
| commit | 882cb60d1a74b752827f176ef9ec0193fbc8fd29 (patch) | |
| tree | 32b20b4f2b527a74cbf8e99ffc3ce73c46fcc6dd | |
| parent | e1eed9a446f77d37232bb435d15c42550fe5d457 (diff) | |
| download | emacs-882cb60d1a74b752827f176ef9ec0193fbc8fd29.tar.gz emacs-882cb60d1a74b752827f176ef9ec0193fbc8fd29.zip | |
(xml-parse-file): Clean up, and use with-temp-buffer.
| -rw-r--r-- | lisp/xml.el | 29 |
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. | |||
| 165 | Returns the top node with all its children. | 165 | Returns the top node with all its children. |
| 166 | If PARSE-DTD is non-nil, the DTD is parsed rather than skipped. | 166 | If PARSE-DTD is non-nil, the DTD is parsed rather than skipped. |
| 167 | If PARSE-NS is non-nil, then QNAMES are expanded." | 167 | If PARSE-NS is non-nil, then QNAMES are expanded." |
| 168 | (let ((keep)) | 168 | (if (get-file-buffer file) |
| 169 | (if (get-file-buffer file) | 169 | (with-current-buffer (get-file-buffer file) |
| 170 | (progn | 170 | (save-excursion |
| 171 | (set-buffer (get-file-buffer file)) | 171 | (xml-parse-region (point-min) |
| 172 | (setq keep (point))) | 172 | (point-max) |
| 173 | (let (auto-mode-alist) ; no need for xml-mode | 173 | (current-buffer) |
| 174 | (find-file file))) | 174 | parse-dtd parse-ns))) |
| 175 | 175 | (with-temp-buffer | |
| 176 | (let ((xml (xml-parse-region (point-min) | 176 | (insert-file-contents file) |
| 177 | (point-max) | 177 | (xml-parse-region (point-min) |
| 178 | (current-buffer) | 178 | (point-max) |
| 179 | parse-dtd parse-ns))) | 179 | (current-buffer) |
| 180 | (if keep | 180 | parse-dtd parse-ns)))) |
| 181 | (goto-char keep) | ||
| 182 | (kill-buffer (current-buffer))) | ||
| 183 | xml))) | ||
| 184 | 181 | ||
| 185 | 182 | ||
| 186 | (defvar xml-name-re) | 183 | (defvar xml-name-re) |