Modify method to set up load-path.
[elisp/nabe.git] / skkdic-ext.el
1 ;;; skkdic-ext.el --- An extension for skkdic-util to support conjugation
2
3 ;; Copyright (C) 1996 MORIOKA Tomohiko
4
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Version: $Id: skkdic-ext.el,v 0.7 1996/11/12 09:13:25 morioka Exp $
7 ;; Keywords: input, Japanese, mule
8
9 ;; This file is not part of GNU Emacs.
10
11 ;; This program is free software; you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License as
13 ;; published by the Free Software Foundation; either version 2, or (at
14 ;; your option) any later version.
15
16 ;; This program is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 ;; General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Code:
27
28 (require 'skkdic-util)
29
30 (or (fboundp 'orig::skkdic-lookup-key)
31     (fset 'orig::skkdic-lookup-key
32           (symbol-function 'skkdic-lookup-key))
33     )
34
35 (defun skkdic-lookup-key (vec len &optional postfix ps)
36   "Return a list of conversion string for sequence SEQ of length LEN.
37
38 SEQ is a vector of Kana characters to be converted by SKK dictionary.
39 If LEN is shorter than the length of KEYSEQ, the first LEN keys in SEQ
40 is concerned.
41
42 Postfixes are concerned only if the optional argument POSTFIX is
43 non-nil.
44
45 \[skkdic-ext.el]"
46   (let ((dest (reverse (orig::skkdic-lookup-key vec len nil))))
47     (setq vec (subseq (copy-sequence vec) 0 len))
48     (let ((ws (cdr (assq ps skkdic-ext-suffix))))
49       (mapcar (lambda (word)
50                 (let ((ret (bottom-vector-string-match (aref word 1) vec)))
51                   (if ret
52                       (let* ((lr (length (cdr ret)))
53                              (pre (car ret))
54                              (lpre (length pre))
55                              )
56                         (if (= lpre 0)
57                             (let ((str
58                                    (mapconcat (function char-to-string)
59                                               (aref word 2)
60                                               "")))
61                               (or (member str dest)
62                                   (setq dest (cons str dest))
63                                   )
64                               )
65                           (let ((rret (skkdic-lookup-key
66                                        pre lpre nil (aref word 0)))
67                                 )
68                             (if rret
69                                 (let ((suf
70                                        (mapconcat (function char-to-string)
71                                                   (aref word 2)
72                                                   "")))
73                                   (mapcar (lambda (r)
74                                             (let ((str
75                                                    (concat
76                                                     (mapconcat
77                                                      (function char-to-string)
78                                                      r
79                                                      "")
80                                                     suf)))
81                                               (or (member str dest)
82                                                   (setq dest (cons str dest))
83                                                   )))
84                                           rret)))
85                             ))))))
86               ws))
87     dest))
88
89 (setq skkdic-ext-suffix
90       '((nil
91          [nil   "\e$B!#\e(B"      "\e$B!#\e(B"]
92          [nil   "\e$B!"\e(B"      "\e$B!"\e(B"]
93          [nil   "\e$B!)\e(B"      "\e$B!)\e(B"]
94          [nil   "\e$B!'\e(B"      "\e$B!'\e(B"]
95          [nil   "\e$B!(\e(B"      "\e$B!(\e(B"]
96          [nil   "\e$B$P$"$$\e(B" "\e$B>l9g\e(B"]
97          [nil   "\e$B$[$&$[$&\e(B" "\e$BJ}K!\e(B"]
98          [noun  "\e$B$h$j\e(B"    "\e$B$h$j\e(B"]
99          [noun  "\e$B$+$i\e(B"    "\e$B$+$i\e(B"]
100          [noun  "\e$B$X$O\e(B"    "\e$B$X$O\e(B"]
101          [noun  "\e$B$+$b\e(B"    "\e$B$+$b\e(B"]
102          [noun  "\e$B$G$b\e(B"    "\e$B$G$b\e(B"]
103          [noun  "\e$B$G$O\e(B"    "\e$B$G$O\e(B"]
104          [noun  "\e$B$h\e(B"      "\e$B$h\e(B"]
105          [noun  "\e$B$O\e(B"      "\e$B$O\e(B"]
106          [noun  "\e$B$,\e(B"      "\e$B$,\e(B"]
107          [noun  "\e$B$K\e(B"      "\e$B$K\e(B"]
108          [noun  "\e$B$r\e(B"      "\e$B$r\e(B"]
109          [noun  "\e$B$X\e(B"      "\e$B$X\e(B"]
110          [noun  "\e$B$N\e(B"      "\e$B$N\e(B"]
111          [noun  "\e$B$H\e(B"      "\e$B$H\e(B"]
112          [noun  "\e$B$+\e(B"      "\e$B$+\e(B"]
113          [noun  "\e$B$b\e(B"      "\e$B$b\e(B"]
114          [noun  "\e$B$G\e(B"      "\e$B$G\e(B"]
115          [noun  "\e$B$+\e(B"      "\e$B2=\e(B"]
116          [noun  "\e$B$+\e(B"      "\e$B$+\e(B"]
117          [noun  "\e$B$9\e(B"      "\e$B$9\e(B"]
118          [mizen "\e$B$&\e(B"      "\e$B$&\e(B"]
119          [renyou "\e$B$?\e(B"     "\e$B$?\e(B"]
120          [renyou "\e$B$F\e(B"     "\e$B$F\e(B"]
121          [renyou "\e$B$@\e(B"     "\e$B$@\e(B"]
122          [v-u1  "\e$B$k\e(B"      "\e$B$k\e(B"]
123          [v-u1  "\e$B$l\e(B"      "\e$B$l\e(B"]
124          [v-u1  "\e$B$h\e(B"      "\e$B$h\e(B"]
125          [v-k5  "\e$B$/\e(B"      "\e$B$/\e(B"]
126          [v-k5  "\e$B$1\e(B"      "\e$B$1\e(B"]
127          [v-g5  "\e$B$0\e(B"      "\e$B$0\e(B"]
128          [v-g5  "\e$B$2\e(B"      "\e$B$2\e(B"]
129          [v-s5  "\e$B$9\e(B"      "\e$B$9\e(B"]
130          [nil   "\e$B$9\e(B"      "\e$B$9\e(B"]
131          [nil   "\e$B$9$k\e(B"    "\e$B$9$k\e(B"]
132          [nil   "\e$B$9$l\e(B"    "\e$B$9$l\e(B"]
133          [nil   "\e$B$;$h\e(B"    "\e$B$;$h\e(B"]
134          [nil   "\e$B$7$m\e(B"    "\e$B$7$m\e(B"]
135          [v-s5  "\e$B$;\e(B"      "\e$B$;\e(B"]
136          [v-t5  "\e$B$D\e(B"      "\e$B$D\e(B"]
137          [v-t5  "\e$B$F\e(B"      "\e$B$F\e(B"]
138          [v-n5  "\e$B$L\e(B"      "\e$B$L\e(B"]
139          [v-n5  "\e$B$M\e(B"      "\e$B$M\e(B"]
140          [v-m5  "\e$B$`\e(B"      "\e$B$`\e(B"]
141          [v-m5  "\e$B$a\e(B"      "\e$B$a\e(B"]
142          [v-b5  "\e$B$V\e(B"      "\e$B$V\e(B"]
143          [v-b5  "\e$B$Y\e(B"      "\e$B$Y\e(B"]
144          [v-r5  "\e$B$k\e(B"      "\e$B$k\e(B"]
145          [v-r5  "\e$B$l\e(B"      "\e$B$l\e(B"]
146          [v-w5  "\e$B$&\e(B"      "\e$B$&\e(B"]
147          [v-w5  "\e$B$(\e(B"      "\e$B$(\e(B"]
148          [adj   "\e$B$$\e(B"      "\e$B$$\e(B"]
149          [adj   "\e$B$1$l\e(B"    "\e$B$1$l\e(B"]
150          [noun  "\e$B$7$c\e(B"    "\e$B<T\e(B"]
151          )
152         (noun
153          [nil   "\e$B$"$U$)!<$@$s$9\e(B" "\e$B%"%U%)!<%@%s%9\e(B"]
154          [nil   "\e$B$8$g$&$[$&\e(B"      "\e$B>pJs\e(B"]
155          )
156         (mizen
157          [adj   "\e$B$+$m\e(B"    "\e$B$+$m\e(B"]
158          [v-k5  "\e$B$+\e(B"      "\e$B$+\e(B"]
159          [v-k5  "\e$B$3\e(B"      "\e$B$3\e(B"]
160          [v-g5  "\e$B$,\e(B"      "\e$B$,\e(B"]
161          [v-g5  "\e$B$4\e(B"      "\e$B$4\e(B"]
162          [v-s5  "\e$B$5\e(B"      "\e$B$5\e(B"]
163          [v-s5  "\e$B$=\e(B"      "\e$B$=\e(B"]
164          [nil   "\e$B$;\e(B"      "\e$B$;\e(B"]
165          [v-t5  "\e$B$?\e(B"      "\e$B$?\e(B"]
166          [v-t5  "\e$B$H\e(B"      "\e$B$H\e(B"]
167          [v-n5  "\e$B$J\e(B"      "\e$B$J\e(B"]
168          [v-n5  "\e$B$N\e(B"      "\e$B$N\e(B"]
169          [v-m5  "\e$B$^\e(B"      "\e$B$^\e(B"]
170          [v-m5  "\e$B$b\e(B"      "\e$B$b\e(B"]
171          [v-b5  "\e$B$P\e(B"      "\e$B$P\e(B"]
172          [v-b5  "\e$B$\\e(B"      "\e$B$\\e(B"]
173          [v-r5  "\e$B$i\e(B"      "\e$B$i\e(B"]
174          [v-r5  "\e$B$m\e(B"      "\e$B$m\e(B"]
175          [v-w5  "\e$B$o\e(B"      "\e$B$o\e(B"]
176          [v-w5  "\e$B$*\e(B"      "\e$B$*\e(B"]
177          )
178         (renyou
179          [adj   "\e$B$+$C\e(B"    "\e$B$+$C\e(B"]
180          [adj   "\e$B$/\e(B"      "\e$B$/\e(B"]
181          [renyou "\e$B$^$7\e(B"   "\e$B$^$7\e(B"]
182          [v-5i  "\e$B$$\e(B"      "\e$B$$\e(B"]
183          [v-5q  "\e$B$C\e(B"      "\e$B$C\e(B"]
184          [v-5n  "\e$B$s\e(B"      "\e$B$s\e(B"]
185          [v-k5  "\e$B$-\e(B"      "\e$B$-\e(B"]
186          [v-k5  "\e$B$.\e(B"      "\e$B$.\e(B"]
187          [v-s5  "\e$B$7\e(B"      "\e$B$7\e(B"]
188          [nil   "\e$B$7\e(B"      "\e$B$7\e(B"]
189          [v-t5  "\e$B$A\e(B"      "\e$B$A\e(B"]
190          [v-n5  "\e$B$K\e(B"      "\e$B$K\e(B"]
191          [v-m5  "\e$B$_\e(B"      "\e$B$_\e(B"]
192          [v-b5  "\e$B$S\e(B"      "\e$B$S\e(B"]
193          [v-r5  "\e$B$j\e(B"      "\e$B$j\e(B"]
194          )
195         (v-5i
196          [nil   "\e$B$+\e(B"      "\e$B=q\e(B"]
197          )
198         (v-s5
199          [nil   "\e$B$+$s\e(B"    "\e$B4X\e(B"]
200          )
201         (adj
202          [nil   "\e$B$i$7\e(B"    "\e$B$i$7\e(B"]
203          [nil   "\e$B$J\e(B"      "\e$B$J\e(B"]
204          )
205         ))
206
207 (defun bottom-vector-string-match (pat seq)
208   (or (vectorp pat)
209       (setq pat (string-to-vector pat))
210       )
211   (if (vectorp seq)
212       (setq seq (copy-sequence seq))
213     (setq seq (string-to-vector seq))
214     )
215   (let ((lp (length pat))
216         (ls (length seq))
217         )
218     (if (> lp ls)
219         nil
220       (catch 'not-matched
221         (while (> lp 0)
222           (setq lp (1- lp)
223                 ls (1- ls))
224           (or (eq (aref pat lp)(aref seq ls))
225               (throw 'not-matched nil)
226               )
227           )
228         (cons (subseq seq 0 ls) pat)
229         ))))
230
231
232 (defvar sana-prefix
233 ;;(setq sana-prefix
234   '((1 (adj
235         ["\e$B$/\e(B"     "\e$B$/\e(B"]
236         ["\e$B$7\e(B"     "\e$B$7\e(B"]
237         ["\e$B$-\e(B"     "\e$B$-\e(B"]
238         ["\e$B$$\e(B"     "\e$B$$\e(B"]
239         ["\e$B$5\e(B"     "\e$B$5\e(B"]
240         )
241        ;; (v-k*
242        ;;  ["\e$B$-\e(B"   "\e$B$-\e(B"]
243        ;;  ["\e$B$-\e(B"   "\e$BMh\e(B"]
244        ;;  ["\e$B$-\e(B"   "\e$BPT\e(B"]
245        ;;  ["\e$B$/\e(B"   "\e$B$/\e(B"]
246        ;;  ["\e$B$/\e(B"   "\e$BMh\e(B"]
247        ;;  ["\e$B$/\e(B"   "\e$BPT\e(B"]
248        ;;  ["\e$B$3\e(B"   "\e$B$3\e(B"]
249        ;;  ["\e$B$3\e(B"   "\e$BMh\e(B"]
250        ;;  ["\e$B$3\e(B"   "\e$BPT\e(B"]
251        ;;  )
252        ;; (v-s*
253        ;;  ["\e$B$7\e(B"   "\e$B$7\e(B"]
254        ;;  ["\e$B$;\e(B"   "\e$B$;\e(B"]
255        ;;  )
256        ;; (v-z*
257        ;;  ["\e$B$8\e(B"   "\e$B$8\e(B"]
258        ;;  ["\e$B$:\e(B"   "\e$B$:\e(B"]
259        ;;  ["\e$B$<\e(B"   "\e$B$<\e(B"]
260        ;;  )
261
262        (+v-nari
263         ["\e$B$K\e(B"     "\e$B$K\e(B"]
264         )
265        (+v-tari
266         ["\e$B$H\e(B"     "\e$B$H\e(B"]
267         )
268        (+v-da
269         ["\e$B$G\e(B"     "\e$B$G\e(B"]
270         ["\e$B$K\e(B"     "\e$B$K\e(B"]
271         ["\e$B$J\e(B"     "\e$B$J\e(B"]
272         )
273        (+v-ya
274         ["\e$B$(\e(B"     "\e$B$'\e(B"]
275         ["\e$B$d\e(B"     "\e$B$d\e(B"]
276         )
277        )
278     (2 
279        (v-k*
280         ["\e$B$/$k\e(B"   "\e$B$/$k\e(B"]
281         ["\e$B$/$k\e(B"   "\e$BMh$k\e(B"]
282         ["\e$B$/$k\e(B"   "\e$BPT$k\e(B"]
283         ["\e$B$/$l\e(B"   "\e$B$/$l\e(B"]
284         ["\e$B$/$l\e(B"   "\e$BMh$l\e(B"]
285         ["\e$B$/$l\e(B"   "\e$BPT$l\e(B"]
286         ["\e$B$3$h\e(B"   "\e$B$3$h\e(B"]
287         ["\e$B$3$h\e(B"   "\e$BMh$h\e(B"]
288         ["\e$B$3$h\e(B"   "\e$BPT$h\e(B"]
289         ["\e$B$3$$\e(B"   "\e$B$3$$\e(B"]
290         ["\e$B$3$$\e(B"   "\e$BMh$$\e(B"]
291         ["\e$B$3$$\e(B"   "\e$BPT$$\e(B"]
292         )
293        (v-s*
294         ["\e$B$9$k\e(B"   "\e$B$9$k\e(B"]
295         ["\e$B$9$l\e(B"   "\e$B$9$l\e(B"]
296         ["\e$B$5$l\e(B"   "\e$B$5$l\e(B"]
297         ["\e$B$;$h\e(B"   "\e$B$;$h\e(B"]
298         )
299        (v-z*
300         ["\e$B$:$k\e(B"   "\e$B$:$k\e(B"]
301         ["\e$B$:$l\e(B"   "\e$B$:$l\e(B"]
302         ["\e$B$<$h\e(B"   "\e$B$<$h\e(B"]
303         )
304        (+v-nari
305         ["\e$B$J$i\e(B"   "\e$B$J$i\e(B"]
306         ["\e$B$J$j\e(B"   "\e$B$J$j\e(B"]
307         ["\e$B$J$k\e(B"   "\e$B$J$k\e(B"]
308         ["\e$B$J$l\e(B"   "\e$B$J$l\e(B"]
309         )
310        (+v-tari
311         ["\e$B$?$i\e(B"   "\e$B$?$i\e(B"]
312         ["\e$B$?$j\e(B"   "\e$B$?$j\e(B"]
313         ["\e$B$?$k\e(B"   "\e$B$?$k\e(B"]
314         ["\e$B$?$l\e(B"   "\e$B$?$l\e(B"]
315         )
316        (+v-da
317         ["\e$B$@$m\e(B"   "\e$B$@$m\e(B"]
318         ;;["\e$B$@$C\e(B" "\e$B$@$C\e(B"]
319         ;;["\e$B$J$i\e(B" "\e$B$J$i\e(B"]
320         )
321        (+v-ya
322         ["\e$B$d$m\e(B"   "\e$B$d$m\e(B"]
323         ;;["\e$B$d$C\e(B" "\e$B$d$C\e(B"]
324         ;;["\e$B$d$i\e(B" "\e$B$d$i\e(B"]
325         )
326        (+v-desu
327         ["\e$B$G$9\e(B"   "\e$B$G$9\e(B"]
328         ;;["\e$B$G$7\e(B" "\e$B$G$7\e(B"]
329         )
330        (beki
331         ["\e$B$Y$/\e(B"   "\e$B$Y$/\e(B"]
332         ["\e$B$Y$7\e(B"   "\e$B$Y$7\e(B"]
333         ["\e$B$Y$-\e(B"   "\e$B$Y$-\e(B"]
334         )
335        (renyou
336         ["\e$B$$$?\e(B" "\e$B$$$?\e(B"]
337         ["\e$B$C$?\e(B" "\e$B$C$?\e(B"]
338         )
339        )
340     (3 (+v-dearu
341         ;;["\e$B$G$"$i\e(B"       "\e$B$G$"$i\e(B"]
342         ["\e$B$G$"$j\e(B" "\e$B$G$"$j\e(B"]
343         ["\e$B$G$"$k\e(B" "\e$B$G$"$k\e(B"]
344         ;;["\e$B$G$"$l\e(B"       "\e$B$G$"$l\e(B"]
345         )
346        (+v-desu
347         ["\e$B$G$7$g\e(B" "\e$B$G$7$g\e(B"]
348         )
349        ;; (beki
350        ;;  ["\e$B$Y$+$i\e(B"       "\e$B$Y$+$i\e(B"]
351        ;;  ["\e$B$Y$+$j\e(B"       "\e$B$Y$+$j\e(B"]
352        ;;  ["\e$B$Y$+$k\e(B"       "\e$B$Y$+$k\e(B"]
353        ;;  ["\e$B$Y$1$l\e(B"       "\e$B$Y$1$l\e(B"]
354        ;;  )
355        (renyou
356         ["\e$B$^$9$+\e(B" "\e$B$^$9$+\e(B"]
357         )
358        )
359     (4 (+v-desu
360         ["\e$B$G$7$g$&\e(B" "\e$B$G$7$g$&\e(B"]
361         ))
362     (5 (n
363         ["\e$B$K$+$s$7$F\e(B" "\e$B$K4X$7$F\e(B"]
364         ))))
365
366
367 ;;; @ end
368 ;;;
369
370 (provide 'skkdic-ext)
371
372 (run-hooks 'skkdic-ext-load-hook)
373
374 ;;; skkdic-ext.el ends here