From 6f8dc64b8d9b65887a29a0f94705cbf9ac2bf631 Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Fri, 15 Feb 2008 02:58:00 +0000 Subject: emms-url: Improve emms-url-quote. - Don't clobber the match data. - Don't escape the colon in "http://". darcs-hash:20080215025800-1bfb2-ad6899b9c1134c782a1fab2ca206e158d62042e3.gz --- emms-url.el | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/emms-url.el b/emms-url.el index 9fca29d..59c09f5 100644 --- a/emms-url.el +++ b/emms-url.el @@ -35,19 +35,25 @@ quoted. e.g., (url-quote \"abc def\") => \"abc%20def\"." (or safe (setq safe "")) - (mapconcat (lambda (c) - (if (if (string-match "]" safe) - ;; ] should be place at the beginning inside [] - (string-match - (format "[]a-zA-Z_.-/%s]" - (emms-replace-regexp-in-string "]" "" safe)) - (char-to-string c)) - (string-match (format "[a-zA-Z_.-/%s]" safe) - (char-to-string c))) - (char-to-string c) - (format "%%%02x" c))) - (string-to-list (encode-coding-string s 'utf-8)) - "")) + (save-match-data + (string-match "\\`\\([^:]+:\\)\\(.+\\)\\'" s) + (let ((handler (match-string 1 s)) + (loc (or (match-string 2 s) s))) + (concat handler + (mapconcat + (lambda (c) + (if (if (string-match "]" safe) + ;; ] should be place at the beginning inside [] + (string-match + (format "[]a-zA-Z_.-/%s]" + (emms-replace-regexp-in-string "]" "" safe)) + (char-to-string c)) + (string-match (format "[a-zA-Z_.-/%s]" safe) + (char-to-string c))) + (char-to-string c) + (format "%%%02x" c))) + (string-to-list (encode-coding-string loc 'utf-8)) + ""))))) (defun emms-url-quote-plus (s &optional safe) "Run (emms-url-quote s \" \"), then replace ` ' with `+'." -- cgit v1.2.3