1 ;;; ids-find.el --- search utility based on Ideographic-structures
3 ;; Copyright (C) 2002 MORIOKA Tomohiko
5 ;; Author: MORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
6 ;; Keywords: Kanji, Ideographs, search, IDS
8 ;; This file is a part of Tomoyo-Tools.
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
15 ;; This program is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with this program; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 (defun ideographic-structure-char= (c1 c2)
30 (let ((m1 (char-ucs c1))
35 (setq m1 (car (get-char-attribute c1 '<-radical))
36 m2 (car (get-char-attribute c2 '<-radical)))
37 (unless (characterp m1)
38 (setq m1 (or (find-char m1))))
39 (unless (characterp m2)
40 (setq m2 (find-char m2)))
42 (ideographic-structure-char= m1 m2))))))))
44 (defun ideographic-structure-member-compare-parts (part s-part)
46 (cond ((char-ref= part s-part #'ideographic-structure-char=))
48 (if (setq ret (assq 'ideographic-structure s-part))
49 (ideographic-structure-member part (cdr ret))))
50 ((setq ret (get-char-attribute s-part 'ideographic-structure))
51 (ideographic-structure-member part ret)))))
53 (defun ideographic-structure-member (part structure)
55 (setq structure (cdr structure))
56 (ideographic-structure-member-compare-parts part (car structure)))
58 (setq structure (cdr structure))
59 (ideographic-structure-member-compare-parts part (car structure)))
61 (setq structure (cdr structure))
63 (ideographic-structure-member-compare-parts
64 part (car structure))))))
67 (defun ideographic-structure-search-chars (parts)
68 "Search Ideographs by PARTS."
69 (interactive "sParts : ")
70 (with-current-buffer (get-buffer-create " *ids-chars*")
71 (setq buffer-read-only nil)
77 ;; (member* p v :test #'char-ref=)
78 (ideographic-structure-member p v))
80 (insert (format "%c\t%s\n"
82 (or (ideographic-structure-to-ids v)
85 'ideographic-structure)
86 (goto-char (point-min)))
87 (view-buffer " *ids-chars*"))
95 ;;; ids-find.el ends here