;;; egg.el --- EGG Input Method Architecture ;; Copyright (C) 1997 Mule Project, Powered by Electrotechnical ;; Laboratory, JAPAN. ;; Project Leader: Satoru Tomura ;; Author: NIIBE Yutaka ;; Maintainer: NIIBE Yutaka ;; 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 ;; 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, ;; 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. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;; Commentary: ;;; Code: (defvar egg-mode-preference t "Non-nil if modefull.") ;;;###autoload (defun egg-mode (&optional arg) "Toggle EGG mode. \\[describe-bindings] " (interactive "P") (if (null arg) ;; Turn off (progn (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 (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)) (defun egg-modefull-map () "Generate modefull keymap for EGG mode." (let ((map (make-sparse-keymap)) (i 33)) (define-key map "\C-_" 'egg-jis-code-input) (while (< i 127) (define-key map (vector i) 'egg-self-insert-char) (setq i (1+ i))) (set-keymap-parent map (current-local-map)) map)) (defun egg-modeless-map () "Generate modeless keymap for EGG mode." (let ((map (make-sparse-keymap))) (define-key map " " 'mlh-space-bar-backward-henkan) (define-key map "\C-_" 'egg-jis-code-input) (set-keymap-parent map (current-local-map)) map)) (defun egg-self-insert-char () (interactive) (its-start last-command-char)) (defun egg-hinshi-select () (menudiag-select ; Should generate at initialization time '(menu "品詞名:" (("普通名詞" . (menu "品詞名[普通名詞]:" ("名詞" "サ行(する)&名詞" "一段&名詞" "形容動詞&名詞" "数詞"))) ("固有名詞" . (menu "品詞名[固有名詞]:" ("人名" "地名" "人名&地名" "固有名詞"))) ("動詞" . (menu "品詞名[動詞]:" ("一段" "一段&名詞" "カ行五段" "ガ行五段" "サ行五段" "タ行五段"))) ("特殊な動詞" . (menu "品詞名[特殊な動詞]:" ("カ行(行く)" "ラ行(下さい)" "来(こ)" "来(き)" "来(く)" "為(し)"))) ("動詞以外の用言" . (menu "品詞名[動詞以外の用言]:" ("形容詞" "形容動詞" "形容動詞&名詞" "形容動詞(たる)"))))))) ;; XXX: Should use backend interface (defun egg-toroku-region (start end) (interactive "r") (let* ((env (wnn-get-environment wnn-dictionary-specification)) ; XXX (kanji (buffer-substring start end)) (yomi (read-multilingual-string (format "辞書登録『%s』 読み:" kanji))) (dic (menudiag-select (list 'menu "登録辞書名:" ;; XXX (wnn-list-writable-dictionaries-byname env)))) (dic-name (wnn-dict-name dic)) (hinshi (egg-hinshi-select)) (hinshi-id (wnn-hinshi-number env hinshi))) (if (y-or-n-p (format "辞書項目『%s』(%s: %s)を %s に登録します" kanji yomi hinshi dic-name)) (let ((r (wnn-add-word env dic yomi kanji "" hinshi-id 0))) (if (< r 0) (error "辞書登録『%s』(%s: %s) %s に失敗しました: %s" kanji yomi hinshi dic-name (wnnrpc-get-error-message (- r))) (message "辞書項目『%s』(%s: %s)を %s に登録しました" kanji yomi hinshi dic-name)))))) ;;; ;;; auto fill controll ;;; (defun egg-do-auto-fill () (if (and auto-fill-function (> (current-column) fill-column)) (let ((ocolumn (current-column))) (funcall auto-fill-function) (while (and (< fill-column (current-column)) (< (current-column) ocolumn)) (setq ocolumn (current-column)) (funcall auto-fill-function))))) (setq its-hira-period "。") ; ". " "." "。" (setq its-hira-comma ", ") ; ", " "," "、" (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 "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) (add-hook 'kill-emacs-hook 'egg-kill-emacs-function) (defun egg-kill-emacs-function () (egg-finalize-backend)) (provide 'egg) ;;; egg.el ends here