.emacs-my
changeset 716 a3f42d9dd281
parent 715 973cc8f1023a
child 717 b958f182d0d4
--- a/.emacs-my	Wed Oct 05 01:36:19 2011 +0300
+++ b/.emacs-my	Wed Oct 05 02:56:52 2011 +0300
@@ -66,6 +66,16 @@
            ,list)
      r))
 
+(defun my-fold (f x list)
+  "Recursively applies (F i j) to LIST starting with X.
+For example, (fold F X '(1 2 3)) computes (F (F (F X 1) 2) 3)."
+  (let ((li list) (x2 x))
+    (while li
+      (setq x2 (funcall f x2 (pop li)))
+      )
+    x2
+    ) )
+
 ;;; ----------------------------------------------------------------
 (message "mode groups")
 
@@ -762,6 +772,23 @@
       gnus-audio-wav-player "winamp.exe")
 
 ;;; ----------------------------------------------------------------
+(message "url")
+
+;; http://tools.ietf.org/html/rfc3986
+;; http://en.wikipedia.org/wiki/Percent-encoding
+(defun my-percent-decode (str)
+  (decode-coding-string
+   (let* ( (s (split-string str "%")) )
+     (my-fold
+      'concat
+      (car s)
+      (mapcar
+       (lambda (x)
+         (concat (unibyte-string (string-to-number (substring x 0 2) 16)) (substring x 2)))
+       (cdr s))
+      )) 'utf-8))
+
+;;; ----------------------------------------------------------------
 (message "browser")
 
 (cond