X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=canna.el;h=8c4e055083521cc083e685a068a4b3f410e9af49;hb=21a33f63eb6c79b18f5ff8d978069bbaa16712e5;hp=0ea53eaf22715cd6562a70ffef067534df0c80c6;hpb=a98a55262e7f60ac6ae3f0adee6b1b57476a2a65;p=elisp%2Femacs-canna.git diff --git a/canna.el b/canna.el index 0ea53ea..8c4e055 100644 --- a/canna.el +++ b/canna.el @@ -1,14 +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 -;; Version: $Revision: 1.10 $ +;; Stephen Turnbull ;; 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 @@ -36,7 +37,7 @@ ;;; Code: -;; -*-mode: emacs-lisp-*- +(require 'poem) (defvar canna-dl-module (expand-file-name "canna.so" exec-directory)) @@ -49,39 +50,50 @@ (and canna-dl-handle (dynamic-call "emacs_canna_init" canna-dl-handle)) +(or (boundp 'CANNA) + (featurep 'CANNA) + (error "Canna is not built into this Emacs")) + (defvar self-insert-after-hook nil) ;; (defalias 'self-insert-internal 'self-insert-command) ;; end -(defconst canna-rcs-version - "$Id: canna.el,v 1.10 1998-01-16 08:49:29 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)) - )) - " ..."))) - -(require 'emu) - -(if running-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)) + )) ;;; かんなの変数 @@ -174,13 +186,13 @@ (canna:memq-recursive a (cdr l)) ))) (defun canna:create-mode-line () - "Add string of Canna status into mode-line." - (cond (running-xemacs + "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) @@ -189,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)) @@ -281,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)) @@ -292,7 +304,7 @@ t の時はデフォルトの色を使用する。 (define-key canna-mode-map (make-string 1 ch) 'canna-functional-insert-command) (setq ch (1+ ch)))) -(cond (running-xemacs +(cond ((featurep 'xemacs) (define-key canna-mode-map [up] "\C-p") (define-key canna-mode-map [(shift up)] "\C-p") (define-key canna-mode-map [(control up)] "\C-p") @@ -307,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]) @@ -333,7 +347,7 @@ t の時はデフォルトの色を使用する。 (define-key canna-minibuffer-mode-map (make-string 1 ch) 'canna-minibuffer-insert-command) (setq ch (1+ ch)))) -(cond (running-xemacs +(cond ((featurep 'xemacs) (define-key canna-minibuffer-mode-map [up] "\C-p") (define-key canna-minibuffer-mode-map [(shift up)] "\C-p") (define-key canna-minibuffer-mode-map [(control up)] "\C-p") @@ -439,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)) @@ -449,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のバッファに反映させる ;; 関数である。 @@ -642,7 +656,7 @@ kana-to-kanji translation." ; (set-window-buffer (minibuffer-window) ; (get-buffer-create canna:*menu-buffer*)) ;; modified by 守岡 知彦 , 1996/6/7 - (unless running-xemacs + (unless (featurep 'xemacs) ;; とりあえず XEmacs では動かさないことにしておこう (^_^; (setq canna:*saved-redirection* (frame-focus (selected-frame))) (redirect-frame-focus (selected-frame) @@ -688,7 +702,7 @@ kana-to-kanji translation." (set-window-buffer (minibuffer-window) canna:*saved-minibuffer*) ; (setq canna:*saved-minibuffer* nil) ;; modified by 守岡 知彦 , 1996/6/7 - (unless running-xemacs + (unless (featurep 'xemacs) ;; とりあえず XEmacs では動かさないようにしておこう (^_^; (redirect-frame-focus (window-frame canna:*previous-window*) canna:*saved-redirection*) @@ -729,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." @@ -765,6 +779,9 @@ kana-to-kanji translation, even if you are in the minibuffer." (- (point) arg) (point))) (if (= last-command-char ? ) (canna:do-auto-fill)))))) +;; wire us into pending-delete +(put 'canna-self-insert-command 'pending-delete t) + (defun canna-toggle-japanese-mode () "Toggle canna japanese mode." (interactive) @@ -843,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)) @@ -868,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*)) )) @@ -902,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* @@ -1001,7 +1019,7 @@ dictionary." (eq hilit-background-mode 'dark)) (string-match "on\\|t" - (or (if running-xemacs + (or (if (featurep 'xemacs) (x-get-resource "ReverseVideo" "reverseVideo" 'string) (x-get-resource "ReverseVideo" "reverseVideo")) @@ -1058,7 +1076,14 @@ dictionary." (define-key global-map (make-string 1 ch) 'canna-self-insert-command) (setq ch (1+ ch)) )) - (cond ((let ((keys (car init-val)) (ok nil)) + (cond + ;; #### I'm just guessing that this should come before the + ;; init-val setting + ;; if registered with LEIM, no-op + ((featurep 'canna-leim) t) + ;; check to see if an X resource or the like is available in + ;; init-val + ((let ((keys (car init-val)) (ok nil)) (while keys (cond ((< (car keys) 128) (global-set-key @@ -1067,9 +1092,13 @@ dictionary." (setq ok t) )) (setq keys (cdr keys)) ) ok)) - (t ; デフォルトの設定 - (global-set-key "\C-o" 'canna-toggle-japanese-mode) )) + ;; デフォルトの設定 + ;; Since XEmacs provides canna-leim.el, we should leave this + ;; as is. + (t (global-set-key "\C-o" 'canna-toggle-japanese-mode) )) + ;; #### should these global bindings be conditional on LEIM? + ;; LEIM doesn't use kanji key yet AFAIK, so leave them. (if (not (keymapp (global-key-binding "\e["))) (global-unset-key "\e[") ) (global-set-key "\e[210z" 'canna-toggle-japanese-mode) ; XFER @@ -1207,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* @@ -1217,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))