1 ;;; egg.el --- EGG Input Method Architecture
3 ;; Copyright (C) 1997 Mule Project, Powered by Electrotechnical
5 ;; Project Leader: Satoru Tomura <tomura@etl.go.jp>
7 ;; Author: NIIBE Yutaka <gniibe@mri.co.jp>
8 ;; Maintainer: NIIBE Yutaka <gniibe@mri.co.jp>
9 ;; Keywords: mule, multilingual, input method
11 ;; This file will be part of GNU Emacs (in future).
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
31 (defvar egg-mode-preference t
32 "Non-nil if modefull.")
35 (defun egg-mode (&optional arg)
43 (setq describe-current-input-method-function nil)
44 (setq current-input-method nil)
45 (let ((orig-local-map (keymap-parent (current-local-map))))
46 (use-local-map orig-local-map))
47 (run-hooks 'input-method-inactivate-hook))
49 (use-local-map (if egg-mode-preference
52 (setq inactivate-current-input-method-function 'egg-mode)
53 (setq describe-current-input-method-function 'egg-help)
54 (run-hooks 'input-method-activate-hook))
55 (force-mode-line-update))
57 (defun egg-modefull-map ()
58 "Generate modefull keymap for EGG mode."
59 (let ((map (make-sparse-keymap))
61 (define-key map "\C-_" 'egg-jis-code-input)
63 (define-key map (vector i) 'egg-self-insert-char)
65 (set-keymap-parent map (current-local-map))
68 (defun egg-modeless-map ()
69 "Generate modeless keymap for EGG mode."
70 (let ((map (make-sparse-keymap)))
71 (define-key map " " 'mlh-space-bar-backward-henkan)
72 (define-key map "\C-_" 'egg-jis-code-input)
73 (set-keymap-parent map (current-local-map))
76 (defun egg-self-insert-char ()
78 (its-start last-command-char))
80 (defun egg-hinshi-select ()
81 (menudiag-select ; Should generate at initialization time
82 '(menu "
\e$BIJ;lL>
\e(B:"
83 (("
\e$BIaDLL>;l
\e(B" .
84 (menu "
\e$BIJ;lL>
\e(B[
\e$BIaDLL>;l
\e(B]:"
85 ("
\e$BL>;l
\e(B" "
\e$B%59T
\e(B(
\e$B$9$k
\e(B)&
\e$BL>;l
\e(B" "
\e$B0lCJ
\e(B&
\e$BL>;l
\e(B"
86 "
\e$B7AMFF0;l
\e(B&
\e$BL>;l
\e(B" "
\e$B?t;l
\e(B")))
88 (menu "
\e$BIJ;lL>
\e(B[
\e$B8GM-L>;l
\e(B]:"
89 ("
\e$B?ML>
\e(B" "
\e$BCOL>
\e(B" "
\e$B?ML>
\e(B&
\e$BCOL>
\e(B" "
\e$B8GM-L>;l
\e(B")))
91 (menu "
\e$BIJ;lL>
\e(B[
\e$BF0;l
\e(B]:"
92 ("
\e$B0lCJ
\e(B" "
\e$B0lCJ
\e(B&
\e$BL>;l
\e(B" "
\e$B%+9T8^CJ
\e(B" "
\e$B%,9T8^CJ
\e(B"
93 "
\e$B%59T8^CJ
\e(B" "
\e$B%?9T8^CJ
\e(B")))
94 ("
\e$BFC<l$JF0;l
\e(B" .
95 (menu "
\e$BIJ;lL>
\e(B[
\e$BFC<l$JF0;l
\e(B]:"
96 ("
\e$B%+9T
\e(B(
\e$B9T$/
\e(B)" "
\e$B%i9T
\e(B(
\e$B2<$5$$
\e(B)" "
\e$BMh
\e(B(
\e$B$3
\e(B)"
97 "
\e$BMh
\e(B(
\e$B$-
\e(B)" "
\e$BMh
\e(B(
\e$B$/
\e(B)" "
\e$B0Y
\e(B(
\e$B$7
\e(B)")))
98 ("
\e$BF0;l0J30$NMQ8@
\e(B" .
99 (menu "
\e$BIJ;lL>
\e(B[
\e$BF0;l0J30$NMQ8@
\e(B]:"
100 ("
\e$B7AMF;l
\e(B" "
\e$B7AMFF0;l
\e(B" "
\e$B7AMFF0;l
\e(B&
\e$BL>;l
\e(B"
101 "
\e$B7AMFF0;l
\e(B(
\e$B$?$k
\e(B)")))))))
103 ;; XXX: Should use backend interface
104 (defun egg-toroku-region (start end)
106 (let* ((env (wnn-get-environment)) ; XXX
107 (kanji (buffer-substring start end))
108 (yomi (read-multilingual-string
109 (format "
\e$B<-=qEPO?!X
\e(B%s
\e$B!Y
\e(B
\e$BFI$_
\e(B:" kanji)))
110 (dic (menudiag-select (list 'menu "
\e$BEPO?<-=qL>
\e(B:"
112 (wnn-list-writable-dictionaries-byname env))))
113 (dic-name (wnn-dict-name dic))
114 (hinshi (egg-hinshi-select))
115 (hinshi-id (wnn-hinshi-number env hinshi)))
117 (format "
\e$B<-=q9`L\!X
\e(B%s
\e$B!Y
\e(B(%s: %s)
\e$B$r
\e(B %s
\e$B$KEPO?$7$^$9
\e(B"
118 kanji yomi hinshi dic-name))
119 (let ((r (wnn-add-word env dic yomi kanji "" hinshi-id 0)))
121 (error "
\e$B<-=qEPO?!X
\e(B%s
\e$B!Y
\e(B(%s: %s) %s
\e$B$K<:GT$7$^$7$?
\e(B: %s"
122 kanji yomi hinshi dic-name
123 (wnnrpc-get-error-message (- r)))
125 "
\e$B<-=q9`L\!X
\e(B%s
\e$B!Y
\e(B(%s: %s)
\e$B$r
\e(B %s
\e$B$KEPO?$7$^$7$?
\e(B"
126 kanji yomi hinshi dic-name))))))
129 ;;; auto fill controll
132 (defun egg-do-auto-fill ()
133 (if (and auto-fill-function (> (current-column) fill-column))
134 (let ((ocolumn (current-column)))
135 (funcall auto-fill-function)
136 (while (and (< fill-column (current-column))
137 (< (current-column) ocolumn))
138 (setq ocolumn (current-column))
139 (funcall auto-fill-function)))))
141 (setq its-hira-period "
\e$B!#
\e(B") ; ". " "
\e$B!%
\e(B" "
\e$B!#
\e(B"
142 (setq its-hira-comma ", ") ; ", " "
\e$B!$
\e(B" "
\e$B!"
\e(B"
150 (load-library "its/hira")
151 (setq-default its-current-map its-hira-map)
153 (load-library "egg/wnn")
154 (load-library "egg/wnnrpc")
155 (setq egg-conversion-backend wnn-conversion-backend)
157 ;;(load-library "egg/sj3rpc")
158 ;;(load-library "egg/sj3")
159 ;;(setq egg-conversion-backend sj3-conversion-backend)
161 (add-hook 'kill-emacs-hook 'egg-kill-emacs-function)
162 (defun egg-kill-emacs-function ()
163 (egg-finalize-backend))