Merge egg-980220.
[elisp/egg.git] / egg.el
diff --git a/egg.el b/egg.el
index d722a3a..c8403a0 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)
+(defvar egg-mode-line-title)
+(make-variable-buffer-local 'egg-mode-line-title)
+
 ;;;###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))
     ;; Turn on
+    (if (null (string= (car arg) egg-last-method-name))
+       (progn
+         (funcall (nth 1 arg))
+        (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)))
     (run-hooks 'input-method-activate-hook))
   (force-mode-line-update))
 
+(defun egg-set-mode-line-title (title)
+  (setq egg-mode-line-title title)
+  (force-mode-line-update))
+
+(defun egg-check-language (lang)
+  (if (null (member lang egg-support-languages))
+      (error "%S is not supported" lang)))
+
 (defun egg-modefull-map ()
   "Generate modefull keymap for EGG mode."  
   (let ((map (make-sparse-keymap))
          (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)
 (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")
 ;;(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))