A better prelude-view-url

- remove HTTP headers, what we care most of the time is the content
- `set-auto-mode` is way better than the naive xml, html tag check
This commit is contained in:
toctan 2014-07-30 20:24:33 +08:00
parent 237104bbae
commit 2d11c0bc4b

View file

@ -266,8 +266,11 @@ there's a region, all lines that region covers will be duplicated."
(url (read-from-minibuffer "URL: " default))) (url (read-from-minibuffer "URL: " default)))
(switch-to-buffer (url-retrieve-synchronously url)) (switch-to-buffer (url-retrieve-synchronously url))
(rename-buffer url t) (rename-buffer url t)
(cond ((search-forward "<?xml" nil t) (nxml-mode)) (goto-char (point-min))
((search-forward "<html" nil t) (html-mode))))) (re-search-forward "^$")
(delete-region (point-min) (point))
(delete-blank-lines)
(set-auto-mode)))
(defun prelude-cleanup-buffer-or-region () (defun prelude-cleanup-buffer-or-region ()
"Cleanup a region if selected, otherwise the whole buffer." "Cleanup a region if selected, otherwise the whole buffer."