aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Xu <william.xwl@gmail.com>2008-02-16 04:31:00 +0000
committerWilliam Xu <william.xwl@gmail.com>2008-02-16 04:31:00 +0000
commit3294650f52d5a1ac41fb933fade5b46753ed13f1 (patch)
treefa65a78752203ced38cce1157adcde94b9b520e0
parent2964c94e715085829002ded00cc9933cf4b2279c (diff)
(emms-url-quote): Slightly rewrote to be more readable. Fix docstring typo.
darcs-hash:20080216043149-cfa61-d40e96954a985f13ea81f618aef396cff7037363.gz
-rw-r--r--emms-url.el28
1 files changed, 14 insertions, 14 deletions
diff --git a/emms-url.el b/emms-url.el
index 24ae903..5c7746e 100644
--- a/emms-url.el
+++ b/emms-url.el
@@ -60,22 +60,22 @@ This is useful for escaping parts of URLs, but not entire URLs.
Characters in [a-zA-Z_.-/] and SAFE(default is \"\") will never be
quoted.
e.g.,
- (url-quote \"abc def\") => \"abc%20def\"."
+ (emms-url-quote \"abc def\") => \"abc%20def\"."
(or safe (setq safe ""))
(save-match-data
- (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))
- "")))
+ (let ((re (if (string-match "]" safe)
+ ;; `]' should be placed at the beginning inside []
+ (format "[]a-zA-Z_.-/%s]"
+ (emms-replace-regexp-in-string "]" "" safe))
+ (format "[a-zA-Z_.-/%s]" safe))))
+ (mapconcat
+ (lambda (c)
+ (let ((s1 (char-to-string c)))
+ (if (string-match re s1)
+ s1
+ (format "%%%02x" c))))
+ (string-to-list (encode-coding-string s 'utf-8))
+ ""))))
(defun emms-url-quote-plus (s &optional safe)
"Run (emms-url-quote s \" \"), then replace ` ' with `+'."