egg-980315.
[elisp/egg.git] / egg.el
diff --git a/egg.el b/egg.el
index 905cb53..a88bcf2 100644 (file)
--- a/egg.el
+++ b/egg.el
@@ -1,21 +1,22 @@
 ;;; egg.el --- EGG Input Method Architecture
 
-;; Copyright (C) 1997 Mule Project, Powered by Electrotechnical
+;; Copyright (C) 1997, 1998 Mule Project, Powered by Electrotechnical
 ;; Laboratory, JAPAN.
 ;; Project Leader: Satoru Tomura <tomura@etl.go.jp>
 
 ;; Author: NIIBE Yutaka <gniibe@mri.co.jp>
+;;         KATAYAMA Yoshio <kate@pfu.co.jp>
 ;; Maintainer: NIIBE Yutaka <gniibe@mri.co.jp>
 ;; Keywords: mule, multilingual, input method
 
 ;; This file will be part of GNU Emacs (in future).
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; EGG is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 ;; the Free Software Foundation; either version 2, or (at your option)
 ;; any later version.
 
-;; GNU Emacs is distributed in the hope that it will be useful,
+;; EGG is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
 (defvar egg-mode-preference t
   "Non-nil if modefull.")
 
+(defvar egg-default-language "Japanese")
+(defvar egg-last-method-name)
+(make-variable-buffer-local 'egg-last-method-name)
+
 ;;;###autoload
-(defun egg-mode (&optional arg)
+(defun egg-mode (&rest arg)
   "Toggle EGG  mode.
 \\[describe-bindings]
 "
   (if (null arg)
       ;; Turn off
       (progn
+       (cond
+        ((its-in-fence-p)
+         (its-exit-mode))
+        ((egg-get-bunsetsu-info (point))
+         (egg-exit-conversion)))
        (setq describe-current-input-method-function nil)
        (setq current-input-method nil)
-       (let ((orig-local-map (keymap-parent (current-local-map))))
-         (use-local-map orig-local-map))
-       (run-hooks 'input-method-inactivate-hook))
+       (use-local-map (keymap-parent (current-local-map)))
+       (force-mode-line-update))
     ;; Turn on
+    (if (null (string= (car arg) egg-last-method-name))
+       (progn
+         (funcall (nth 1 arg))
+         (egg-set-conversion-backend nil (list its-current-language) t)
+         (setq egg-default-language its-current-language)))
+    (setq egg-last-method-name (car arg))
     (use-local-map (if egg-mode-preference
                       (egg-modefull-map)
                     (egg-modeless-map)))
     (setq inactivate-current-input-method-function 'egg-mode)
     (setq describe-current-input-method-function 'egg-help)
-    (run-hooks 'input-method-activate-hook))
-  (force-mode-line-update))
+    (add-hook 'input-method-activate-hook 'its-set-mode-line-title)))
 
 (defun egg-modefull-map ()
   "Generate modefull keymap for EGG mode."  
@@ -62,6 +76,7 @@
     (while (< i 127)
       (define-key map (vector i) 'egg-self-insert-char)
       (setq i (1+ i)))
+    (its-define-select-keys map)
     (set-keymap-parent map (current-local-map))
     map))
 
          (setq ocolumn (current-column))
          (funcall auto-fill-function)))))
 
-(setq its-hira-period "\e$B!#\e(B")    ; ". " "\e$B!%\e(B" "\e$B!#\e(B"
-(setq its-hira-comma  ", ")    ; ", " "\e$B!$\e(B" "\e$B!"\e(B"
-
 (require 'its)
 (require 'menudiag)
 (require 'egg-mlh)
 (require 'egg-cnv)
 (require 'egg-com)
+(require 'custom)
+
+(defgroup egg nil
+  "Tamagotchy --- EGG Versio 4.0")
 
-(load-library "its/hira")
-(setq-default its-current-map its-hira-map)
+;;(load-library "its/hira")
+;;(setq-default its-current-map its-hira-map)
 
-(load-library "egg/wnn")
-(load-library "egg/wnnrpc")
-(setq egg-conversion-backend wnn-conversion-backend)
+;;(load-library "egg/wnn")
+;;(load-library "egg/wnnrpc")
+;;(setq egg-conversion-backend wnn-conversion-backend)
 
 ;;(load-library "egg/sj3rpc")
 ;;(load-library "egg/sj3")
 ;;(setq egg-conversion-backend sj3-conversion-backend)
 
+(defvar egg-support-languages nil)
+
+(defun egg-set-support-languages (langs)
+  (while langs
+    (if (null (member (car langs) egg-support-languages))
+       (setq egg-support-languages (cons (car langs) egg-support-languages)))
+    (setq langs (cdr langs))))
+
 (add-hook 'kill-emacs-hook 'egg-kill-emacs-function)
 (defun egg-kill-emacs-function ()
   (egg-finalize-backend))