(get-char-feature-from-domains): New function [moved from
authortomo <tomo>
Mon, 31 May 2010 14:40:10 +0000 (14:40 +0000)
committertomo <tomo>
Mon, 31 May 2010 14:40:10 +0000 (14:40 +0000)
ideograph-util.el].
(char-ideographic-radical): Ditto.

lisp/utf-2000/ideograph-subr.el

index c49794a..1ef2fcd 100644 (file)
@@ -25,7 +25,7 @@
 
 ;;; Code:
 
-;;; @ radical
+;;; @ radical code
 ;;;
 
 (defconst ideographic-radicals
   (aref ideographic-radicals number))
 
 
+;;; @ char feature
+;;;
+
+(defun get-char-feature-from-domains (char feature domains
+                                          &optional tester arg
+                                          ignore-sisters)
+  (map-char-family
+   (lambda (ch)
+     (let (ret)
+       (catch 'tag
+        (dolist (domain domains)
+          (if (and (or (null tester)
+                       (equal (or (char-feature
+                                   ch (expand-char-feature-name
+                                       tester domain))
+                                  (char-feature ch tester))
+                              arg))
+                   (setq ret (or (char-feature
+                                  ch (expand-char-feature-name
+                                      feature domain))
+                                 (char-feature ch feature))))
+              (throw 'tag ret))))))
+   char ignore-sisters))
+
+(defun char-ideographic-radical (char &optional radical ignore-sisters)
+  (let (ret)
+    (or (if radical
+           (get-char-feature-from-domains
+            char 'ideographic-radical (cons nil char-db-feature-domains)
+            'ideographic-radical radical ignore-sisters)
+         (get-char-feature-from-domains
+          char 'ideographic-radical (cons nil char-db-feature-domains)
+          ignore-sisters))
+        ;; (catch 'tag
+        ;;   (dolist (domain char-db-feature-domains)
+        ;;     (if (and (setq ret (char-feature
+        ;;                         char
+        ;;                         (intern
+        ;;                          (format "%s@%s"
+        ;;                                  'ideographic-radical domain))))
+        ;;              (or (eq ret radical)
+        ;;                  (null radical)))
+        ;;         (throw 'tag ret))))
+       (catch 'tag
+         (dolist (cell (get-char-attribute char 'ideographic-))
+           (if (and (setq ret (plist-get cell :radical))
+                    (or (eq ret radical)
+                        (null radical)))
+               (throw 'tag ret))))
+       (get-char-feature-from-domains
+        char 'ideographic-radical (cons nil char-db-feature-domains))
+        ;; (char-feature char 'ideographic-radical)
+       (progn
+         (setq ret
+               (or (get-char-attribute char 'daikanwa-radical)
+                   (get-char-attribute char 'kangxi-radical)
+                   (get-char-attribute char 'japanese-radical)
+                   (get-char-attribute char 'korean-radical)))
+         (when ret
+           (put-char-attribute char 'ideographic-radical ret)
+           ret)))))
+
+
 ;;; @ end
 ;;;