Author: sasugaanija
Date: Mon Sep 24 03:29:35 2007
New Revision: 5013
Modified:
trunk/emacs/uim-key.el
trunk/emacs/uim-var.el
trunk/emacs/uim.el
Log:
* Add workaround for Emacs21
Some key-binds defined in key-translation-map require a
2nd character in japanese environment and they call
read-char-exclusive command.
However, when such key-binds are called by command-execute
function, read-char-exclusive function always returns -1
and then the key-binds cause the errors.
This change introduces a workaround of this problem by wrapping
the read-char-exclusive function.
* emacs/uim-key.el
- (uim-read-char-exclusive-override): New function to override
read-char-exclusive
- (uim-read-char-exclusive-restore): New function to restore
original read-char-exclusive
* emacs/uim.el
- (uim-mode-on): Call uim-read-char-exclusive-override
- (uim-mode-off): Call uim-read-char-exclusive-restore
* emacs/uim-var.el
- (uim-read-char-exclusive-original): New variable to save original
read-char-exclusive
Modified: trunk/emacs/uim-key.el
==============================================================================
--- trunk/emacs/uim-key.el (original)
+++ trunk/emacs/uim-key.el Mon Sep 24 03:29:35 2007
@@ -156,6 +156,31 @@
(setq uim-this-command-keys-original nil))))
+;; for Emacs21
+(defun uim-read-char-exclusive-override ()
+ (if (not uim-read-char-exclusive-original)
+ (let ((doc (documentation 'read-char-exclusive)))
+ (setq uim-read-char-exclusive-original
+ (symbol-function 'read-char-exclusive))
+ (eval
+ `(fset 'read-char-exclusive
+ '(lambda (&optional prompt inherit-input-method)
+ ,doc
+ (if (and (boundp 'uim-key-vector) uim-key-vector)
+ (let (executing-macro)
+ (funcall uim-read-char-exclusive-original
+ prompt inherit-input-method))
+ (funcall uim-read-char-exclusive-original))))))))
+
+
+;; for Emacs21
+(defun uim-read-char-exclusive-restore ()
+ (if uim-read-char-exclusive-original
+ (progn
+ (fset 'read-char-exclusive uim-read-char-exclusive-original)
+ (setq uim-read-char-exclusive-original nil))))
+
+
(defun uim-command-execute (uim-key-vector &optional bind)
(uim-debug (format "uim-command-execute: %s %s" uim-key-vector bind))
Modified: trunk/emacs/uim-var.el
==============================================================================
--- trunk/emacs/uim-var.el (original)
+++ trunk/emacs/uim-var.el Mon Sep 24 03:29:35 2007
@@ -301,6 +301,8 @@
(defvar uim-this-command-keys-original nil)
+(defvar uim-read-char-exclusive-original nil)
+
;;; Buffer Local Variables
(uim-deflocalvar uim-mode-line-string " U"
Modified: trunk/emacs/uim.el
==============================================================================
--- trunk/emacs/uim.el (original)
+++ trunk/emacs/uim.el Mon Sep 24 03:29:35 2007
@@ -385,6 +385,8 @@
;; override some functions
(uim-this-command-keys-override)
+ (if (= emacs-major-version 21)
+ (uim-read-char-exclusive-override))
(if (not buffer-read-only)
(progn
@@ -431,6 +433,8 @@
;; restore original functions
(uim-this-command-keys-restore)
+ (if (= emacs-major-version 21)
+ (uim-read-char-exclusive-restore))
(uim-debug (format "uim-mode: %s" uim-mode))