Function: kkc-region
kkc-region is an autoloaded, interactive and byte-compiled function
defined in kkc.el.gz.
Signature
(kkc-region FROM TO)
Documentation
Convert Kana string in the current region to Kanji-Kana mixed string.
Users can select a desirable conversion interactively. When called from a program, expects two arguments, positions FROM and TO (integers or markers) specifying the target region. When it returns, the point is at the tail of the selected conversion, and the return value is the length of the conversion.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/international/kkc.el.gz
;;;###autoload
(defun kkc-region (from to)
"Convert Kana string in the current region to Kanji-Kana mixed string.
Users can select a desirable conversion interactively.
When called from a program, expects two arguments,
positions FROM and TO (integers or markers) specifying the target region.
When it returns, the point is at the tail of the selected conversion,
and the return value is the length of the conversion."
(interactive "r")
(setq kkc-original-kana (buffer-substring from to))
(goto-char from)
;; Setup overlays.
(if (overlayp kkc-overlay-head)
(move-overlay kkc-overlay-head from to)
(setq kkc-overlay-head (make-overlay from to nil nil t))
(overlay-put kkc-overlay-head 'face 'highlight))
(if (overlayp kkc-overlay-tail)
(move-overlay kkc-overlay-tail to to)
(setq kkc-overlay-tail (make-overlay to to nil nil t))
(overlay-put kkc-overlay-tail 'face 'underline))
(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 (this-single-command-raw-keys))
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)))