Author: sasugaanija
Date: Sun Jun  3 06:23:15 2007
New Revision: 4577

Modified:
   trunk/emacs/uim-key.el
   trunk/emacs/uim-keymap.el

Log:
* emacs/uim-keymap.el
* emacs/uim-key.el
 - Fix bug reported by Kouhei Sutou
   http://groups.google.com/group/uim-ja/browse_thread/thread/a6b63c2d36176ac2



Modified: trunk/emacs/uim-key.el
==============================================================================
--- trunk/emacs/uim-key.el      (original)
+++ trunk/emacs/uim-key.el      Sun Jun  3 06:23:15 2007
@@ -137,15 +137,27 @@
 
 
 (defun uim-command-execute (keyvec)
-  (let ((mode uim-mode))
+  (uim-debug (format "uim-command-execute: %s" keyvec))
+  (let (this-command-keys-original 
+       (mode uim-mode))
+
+    (fset 'this-command-keys-original
+         (symbol-function 'this-command-keys))
+
     (unwind-protect
        (progn
+         (fset 'this-command-keys 
+               '(lambda ()
+                  keyvec))
          (setq uim-mode nil)
          (setq this-command keyvec)
          (run-hooks 'pre-command-hook)
          (command-execute this-command)
          )
-      (setq uim-mode mode))))
+      (progn
+       (fset 'this-command-keys 
+             (symbol-function 'this-command-keys-original))
+       (setq uim-mode mode)))))
 
 
 (defun uim-blink-match (char)
@@ -177,7 +189,8 @@
 (defun uim-process-keyvec (keyvec &optional count)
   (let ((bind (uim-getbind keyvec))
        keyvectmp)
-
+    (uim-debug (format "uim-process-keyvec"))
+    
     (if uim-emacs
        ;; for transient-mark-mode
        (setq deactivate-mark nil))
@@ -215,20 +228,61 @@
               )
              
              ((commandp bind)
-              (if (eq bind 'self-insert-command)
-                  (progn
-                    (setq this-command bind)
-                    (setq last-command-char (aref keyvec 0))
-                    (call-interactively bind)
-                    (uim-concat-undo))
-                (setq this-command bind)
-                (uim-debug (format "this-command is %s" this-command))
-                (setq last-command-char (aref keyvec 0))
-                (run-hooks 'pre-command-hook)
-                (command-execute this-command) 
 
-                (uim-flush-concat-undo)
+              (let (this-command-keys-original)
+                (fset 'this-command-keys-original
+                      (symbol-function 'this-command-keys))
+
+                (unwind-protect
+                    (progn
+                      (fset 'this-command-keys 
+                            '(lambda ()
+                               keyvec))
+
+                      (if (eq bind 'self-insert-command)
+                          (progn
+                            (setq this-command bind)
+                            (setq last-command-char (aref keyvec 0))
+                            (call-interactively bind)
+                            (uim-concat-undo))
+                        (setq this-command bind)
+                        (uim-debug (format "this-command is %s" this-command))
+                        (setq last-command-char (aref keyvec 0))
+
+                        (run-hooks 'pre-command-hook)
+                        (command-execute this-command) 
+
+                        (uim-flush-concat-undo)
+                        )
+                      )
+                  (fset 'this-command-keys 
+                        (symbol-function 'this-command-keys-original))
+                  )
                 )
+              )
+             ((or (and uim-emacs
+                       (= help-char (aref (uim-last-onestroke-key keyvec) 0)))
+                  (and uim-xemacs
+                       (equal (uim-xemacs-make-event 
+                               (uim-convert-char-to-symbolvector 
(key-description help-char)))
+                              (aref (uim-last-onestroke-key keyvec) 0))))
+              (uim-debug "help-char")
+              (let (this-command-keys-original 
+                    (mode uim-mode))
+                (fset 'this-command-keys-original
+                      (symbol-function 'this-command-keys))
+                (unwind-protect
+                    (progn
+                      (fset 'this-command-keys 
+                            '(lambda ()
+                               keyvec))
+                      (setq uim-mode nil)
+                      (funcall prefix-help-command)
+                      )
+                  (progn
+                    (fset 'this-command-keys 
+                          (symbol-function 'this-command-keys-original))
+                    (setq uim-mode mode))))
               )
              (t
               (uim-flush-concat-undo)

Modified: trunk/emacs/uim-keymap.el
==============================================================================
--- trunk/emacs/uim-keymap.el   (original)
+++ trunk/emacs/uim-keymap.el   Sun Jun  3 06:23:15 2007
@@ -62,19 +62,6 @@
     (shift control meta)  
     ))
 
-
-(defconst uim-emacs-prefix-keys
-  '(help-command
-    2C-command
-    Control-X-prefix
-    mode-specific-command-prefix
-    ctl-x-4-prefix
-    ctl-x-5-prefix
-    vc-prefix-map
-    facemenu-keymap
-    ))
-
-
 (defun uim-mouse-set-point (event)
   (interactive "e")
   (mouse-minibuffer-check event)
@@ -139,17 +126,6 @@
   (setq uim-mode-map (make-sparse-keymap))
   (setq uim-preedit-map (make-sparse-keymap))
 
-
-  ;; copy special keys
-  (let ((prefixs uim-emacs-prefix-keys))
-    (while prefixs
-      (let ((prefix-keys (where-is-internal (car prefixs))))
-       (while prefix-keys
-         (define-key uim-mode-map (car prefix-keys) (car prefixs))
-         (setq prefix-keys (cdr prefix-keys))))
-      (setq prefixs (cdr prefixs))))
-
-  
   (define-prefix-command 'uim-escape-map)
 
   ;; set default key-binds

Reply via email to