aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Olson <mwolson@gnu.org>2008-02-15 02:58:00 +0000
committerMichael Olson <mwolson@gnu.org>2008-02-15 02:58:00 +0000
commit6f8dc64b8d9b65887a29a0f94705cbf9ac2bf631 (patch)
tree612c6ee6daf65c634c512872b7566e7d1125d498
parent535f7f7bf8ca34162b3ad854576d78ebf3ffb480 (diff)
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
-rw-r--r--emms-url.el32
1 files 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 `+'."