Author: ek.kato
Date: Sun Jul 20 10:55:58 2008
New Revision: 5509

Modified:
   branches/1.5/emacs/uim-el-helper-agent.c
   branches/1.5/emacs/uim-key.el
   branches/1.5/emacs/uim-keymap.el
   branches/1.5/emacs/uim-util.el
   branches/1.5/emacs/uim.el
   branches/1.5/scm/elatin.scm
   branches/1.5/scm/im-custom.scm
   branches/1.5/scm/im.scm
   branches/1.5/scm/prime.scm
   branches/1.5/scm/trycode.scm
   branches/1.5/uim/canna.c
   branches/1.5/xim/ximserver.cpp

Log:
* merge -r5496:5508 from trunk


Modified: branches/1.5/emacs/uim-el-helper-agent.c
==============================================================================
--- branches/1.5/emacs/uim-el-helper-agent.c    (original)
+++ branches/1.5/emacs/uim-el-helper-agent.c    Sun Jul 20 10:55:58 2008
@@ -206,13 +206,10 @@
   debug_printf(DEBUG_NOTE, "read command\n");
 
   do {
-       if ((len = read(STDIN_FILENO, rbuf, sizeof(rbuf) - 1)) == -1 || len == 
0) {
-         rbuf[0] = '\n';
-         rbuf[1] = '\0';
-         len = 1;
+       if ((len = read(STDIN_FILENO, rbuf, sizeof(rbuf) - 1)) == -1)
          debug_printf(DEBUG_NOTE, "stdin has corrupted\n");
-       } else
-         rbuf[len] = '\0';
+
+       rbuf[len] = '\0';
 
        if (strlen(cmdbuf) + len + 1 > cmdbuf_len) {
          cmdbuf_len += DEFAULT_MESSAGE_SIZE;

Modified: branches/1.5/emacs/uim-key.el
==============================================================================
--- branches/1.5/emacs/uim-key.el       (original)
+++ branches/1.5/emacs/uim-key.el       Sun Jul 20 10:55:58 2008
@@ -212,8 +212,8 @@
          (setq last-command-char 
                (aref (uim-get-vector-from-tail uim-key-vector 1) 0))
          
-         (setq map (cdr (assq 'uim-mode minor-mode-map-alist)))
-         (setcdr (assq 'uim-mode minor-mode-map-alist) uim-dummy-map)
+         ;; backup current keymap of uim-mode
+         (setq map (uim-disable-keymap))
 
          (if (or (and bind
                       (eq bind 'digit-argument))         
@@ -236,7 +236,8 @@
               (buffer-live-p buffer))
          (progn 
            (set-buffer buffer)
-           (setcdr (assq 'uim-mode minor-mode-map-alist) map)
+           ;; restore keymap of uim-mode
+           (uim-set-keymap map)
            ))
       )))
 

Modified: branches/1.5/emacs/uim-keymap.el
==============================================================================
--- branches/1.5/emacs/uim-keymap.el    (original)
+++ branches/1.5/emacs/uim-keymap.el    Sun Jul 20 10:55:58 2008
@@ -179,34 +179,68 @@
   
   )
 
+;; 
+;; Disable other minor-mode keymaps while preedit strings or candidates 
+;; are displayed.
+;;
+(defun uim-disable-other-minor-mode-map ()
+  (when (not uim-minor-mode-map-alist)
+    (setq uim-minor-mode-map-alist minor-mode-map-alist)
+    (setq minor-mode-map-alist (list (assq 'uim-mode minor-mode-map-alist)))
+
+    (when (and uim-emacs (>= emacs-major-version 22)) 
+      (setq uim-emulation-mode-map-alists emulation-mode-map-alists)
+      (setq emulation-mode-map-alists nil)))
+  )
+
+(defun uim-enable-other-minor-mode-map ()
+  (when uim-minor-mode-map-alist
+    (setq minor-mode-map-alist uim-minor-mode-map-alist)
+    (setq uim-minor-mode-map-alist nil)
+
+    (when (and uim-emacs (>= emacs-major-version 22)) 
+      (setq emulation-mode-map-alists uim-emulation-mode-map-alists)
+      (setq uim-emulation-mode-map-alists nil)))
+  )
+
 
 ;;
-;; Switch keymap
+;; Change keymap of uim-mode
 ;;
-(defun uim-enable-mode-keymap ()
+(defun uim-set-keymap (map)
   (setcdr (assq 'uim-mode minor-mode-map-alist) 
-         uim-mode-map))
+         map))
 
-(defun uim-disable-mode-keymap ()
-  (setcdr (assq 'uim-mode minor-mode-map-alist) 
-         nil))
+;;
+;; Return current keymap of uim-mode
+;;
+(defun uim-get-keymap ()
+  (cdr (assq 'uim-mode minor-mode-map-alist)))
 
-(defun uim-enable-preedit-keymap ()
-  (when (not uim-preedit-keymap-enabled)
+;;
+;; Set normal keymap
+;;
+(defun uim-enable-mode-keymap ()
+  (uim-set-keymap uim-mode-map))
 
-    (setq uim-preedit-keymap-enabled t)
+;;
+;; Disable and return current keymap
+;;
+(defun uim-disable-keymap ()
+  (let (map)
+    (setq map (uim-get-keymap))
+    (uim-set-keymap uim-dummy-map)
+    map)
+  )
 
-    (setcdr (assq 'uim-mode minor-mode-map-alist) 
-           uim-preedit-map) 
+;;
+;; Set preedit keymap
+;;
+(defun uim-enable-preedit-keymap ()
+  (when (not uim-preedit-keymap-enabled)
+    (setq uim-preedit-keymap-enabled t))
 
-    ;; disable other keymaps
-    (when (not uim-minor-mode-map-alist)
-      (setq uim-minor-mode-map-alist minor-mode-map-alist)
-      (setq minor-mode-map-alist (list (assq 'uim-mode minor-mode-map-alist)))
-
-      (when (and uim-emacs (>= emacs-major-version 22)) 
-       (setq uim-emulation-mode-map-alists emulation-mode-map-alists)
-       (setq emulation-mode-map-alists nil)))
+  (uim-set-keymap uim-preedit-map)
 
     (when uim-xemacs
       ;; disable toolbar and menubar
@@ -214,29 +248,22 @@
       (setq toolbar-map uim-toolbar-map)
       (uim-xemacs-save-menubar))
     )
-  )
 
+;;
+;; Unset preedit keymap
+;;
 (defun uim-disable-preedit-keymap ()
-  (when uim-preedit-keymap-enabled
-    (setq uim-preedit-keymap-enabled nil)
 
-    ;; enable other keymaps
-    (when uim-minor-mode-map-alist
-      (setq minor-mode-map-alist uim-minor-mode-map-alist)
-      (setq uim-minor-mode-map-alist nil)
-
-      (when (and uim-emacs (>= emacs-major-version 22)) 
-       (setq emulation-mode-map-alists uim-emulation-mode-map-alists)
-       (setq uim-emulation-mode-map-alists nil)))
+  (when uim-preedit-keymap-enabled
+    (setq uim-preedit-keymap-enabled nil))
 
+  (uim-enable-other-minor-mode-map)
     (uim-enable-mode-keymap)
 
     (when uim-xemacs
       ;;enable toolbar and menubar
       (kill-local-variable 'toolbar-map)
       (uim-xemacs-restore-menubar))
-
-    )
   )
 
 

Modified: branches/1.5/emacs/uim-util.el
==============================================================================
--- branches/1.5/emacs/uim-util.el      (original)
+++ branches/1.5/emacs/uim-util.el      Sun Jul 20 10:55:58 2008
@@ -270,7 +270,7 @@
     (save-excursion
       (when (and (char-after)
                 (= (char-after) ?\t))
-       (insert-char 32)
+       (insert-char 32 1)
        (setq dummy-space t)
        ))
 
@@ -291,7 +291,7 @@
       )
 
     (if dummy-space
-       (delete-char))
+       (delete-char 1))
     i
     ))
 

Modified: branches/1.5/emacs/uim.el
==============================================================================
--- branches/1.5/emacs/uim.el   (original)
+++ branches/1.5/emacs/uim.el   Sun Jul 20 10:55:58 2008
@@ -64,7 +64,7 @@
   (if (not (assq 'uim-mode minor-mode-map-alist))
       (setq minor-mode-map-alist
            (cons
-            (cons 'uim-mode uim-mode-map)
+            (cons 'uim-mode nil)
             minor-mode-map-alist))))
 
 
@@ -183,6 +183,20 @@
 ;; Focused 
 ;;
 (defun uim-focused ()
+  (if uim-preedit-keymap-enabled
+      (progn
+       ;; If preedit strings and/or candidates are displayed,
+       ;; other keymaps of minor-mode-map-alist should be disabled.
+       ;; Since minor-mode-map-alist is not a buffer local variable, 
+       ;; we must re-enable the other keymaps of minor-mode-map-alist
+       ;; when the focus has moved to other buffer.
+       ;; So, we also need to re-disable other keymaps of minor-mode-map-alist
+       ;; when the focus has move to a buffer which have
+       ;; preedit strings and/or candidates.
+       (uim-disable-other-minor-mode-map)
+       (uim-enable-preedit-keymap))
+    (uim-enable-mode-keymap))
+
   (uim-change-process-encoding uim-decoding-code)
   (setq uim-focused-buffer (current-buffer))
   (uim-do-send-recv-cmd (format "%d FOCUSED" uim-context-id))
@@ -196,6 +210,9 @@
   ;; don't send a message to uim-el-agent if it has been dead
   (if uim-el-agent-process
       (uim-do-send-recv-cmd (format "%d UNFOCUSED" uim-context-id)))
+  ;; Enable other keymaps of minor-mode-map-alist.  See uim-focused.
+  (if uim-preedit-keymap-enabled
+      (uim-enable-other-minor-mode-map))
   )
 
 
@@ -1116,6 +1133,7 @@
 (defun uim-enter-preedit-mode ()
   ;; change keymap and freeze faces at first time
   (uim-enable-preedit-keymap)
+  (uim-disable-other-minor-mode-map)
   (when (= (minibuffer-depth) 0)
     (uim-freeze-buffer)
     (setq uim-buffer-read-only buffer-read-only)
@@ -1431,6 +1449,7 @@
 
   ;; initialize minor-mode
   (uim-init-minor-mode)
+  (uim-enable-mode-keymap)
 
   ;; initialize keymap
   (uim-init-keymap)

Modified: branches/1.5/scm/elatin.scm
==============================================================================
--- branches/1.5/scm/elatin.scm (original)
+++ branches/1.5/scm/elatin.scm Sun Jul 20 10:55:58 2008
@@ -36,6 +36,7 @@
 (require "util.scm")
 (require "rk.scm")
 (require "elatin-rules.scm")
+(require-custom "generic-key-custom.scm")
 (require-custom "elatin-custom.scm")
 
 (define elatin-context-rec-spec

Modified: branches/1.5/scm/im-custom.scm
==============================================================================
--- branches/1.5/scm/im-custom.scm      (original)
+++ branches/1.5/scm/im-custom.scm      Sun Jul 20 10:55:58 2008
@@ -274,34 +274,38 @@
 ;;
 ;; im-switching
 ;;
+(define-custom-group 'im-switching
+  (N_ "Input method switching")
+  (N_ "long description will be here."))
 
-;; I think that current "im-switching by hotkey" feature is not
-;; useful. So commented out them to avoid confusion of users.
-;;   -- YamaKen 2005-02-01
+(define-custom 'enable-im-switch #f
+  '(global im-switching)
+  '(boolean)
+  (N_ "Enable IM switching by hotkey")
+  (N_ "long description will be here."))
 
-;;(define-custom-group 'im-switching
-;;                  (N_ "Input method switching")
-;;                  (N_ "long description will be here."))
-;;
-;;(define-custom 'enable-im-switch #f
-;;  '(global im-switching)
-;;  '(boolean)
-;;  (N_ "Enable IM switching by hotkey")
-;;  (N_ "long description will be here."))
-;;
-;;(define-custom 'switch-im-key '("<Control>Shift_key" "<Shift>Control_key")
-;;  '(global im-switching)
-;;  '(key)
-;;  (N_ "IM switching key")
-;;  (N_ "long description will be here."))
-;;
-;;;; activity dependency
-;;(custom-add-hook 'switch-im-key?
-;;              'custom-activity-hooks
-;;              (lambda ()
-;;                enable-im-switch))
+(define-custom 'switch-im-key '("<Control>Shift_key" "<Shift>Control_key")
+  '(global im-switching)
+  '(key)
+  (N_ "IM switching key")
+  (N_ "long description will be here."))
 
-(define-key switch-im-key? '())
+(define-custom 'switch-im-skip-direct-im? #f
+  '(global im-switching)
+  '(boolean)
+  (N_ "Skip direct method for IM switching by hotkey")
+  (N_ "long description will be here."))
+
+;; activity dependency
+(custom-add-hook 'switch-im-key?
+                'custom-activity-hooks
+                (lambda ()
+                  enable-im-switch))
+
+(custom-add-hook 'switch-im-skip-direct-im?
+                'custom-activity-hooks
+                (lambda ()
+                  enable-im-switch))
 
 ;; im-toggle 
 (define-custom-group 'im-toggle

Modified: branches/1.5/scm/im.scm
==============================================================================
--- branches/1.5/scm/im.scm     (original)
+++ branches/1.5/scm/im.scm     Sun Jul 20 10:55:58 2008
@@ -246,18 +246,28 @@
 
 (define next-im
   (lambda (name)
-    (let* ((im-names (map car im-list))
+    (let* ((im-names enabled-im-list)
           (im-rest (memq name im-names)))
       (or (and im-rest
               (pair? (cdr im-rest))
               (cadr im-rest))
          (car im-names)))))
 
+(define next-im-for-switch-im
+  (lambda (name)
+    (let ((im (next-im name)))
+      (or
+       (and
+       switch-im-skip-direct-im?
+       (eq? im 'direct)
+       (next-im im))
+       im))))
+
 ;; 'switch-im' is not a API but an IM-switching method. Don't confuse with
 ;; im-switch-im
 (define switch-im
   (lambda (uc name)
-    (im-switch-im uc (next-im name))))
+    (im-switch-im uc (next-im-for-switch-im name))))
 
 ;; FIXME: Input states are kept only if the state is appeared in the
 ;; toolbar.

Modified: branches/1.5/scm/prime.scm
==============================================================================
--- branches/1.5/scm/prime.scm  (original)
+++ branches/1.5/scm/prime.scm  Sun Jul 20 10:55:58 2008
@@ -59,7 +59,7 @@
 (define-key prime-escape-key?         '("escape" "<Control>["))
 (define-key prime-space-key?          '(" "))
 
-(define prime-app-mode-end-stroke-list #f)
+(define prime-app-mode-end-stroke-list '())
 ;;;; If you're a Vi user, modify the lines below.
 (define prime-configure-app-mode-vi
   (lambda ()
@@ -72,7 +72,7 @@
        (begin
          ;; Default
          (define-key prime-app-mode-start-key?  #f)
-         (set! prime-app-mode-end-stroke-list #f)))))
+         (set! prime-app-mode-end-stroke-list '())))))
 
 (prime-configure-app-mode-vi)
 

Modified: branches/1.5/scm/trycode.scm
==============================================================================
--- branches/1.5/scm/trycode.scm        (original)
+++ branches/1.5/scm/trycode.scm        Sun Jul 20 10:55:58 2008
@@ -27,7 +27,7 @@
 ;;; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 ;;; SUCH DAMAGE.
 ;;;;
-;; 2007-12-10 version
+;; 2008-04-18 version
 
 ;;
 (require "generic.scm")
@@ -1534,7 +1534,7 @@
     ((("r" "v"))("��")) (((" " "r" "v"))("��"))
     ((("l" "v"))("��")) (((" " "l" "v"))("˦"))
     ((("a" "v"))("��")) (((" " "a" "v"))("̻"))
-    ((("o" "v"))("��")) (((" " "o" "v"))("��"))
+    ((("o" "v"))("��")) (((" " "o" "v"))("ǣ"))
     ((("e" "v"))("��")) (((" " "e" "v"))("��"))
     ((("u" "v"))("��")) (((" " "u" "v"))("��"))
     ((("i" "v"))("��")) (((" " "i" "v"))("��"))

Modified: branches/1.5/uim/canna.c
==============================================================================
--- branches/1.5/uim/canna.c    (original)
+++ branches/1.5/uim/canna.c    Sun Jul 20 10:55:58 2008
@@ -120,8 +120,10 @@
    * initialization is exist at beginning of create_context(). I don't
    * know why this sequence is needed at here.  -- YamaKen 2007-07-21 */
   if (rk_initialized == -1) {
-    if (RkInitialize(cannaserver) == ERR)
-      uim_fatal_error("RkInitialize() failed");
+    if (RkInitialize(cannaserver) == ERR) {
+      uim_notify_fatal("RkInitialize() failed");
+      return uim_scm_f();
+    }
     RkFinalize();
   }
 
@@ -138,8 +140,10 @@
   int buflen, i;
 
   if (rk_initialized == -1) {
-    if (RkInitialize(cannaserver) == ERR)
-      uim_fatal_error("RkInitialize() failed");
+    if (RkInitialize(cannaserver) == ERR) {
+      uim_notify_fatal("RkInitialize() failed");
+      return uim_scm_f();
+    }
     rk_initialized = 1;
   }
 

Modified: branches/1.5/xim/ximserver.cpp
==============================================================================
--- branches/1.5/xim/ximserver.cpp      (original)
+++ branches/1.5/xim/ximserver.cpp      Sun Jul 20 10:55:58 2008
@@ -1105,10 +1105,6 @@
     if (x->state & Mod5Mask)
        mModifier |= (gMod5Mask & mPreModState);
 
-#if UIM_XIM_USE_JAPANESE_KANA_KEYBOARD_HACK
-    mKey = uim_x_kana_input_hack_translate_key(x->key_sym,
-                                              (KeyCode)x->ev.xkey.keycode);
-#endif
     if (x->key_sym < 128 && x->key_sym >= 32)
        mKey = x->key_sym;
     else if (x->key_sym >= XK_F1 && x->key_sym <= XK_F35)
@@ -1165,6 +1161,10 @@
            mKey = UKey_Other;
        }
     }
+#if UIM_XIM_USE_JAPANESE_KANA_KEYBOARD_HACK
+    mKey = uim_x_kana_input_hack_translate_key(mKey,
+                                              (KeyCode)x->ev.xkey.keycode);
+#endif
 }
 
 bool keyState::check_compose()

Reply via email to