Nabe 0.2.
[elisp/nabe.git] / yude-canna.el
1 ;;; yude-canna.el --- Boiled-Egg like roman to kanaji converter
2
3 ;; Copyright (C) 1996 MORIOKA Tomohiko
4
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Version: $Id: yude-canna.el,v 0.2 1996/11/12 09:18:37 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 'nabe)
29 (require 'canna)
30
31
32 ;;; @ initialize
33 ;;;
34
35 (canna)
36
37
38 ;;; @ functions
39 ;;;
40
41 (defun canna-rk-no-trans-region (start end)
42   "Insert alpha-numeric string as it is sent from keyboard."
43   (interactive "r")
44   (let ((res))
45     (setq res (canna-rk-region start end))
46     (delete-region start end)
47     (if (null canna:*japanese-mode*)
48         (progn
49           (setq canna:*exit-japanese-mode* t) ))
50     (canna:enter-canna-mode)
51     (canna:display-candidates res)
52     (canna-kakutei-to-basic-stat)
53     ))
54
55 (setq nabe-roman-to-kanji-function 'canna-rk-trans-region)
56 (setq nabe-roman-to-kana-function 'canna-rk-no-trans-region)
57
58
59 ;;; @ redefine
60 ;;;
61
62 (or (fboundp 'canna:original-quit-canna-mode)
63     (fset 'canna:original-quit-canna-mode
64           (symbol-function 'canna:quit-canna-mode))
65     )
66 (defun canna:quit-canna-mode ()
67   (canna:original-quit-canna-mode)
68   (if (string= (canna-query-mode) "[\e$BH>1Q\e(B]")
69       (progn
70         (canna-do-function canna-func-base-zenkaku)
71         (canna-do-function canna-func-base-kana)
72         (canna-toggle-japanese-mode)
73         )))
74
75 (defun canna-kakutei-to-basic-stat ()
76   (let ((res 0)
77         (kakutei
78          (mapconcat (function
79                      (lambda (chr)
80                        (if (eq chr ?\ )
81                            ""
82                          (char-to-string chr)
83                          )
84                        ))
85                     canna-henkan-string ""))
86         )
87     (while (not canna-empty-info)
88       (setq res (canna-do-function canna-func-kakutei))
89       )
90     (setq canna-kakutei-string kakutei)
91     (canna:display-candidates (length canna-kakutei-string))
92     (if (not canna:*japanese-mode*)
93         (mode-line-canna-mode-update canna:*alpha-mode-string*))
94     ))
95
96
97 ;;; @ end
98 ;;;
99
100 (provide 'yude-canna)
101
102 ;;; yude-canna.el ends here