-;; This file is a part of Canna on Nemacs/Mule.
+;;; canna.el --- Interface to the Canna input method.
-;; Canna on Nemacs/Mule is distributed in the forms of
-;; patches to Nemacs under the terms of the GNU EMACS
-;; GENERAL PUBLIC LICENSE which is distributed along with
-;; GNU Emacs by the Free Software Foundation.
+;; Copyright (C) 1994 Akira Kon, NEC Corporation.
+;; Copyright (C) 1996,1997 MORIOKA Tomohiko
-;; Canna on Nemacs/Mule 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 EMACS GENERAL PUBLIC
-;; LICENSE for more details.
+;; Author: Akira Kon <kon@d1.bs2.mt.nec.co.jp>
+;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
+;; Version: $Revision: 1.6 $
+;; Keywords: Canna, Japanese, input method, mule, multilingual
-;; You should have received a copy of the GNU EMACS GENERAL
-;; PUBLIC LICENSE along with Nemacs/Mule; see the file
-;; COPYING. If not, write to the Free Software Foundation,
-;; 675 Mass Ave, Cambridge, MA 02139, USA.
+;; This file is not a part of Emacs yet.
-;; Egg offered some influences to the implementation of
-;; Canna on Nemacs/Mule, and this file contains a few part
-;; of Egg which is written by S.Tomura, Electrotechnical
-;; Lab. (tomura@etl.go.jp)
+;; This program 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.
-;; Written by Akira Kon, NEC Corporation.
-;; E-Mail: kon@d1.bs2.mt.nec.co.jp.
+;; This program 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:
+
+;; Egg offered some influences to the implementation of Canna on
+;; Nemacs/Mule, and this file contains a few part of Egg which is
+;; written by S.Tomura, Electrotechnical Lab. (tomura@etl.go.jp)
+
+;; This program is rewritten for Emacs/mule and XEmacs/mule by MORIOKA
+;; Tomohiko.
+
+;;; Code:
;; -*-mode: emacs-lisp-*-
;; end
(defconst canna-rcs-version
- "$Id: canna.el,v 1.5 1997-04-03 18:52:22 morioka Exp $")
+ "$Id: canna.el,v 1.6 1997-04-03 20:18:20 morioka Exp $")
(defun canna-version ()
"Display version of canna.el in mini-buffer."
))
" ...")))
-(provide 'canna)
+;; added by MORIOKA Tomohiko <morioka@jaist.ac.jp>, 1996/6/7
+(or (fboundp 'minibuffer-prompt-width)
+ (defun minibuffer-prompt-width ()
+ "Return the display width of the minibuffer prompt."
+ (save-excursion
+ (set-buffer (window-buffer (minibuffer-window)))
+ (current-column)
+ ))
+ )
+
+;; added by MORIOKA Tomohiko <morioka@jaist.ac.jp>, 1997/4/3
+(or (fboundp 'char-or-char-int-p)
+ (defalias 'char-or-char-int-p 'integerp)
+ )
+
+;; added by MORIOKA Tomohiko <morioka@jaist.ac.jp>, 1996/6/18
+(defvar running-xemacs (string-match "XEmacs" emacs-version))
+
+(cond (running-xemacs
+ (require 'overlay)
+ (defun self-insert-string (string)
+ (let ((len (length string))
+ (i 0)
+ ;; \e$BA^F~$NESCf$G\e(B blink \e$B$,5/$-$k$H$&$C$H$*$7$$$N$G!"\e(B
+ ;; \e$B0l;~E*$K\e(B blink \e$B$rM^;_$9$k!#\e(B
+ (blink-matching-paren nil))
+ (while (< i len)
+ (self-insert-internal (aref canna-kakutei-string i))
+ (setq i (1+ i))
+ )))
+ )
+ (t
+ (defalias 'self-insert-string 'insert)
+ ))
;;; \e$B$+$s$J$NJQ?t\e(B
(define-key canna-mode-map (make-string 1 ch) 'canna-functional-insert-command)
(setq ch (1+ ch))))
-(define-key canna-mode-map [up] [?\C-p])
-(define-key canna-mode-map [S-up] [?\C-p])
-(define-key canna-mode-map [C-up] [?\C-p])
-(define-key canna-mode-map [down] [?\C-n])
-(define-key canna-mode-map [S-down] [?\C-n])
-(define-key canna-mode-map [C-down] [?\C-n])
-(define-key canna-mode-map [right] [?\C-f])
-(define-key canna-mode-map [S-right] [?\C-f])
-(define-key canna-mode-map [C-right] [?\C-f])
-(define-key canna-mode-map [left] [?\C-b])
-(define-key canna-mode-map [S-left] [?\C-b])
-(define-key canna-mode-map [C-left] [?\C-b])
-(define-key canna-mode-map [kanji] [? ])
-(define-key canna-mode-map [?\C- ] [?\C-@])
+(cond (running-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")
+ (define-key canna-mode-map [down] "\C-n")
+ (define-key canna-mode-map [(shift down)] "\C-n")
+ (define-key canna-mode-map [(control down)] "\C-n")
+ (define-key canna-mode-map [right] "\C-f")
+ (define-key canna-mode-map [(shift right)] "\C-f")
+ (define-key canna-mode-map [(control right)] "\C-f")
+ (define-key canna-mode-map [left] "\C-b")
+ (define-key canna-mode-map [(shift left)] "\C-b")
+ (define-key canna-mode-map [(control left)] "\C-b")
+ (define-key canna-mode-map [kanji] " ")
+ (define-key canna-mode-map [(control space)] [(control @)])
+ )
+ (t
+ (define-key canna-mode-map [up] [?\C-p])
+ (define-key canna-mode-map [S-up] [?\C-p])
+ (define-key canna-mode-map [C-up] [?\C-p])
+ (define-key canna-mode-map [down] [?\C-n])
+ (define-key canna-mode-map [S-down] [?\C-n])
+ (define-key canna-mode-map [C-down] [?\C-n])
+ (define-key canna-mode-map [right] [?\C-f])
+ (define-key canna-mode-map [S-right] [?\C-f])
+ (define-key canna-mode-map [C-right] [?\C-f])
+ (define-key canna-mode-map [left] [?\C-b])
+ (define-key canna-mode-map [S-left] [?\C-b])
+ (define-key canna-mode-map [C-left] [?\C-b])
+ (define-key canna-mode-map [kanji] [? ])
+ (define-key canna-mode-map [?\C- ] [?\C-@])
+ ))
;; \e$B%_%K%P%C%U%!$K2?$+$rI=<($7$F$$$k;~$N%m!<%+%k%^%C%W\e(B
(defvar canna-minibuffer-mode-map (make-sparse-keymap))
(define-key canna-minibuffer-mode-map (make-string 1 ch) 'canna-minibuffer-insert-command)
(setq ch (1+ ch))))
-(define-key canna-minibuffer-mode-map [up] [?\C-p])
-(define-key canna-minibuffer-mode-map [S-up] [?\C-p])
-(define-key canna-minibuffer-mode-map [C-up] [?\C-p])
-(define-key canna-minibuffer-mode-map [down] [?\C-n])
-(define-key canna-minibuffer-mode-map [S-down] [?\C-n])
-(define-key canna-minibuffer-mode-map [C-down] [?\C-n])
-(define-key canna-minibuffer-mode-map [right] [?\C-f])
-(define-key canna-minibuffer-mode-map [S-right] [?\C-f])
-(define-key canna-minibuffer-mode-map [C-right] [?\C-f])
-(define-key canna-minibuffer-mode-map [left] [?\C-b])
-(define-key canna-minibuffer-mode-map [S-left] [?\C-b])
-(define-key canna-minibuffer-mode-map [C-left] [?\C-b])
-(define-key canna-minibuffer-mode-map [kanji] [? ])
-(define-key canna-minibuffer-mode-map [?\C- ] [?\C-@])
+(cond (running-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")
+ (define-key canna-minibuffer-mode-map [down] "\C-n")
+ (define-key canna-minibuffer-mode-map [(shift down)] "\C-n")
+ (define-key canna-minibuffer-mode-map [(control down)] "\C-n")
+ (define-key canna-minibuffer-mode-map [right] "\C-f")
+ (define-key canna-minibuffer-mode-map [(shift right)] "\C-f")
+ (define-key canna-minibuffer-mode-map [(control right)] "\C-f")
+ (define-key canna-minibuffer-mode-map [left] "\C-b")
+ (define-key canna-minibuffer-mode-map [(shift left)] "\C-b")
+ (define-key canna-minibuffer-mode-map [(control left)] "\C-b")
+ (define-key canna-minibuffer-mode-map [kanji] " ")
+ (define-key canna-minibuffer-mode-map [(control space)] [(control @)])
+ )
+ (t
+ (define-key canna-minibuffer-mode-map [up] [?\C-p])
+ (define-key canna-minibuffer-mode-map [S-up] [?\C-p])
+ (define-key canna-minibuffer-mode-map [C-up] [?\C-p])
+ (define-key canna-minibuffer-mode-map [down] [?\C-n])
+ (define-key canna-minibuffer-mode-map [S-down] [?\C-n])
+ (define-key canna-minibuffer-mode-map [C-down] [?\C-n])
+ (define-key canna-minibuffer-mode-map [right] [?\C-f])
+ (define-key canna-minibuffer-mode-map [S-right] [?\C-f])
+ (define-key canna-minibuffer-mode-map [C-right] [?\C-f])
+ (define-key canna-minibuffer-mode-map [left] [?\C-b])
+ (define-key canna-minibuffer-mode-map [S-left] [?\C-b])
+ (define-key canna-minibuffer-mode-map [C-left] [?\C-b])
+ (define-key canna-minibuffer-mode-map [kanji] [? ])
+ (define-key canna-minibuffer-mode-map [?\C- ] [?\C-@])
+ ))
;;;
;;; \e$B%0%m!<%P%k4X?t$N=q$-BX$(\e(B
"Use input character as a key of complex translation input such as\n\
kana-to-kanji translation."
(interactive "*p")
- (canna:functional-insert-command2 last-command-char arg) )
+ (let ((ch))
+ (if (char-or-char-int-p arg)
+ (setq ch last-command-char)
+ (setq ch (event-to-character last-command-event)))
+ (canna:functional-insert-command2 ch arg) ))
(defun canna:functional-insert-command2 (ch arg)
"This function actualy isert a converted Japanese string."
(set-marker canna:*spos-undo-text* (point))
;;
;; update kbnes
- ;; by \e$B<i2,\e(B \e$BCNI'\e(B <morioka@jaist.ac.jp> 1996/11/8
- ;; \e$B$H$j$"$($:\e(B insert \e$B$K$7$H$/!#\e(B
- (insert canna-kakutei-string)
- ;;(let ((list (string-to-char-list canna-kakutei-string))
- ;; ;; \e$BA^F~$NESCf$G\e(B blink \e$B$,5/$-$k$H$&$C$H$*$7$$$N$G!"\e(B
- ;; ;; \e$B0l;~E*$K\e(B blink \e$B$rM^;_$9$k!#\e(B
- ;; (blink-matching-paren nil))
- ;; (while list
- ;; (self-insert-internal (car list))
- ;; (setq list (cdr list))))
+ (self-insert-string canna-kakutei-string)
;; \e$BL$3NDj$NJ8;z$,$J$/!"3NDjJ8;zNs$N:G8e$,JD$83g8L$N\e(B
;; \e$BN`$@$C$?$H$-$O\e(B blink \e$B$5$;$k!#\e(B
(if (and canna-empty-info
(t
;;
;; update kbnes
- ;; by \e$B<i2,\e(B \e$BCNI'\e(B <morioka@jaist.ac.jp> 1996/11/8
- ;; \e$B$H$j$"$($:\e(B insert \e$B$K$7$H$/!#\e(B
- (insert canna-kakutei-string)
- ;; (let ((list (string-to-char-list canna-kakutei-string))
- ;; ;; \e$BA^F~$NESCf$G\e(B blink \e$B$,5/$-$k$H$&$C$H$*$7$$$N$G!"\e(B
- ;; ;; \e$B0l;~E*$K\e(B blink \e$B$rM^;_$9$k!#\e(B
- ;; (blink-matching-paren nil))
- ;; (while list
- ;; (self-insert-internal (car list))
- ;; (setq list (cdr list))))
-
+ (self-insert-string canna-kakutei-string)
;; \e$BL$3NDj$NJ8;z$,$J$/!"3NDjJ8;zNs$N:G8e$,JD$83g8L$N\e(B
;; \e$BN`$@$C$?$H$-$O\e(B blink \e$B$5$;$k!#\e(B
(if (and canna-empty-info
(setq canna:*saved-minibuffer* (window-buffer (minibuffer-window)))
; (set-window-buffer (minibuffer-window)
; (get-buffer-create canna:*menu-buffer*))
- (setq canna:*saved-redirection* (frame-focus (selected-frame)))
- (redirect-frame-focus (selected-frame)
- (window-frame (minibuffer-window)))
-
+ ;; modified by \e$B<i2,\e(B \e$BCNI'\e(B <morioka@jaist.ac.jp>, 1996/6/7
+ (unless running-xemacs
+ ;; \e$B$H$j$"$($:\e(B XEmacs \e$B$G$OF0$+$5$J$$$3$H$K$7$F$*$3$&\e(B (^_^;
+ (setq canna:*saved-redirection* (frame-focus (selected-frame)))
+ (redirect-frame-focus (selected-frame)
+ (window-frame (minibuffer-window)))
+ )
;; \e$B%_%K%P%C%U%!$N%-!<%^%C%W$rJ]B8$7$F$*$/!#\e(B
(setq canna:*minibuffer-local-map-backup* (current-local-map))
))
;; \e$B%_%K%P%C%U%!%&%#%s%I%&$N%P%C%U%!$r85$KLa$9!#\e(B
(set-window-buffer (minibuffer-window) canna:*saved-minibuffer*)
; (setq canna:*saved-minibuffer* nil)
- (redirect-frame-focus (window-frame canna:*previous-window*)
- canna:*saved-redirection*)
+ ;; modified by \e$B<i2,\e(B \e$BCNI'\e(B <morioka@jaist.ac.jp>, 1996/6/7
+ (unless running-xemacs
+ ;; \e$B$H$j$"$($:\e(B XEmacs \e$B$G$OF0$+$5$J$$$h$&$K$7$F$*$3$&\e(B (^_^;
+ (redirect-frame-focus (window-frame canna:*previous-window*)
+ canna:*saved-redirection*)
+ )
; \e$B%_%K%P%C%U%!$GF~NO$7$F$$$?$N$J$i0J2<$b$9$k!#\e(B
; (if (eq canna:*previous-window* (selected-window))
; (progn
(use-local-map canna:*minibuffer-local-map-backup*)
(set-window-buffer (minibuffer-window) canna:*saved-minibuffer*)
(select-window canna:*previous-window*)
- (canna:functional-insert-command2 last-command-char arg) )
+ (let ((ch))
+ (if (char-or-char-int-p arg)
+ (setq ch last-command-char)
+ (setq ch (event-to-character last-command-event)))
+ (canna:functional-insert-command2 ch arg) ))
;;;
;;; \e$B$+$s$J%b!<%I$N<gLr$O!"<!$N\e(B canna-self-insert-command \e$B$G$"$k!#$3$N\e(B
0)))
(setq canna:*local-map-backup* (current-local-map))
(setq canna:*fence-mode* t)
- (if (boundp 'disable-undo)
- (setq disable-undo canna:*fence-mode*))
- (use-local-map canna-mode-map) )
+ ;; XEmacs change:
+ (buffer-disable-undo (current-buffer))
+ ;; (if (boundp 'disable-undo)
+ ;; (setq disable-undo canna:*fence-mode*))
+ (use-local-map canna-mode-map))
(defun canna:enter-canna-mode-and-functional-insert ()
(canna:enter-canna-mode)
(if canna:*japanese-mode*
(canna-toggle-japanese-mode)
(mode-line-canna-mode-update canna:*alpha-mode-string*) )))
- (if (boundp 'disable-undo)
- (setq disable-undo canna:*fence-mode*))
+ ;; XEmacs change:
+ (buffer-enable-undo (current-buffer))
+ ;; (if (boundp 'disable-undo)
+ ;; (setq disable-undo canna:*fence-mode*))
))
(set-marker canna:*region-start* nil)
(set-marker canna:*region-end* nil)
(eq hilit-background-mode 'dark))
(string-match
"on\\|t"
- (or (x-get-resource "ReverseVideo" "reverseVideo")
+ (or (if running-xemacs
+ (x-get-resource "ReverseVideo"
+ "reverseVideo" 'string)
+ (x-get-resource "ReverseVideo" "reverseVideo"))
"")))
'reverse) ;\e$BH?E>$7$F$$$k$J$i\e(B 'reverse
(t 'normal)))
(delete-overlay canna:*select-overlay*)
)
)
+
+
+(provide 'canna)
+
+;;; canna.el ends here