From de2edaf1dce1e13b0212845b290178d97997067c Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Mon, 9 Apr 2007 05:54:00 +0000 Subject: emms-url: Avoid stringp errors when fetch of page failed darcs-hash:20070409055428-1bfb2-caef9a48dbe90295d8dc374de00143e77cf19803.gz --- emms-url.el | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/emms-url.el b/emms-url.el index b3841c2..d77a382 100644 --- a/emms-url.el +++ b/emms-url.el @@ -50,10 +50,12 @@ variable." (append url nil)))) (defun emms-http-content-coding () - (and (boundp 'url-http-content-type) - (string-match ";\\s-*charset=\\([^;[:space:]]+\\)" - url-http-content-type) - (intern-soft (downcase (match-string 1 url-http-content-type))))) + (save-match-data + (and (boundp 'url-http-content-type) + (stringp url-http-content-type) + (string-match ";\\s-*charset=\\([^;[:space:]]+\\)" + url-http-content-type) + (intern-soft (downcase (match-string 1 url-http-content-type)))))) (defun emms-http-decode-buffer (&optional buffer) "Recode the buffer with `url-retrieve's contents. Else the @@ -61,11 +63,12 @@ buffer would contain multibyte chars like \\123\\456." (with-current-buffer (or buffer (current-buffer)) (let* ((default (or (car default-process-coding-system) 'utf-8)) (coding (or (emms-http-content-coding) default))) - ;; (pop-to-buffer (current-buffer)) - ;; (message "content-type: %s" url-http-content-type) - ;; (message "coding: %S [default: %S]" coding default) - (set-buffer-multibyte t) - (decode-coding-region (point-min) (point-max) coding)))) + (when coding + ;; (pop-to-buffer (current-buffer)) + ;; (message "content-type: %s" url-http-content-type) + ;; (message "coding: %S [default: %S]" coding default) + (set-buffer-multibyte t) + (decode-coding-region (point-min) (point-max) coding))))) (provide 'emms-url) ;;; emms-url.el ends here -- cgit v1.2.3