X-Git-Url: http://git.chise.org/gitweb/?p=elisp%2Femacs-canna.git;a=blobdiff_plain;f=canna.el;h=8c4e055083521cc083e685a068a4b3f410e9af49;hp=7e443f8955de450409e514621c5425af451f8011;hb=7d8f15b44355d80b17d1121c86ac4bdd9a6bea47;hpb=5f79a729e06dd040891e851190907055bfbdb799 diff --git a/canna.el b/canna.el index 7e443f8..8c4e055 100644 --- a/canna.el +++ b/canna.el @@ -1,16 +1,15 @@ ;;; canna.el --- Interface to the Canna input method. ;; Copyright (C) 1994 Akira Kon, NEC Corporation. -;; Copyright (C) 1996,1997,1998 MORIOKA Tomohiko +;; Copyright (C) 1996,1997,1998,2004 MORIOKA Tomohiko ;; Copyright (C) 1997 Stephen Turnbull ;; Author: Akira Kon ;; MORIOKA Tomohiko ;; Stephen Turnbull -;; Version: $Revision: 1.15 $ ;; Keywords: Canna, Japanese, input method, mule, multilingual -;; This file is not a part of Emacs yet. +;; This file is part of Emacs-Canna. ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as @@ -38,7 +37,7 @@ ;;; Code: -;; -*-mode: emacs-lisp-*- +(require 'poem) (defvar canna-dl-module (expand-file-name "canna.so" exec-directory)) @@ -59,33 +58,42 @@ ;; (defalias 'self-insert-internal 'self-insert-command) ;; end -(defconst canna-rcs-version - "$Id: canna.el,v 1.15 1998-02-09 13:09:08 morioka Exp $") +(defconst canna-version "Emacs-Canna 1.5") (defun canna-version () "Display version of canna.el in mini-buffer." (interactive) - (message (concat - (substring canna-rcs-version - 5 - (if (string-match "[0-9] [a-z]" canna-rcs-version) - (1+ (match-beginning 0)) - )) - " ..."))) - -(if (featurep 'xemacs) - (defun canna-self-insert-string (string) - (let ((len (length string)) - (i 0) - ;; 挿入の途中で blink が起きるとうっとおしいので、 - ;; 一時的に blink を抑止する。 - (blink-matching-paren nil)) - (while (< i len) - (self-insert-internal (aref canna-kakutei-string i)) - (setq i (1+ i)) - ))) - (defalias 'canna-self-insert-string 'insert) + (message (concat canna-version " ..."))) + +(defvar canna-self-insert-string-filter nil + "*確定時に呼ばれるフィルター関数を指定するための変数。 +設定されるフィルター関数は1引数の関数で、 +その引数に確定文字列が渡される。 +また、フィルター関数は文字列を返さなければならない。 +上記の使用を満たす関数の他、nil を指定することができ、 +その場合は無変換を表す。") + +(cond + ((featurep 'xemacs) + (defun canna-self-insert-string (string) + (if (functionp canna-self-insert-string-filter) + (setq string (funcall canna-self-insert-string-filter string))) + (let ((len (length string)) + (i 0) + ;; 挿入の途中で blink が起きるとうっとおしいので、 + ;; 一時的に blink を抑止する。 + (blink-matching-paren nil)) + (while (< i len) + (self-insert-internal (aref string i)) + (setq i (1+ i))))) ) + (t + ;; (defalias 'canna-self-insert-string 'insert) + (defun canna-self-insert-string (string) + (if canna-self-insert-string-filter + (setq string (funcall canna-self-insert-string-filter string))) + (insert string)) + )) ;;; かんなの変数 @@ -178,13 +186,13 @@ (canna:memq-recursive a (cdr l)) ))) (defun canna:create-mode-line () - "Add string of Canna status into mode-line." + "Add Canna status string into mode-line." (cond ((featurep 'xemacs) (or (canna:memq-recursive 'mode-line-canna-mode default-modeline-format) (setq-default default-modeline-format - (nconc '("" mode-line-canna-mode) - default-modeline-format)) + (append '("" mode-line-canna-mode) + default-modeline-format)) ) (mapcar (function (lambda (buffer) @@ -193,8 +201,8 @@ (or (canna:memq-recursive 'mode-line-canna-mode modeline-format) (setq modeline-format - (nconc '("" mode-line-canna-mode) - modeline-format)) + (append '("" mode-line-canna-mode) + modeline-format)) ) ))) (buffer-list)) @@ -285,10 +293,10 @@ t の時はデフォルトの色を使用する。 (make-variable-buffer-local (defvar canna:*select-overlay* nil)) ;;; -;;; キーマップテーブル +;;; Keymap table ;;; -;; フェンスモードでのローカルマップ +;; Fence mode local map (defvar canna-mode-map (make-sparse-keymap)) (let ((ch 0)) @@ -311,6 +319,8 @@ t の時はデフォルトの色を使用する。 (define-key canna-mode-map [(control left)] "\C-b") (define-key canna-mode-map [kanji] " ") (define-key canna-mode-map [(control space)] [(control @)]) + (define-key canna-mode-map [delete] "\C-?") + (define-key canna-mode-map [backspace] "\C-h") ) (t (define-key canna-mode-map [up] [?\C-p]) @@ -443,7 +453,7 @@ See also document for canna:saved-exit-minibuffer." ;;; (defun canna-functional-insert-command (arg) - "Use input character as a key of complex translation input such as\n\ + "Use input character as a key of complex translation input such as kana-to-kanji translation." (interactive "*p") (let ((ch)) @@ -453,7 +463,7 @@ kana-to-kanji translation." (canna:functional-insert-command2 ch arg) )) (defun canna:functional-insert-command2 (ch arg) - "This function actualy isert a converted Japanese string." + "This function actually inserts a converted Japanese string." ;; この関数は与えられた文字を日本語入力のためのキー入力として取り扱 ;; い、日本語入力の中間結果を含めた処理をEmacsのバッファに反映させる ;; 関数である。 @@ -733,8 +743,8 @@ kana-to-kanji translation, even if you are in the minibuffer." ;;; canna-functional-insert-command を呼ぶ。 ;;; -(if (not (boundp 'MULE)) ; for Nemacs - (defun cancel-undo-boundary ())) +;; (if (not (boundp 'MULE)) ; for Nemacs +;; (defun cancel-undo-boundary ())) (defun canna-self-insert-command (arg) "Self insert pressed key and use it to assemble Romaji character." @@ -850,10 +860,11 @@ kana-to-kanji translation, even if you are in the minibuffer." canna:*saved-mode-string* new-mode))) 0))) - (setq canna:*local-map-backup* (current-local-map)) + (setq canna:*local-map-backup* (current-local-map)) (setq canna:*fence-mode* t) ;; XEmacs change: - (buffer-disable-undo (current-buffer)) + ;; (buffer-disable-undo (current-buffer)) + ;; Original: ;; (if (boundp 'disable-undo) ;; (setq disable-undo canna:*fence-mode*)) (use-local-map canna-mode-map)) @@ -875,7 +886,8 @@ kana-to-kanji translation, even if you are in the minibuffer." (canna-toggle-japanese-mode) (mode-line-canna-mode-update canna:*alpha-mode-string*) ))) ;; XEmacs change: - (buffer-enable-undo (current-buffer)) + ;; (buffer-enable-undo (current-buffer)) + ;; Original: ;; (if (boundp 'disable-undo) ;; (setq disable-undo canna:*fence-mode*)) )) @@ -909,8 +921,7 @@ kana-to-kanji translation, even if you are in the minibuffer." ))) (defun canna-touroku-region (start end) - "Register a word which is indicated by region into a kana-to-kanji\n\ -dictionary." + "Register a word in the selected region into a kana-to-kanji dictionary." (interactive "r") (if (canna-without-newline start end) ; (if canna:*japanese-mode* @@ -1225,8 +1236,7 @@ dictionary." ;;; (defun canna-set-mark-command (arg) - "Besides setting mark, set mark as a HENKAN region if it is in\n\ -the japanese mode." + "Set mark, also set mark as HENKAN region if in Japanese mode." (interactive "P") (set-mark-command arg) (if canna:*japanese-mode* @@ -1235,8 +1245,7 @@ the japanese mode." (message "Mark set(変換領域開始)") ))) (defun canna-henkan-region-or-self-insert (arg) - "Do kana-to-kanji convert region if HENKAN region is defined,\n\ -self insert otherwise." + "Do kana-to-kanji convert region if HENKAN region is defined, else insert." (interactive "*p") (if (and canna:*use-region-as-henkan-region* ; (< (mark) (point))