comparison yahtml.el @ 153:207f0b4af9df dev

Unescape URL strings from buffer(yahtml-unescape-string).
author yuuji@gentei.org
date Sat, 06 Nov 2010 19:24:34 +0900
parents f9d3c2451d19
children d3bcc4e2166a
comparison
equal deleted inserted replaced
152:095a5c97ecac 153:207f0b4af9df
1 ;;; -*- Emacs-Lisp -*- 1 ;;; -*- Emacs-Lisp -*-
2 ;;; (c) 1994-2010 by HIROSE Yuuji [yuuji(@)yatex.org] 2 ;;; (c) 1994-2010 by HIROSE Yuuji [yuuji(@)yatex.org]
3 ;;; Last modified Mon Sep 13 08:09:46 2010 on firestorm 3 ;;; Last modified Sat Nov 6 19:22:54 2010 on firestorm
4 ;;; $Id$ 4 ;;; $Id$
5 5
6 (defconst yahtml-revision-number "1.74.2" 6 (defconst yahtml-revision-number "1.74.2"
7 "Revision number of running yahtml.el") 7 "Revision number of running yahtml.el")
8 8
1049 (format "%%%x" (aref str p)))) 1049 (format "%%%x" (aref str p))))
1050 (setq target (concat target (substring str 0 (1+ p))))) 1050 (setq target (concat target (substring str 0 (1+ p)))))
1051 (setq str (substring str (1+ p)))) 1051 (setq str (substring str (1+ p))))
1052 (concat target str))))) 1052 (concat target str)))))
1053 1053
1054 (defun yahtml-unescape-string (str)
1055 "Untranslate reserved URL-encoded string."
1056 (let ((p 0) c (target "") (md (match-data)) (case-fold-search nil))
1057 (unwind-protect
1058 (progn
1059 (while (string-match "%\\([0-9a-f][0-9a-f]\\)" str p)
1060 (setq target (concat target
1061 (substring str p (1- (match-beginning 1))))
1062 p (match-end 0)
1063 c (YaTeX-hex (substring
1064 str (match-beginning 1) (match-end 1)))
1065 target (concat target (format "%c" c))))
1066 (concat target (substring str p)))
1067 (store-match-data md))))
1068
1054 (defun yahtml-escape-chars-region (beg end) 1069 (defun yahtml-escape-chars-region (beg end)
1055 "Translate reserved chars to encoded string in the region." 1070 "Translate reserved chars to encoded string in the region."
1056 (interactive "r") 1071 (interactive "r")
1057 (save-excursion 1072 (save-excursion
1058 (let ((e (set-marker (make-marker) end)) c m yes) 1073 (let ((e (set-marker (make-marker) end)) c m yes)
1709 (search-forward "=" e t) 1724 (search-forward "=" e t)
1710 (progn 1725 (progn
1711 (skip-chars-forward " \t\n") 1726 (skip-chars-forward " \t\n")
1712 (looking-at "\"?\\([^\"> \t\n]+\\)\"?")) 1727 (looking-at "\"?\\([^\"> \t\n]+\\)\"?"))
1713 (< p (match-end 0)) 1728 (< p (match-end 0))
1714 (YaTeX-match-string 1))))) 1729 (yahtml-unescape-string (YaTeX-match-string 1))))))
1715 1730
1716 (defun yahtml-netscape-sentinel (proc mes) 1731 (defun yahtml-netscape-sentinel (proc mes)
1717 (cond 1732 (cond
1718 ((null (buffer-name (process-buffer proc))) 1733 ((null (buffer-name (process-buffer proc)))
1719 (set-process-buffer proc nil)) 1734 (set-process-buffer proc nil))
1887 (defun yahtml-goto-corresponding-img () 1902 (defun yahtml-goto-corresponding-img ()
1888 "View image on point" 1903 "View image on point"
1889 (let ((tag (yahtml-current-tag)) image (p (point)) (case-fold-search t)) 1904 (let ((tag (yahtml-current-tag)) image (p (point)) (case-fold-search t))
1890 (if (and tag 1905 (if (and tag
1891 (string-match "img" tag) 1906 (string-match "img" tag)
1892 (setq image (yahtml-get-attrvalue "src"))) 1907 (setq image
1908 (yahtml-unescape-string (yahtml-get-attrvalue "src"))))
1893 (progn 1909 (progn
1894 (message "Invoking %s %s..." yahtml-image-viewer image) 1910 (message "Invoking %s %s..." yahtml-image-viewer image)
1895 (start-process 1911 (start-process
1896 "Viewer" " * Image Viewer *" 1912 "Viewer" " * Image Viewer *"
1897 shell-file-name yahtml-shell-command-option ;"-c" 1913 shell-file-name yahtml-shell-command-option ;"-c"
1901 (defun yahtml-goto-corresponding-source (&optional other) 1917 (defun yahtml-goto-corresponding-source (&optional other)
1902 "Goto applet's or script's source." 1918 "Goto applet's or script's source."
1903 (let ((env (yahtml-current-tag)) s (p (point))) 1919 (let ((env (yahtml-current-tag)) s (p (point)))
1904 (cond 1920 (cond
1905 ((string-match "applet" env) 1921 ((string-match "applet" env)
1906 (if (setq s (yahtml-get-attrvalue "code")) 1922 (if (setq s (yahtml-unescape-string (yahtml-get-attrvalue "code")))
1907 (progn 1923 (progn
1908 (setq s (YaTeX-match-string 1) 1924 (setq s (YaTeX-match-string 1)
1909 s (concat 1925 s (concat
1910 (substring s 0 (string-match "\\.[A-Za-z]+$" s)) 1926 (substring s 0 (string-match "\\.[A-Za-z]+$" s))
1911 ".java")) 1927 ".java"))

yatex.org