X-Git-Url: http://git.chise.org/gitweb/?p=elisp%2Femacs-canna.git;a=blobdiff_plain;f=canna.el;h=9e89926ae4d02d8c7e2bb76885fdfd5241362589;hp=768a8f6d91c5f1e95d118b8d9894dec2c8374afd;hb=840ae24229e63454f9130150d280ed4aceeb1251;hpb=54e55a6d8bbdd78ace38f4ab6eda7935c11be5b7 diff --git a/canna.el b/canna.el index 768a8f6..9e89926 100644 --- a/canna.el +++ b/canna.el @@ -1,14 +1,16 @@ ;;; 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.11 $ +;; Stephen Turnbull +;; Version: $Revision: 1.21 $ ;; 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 +38,7 @@ ;;; Code: -;; -*-mode: emacs-lisp-*- +(require 'poem) (defvar canna-dl-module (expand-file-name "canna.so" exec-directory)) @@ -49,37 +51,39 @@ (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.11 1998-02-09 12:01:53 morioka Exp $") +(defconst canna-version "Emacs-Canna 1.3") (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 " ..."))) + +(cond + ((featurep 'xemacs) + (defvar canna-self-insert-string-filter (function identity)) + (defun canna-self-insert-string (string) + (if (fboundp 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) + )) ;;; かんなの変数 @@ -172,13 +176,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) @@ -187,8 +191,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)) @@ -279,10 +283,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)) @@ -290,7 +294,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") @@ -331,7 +335,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") @@ -437,7 +441,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)) @@ -447,7 +451,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のバッファに反映させる ;; 関数である。 @@ -640,7 +644,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) @@ -686,7 +690,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*) @@ -727,8 +731,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." @@ -763,6 +767,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) @@ -841,10 +848,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)) @@ -866,7 +874,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*)) )) @@ -900,8 +909,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* @@ -999,7 +1007,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")) @@ -1056,7 +1064,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 @@ -1065,9 +1080,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 @@ -1205,8 +1224,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* @@ -1215,8 +1233,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))