-;;; kkc.el --- Kana Kanji converter
+;;; kkc.el --- Kana Kanji converter -*- coding: iso-2022-7bit; -*-
;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
;; Licensed to the Free Software Foundation.
-;; Keywords: mule, multilingual, Japanese, SKK
+;; Keywords: mule, multilingual, Japanese
;; This file is part of GNU Emacs.
;;; Code:
-(require 'skkdic-utl)
+(require 'ja-dic-utl)
(defvar kkc-input-method-title "\e$B4A\e(B"
"String denoting KKC input method.
"Save initial setup code for KKC to a file specified by `kkc-init-file-name'"
(if (and kkc-init-file-flag
(not (eq kkc-init-file-flag t)))
- (let ((coding-system-for-write 'iso-2022-7bit))
+ (let ((coding-system-for-write 'iso-2022-7bit)
+ (print-length nil))
(write-region (format "(setq kkc-lookup-cache '%S)\n" kkc-lookup-cache)
nil
kkc-init-file-name))))
;; Cursor type (`box' or `bar') of the current frame.
(defvar kkc-cursor-type nil)
-;; Lookup SKK dictionary to set list of conversions in
+;; Lookup Japanese dictionary to set list of conversions in
;; kkc-current-conversions for key sequence kkc-current-key of length
;; LEN. If no conversion is found in the dictionary, don't change
;; kkc-current-conversions and return nil.
-;; Postfixes are handled only if POSTFIX is non-nil.
+;; Postfixes are handled only if POSTFIX is non-nil.
(defun kkc-lookup-key (len &optional postfix prefer-noun)
;; At first, prepare cache data if any.
(unless kkc-init-file-flag
(defvar kkc-converting nil)
+;;;###autoload
+(defvar kkc-after-update-conversion-functions nil
+ "Functions to run after a conversion is selected in `japanese' input method.
+With this input method, a user can select a proper conversion from
+candidate list. Each time he changes the selection, functions in this
+list are called with two arguments; starting and ending buffer
+positions that contains the current selection.")
+
;;;###autoload
(defun kkc-region (from to)
"Convert Kana string in the current region to Kanji-Kana mixed string.
;; 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)
;; The currently selected conversion is after the list shown
;; previously. We start calculation of message width from
;; the conversion next of TO.
- (setq this-idx next-idx msg nil)
- ;; The current conversion is in MSG. Just clear brackets
- ;; around index number.
- (if (string-match "<.>" msg)
- (progn
- (aset msg (match-beginning 0) ?\ )
- (aset msg (1- (match-end 0)) ?\ )))))
+ (setq this-idx next-idx msg nil)))
(if (not msg)
(let ((len (length kkc-current-conversions))
(max-width (window-width (minibuffer-window)))
(setq l (nthcdr this-idx kkc-current-conversions))
(setq msg (format " %c %s"
(aref kkc-show-conversion-list-index-chars 0)
- (car l))
+ (propertize (car l)
+ 'kkc-conversion-index this-idx))
idx (1+ this-idx)
l (cdr l))
(while (< idx next-idx)
msg
(aref kkc-show-conversion-list-index-chars
(- idx this-idx))
- (car l)))
- (setq idx (1+ idx)
+ (propertize (car l)
+ 'kkc-conversion-index idx))
+ idx (1+ idx)
l (cdr l)))
(aset first-slot 2 msg)))
+
+ ;; Highlight the current conversion.
(if (> current-idx 0)
- (progn
- ;; Highlight the current conversion by brackets.
- (string-match (format " \\(%c\\) "
- (aref kkc-show-conversion-list-index-chars
- (- current-idx this-idx)))
- msg)
- (aset msg (match-beginning 0) ?<)
- (aset msg (1- (match-end 0)) ?>)))
- (message "%s" msg)))
+ (let ((pos 3)
+ (limit (length msg)))
+ (remove-text-properties 0 (length msg) '(face nil) msg)
+ (while (not (eq (get-text-property pos 'kkc-conversion-index msg)
+ current-idx))
+ (setq pos (next-single-property-change pos 'kkc-conversion-index
+ msg limit)))
+ (put-text-property pos (next-single-property-change
+ pos 'kkc-conversion-index msg limit)
+ 'face 'highlight msg)))
+ (let ((message-log-max nil))
+ (message "%s" msg))))
;; Update the conversion area with the latest conversion selected.
;; ALL if non nil means to update the whole area, else update only
(move-overlay kkc-overlay-head
(overlay-start kkc-overlay-head) pos)
(delete-region (point) (overlay-end kkc-overlay-tail)))))
- (goto-char (overlay-end kkc-overlay-tail)))
+ (unwind-protect
+ (run-hook-with-args 'kkc-after-update-conversion-functions
+ (overlay-start kkc-overlay-head)
+ (overlay-end kkc-overlay-head))
+ (goto-char (overlay-end kkc-overlay-tail))))
;;
(provide 'kkc)
-;; kkc.el ends here
+;;; arch-tag: 3cbfd56e-74e6-4f60-bb46-ba7c2d366fbf
+;;; kkc.el ends here