- ;; After updating the conversion region with the first candidate of
- ;; conversion, jump into a recursive editing environment with KKC
- ;; mode.
- (let ((overriding-local-map nil)
- (previous-local-map (current-local-map))
- (minor-mode-alist nil)
- (minor-mode-map-alist nil)
- (current-input-method-title kkc-input-method-title)
- major-mode mode-name)
- (unwind-protect
- (let (len)
- (setq kkc-canceled nil)
- (setq kkc-current-key (string-to-vector kkc-original-kana))
- (setq kkc-length-head (length kkc-current-key))
- (setq len kkc-length-head)
- (setq kkc-length-converted 0)
- (while (not (kkc-lookup-key kkc-length-head nil
- (< kkc-length-head len)))
- (setq kkc-length-head (1- kkc-length-head)))
- (goto-char to)
- (kkc-update-conversion 'all)
- (kkc-mode)
- (recursive-edit))
- (goto-char (overlay-end kkc-overlay-tail))
- (delete-overlay kkc-overlay-head)
- (delete-overlay kkc-overlay-tail)
- (use-local-map previous-local-map)
- (if (and kkc-mode-exit-function
- (fboundp kkc-mode-exit-function))
- (funcall kkc-mode-exit-function (if kkc-canceled
- (cons kkc-canceled (point))))))))
+ (setq kkc-current-key (string-to-vector kkc-original-kana))
+ (setq kkc-length-head (length kkc-current-key))
+ (setq kkc-length-converted 0)
+
+ (unwind-protect
+ ;; At first convert the region to the first candidate.
+ (let ((current-input-method-title kkc-input-method-title)
+ (input-method-function nil)
+ (modified-p (buffer-modified-p))
+ (first t))
+ (while (not (kkc-lookup-key kkc-length-head nil first))
+ (setq kkc-length-head (1- kkc-length-head)
+ first nil))
+ (goto-char to)
+ (kkc-update-conversion 'all)
+ (setq kkc-next-count 1 kkc-prev-count 0)
+ (if (and (>= kkc-next-count kkc-show-conversion-list-count)
+ (>= (length kkc-current-conversions) 3))
+ (kkc-show-conversion-list-or-next-group))
+
+ ;; Then, ask users to select a desirable conversion.
+ (force-mode-line-update)
+ (setq kkc-converting t)
+ ;; Hide "... loaded" message.
+ (message nil)
+ (while kkc-converting
+ (set-buffer-modified-p modified-p)
+ (let* ((overriding-terminal-local-map kkc-keymap)
+ (help-char nil)
+ (keyseq (read-key-sequence nil))
+ (cmd (lookup-key kkc-keymap keyseq)))
+ (if (commandp cmd)
+ (condition-case err
+ (progn
+ (cond ((eq cmd 'kkc-next)
+ (setq kkc-next-count (1+ kkc-next-count)
+ kkc-prev-count 0))
+ ((eq cmd 'kkc-prev)
+ (setq kkc-prev-count (1+ kkc-prev-count)
+ kkc-next-count 0))
+ (t
+ (setq kkc-next-count 0 kkc-prev-count 0)))
+ (call-interactively cmd))
+ (kkc-error (message "%s" (cdr err)) (beep)))
+ ;; KEYSEQ is not defined in KKC keymap.
+ ;; Let's put the event back.
+ (setq unread-input-method-events
+ (append (string-to-list keyseq)
+ unread-input-method-events))
+ (kkc-terminate))))
+
+ (force-mode-line-update)
+ (goto-char (overlay-end kkc-overlay-tail))
+ (- (overlay-start kkc-overlay-head) from))
+ (delete-overlay kkc-overlay-head)
+ (delete-overlay kkc-overlay-tail)))