(www-get-genre): New function.
authorMORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
Tue, 12 Oct 2010 01:08:28 +0000 (10:08 +0900)
committerMORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
Tue, 12 Oct 2010 01:08:28 +0000 (10:08 +0900)
(www-get-feature-value): Renamed from `www-char-feature'.
(www-uri-decode-object): Renamed from `www-uri-decode-char'; add new
argument `genre'.

cwiki-common.el

index c682cbd..aa35fd6 100644 (file)
         (concat dest (substring string i))
         coding-system))))
 
+(defun www-get-genre (object)
+  (if (characterp object)
+      'character
+    'default))
+
 (defun www-feature-type (feature-name)
   (or (char-feature-property feature-name 'type)
       (let ((str (symbol-name feature-name)))
        (intern (substring feature-name 0 (match-beginning 0)))
       feature)))
 
-(defun www-char-feature (character feature)
+(defun www-get-feature-value (object feature)
   (let ((latest-feature (char-feature-name-at-domain feature '$rev=latest)))
     (mount-char-attribute-table latest-feature)
-    (or (char-feature character latest-feature)
-       (char-feature character feature))))
+    (or (char-feature object latest-feature)
+       (char-feature object feature))))
 
 (defun get-previous-code-point (ccs code)
   (let ((chars (charset-chars ccs))
   (format "%s?feature=%s&char=%s"
          chise-wiki-view-url uri-feature-name uri-char))
 
-(defun www-uri-decode-char (char-rep)
+(defun www-uri-decode-object (genre char-rep)
   (let (ccs cpos)
     (cond
      ((string-match "\\(%3A\\|:\\)" char-rep)
              (string-to-number (substring cpos (match-end 0)) 16))
        )
        (t
-       (setq cpos (string-to-number cpos))
+       (setq cpos (car (read-from-string cpos)))
        ))
-      (if (numberp cpos)
-         (decode-char ccs cpos))
+      (if (and (eq genre 'character)
+              (numberp cpos))
+         (decode-char ccs cpos)
+       (concord-decode-object ccs cpos genre))
       )
      (t
       (setq char-rep (decode-uri-string char-rep 'utf-8-mcs-er))
-      (when (= (length char-rep) 1)
-       (aref char-rep 0))
-      ))))
+      (if (eq genre 'character)
+         (when (= (length char-rep) 1)
+           (aref char-rep 0))
+       (concord-decode-object '=id char-rep genre))))))
 
 (defun www-uri-encode-char (char)
   (if (encode-char char '=ucs)
                                &optional value format
                                without-tags without-edit)
   (unless value
-    (setq value (www-char-feature object feature-name)))
+    (setq value (www-get-feature-value object feature-name)))
   (www-format-apply-value object feature-name
                          format nil value nil nil
                          without-tags without-edit)
            (setq char (decode-char 'system-char-id code))
            (cond
             ((and (setq variants
-                        (or (www-char-feature char '->subsumptive)
-                            (www-char-feature char '->denotational)))
+                        (or (www-get-feature-value char '->subsumptive)
+                            (www-get-feature-value char '->denotational)))
                   (progn
                     (while (and variants
                                 (setq ret (www-format-encode-string
                (delete-region start end)
                (insert ret))
              )
-            ((setq ret (or (www-char-feature char 'ideographic-combination)
-                           (www-char-feature char 'ideographic-structure)))
+            ((setq ret (or (www-get-feature-value char 'ideographic-combination)
+                           (www-get-feature-value char 'ideographic-structure)))
              (setq ret
                    (mapconcat
                     (lambda (ch)
                                      &optional format lang uri-char value
                                      without-tags without-edit)
   (unless value
-    (setq value (www-char-feature char feature-name)))
+    (setq value (www-get-feature-value char feature-name)))
   (unless format
     (setq format (www-feature-value-format feature-name)))
   (cond
                                 &optional lang uri-char value
                                 without-tags without-edit)
   (unless value
-    (setq value (www-char-feature char feature-name)))
+    (setq value (www-get-feature-value char feature-name)))
   (unless uri-char
     (setq uri-char (www-uri-encode-char char)))
   (cond
            (setq fn (intern fn)))
          (setq domain (char-feature-name-domain feature-name))
          (setq domain-fn (char-feature-name-at-domain fn domain))
-         (if (setq ret (www-char-feature char domain-fn))
+         (if (setq ret (www-get-feature-value char domain-fn))
              (setq feature-name domain-fn
                    value ret)
            (setq feature-name fn
-                 value (www-char-feature char fn)))
+                 value (www-get-feature-value char fn)))
          (push feature-name chise-wiki-displayed-features)
           ))
       (if (eq (car exp) 'value)