annotate lisp/international/ja-dic-cnv.el @ 110585:677b6dea1d61

gnus-sum.el (gnus-auto-center-group): Transform into a defcustom. gnus.el (gnus-group-fast-parameter): Return the last matching parameter instead of the first matching parameter. auth-source.el (auth-source-user-or-password): Query for password, although there are no existing auth sources. auth-source.el (auth-source-user-or-password): Use the existing auth sources, if any, for creation.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Sun, 26 Sep 2010 12:47:09 +0000
parents e8f730fcd169
children 376148b31b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 36681
diff changeset
1 ;;; ja-dic-cnv.el --- convert a Japanese dictionary (SKK-JISYO.L) to Emacs Lisp
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2
74605
6ee41fdd69ff Update AIST copyright years.
Kenichi Handa <handa@m17n.org>
parents: 74544
diff changeset
3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 106255
diff changeset
4 ;; 2005, 2006, 2007, 2008, 2009, 2010
62274
c36561fe0657 Fix copyrights.
Kenichi Handa <handa@m17n.org>
parents: 52401
diff changeset
5 ;; National Institute of Advanced Industrial Science and Technology (AIST)
c36561fe0657 Fix copyrights.
Kenichi Handa <handa@m17n.org>
parents: 52401
diff changeset
6 ;; Registration Number H14PRO021
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
7
106255
7f0c795dd2e7 * international/isearch-x.el, international/ja-dic-cnv.el,
Kevin Ryde <user42@zip.com.au>
parents: 105813
diff changeset
8 ;; Keywords: i18n, mule, multilingual, Japanese
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
9
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
11
94664
889bc336b89b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
94664
889bc336b89b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
14 ;; the Free Software Foundation, either version 3 of the License, or
889bc336b89b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
15 ;; (at your option) any later version.
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
16
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
21
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
94664
889bc336b89b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
24
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
25 ;;; Commentary:
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
26
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
27 ;; SKK is a Japanese input method running on Mule created by Masahiko
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
28 ;; Sato <masahiko@sato.riec.tohoku.ac.jp>. Here we provide utilities
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
29 ;; to handle a dictionary distributed with SKK so that a different
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
30 ;; input method (e.g. quail-japanese) can utilize the dictionary.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
31
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
32 ;; The format of SKK dictionary is quite simple. Each line has the
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
33 ;; form "KANASTRING /CONV1/CONV2/.../" which means KANASTRING ($B2>L>J8(B
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
34 ;; $B;zNs(B) can be converted to one of CONVi. CONVi is a Kanji ($B4A;z(B)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
35 ;; and Kana ($B2>L>(B) mixed string.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
36 ;;
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
37 ;; KANASTRING may have a trailing ASCII letter for Okurigana ($BAw$j2>L>(B)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
38 ;; information. For instance, the trailing letter `k' means that one
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
39 ;; of the following Okurigana is allowed: $B$+$-$/$1$3(B. So, in that
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
40 ;; case, the string "KANASTRING$B$/(B" can be converted to one of "CONV1$B$/(B",
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
41 ;; CONV2$B$/(B, ...
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
42
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
43 ;;; Code:
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
44
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
45 ;; Name of a file to generate from SKK dictionary.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
46 (defvar ja-dic-filename "ja-dic.el")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
47
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
48 (defun skkdic-convert-okuri-ari (skkbuf buf)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
49 (message "Processing OKURI-ARI entries ...")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
50 (goto-char (point-min))
105813
df4934f25eef * textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
51 (with-current-buffer buf
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
52 (insert ";; Setting okuri-ari entries.\n"
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
53 "(skkdic-set-okuri-ari\n"))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
54 (while (not (eobp))
107160
e8f730fcd169 Fix for the new SKK-JISYO.L format.
Kenichi Handa <handa@m17n.org>
parents: 106815
diff changeset
55 (if (/= (following-char) ?>)
e8f730fcd169 Fix for the new SKK-JISYO.L format.
Kenichi Handa <handa@m17n.org>
parents: 106815
diff changeset
56 (let ((from (point))
e8f730fcd169 Fix for the new SKK-JISYO.L format.
Kenichi Handa <handa@m17n.org>
parents: 106815
diff changeset
57 (to (line-end-position)))
e8f730fcd169 Fix for the new SKK-JISYO.L format.
Kenichi Handa <handa@m17n.org>
parents: 106815
diff changeset
58 (with-current-buffer buf
e8f730fcd169 Fix for the new SKK-JISYO.L format.
Kenichi Handa <handa@m17n.org>
parents: 106815
diff changeset
59 (insert-buffer-substring skkbuf from to)
e8f730fcd169 Fix for the new SKK-JISYO.L format.
Kenichi Handa <handa@m17n.org>
parents: 106815
diff changeset
60 (beginning-of-line)
e8f730fcd169 Fix for the new SKK-JISYO.L format.
Kenichi Handa <handa@m17n.org>
parents: 106815
diff changeset
61 (insert "\"")
e8f730fcd169 Fix for the new SKK-JISYO.L format.
Kenichi Handa <handa@m17n.org>
parents: 106815
diff changeset
62 (search-forward " ")
e8f730fcd169 Fix for the new SKK-JISYO.L format.
Kenichi Handa <handa@m17n.org>
parents: 106815
diff changeset
63 (delete-char 1) ; delete the first '/'
e8f730fcd169 Fix for the new SKK-JISYO.L format.
Kenichi Handa <handa@m17n.org>
parents: 106815
diff changeset
64 (let ((p (point)))
e8f730fcd169 Fix for the new SKK-JISYO.L format.
Kenichi Handa <handa@m17n.org>
parents: 106815
diff changeset
65 (end-of-line)
e8f730fcd169 Fix for the new SKK-JISYO.L format.
Kenichi Handa <handa@m17n.org>
parents: 106815
diff changeset
66 (delete-char -1) ; delete the last '/'
e8f730fcd169 Fix for the new SKK-JISYO.L format.
Kenichi Handa <handa@m17n.org>
parents: 106815
diff changeset
67 (subst-char-in-region p (point) ?/ ? 'noundo))
e8f730fcd169 Fix for the new SKK-JISYO.L format.
Kenichi Handa <handa@m17n.org>
parents: 106815
diff changeset
68 (insert "\"\n"))))
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
69
107160
e8f730fcd169 Fix for the new SKK-JISYO.L format.
Kenichi Handa <handa@m17n.org>
parents: 106815
diff changeset
70 (forward-line 1))
105813
df4934f25eef * textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
71 (with-current-buffer buf
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
72 (insert ")\n\n")))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
73
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
74 (defconst skkdic-postfix-list '(skkdic-postfix-list))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
75
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
76 (defconst skkdic-postfix-data
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
77 '(("$B$$$-(B" "$B9T(B")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
78 ("$B$,$+$j(B" "$B78(B")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
79 ("$B$,$/(B" "$B3X(B")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
80 ("$B$,$o(B" "$B@n(B")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
81 ("$B$7$c(B" "$B<R(B")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
82 ("$B$7$e$&(B" "$B=8(B")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
83 ("$B$7$g$&(B" "$B>^(B" "$B>k(B")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
84 ("$B$8$g$&(B" "$B>k(B")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
85 ("$B$;$s(B" "$B@~(B")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
86 ("$B$@$1(B" "$B3Y(B")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
87 ("$B$A$c$/(B" "$BCe(B")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
88 ("$B$F$s(B" "$BE9(B")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
89 ("$B$H$&$2(B" "$BF=(B")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
90 ("$B$I$*$j(B" "$BDL$j(B")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
91 ("$B$d$^(B" "$B;3(B")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
92 ("$B$P$7(B" "$B66(B")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
93 ("$B$O$D(B" "$BH/(B")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
94 ("$B$b$/(B" "$BL\(B")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
95 ("$B$f$-(B" "$B9T(B")))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
96
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
97 (defun skkdic-convert-postfix (skkbuf buf)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
98 (message "Processing POSTFIX entries ...")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
99 (goto-char (point-min))
105813
df4934f25eef * textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
100 (with-current-buffer buf
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
101 (insert ";; Setting postfix entries.\n"
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
102 "(skkdic-set-postfix\n"))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
103
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
104 ;; Initialize SKKDIC-POSTFIX-LIST by predefined data
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
105 ;; SKKDIC-POSTFIX-DATA.
105813
df4934f25eef * textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
106 (with-current-buffer buf
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
107 (let ((l skkdic-postfix-data)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
108 kana candidates entry)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
109 (while l
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
110 (setq kana (car (car l)) candidates (cdr (car l)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
111 (insert "\"" kana)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
112 (while candidates
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
113 (insert " " (car candidates))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
114 (setq entry (lookup-nested-alist (car candidates)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
115 skkdic-postfix-list nil nil t))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
116 (if (consp (car entry))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
117 (setcar entry (cons kana (car entry)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
118 (set-nested-alist (car candidates) (list kana)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
119 skkdic-postfix-list))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
120 (setq candidates (cdr candidates)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
121 (insert "\"\n")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
122 (setq l (cdr l)))))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
123
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
124 ;; Search postfix entries.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
125 (while (re-search-forward "^[#<>?]\\(\\(\\cH\\|$B!<(B\\)+\\) " nil t)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
126 (let ((kana (match-string 1))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
127 str candidates)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
128 (while (looking-at "/[#0-9 ]*\\([^/\n]*\\)/")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
129 (setq str (match-string 1))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
130 (if (not (member str candidates))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
131 (setq candidates (cons str candidates)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
132 (goto-char (match-end 1)))
105813
df4934f25eef * textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
133 (with-current-buffer buf
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
134 (insert "\"" kana)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
135 (while candidates
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
136 (insert " " (car candidates))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
137 (let ((entry (lookup-nested-alist (car candidates)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
138 skkdic-postfix-list nil nil t)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
139 (if (consp (car entry))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
140 (if (not (member kana (car entry)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
141 (setcar entry (cons kana (car entry))))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
142 (set-nested-alist (car candidates) (list kana)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
143 skkdic-postfix-list)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
144 (setq candidates (cdr candidates)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
145 (insert "\"\n"))))
105813
df4934f25eef * textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
146 (with-current-buffer buf
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
147 (insert ")\n\n")))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46671
diff changeset
148
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
149 (defconst skkdic-prefix-list '(skkdic-prefix-list))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
150
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
151 (defun skkdic-convert-prefix (skkbuf buf)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
152 (message "Processing PREFIX entries ...")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
153 (goto-char (point-min))
105813
df4934f25eef * textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
154 (with-current-buffer buf
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
155 (insert ";; Setting prefix entries.\n"
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
156 "(skkdic-set-prefix\n"))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
157 (save-excursion
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
158 (while (re-search-forward "^\\(\\(\\cH\\|$B!<(B\\)+\\)[<>?] " nil t)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
159 (let ((kana (match-string 1))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
160 str candidates)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
161 (while (looking-at "/\\([^/\n]+\\)/")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
162 (setq str (match-string 1))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
163 (if (not (member str candidates))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
164 (setq candidates (cons str candidates)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
165 (goto-char (match-end 1)))
105813
df4934f25eef * textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
166 (with-current-buffer buf
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
167 (insert "\"" kana)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
168 (while candidates
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
169 (insert " " (car candidates))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
170 (set-nested-alist (car candidates) kana skkdic-prefix-list)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
171 (setq candidates (cdr candidates)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
172 (insert "\"\n")))))
105813
df4934f25eef * textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
173 (with-current-buffer buf
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
174 (insert ")\n\n")))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46671
diff changeset
175
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
176 ;; FROM and TO point the head and tail of "/J../J../.../".
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
177 (defun skkdic-get-candidate-list (from to)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
178 (let (candidates)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
179 (goto-char from)
34626
6e98a6e86b7f (skkdic-get-candidate-list): Fix the regexp to search for candidates.
Kenichi Handa <handa@m17n.org>
parents: 34532
diff changeset
180 (while (re-search-forward "/[^/ \n]+" to t)
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
181 (setq candidates (cons (buffer-substring (1+ (match-beginning 0))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
182 (match-end 0))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
183 candidates)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
184 candidates))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
185
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
186 ;; Return entry for STR from nested alist ALIST.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
187 (defsubst skkdic-get-entry (str alist)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
188 (car (lookup-nested-alist str alist nil nil t)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
189
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
190
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
191 (defconst skkdic-word-list '(skkdic-word-list))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
192
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
193 ;; Return t if substring of STR (between FROM and TO) can be broken up
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
194 ;; to chunks all of which can be derived from another entry in SKK
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
195 ;; dictionary. SKKBUF is the buffer where the original SKK dictionary
78484
edc666d07b2c Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents: 78310
diff changeset
196 ;; is visited, KANA is the current entry for STR. FIRST is t only if
edc666d07b2c Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents: 78310
diff changeset
197 ;; this is called at top level.
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
198
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
199 (defun skkdic-breakup-string (skkbuf kana str from to &optional first)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
200 (let ((len (- to from)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
201 (or (and (>= len 2)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
202 (let ((min-idx (+ from 2))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
203 (idx (if first (1- to ) to))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
204 (found nil))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
205 (while (and (not found) (>= idx min-idx))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
206 (let ((kana2-list (skkdic-get-entry
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
207 (substring str from idx)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
208 skkdic-word-list)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
209 (if (or (and (consp kana2-list)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
210 (let ((kana-len (length kana))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
211 kana2)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
212 (catch 'skkdic-tag
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
213 (while kana2-list
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
214 (setq kana2 (car kana2-list))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
215 (if (string-match kana2 kana)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
216 (throw 'skkdic-tag t))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
217 (setq kana2-list (cdr kana2-list)))))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
218 (or (= idx to)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
219 (skkdic-breakup-string skkbuf kana str
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
220 idx to)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
221 (and (stringp kana2-list)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
222 (string-match kana2-list kana)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
223 (setq found t)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
224 (setq idx (1- idx)))))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
225 found))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
226 (and first
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
227 (> len 2)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
228 (let ((kana2 (skkdic-get-entry
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
229 (substring str from (1+ from))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
230 skkdic-prefix-list)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
231 (and (stringp kana2)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
232 (eq (string-match kana2 kana) 0)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
233 (skkdic-breakup-string skkbuf kana str (1+ from) to))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
234 (and (not first)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
235 (>= len 1)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
236 (let ((kana2-list (skkdic-get-entry
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
237 (substring str from to)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
238 skkdic-postfix-list)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
239 (and (consp kana2-list)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
240 (let (kana2)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
241 (catch 'skkdic-tag
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
242 (while kana2-list
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
243 (setq kana2 (car kana2-list))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
244 (if (string= kana2
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
245 (substring kana (- (length kana2))))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
246 (throw 'skkdic-tag t))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
247 (setq kana2-list (cdr kana2-list)))))))))))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
248
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
249 ;; Return list of candidates which excludes some from CANDIDATES.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
250 ;; Excluded candidates can be derived from another entry.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
251
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
252 (defun skkdic-reduced-candidates (skkbuf kana candidates)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
253 (let (elt l)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
254 (while candidates
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
255 (setq elt (car candidates))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
256 (if (or (= (length elt) 1)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
257 (and (string-match "^\\cj" elt)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
258 (not (skkdic-breakup-string skkbuf kana elt 0 (length elt)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
259 'first))))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
260 (setq l (cons elt l)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
261 (setq candidates (cdr candidates)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
262 (nreverse l)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
263
51055
b3d9bd5b31b8 (skkdic-okuri-nasi-entries, skkdic-okuri-nasi-entries-count):
John Paul Wallington <jpw@pobox.com>
parents: 49598
diff changeset
264 (defvar skkdic-okuri-nasi-entries (list nil))
b3d9bd5b31b8 (skkdic-okuri-nasi-entries, skkdic-okuri-nasi-entries-count):
John Paul Wallington <jpw@pobox.com>
parents: 49598
diff changeset
265 (defvar skkdic-okuri-nasi-entries-count 0)
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
266
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
267 (defun skkdic-collect-okuri-nasi ()
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
268 (message "Collecting OKURI-NASI entries ...")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
269 (save-excursion
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
270 (let ((prev-ratio 0)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
271 ratio)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
272 (while (re-search-forward "^\\(\\(\\cH\\|$B!<(B\\)+\\) \\(/\\cj.*\\)/$"
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
273 nil t)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
274 (let ((kana (match-string 1))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
275 (candidates (skkdic-get-candidate-list (match-beginning 3)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
276 (match-end 3))))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
277 (setq skkdic-okuri-nasi-entries
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
278 (cons (cons kana candidates) skkdic-okuri-nasi-entries)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
279 skkdic-okuri-nasi-entries-count
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
280 (1+ skkdic-okuri-nasi-entries-count))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
281 (setq ratio (floor (/ (* (point) 100.0) (point-max))))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
282 (if (/= ratio prev-ratio)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
283 (progn
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
284 (message "collected %2d%% %s ..." ratio kana)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
285 (setq prev-ratio ratio)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
286 (while candidates
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
287 (let ((entry (lookup-nested-alist (car candidates)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
288 skkdic-word-list nil nil t)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
289 (if (consp (car entry))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
290 (setcar entry (cons kana (car entry)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
291 (set-nested-alist (car candidates) (list kana)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
292 skkdic-word-list)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
293 (setq candidates (cdr candidates))))))))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
294
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
295 (defun skkdic-convert-okuri-nasi (skkbuf buf)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
296 (message "Processing OKURI-NASI entries ...")
105813
df4934f25eef * textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
297 (with-current-buffer buf
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
298 (insert ";; Setting okuri-nasi entries.\n"
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
299 "(skkdic-set-okuri-nasi\n")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
300 (let ((l (nreverse skkdic-okuri-nasi-entries))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
301 (count 0)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
302 (prev-ratio 0)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
303 ratio)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
304 (while l
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
305 (let ((kana (car (car l)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
306 (candidates (cdr (car l))))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
307 (setq ratio (/ (* count 1000) skkdic-okuri-nasi-entries-count)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
308 count (1+ count))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
309 (if (/= prev-ratio (/ ratio 10))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
310 (progn
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
311 (message "processed %2d%% %s ..." (/ ratio 10) kana)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
312 (setq prev-ratio (/ ratio 10))))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
313 (if (setq candidates
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
314 (skkdic-reduced-candidates skkbuf kana candidates))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
315 (progn
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
316 (insert "\"" kana)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
317 (while candidates
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
318 (insert " " (car candidates))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
319 (setq candidates (cdr candidates)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
320 (insert "\"\n"))))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
321 (setq l (cdr l))))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
322 (insert ")\n\n")))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
323
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
324 (defun skkdic-convert (filename &optional dirname)
73796
3da9d5d6d1dc (skkdic-convert): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 64085
diff changeset
325 "Generate Emacs Lisp file form Japanese dictionary file FILENAME.
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
326 The format of the dictionary file should be the same as SKK dictionaries.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
327 Optional argument DIRNAME if specified is the directory name under which
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
328 the generated Emacs Lisp is saved.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
329 The name of generated file is specified by the variable `ja-dic-filename'."
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
330 (interactive "FSKK dictionary file: ")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
331 (message "Reading file \"%s\" ..." filename)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
332 (let* ((coding-system-for-read 'euc-japan)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
333 (skkbuf(find-file-noselect (expand-file-name filename)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
334 (buf (get-buffer-create "*skkdic-work*")))
105813
df4934f25eef * textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
335 ;; Setup and generate the header part of working buffer.
df4934f25eef * textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
336 (with-current-buffer buf
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
337 (erase-buffer)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
338 (buffer-disable-undo)
46671
1c5996975536 (skkdic-convert): Add coding cookie.
Dave Love <fx@gnu.org>
parents: 38479
diff changeset
339 (insert ";;; ja-dic.el --- dictionary for Japanese input method"
107160
e8f730fcd169 Fix for the new SKK-JISYO.L format.
Kenichi Handa <handa@m17n.org>
parents: 106815
diff changeset
340 " -*-coding: euc-japan; byte-compile-disable-print-circle:t; -*-\n"
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
341 ";;\tGenerated by the command `skkdic-convert'\n"
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
342 ";;\tDate: " (current-time-string) "\n"
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
343 ";;\tOriginal SKK dictionary file: "
75395
05d001ce4826 (skkdic-convert): Insert a relative
Kenichi Handa <handa@m17n.org>
parents: 75364
diff changeset
344 (file-relative-name (expand-file-name filename) dirname)
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
345 "\n\n"
38479
758a6e658e72 Doc and coding conventions fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 38414
diff changeset
346 ";; This file is part of GNU Emacs.\n\n"
758a6e658e72 Doc and coding conventions fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 38414
diff changeset
347 ";;; Commentary:\n\n"
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
348 ";; Do byte-compile this file again after any modification.\n\n"
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
349 ";;; Start of the header of the original SKK dictionary.\n\n")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
350 (set-buffer skkbuf)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
351 (widen)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
352 (goto-char 1)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
353 (let (pos)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
354 (search-forward ";; okuri-ari")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
355 (forward-line 1)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
356 (setq pos (point))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
357 (set-buffer buf)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
358 (insert-buffer-substring skkbuf 1 pos))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
359 (insert "\n"
31196
28b5eff78c33 (skkdic-convert): Insert (require 'ja-dic-cnv), not (require
Kenichi Handa <handa@m17n.org>
parents: 31164
diff changeset
360 ";;; Code:\n\n(eval-when-compile (require 'ja-dic-cnv))\n\n")
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
361
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
362 ;; Generate the body part of working buffer.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
363 (set-buffer skkbuf)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
364 (let ((from (point))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
365 to)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
366 ;; Convert okuri-ari entries.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
367 (search-forward ";; okuri-nasi")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
368 (beginning-of-line)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
369 (setq to (point))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
370 (narrow-to-region from to)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
371 (skkdic-convert-okuri-ari skkbuf buf)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
372 (widen)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
373
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
374 ;; Convert okuri-nasi postfix entries.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
375 (goto-char to)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
376 (forward-line 1)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
377 (setq from (point))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
378 (re-search-forward "^\\cH")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
379 (setq to (match-beginning 0))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
380 (narrow-to-region from to)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
381 (skkdic-convert-postfix skkbuf buf)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
382 (widen)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
383
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
384 ;; Convert okuri-nasi prefix entries.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
385 (goto-char to)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
386 (skkdic-convert-prefix skkbuf buf)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
387
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46671
diff changeset
388 ;;
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
389 (skkdic-collect-okuri-nasi)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
390
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
391 ;; Convert okuri-nasi general entries.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
392 (skkdic-convert-okuri-nasi skkbuf buf)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
393
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
394 ;; Postfix
105813
df4934f25eef * textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
395 (with-current-buffer buf
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
396 (goto-char (point-max))
38479
758a6e658e72 Doc and coding conventions fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 38414
diff changeset
397 (insert ";;\n(provide 'ja-dic)\n\n;;; ja-dic.el ends here\n")))
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
398
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
399 ;; Save the working buffer.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
400 (set-buffer buf)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
401 (set-visited-file-name (expand-file-name ja-dic-filename dirname) t)
107160
e8f730fcd169 Fix for the new SKK-JISYO.L format.
Kenichi Handa <handa@m17n.org>
parents: 106815
diff changeset
402 (set-buffer-file-coding-system 'euc-japan)
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
403 (save-buffer 0))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
404 (kill-buffer skkbuf)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
405 (switch-to-buffer buf)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
406
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
407 (defun batch-skkdic-convert ()
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
408 "Run `skkdic-convert' on the files remaining on the command line.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
409 Use this from the command line, with `-batch';
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
410 it won't work in an interactive Emacs.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
411 For example, invoke:
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
412 % emacs -batch -l ja-dic-cnv -f batch-skkdic-convert SKK-JISYO.L
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
413 to generate \"ja-dic.el\" from SKK dictionary file \"SKK-JISYO.L\".
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
414 To get complete usage, invoke:
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
415 % emacs -batch -l ja-dic-cnv -f batch-skkdic-convert -h"
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
416 (defvar command-line-args-left) ; Avoid compiler warning.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
417 (if (not noninteractive)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
418 (error "`batch-skkdic-convert' should be used only with -batch"))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
419 (if (string= (car command-line-args-left) "-h")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
420 (progn
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
421 (message "To convert SKK-JISYO.L into skkdic.el:")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
422 (message " %% emacs -batch -l ja-dic-cnv -f batch-skkdic-convert SKK-JISYO.L")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
423 (message "To convert SKK-JISYO.L into DIR/ja-dic.el:")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
424 (message " %% emacs -batch -l ja-dic-cnv -f batch-skkdic-convert -dir DIR SKK-JISYO.L"))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
425 (let (targetdir filename)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
426 (if (string= (car command-line-args-left) "-dir")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
427 (progn
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
428 (setq command-line-args-left (cdr command-line-args-left))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
429 (setq targetdir (expand-file-name (car command-line-args-left)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
430 (setq command-line-args-left (cdr command-line-args-left))))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
431 (setq filename (expand-file-name (car command-line-args-left)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
432 (message "Converting %s to %s ..." filename ja-dic-filename)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
433 (message "It takes around 10 minutes even on Sun SS20.")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
434 (skkdic-convert filename targetdir)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
435 (message "Do byte-compile the created file by:")
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
436 (message " %% emacs -batch -f batch-byte-compile %s" ja-dic-filename)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
437 ))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
438 (kill-emacs 0))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
439
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
440
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
441 ;; The following macros are expanded at byte-compiling time so that
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
442 ;; compiled code can be loaded quickly.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
443
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
444 (defun skkdic-get-kana-compact-codes (kana)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
445 (let* ((len (length kana))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
446 (vec (make-vector len 0))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
447 (i 0)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
448 ch)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
449 (while (< i len)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
450 (setq ch (aref kana i))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
451 (aset vec i
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
452 (if (< ch 128) ; CH is an ASCII letter for OKURIGANA,
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
453 (- ch) ; represented by a negative code.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
454 (if (= ch ?$B!<(B) ; `$B!<(B' is represented by 0.
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
455 0
88406
934ee50a6eb3 (skkdic-get-kana-compact-codes): Call encode-char instead of
Kenichi Handa <handa@m17n.org>
parents: 38479
diff changeset
456 (- (logand (encode-char ch 'japanese-jisx0208) #xFF) 32))))
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
457 (setq i (1+ i)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
458 vec))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
459
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
460 (defun skkdic-extract-conversion-data (entry)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
461 (string-match "^\\cj+[a-z]* " entry)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
462 (let ((kana (substring entry (match-beginning 0) (1- (match-end 0))))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
463 (i (match-end 0))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
464 candidates)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
465 (while (string-match "[^ ]+" entry i)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
466 (setq candidates (cons (match-string 0 entry) candidates))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
467 (setq i (match-end 0)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
468 (cons (skkdic-get-kana-compact-codes kana) candidates)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
469
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
470 (defmacro skkdic-set-okuri-ari (&rest entries)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
471 `(defconst skkdic-okuri-ari
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
472 ',(let ((l entries)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
473 (map '(skkdic-okuri-ari))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
474 entry)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
475 (while l
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
476 (setq entry (skkdic-extract-conversion-data (car l)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
477 (set-nested-alist (car entry) (cdr entry) map)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
478 (setq l (cdr l)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
479 map)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
480
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
481 (defmacro skkdic-set-postfix (&rest entries)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
482 `(defconst skkdic-postfix
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
483 ',(let ((l entries)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
484 (map '(nil))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
485 (longest 1)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
486 len entry)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
487 (while l
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
488 (setq entry (skkdic-extract-conversion-data (car l)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
489 (setq len (length (car entry)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
490 (if (> len longest)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
491 (setq longest len))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
492 (let ((entry2 (lookup-nested-alist (car entry) map nil nil t)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
493 (if (consp (car entry2))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
494 (let ((conversions (cdr entry)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
495 (while conversions
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
496 (if (not (member (car conversions) (car entry2)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
497 (setcar entry2 (cons (car conversions) (car entry2))))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
498 (setq conversions (cdr conversions))))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
499 (set-nested-alist (car entry) (cdr entry) map)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
500 (setq l (cdr l)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
501 (setcar map longest)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
502 map)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
503
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
504 (defmacro skkdic-set-prefix (&rest entries)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
505 `(defconst skkdic-prefix
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
506 ',(let ((l entries)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
507 (map '(nil))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
508 (longest 1)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
509 len entry)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
510 (while l
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
511 (setq entry (skkdic-extract-conversion-data (car l)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
512 (setq len (length (car entry)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
513 (if (> len longest)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
514 (setq longest len))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
515 (let ((entry2 (lookup-nested-alist (car entry) map len nil t)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
516 (if (consp (car entry2))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
517 (let ((conversions (cdr entry)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
518 (while conversions
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
519 (if (not (member (car conversions) (car entry2)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
520 (setcar entry2 (cons (car conversions) (car entry2))))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
521 (setq conversions (cdr conversions))))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
522 (set-nested-alist (car entry) (cdr entry) map len)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
523 (setq l (cdr l)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
524 (setcar map longest)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
525 map)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
526
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
527 (defmacro skkdic-set-okuri-nasi (&rest entries)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
528 `(defconst skkdic-okuri-nasi
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
529 ',(let ((l entries)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
530 (map '(skdic-okuri-nasi))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
531 (count 0)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
532 entry)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
533 (while l
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
534 (setq count (1+ count))
34532
dad96251e889 (skkdic-set-okuri-nasi): Show
Kenichi Handa <handa@m17n.org>
parents: 31196
diff changeset
535 (if (= (% count 10000) 0)
87170
e50a2e215441 * erc-stamp.el (erc-echo-timestamp):
David Kastrup <dak@gnu.org>
parents: 78484
diff changeset
536 (message "%d entries" count))
31164
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
537 (setq entry (skkdic-extract-conversion-data (car l)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
538 (set-nested-alist (car entry) (cdr entry) map)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
539 (setq l (cdr l)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
540 map)))
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
541
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
542 (provide 'ja-dic-cnv)
bb7de354d69f Renamed from skkdic-cnv.el.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
543
36681
8f93fc285ff3 Add coding: tag in Loval Vairables: section.
Kenichi Handa <handa@m17n.org>
parents: 34626
diff changeset
544 ;; Local Variables:
8f93fc285ff3 Add coding: tag in Loval Vairables: section.
Kenichi Handa <handa@m17n.org>
parents: 34626
diff changeset
545 ;; coding: iso-2022-7bit
8f93fc285ff3 Add coding: tag in Loval Vairables: section.
Kenichi Handa <handa@m17n.org>
parents: 34626
diff changeset
546 ;; End:
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 36681
diff changeset
547
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91327
diff changeset
548 ;; arch-tag: dec06fb0-8118-45b1-80d7-dc360b6fd3b2
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 36681
diff changeset
549 ;;; ja-dic-cnv.el ends here