Debian Codegraph @

experimental/skk-correct.el

raw
1 ;;; skk-correct.el --- correct key word for conversion. -*- coding: iso-2022-jp -*-
2
3 ;; Copyright (C) 1999 NAKAJIMA Mikio <[email protected]>
4
5 ;; Author: NAKAJIMA Mikio <[email protected]>
6 ;; Maintainer: SKK Development Team
7 ;; URL: https://github.com/skk-dev/ddskk
8 ;; Keywords: japanese
9
10 ;; This file is part of Daredevil SKK.
11
12 ;; This program is free software: you can redistribute it and/or
13 ;; modify it under the terms of the GNU General Public License as
14 ;; published by the Free Software Foundation, either version 3 of
15 ;; the License, or (at your option) any later version.
16
17 ;; This program is distributed in the hope that it will be
18 ;; useful, but WITHOUT ANY WARRANTY; without even the implied
19 ;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 ;; PURPOSE. See the GNU General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
24
25 ;;; Commentary:
26
27 ;; $B<-=qCf$K$J$$FI$_$N%V%l$?8+=P$78l$GJQ49$7$?:]$K!"FbIt$G(B skk-correct-table
28 ;; $B$r;2>H$7$F@5$7$$8+=P$78l$KCV$-49$(8uJd$r8!:w$9$k%W%m%0%i%`$G$9!#(B
29 ;; skk-correct-search $B$N0z?t$K!"%V%lJd@58e$K8!:w$7$?$$<-=q$r!"(B
30 ;; skk-search-prog-list $B$HF1$8MWNN$G%j%9%H$GI=$7!"8!:w%W%m%0%i%`$H$H$b$K5-:\(B
31 ;; $B$7$F2<$5$$!#Nc$($P$3$s$J46$8$G$9!#(B
32
33 ;; (skk-correct-search
34 ;; '((skk-search-jisyo-file skk-jisyo 0 t)
35 ;; (skk-search-server skk-aux-large-jisyo 10000)
36 ;; (skk-okuri-search)))
37
38 ;; * $B>e5-$NNc$G$O!"Jd@5$7$?8+=P$78l$KBP$7!"8D?M<-=q!"%5!<%P!<!"<+F0Aw$j(B
39 ;; $B=hM}$7$F8D?M<-=q$H$$$&8!:w$r9T$J$$$^$9$,!"$I$3$+$GJd@58e$N8+=P$78l(B
40 ;; $B$KBP$9$k8uJd$,8+$D$+$l$P$=$l0J>e$O8!:w$r9T$J$$$^$;$s!#(B
41
42 ;; $B$3$l$r99$K(B skk-search-prog-list $B$NCf$NE,Ev$J8D=j$KF~$l$^$7$g$&!#2<5-$N$h(B
43 ;; $B$&$K8D?M<-=q8!:wD>8e$K!"0lEY8+=P$78l$rJd@5$7$F8D?M<-=q$r8!:w$7D>$7!"%5!<(B
44 ;; $B%P!<8!:w8e$K8+$D$+$i$J$+$C$?$i:FEYJd@5$7$F%5!<%P!<$r8!:w$9$k!"$H$$$&$N$b(B
45 ;; $B0l0F$G$9!#$"$k$$$O!"8D?M$NJJ$r$b$m$KH?1G$7$F$$$k8D?M<-=q$N%V%lJd@5$O;_$a(B
46 ;; $B$F!"%5!<%P!<$N$_Jd@58e8!:w$r$9$k!"$H$$$&$N$bNI$$$G$7$g$&!#(B
47
48 ;; (setq skk-search-prog-list
49 ;; '((skk-search-jisyo-file skk-jisyo 0 t)
50 ;; (skk-correct-search '((skk-search-jisyo-file skk-jisyo 0 t)))
51 ;; (skk-search-server skk-aux-large-jisyo 10000)
52 ;; (skk-okuri-search)
53 ;; (skk-correct-search
54 ;; '((skk-search-server skk-aux-large-jisyo 10000)
55 ;; (skk-okuri-search)))))
56
57 ;; $B8=:_$N$H$3$m!"(Bskk-correct-table $B$N3FMWAG$r:G=i$+$i=g$K<h$j=P$7!"%V%l$?8+(B
58 ;; $B=P$78l$,$J$$$+$I$&$+$rD4$Y$F!"%V%l$,8+$D$+$C$?$i$=$l0J>e(B skk-correct-table
59 ;; $B$N8eH>ItJ,$O8+$J$$;EMM$K$J$C$F$$$^$9!#(B
60 ;; $B$H$j$"$($:(B Naoki Wakamatsu <[email protected]> $B$5$s$,(B Message-Id:
61 ;; <[email protected]> $B$GNs5s$7$F$/$@$5$C$?FI$_$N%V%l$r(B
62 ;; $BC1=c$K(B sort $B$7$F!"(B2 $BJ8;z$N$b$N(B, 1 $BJ8;z$N$b$N$H$$$&=g$G(B skk-correct-table
63 ;; $B$K<}$a$F$$$^$9$,!">e5-$N$h$&$K2?$+0l$D%V%l$,8+$D$+$C$?$i$=$l0J>e$O%F!<%V%k(B
64 ;; $B$r8+$F$$$J$$$N$G!"$3$N%F!<%V%k$N%V%l$NM%@h=g0L$O8!F$$7$?J}$,NI$$$G$7$g$&!#(B
65
66 ;; $B:#8e$N2~NI$N%"%$%G%#%"$N0l$D$H$7$F$O!"JQ49>r7o$K1~$8$F8+$k%V%l$H8+$J$$%V%l(B
67 ;; $B$r:n$k$N$bNI$$$+$b$7$l$^$;$s!#Nc$($P!"$3$N%V%l$OAw$j$"$jJQ49$N$H$-$@$1$7$+(B
68 ;; $B8!:w$7$J$$!"$J$I$H$$$&$b$N$G$9!#$3$NJU$j$O<B:]$K;H$C$F$_$F$40U8+$r$*J9$+$;(B
69 ;; $B2<$5$$!#(B
70
71 ;; $B$J$*!"JQ49;~$KEv=i<j$GF~NO$7$?%V%l$?8+=P$78l$O!"$=$N$^$^8D?M<-=q$K<h$j9~$^(B
72 ;; $B$l$^$9$,!"$3$l$O;EMM$G$9!#2?8N$J$i!"3NDj;~$K$O!"3NDj$5$l$?8uJd$,!"8+=P$78l(B
73 ;; $B$N%V%l$rJd@5$7$F8+$D$1$?8uJd$+$I$&$+$r3NG'$9$k=Q$,8=:_$N$H$3$mDs6!$5$l$F$$(B
74 ;; $B$J$$$+$i$G$9!#(B
75
76 ;;; Code:
77
78 (eval-when-compile
79 (require 'skk-macs)
80 (require 'skk-vars))
81
82 (defgroup skk-correct nil "SKK correct related customization."
83 :prefix "skk-correct-"
84 :group 'skk)
85
86 (defvar skk-correct-table
87 '(
88 ;; 2 chars
89 ("$B$*!<(B" . "$B$*$&(B") ; $BBg$-$$(B
90 ("$B$*!<(B" . "$B$*$*(B")
91 ("$B$*$&(B" . "$B$*$*(B")
92 ("$B$H$&(B" . "$B$H$*(B") ; $BDL$k(B
93 ("$B$I$&(B" .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. "$B$o(B") ; $B$a$6$O(Br /$BL\>c(B/ -> $B$a$6$o(Br /$BL\>c(B/
110 ("$B$P(B" . "$B$O(B") ; $B$O$i(Bi /$BJ'(B/ -> $B$P$i(Bi /$BJ'(B/
111 ("$B$Q(B" . "$B$O(B") ; $B$Q(Bt /$BD%(B/ -> $B$O(Bt /$BD%(B/
112 ("$B$R(B" . "$B$$(B") ; $B$U$,$R$J(Bi /$Bg%9CHeL5(B/ -> $B$U$,$$$J(Bi /$Bg%9CHeL5(B/
113 ("$B$R(B" . "$B$S(B") ; $B$j$g$&$R$i(Bk /$BN>3+(B/ -> $B$j$g$&$S$i(Bk /$BN>3+(B/
114 ("$B$U(B" . "$B$V(B") ; $B$U$+(Bk /$B?<(B/ -> $B$V$+(Bk /$B?<(B/
115 ("$B$V(B" . "$B$U(B") ; $B$1$V$+(Bi /$BLS?<(B/ -> $B$1$U$+(Bi /$BLS?<(B/
116 ("$B$`(B" . "$B$s(B") ; $B$d$`$4$H$J(Bs /$B;_;vL5(B/ -> $B$d$s$4$H$J(Bs /$B;_;vL5(B/
117 ("$B$f(B" . "$B$$(B") ; $B$f$-$I(Bm /$B9T$-;_(B/ -> $B$$$-$I(Bm /$B9T$-;_(B/
118 ("$B$h(B" . "$B$$(B") ; $B$h(Bi /$BNI(B/ -> $B$$(Bi /$BNI(B/
119 ("$B$p(B" . "$B$$(B") ; $B$p(Br /$B5o(B/ -> $B$$(Br /$B5o(B/
120 )
121 "*$B8+=P$78lJQ49$N$?$a$N%F!<%V%k!#(B
122 $B3FMWAG$N%G!<%?9=B$$O!"(B\(\"$BFI$_$,$V$l$?8+=P$78l(B\" . \"$B@5$7$$8+=P$78l(B\"\)$B!#(B")
123
124 ;; internal variable
125 (defvar skk-correct-current-table nil)
126
127 ;; functions.
128 ;;;###autoload
129 (defun skk-correct-search (search-method-list)
130 (let ((henkan-key skk-henkan-key)
131 search-list skk-henkan-key v)
132 (setq skk-correct-current-table skk-correct-table)
133 (while (and (not v) (setq search-list search-method-list
134 skk-henkan-key (skk-correct henkan-key)))
135 (while (and search-list (not (setq v (eval (car search-list)))))
136 (setq search-list (cdr search-list))))
137 v))
138
139 (defun skk-correct (string)
140 ;; STRING $BCf$K%V%l$,$"$C$?$i$=$NItJ,$r@5$7$$J8;zNs$KCV$-49$($FJV$9!#(B
141 (let (v)
142 (save-match-data
143 (while (and (not v) skk-correct-current-table)
144 (if (string-match (car (car skk-correct-current-table)) string)
145 (setq v (concat (substring string 0 (match-beginning 0))
146 (cdr (car skk-correct-current-table))
147 (substring string (match-end 0)))))
148 (setq skk-correct-current-table (cdr skk-correct-current-table)))
149 v)))
150
151 (provide 'skk-correct)
152
153 ;; Local Variables:
154 ;; indent-tabs-mode: nil
155 ;; End:
156
157 ;;; skk-correct.el ends here