annotate lisp/international/kkc.el @ 23445:838c9bd2adcd

("latin-1-postfix"): Add a method to enter the small superscript underlined o and a. ("italian-postfix"): Same as above. ("italian-postfix"): Add methods to enter e with acute accent and the >> and << symbols.
author Richard M. Stallman <rms@gnu.org>
date Tue, 13 Oct 1998 15:40:56 +0000
parents 30beacf88b75
children ded7fa3de6db
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17315
a3ca5e15c82a Fix the format of the first line.
Kenichi Handa <handa@m17n.org>
parents: 17082
diff changeset
1 ;;; kkc.el --- Kana Kanji converter
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
18377
8b4a66c66dd6 Change copyright notice.
Richard M. Stallman <rms@gnu.org>
parents: 18198
diff changeset
4 ;; Licensed to the Free Software Foundation.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6 ;; Keywords: mule, multilingual, Japanese, SKK
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
7
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
9
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
13 ;; any later version.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
14
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
19
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
17071
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
23 ;; Boston, MA 02111-1307, USA.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
24
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
26
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
27 ;; These routines provide a simple and easy-to-use converter from
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
28 ;; Kana-string to Kana-Kanji-mixed-string. This converter (here after
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
29 ;; KKC) uses a SKK dictionary to get information how to convert
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
30 ;; Kana-string. Since KKC can't be fully automated, we need an
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
31 ;; interaction with a user to decide the correct conversion. For
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
32 ;; that, we provide KKC major mode.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
33
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
34 ;;; Code:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
35
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
36 (require 'skkdic-utl)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
37
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
38 (defvar kkc-input-method-title "漢"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
39 "String denoting KKC input method.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
40 This string is shown at mode line when users are in KKC mode.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
41
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
42 (defvar kkc-init-file-name "~/.kkcrc"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
43 "Name of a file which contains user's initial setup code for KKC.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
44
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
45 ;; A flag to control a file specified by `kkc-init-file-name'.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
46 ;; The value nil means the file is not yet consulted.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
47 ;; The value t means the file has already been consulted but there's
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
48 ;; no need of updating it yet.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
49 ;; Any other value means that we must update the file before exiting Emacs.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
50 (defvar kkc-init-file-flag nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
51
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
52 ;; Cash data for `kkc-lookup-key'. This may be initialized by loading
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
53 ;; a file specified by `kkc-init-file-name'. If any elements are
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
54 ;; modified, the data is written out to the file when exiting Emacs.
22888
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
55 (defvar kkc-lookup-cache nil)
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
56
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
57 ;; Tag symbol of `kkc-lookup-cache'.
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
58 (defconst kkc-lookup-cache-tag 'kkc-lookup-cache-2)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
59
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
60 (defun kkc-save-init-file ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
61 "Save initial setup code for KKC to a file specified by `kkc-init-file-name'"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
62 (if (and kkc-init-file-flag
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
63 (not (eq kkc-init-file-flag t)))
18198
8286b2dd4db6 (kkc-save-init-file): Coding system name changed from
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
64 (let ((coding-system-for-write 'iso-2022-7bit))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
65 (write-region (format "(setq kkc-lookup-cache '%S)\n" kkc-lookup-cache)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
66 nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
67 kkc-init-file-name))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
68
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
69 ;; Sequence of characters to be used for indexes for shown list. The
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
70 ;; Nth character is for the Nth conversion in the list currently shown.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
71 (defvar kkc-show-conversion-list-index-chars
22766
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
72 "1234567890")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
73
23032
d5a1574f7fb8 (kkc-help): New function.
Kenichi Handa <handa@m17n.org>
parents: 22919
diff changeset
74 (defun kkc-help ()
d5a1574f7fb8 (kkc-help): New function.
Kenichi Handa <handa@m17n.org>
parents: 22919
diff changeset
75 "Show key bindings available while converting by KKC."
d5a1574f7fb8 (kkc-help): New function.
Kenichi Handa <handa@m17n.org>
parents: 22919
diff changeset
76 (interactive)
d5a1574f7fb8 (kkc-help): New function.
Kenichi Handa <handa@m17n.org>
parents: 22919
diff changeset
77 (with-output-to-temp-buffer "*Help*"
d5a1574f7fb8 (kkc-help): New function.
Kenichi Handa <handa@m17n.org>
parents: 22919
diff changeset
78 (princ (substitute-command-keys "\\{kkc-keymap}"))))
d5a1574f7fb8 (kkc-help): New function.
Kenichi Handa <handa@m17n.org>
parents: 22919
diff changeset
79
22766
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
80 (defvar kkc-keymap
23032
d5a1574f7fb8 (kkc-help): New function.
Kenichi Handa <handa@m17n.org>
parents: 22919
diff changeset
81 (let ((map (make-sparse-keymap))
22766
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
82 (len (length kkc-show-conversion-list-index-chars))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
83 (i 0))
22766
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
84 (while (< i len)
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
85 (define-key map
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
86 (char-to-string (aref kkc-show-conversion-list-index-chars i))
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
87 'kkc-select-from-list)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
88 (setq i (1+ i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
89 (define-key map " " 'kkc-next)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
90 (define-key map "\r" 'kkc-terminate)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
91 (define-key map "\C-@" 'kkc-first-char-only)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
92 (define-key map "\C-n" 'kkc-next)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
93 (define-key map "\C-p" 'kkc-prev)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
94 (define-key map "\C-i" 'kkc-shorter)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
95 (define-key map "\C-o" 'kkc-longer)
22888
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
96 (define-key map "I" 'kkc-shorter-conversion)
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
97 (define-key map "O" 'kkc-longer-phrase)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
98 (define-key map "\C-c" 'kkc-cancel)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
99 (define-key map "\C-?" 'kkc-cancel)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
100 (define-key map "\C-f" 'kkc-next-phrase)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
101 (define-key map "K" 'kkc-katakana)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
102 (define-key map "H" 'kkc-hiragana)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
103 (define-key map "l" 'kkc-show-conversion-list-or-next-group)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
104 (define-key map "L" 'kkc-show-conversion-list-or-prev-group)
20638
c3360a392ae4 Change "?\C-\ " to "?\C- " because "\ " is changed
Kenichi Handa <handa@m17n.org>
parents: 19931
diff changeset
105 (define-key map [?\C- ] 'kkc-first-char-only)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
106 (define-key map [delete] 'kkc-cancel)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
107 (define-key map [return] 'kkc-terminate)
23032
d5a1574f7fb8 (kkc-help): New function.
Kenichi Handa <handa@m17n.org>
parents: 22919
diff changeset
108 (define-key map "\C-h" 'kkc-help)
19869
3c4025f3be8f (kkc-mode-map): Bind meta-prefix-char to a
Kenichi Handa <handa@m17n.org>
parents: 19406
diff changeset
109 map)
22766
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
110 "Keymap for KKC (Kana Kanji Converter).")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
111
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
112 ;;; Internal variables used in KKC.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
113
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
114 ;; The current Kana string to be converted.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
115 (defvar kkc-original-kana nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
116
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
117 ;; The current key sequence (vector of Kana characters) generated from
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
118 ;; `kkc-original-kana'.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
119 (defvar kkc-current-key nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
120
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
121 ;; List of the current conversions for `kkc-current-key'.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
122 (defvar kkc-current-conversions nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
123
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
124 ;; Vector of the same length as `kkc-current-conversion'. The first
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
125 ;; element is a vector of:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
126 ;; o index number of the first conversion shown previously,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
127 ;; o index number of a conversion next of the last one shown previously,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
128 ;; o the shown string itself.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
129 ;; The remaining elements are widths (including columns for index
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
130 ;; numbers) of conversions stored in the same order as in
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
131 ;; `kkc-current-conversion'.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
132 (defvar kkc-current-conversions-width nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
133
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
134 (defvar kkc-show-conversion-list-count 4
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
135 "Count of successive `kkc-next' or `kkc-prev' to show conversion list.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
136
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
137 ;; Provided that `kkc-current-key' is [A B C D E F G H I], the current
22766
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
138 ;; conversion target is [A B C D E F], and the sequence of which
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
139 ;; conversion is found is [A B C D]:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
140 ;;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
141 ;; A B C D E F G H I
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
142 ;; kkc-overlay-head (black): |<--------->|
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
143 ;; kkc-overlay-tail (underline): |<------->|
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
144 ;; kkc-length-head: |<--------->|
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
145 ;; kkc-length-converted: |<----->|
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
146 ;;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
147 (defvar kkc-overlay-head nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
148 (defvar kkc-overlay-tail nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
149 (defvar kkc-length-head nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
150 (defvar kkc-length-converted nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
151
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
152 ;; Cursor type (`box' or `bar') of the current frame.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
153 (defvar kkc-cursor-type nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
154
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
155 ;; Lookup SKK dictionary to set list of conversions in
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
156 ;; kkc-current-conversions for key sequence kkc-current-key of length
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
157 ;; LEN. If no conversion is found in the dictionary, don't change
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
158 ;; kkc-current-conversions and return nil.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
159 ;; Postfixes are handled only if POSTFIX is non-nil.
18644
69c91eee7ba1 (kkc-region): Call skkdic-lookup-key with
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
160 (defun kkc-lookup-key (len &optional postfix prefer-noun)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
161 ;; At first, prepare cache data if any.
22888
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
162 (unless kkc-init-file-flag
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
163 (setq kkc-init-file-flag t
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
164 kkc-lookup-cache nil)
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
165 (add-hook 'kill-emacs-hook 'kkc-save-init-file)
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
166 (if (file-readable-p kkc-init-file-name)
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
167 (condition-case nil
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
168 (load-file kkc-init-file-name)
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
169 (kkc-error "Invalid data in %s" kkc-init-file-name))))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
170 (or (and (nested-alist-p kkc-lookup-cache)
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
171 (eq (car kkc-lookup-cache) kkc-lookup-cache-tag))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
172 (setq kkc-lookup-cache (list kkc-lookup-cache-tag)
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
173 kkc-init-file-flag 'kkc-lookup-cache))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
174 (let ((entry (lookup-nested-alist kkc-current-key kkc-lookup-cache len 0 t)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
175 (if (consp (car entry))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
176 (setq kkc-length-converted len
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
177 kkc-current-conversions-width nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
178 kkc-current-conversions (car entry))
18644
69c91eee7ba1 (kkc-region): Call skkdic-lookup-key with
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
179 (setq entry (skkdic-lookup-key kkc-current-key len postfix prefer-noun))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
180 (if entry
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
181 (progn
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
182 (setq kkc-length-converted len
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
183 kkc-current-conversions-width nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
184 kkc-current-conversions (cons 1 entry))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
185 (if postfix
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
186 ;; Store this conversions in the cache.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
187 (progn
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
188 (set-nested-alist kkc-current-key kkc-current-conversions
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
189 kkc-lookup-cache kkc-length-converted)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
190 (setq kkc-init-file-flag 'kkc-lookup-cache)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
191 t)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
192 (if (= len 1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
193 (setq kkc-length-converted 1
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
194 kkc-current-conversions-width nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
195 kkc-current-conversions (cons 0 nil)))))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
196
22888
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
197 (put 'kkc-error 'error-conditions '(kkc-error error))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
198 (defun kkc-error (&rest args)
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
199 (signal 'kkc-error (apply 'format args)))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
200
22766
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
201 (defvar kkc-converting nil)
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
202
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
203 ;;;###autoload
22766
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
204 (defun kkc-region (from to)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
205 "Convert Kana string in the current region to Kanji-Kana mixed string.
22766
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
206 Users can select a desirable conversion interactively.
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
207 When called from a program, expects two arguments,
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
208 positions FROM and TO (integers or markers) specifying the target region.
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
209 When it returns, the point is at the tail of the selected conversion,
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
210 and the return value is the length of the conversion."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
211 (interactive "r")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
212 (setq kkc-original-kana (buffer-substring from to))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
213 (goto-char from)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
214
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
215 ;; Setup overlays.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
216 (if (overlayp kkc-overlay-head)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
217 (move-overlay kkc-overlay-head from to)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
218 (setq kkc-overlay-head (make-overlay from to nil nil t))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
219 (overlay-put kkc-overlay-head 'face 'highlight))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
220 (if (overlayp kkc-overlay-tail)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
221 (move-overlay kkc-overlay-tail to to)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
222 (setq kkc-overlay-tail (make-overlay to to nil nil t))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
223 (overlay-put kkc-overlay-tail 'face 'underline))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
224
22766
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
225 (setq kkc-current-key (string-to-vector kkc-original-kana))
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
226 (setq kkc-length-head (length kkc-current-key))
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
227 (setq kkc-length-converted 0)
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
228
22888
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
229 (unwind-protect
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
230 ;; At first convert the region to the first candidate.
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
231 (let ((current-input-method-title kkc-input-method-title)
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
232 (input-method-function nil)
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
233 (first t))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
234 (while (not (kkc-lookup-key kkc-length-head nil first))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
235 (setq kkc-length-head (1- kkc-length-head)
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
236 first nil))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
237 (goto-char to)
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
238 (kkc-update-conversion 'all)
22766
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
239
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23032
diff changeset
240 ;; Then, ask users to select a desirable conversion.
22816
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
241 (force-mode-line-update)
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
242 (setq kkc-converting t)
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
243 (while kkc-converting
22919
95d147bbdce0 (kkc-region): Don't bind echo-keystrokes.
Kenichi Handa <handa@m17n.org>
parents: 22888
diff changeset
244 (let* ((overriding-terminal-local-map kkc-keymap)
23032
d5a1574f7fb8 (kkc-help): New function.
Kenichi Handa <handa@m17n.org>
parents: 22919
diff changeset
245 (help-char nil)
22816
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
246 (keyseq (read-key-sequence nil))
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
247 (cmd (lookup-key kkc-keymap keyseq)))
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
248 (if (commandp cmd)
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
249 (condition-case err
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
250 (call-interactively cmd)
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
251 (kkc-error (message "%s" (cdr err)) (beep)))
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
252 ;; KEYSEQ is not defined in KKC keymap.
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
253 ;; Let's put the event back.
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
254 (setq unread-input-method-events
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
255 (append (string-to-list keyseq)
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
256 unread-input-method-events))
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
257 (kkc-terminate))))
22766
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
258
22816
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
259 (force-mode-line-update)
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
260 (goto-char (overlay-end kkc-overlay-tail))
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
261 (- (overlay-start kkc-overlay-head) from))
22766
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
262 (delete-overlay kkc-overlay-head)
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
263 (delete-overlay kkc-overlay-tail)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
264
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
265 (defun kkc-terminate ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
266 "Exit from KKC mode by fixing the current conversion."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
267 (interactive)
22794
9ace35333789 (kkc-region): Handled the case that
Kenichi Handa <handa@m17n.org>
parents: 22779
diff changeset
268 (goto-char (overlay-end kkc-overlay-tail))
9ace35333789 (kkc-region): Handled the case that
Kenichi Handa <handa@m17n.org>
parents: 22779
diff changeset
269 (move-overlay kkc-overlay-head (point) (point))
22766
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
270 (setq kkc-converting nil))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
271
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
272 (defun kkc-cancel ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
273 "Exit from KKC mode by canceling any conversions."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
274 (interactive)
22766
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
275 (goto-char (overlay-start kkc-overlay-head))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
276 (delete-region (overlay-start kkc-overlay-head)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
277 (overlay-end kkc-overlay-tail))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
278 (insert kkc-original-kana)
22794
9ace35333789 (kkc-region): Handled the case that
Kenichi Handa <handa@m17n.org>
parents: 22779
diff changeset
279 (setq kkc-converting nil))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
280
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
281 (defun kkc-first-char-only ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
282 "Select only the first character currently converted."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
283 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
284 (goto-char (overlay-start kkc-overlay-head))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
285 (forward-char 1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
286 (delete-region (point) (overlay-end kkc-overlay-tail))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
287 (kkc-terminate))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
288
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
289 ;; Count of successive invocations of `kkc-next'.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
290 (defvar kkc-next-count nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
291
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
292 (defun kkc-next ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
293 "Select the next candidate of conversion."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
294 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
295 (if (eq this-command last-command)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
296 (setq kkc-next-count (1+ kkc-next-count))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
297 (setq kkc-next-count 1))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
298 (let ((idx (1+ (car kkc-current-conversions))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
299 (if (< idx 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
300 (setq idx 1))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
301 (if (>= idx (length kkc-current-conversions))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
302 (setq idx 0))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
303 (setcar kkc-current-conversions idx)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
304 (if (> idx 1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
305 (progn
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
306 (set-nested-alist kkc-current-key kkc-current-conversions
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
307 kkc-lookup-cache kkc-length-converted)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
308 (setq kkc-init-file-flag 'kkc-lookup-cache)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
309 (if (or kkc-current-conversions-width
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
310 (>= kkc-next-count kkc-show-conversion-list-count))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
311 (kkc-show-conversion-list-update))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
312 (kkc-update-conversion)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
313
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
314 ;; Count of successive invocations of `kkc-next'.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
315 (defvar kkc-prev-count nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
316
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
317 (defun kkc-prev ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
318 "Select the previous candidate of conversion."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
319 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
320 (if (eq this-command last-command)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
321 (setq kkc-prev-count (1+ kkc-prev-count))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
322 (setq kkc-prev-count 1))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
323 (let ((idx (1- (car kkc-current-conversions))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
324 (if (< idx 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
325 (setq idx (1- (length kkc-current-conversions))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
326 (setcar kkc-current-conversions idx)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
327 (if (> idx 1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
328 (progn
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
329 (set-nested-alist kkc-current-key kkc-current-conversions
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
330 kkc-lookup-cache kkc-length-converted)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
331 (setq kkc-init-file-flag 'kkc-lookup-cache)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
332 (if (or kkc-current-conversions-width
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
333 (>= kkc-prev-count kkc-show-conversion-list-count))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
334 (kkc-show-conversion-list-update))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
335 (kkc-update-conversion)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
336
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
337 (defun kkc-select-from-list ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
338 "Select one candidate from the list currently shown in echo area."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
339 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
340 (let (idx)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
341 (if kkc-current-conversions-width
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
342 (let ((len (length kkc-show-conversion-list-index-chars))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
343 (maxlen (- (aref (aref kkc-current-conversions-width 0) 1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
344 (aref (aref kkc-current-conversions-width 0) 0)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
345 (i 0))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
346 (if (> len maxlen)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
347 (setq len maxlen))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
348 (while (< i len)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
349 (if (= (aref kkc-show-conversion-list-index-chars i)
22766
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
350 last-input-event)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
351 (setq idx i i len)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
352 (setq i (1+ i))))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
353 (if idx
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
354 (progn
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
355 (setcar kkc-current-conversions
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
356 (+ (aref (aref kkc-current-conversions-width 0) 0) idx))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
357 (kkc-show-conversion-list-update)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
358 (kkc-update-conversion))
22766
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
359 (setq unread-input-method-events
a83818674920 (kkc-show-conversion-list-index-chars):
Kenichi Handa <handa@m17n.org>
parents: 20638
diff changeset
360 (cons last-input-event unread-input-method-events))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
361 (kkc-terminate))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
362
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
363 (defun kkc-katakana ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
364 "Convert to Katakana."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
365 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
366 (setcar kkc-current-conversions -1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
367 (kkc-update-conversion 'all))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
368
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
369 (defun kkc-hiragana ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
370 "Convert to hiragana."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
371 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
372 (setcar kkc-current-conversions 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
373 (kkc-update-conversion))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
374
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
375 (defun kkc-shorter ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
376 "Make the Kana string to be converted shorter."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
377 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
378 (if (<= kkc-length-head 1)
22888
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
379 (kkc-error "Can't be shorter"))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
380 (setq kkc-length-head (1- kkc-length-head))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
381 (if (> kkc-length-converted kkc-length-head)
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
382 (let ((len kkc-length-head))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
383 (setq kkc-length-converted 0)
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
384 (while (not (kkc-lookup-key len))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
385 (setq len (1- len)))))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
386 (kkc-update-conversion 'all))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
387
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
388 (defun kkc-longer ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
389 "Make the Kana string to be converted longer."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
390 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
391 (if (>= kkc-length-head (length kkc-current-key))
22888
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
392 (kkc-error "Can't be longer"))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
393 (setq kkc-length-head (1+ kkc-length-head))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
394 ;; This time, try also entries with postfixes.
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
395 (kkc-lookup-key kkc-length-head 'postfix)
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
396 (kkc-update-conversion 'all))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
397
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
398 (defun kkc-shorter-conversion ()
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
399 "Make the Kana string to be converted shorter."
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
400 (interactive)
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
401 (if (<= kkc-length-converted 1)
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
402 (kkc-error "Can't be shorter"))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
403 (let ((len (1- kkc-length-converted)))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
404 (setq kkc-length-converted 0)
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
405 (while (not (kkc-lookup-key len))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
406 (setq len (1- len))))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
407 (kkc-update-conversion 'all))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
408
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
409 (defun kkc-longer-phrase ()
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
410 "Make the current phrase (BUNSETSU) longer without looking up dictionary."
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
411 (interactive)
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
412 (if (>= kkc-length-head (length kkc-current-key))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
413 (kkc-error "Can't be longer"))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
414 (setq kkc-length-head (1+ kkc-length-head))
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
415 (kkc-update-conversion 'all))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
416
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
417 (defun kkc-next-phrase ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
418 "Fix the currently converted string and try to convert the remaining string."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
419 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
420 (if (>= kkc-length-head (length kkc-current-key))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
421 (kkc-terminate)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
422 (setq kkc-length-head (- (length kkc-current-key) kkc-length-head))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
423 (goto-char (overlay-end kkc-overlay-head))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
424 (while (and (< (point) (overlay-end kkc-overlay-tail))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
425 (looking-at "\\CH"))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
426 (goto-char (match-end 0))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
427 (setq kkc-length-head (1- kkc-length-head)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
428 (if (= kkc-length-head 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
429 (kkc-terminate)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
430 (let ((newkey (make-vector kkc-length-head 0))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
431 (idx (- (length kkc-current-key) kkc-length-head))
18644
69c91eee7ba1 (kkc-region): Call skkdic-lookup-key with
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
432 (len kkc-length-head)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
433 (i 0))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
434 ;; For the moment, (setq kkc-original-kana (concat newkey))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
435 ;; doesn't work.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
436 (setq kkc-original-kana "")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
437 (while (< i kkc-length-head)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
438 (aset newkey i (aref kkc-current-key (+ idx i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
439 (setq kkc-original-kana
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
440 (concat kkc-original-kana (char-to-string (aref newkey i))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
441 (setq i (1+ i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
442 (setq kkc-current-key newkey)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
443 (setq kkc-length-converted 0)
18644
69c91eee7ba1 (kkc-region): Call skkdic-lookup-key with
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
444 (while (and (not (kkc-lookup-key kkc-length-head nil
69c91eee7ba1 (kkc-region): Call skkdic-lookup-key with
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
445 (< kkc-length-head len)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
446 (> kkc-length-head 1))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
447 (setq kkc-length-head (1- kkc-length-head)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
448 (let ((pos (point))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
449 (tail (overlay-end kkc-overlay-tail)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
450 (move-overlay kkc-overlay-head pos tail)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
451 (move-overlay kkc-overlay-tail tail tail))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
452 (kkc-update-conversion 'all)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
453
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
454 ;; We'll show users a list of available conversions in echo area with
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
455 ;; index numbers so that users can select one conversion with the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
456 ;; number.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
457
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
458 ;; Set `kkc-current-conversions-width'.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
459 (defun kkc-setup-current-conversions-width ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
460 (let ((convs (cdr kkc-current-conversions))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
461 (len (length kkc-current-conversions))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
462 (idx 1))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
463 (setq kkc-current-conversions-width (make-vector len nil))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
464 ;; To tell `kkc-show-conversion-list-update' to generate
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
465 ;; message from scratch.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
466 (aset kkc-current-conversions-width 0 (vector len -2 nil))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
467 ;; Fill the remaining slots.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
468 (while convs
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
469 (aset kkc-current-conversions-width idx
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
470 (+ (string-width (car convs)) 4))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
471 (setq convs (cdr convs)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
472 idx (1+ idx)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
473
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
474 (defun kkc-show-conversion-list-or-next-group ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
475 "Show list of available conversions in echo area with index numbers.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
476 If the list is already shown, show the next group of conversions,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
477 and change the current conversion to the first one in the group."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
478 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
479 (if (< (length kkc-current-conversions) 3)
22888
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
480 (kkc-error "No alternative"))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
481 (if kkc-current-conversions-width
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
482 (let ((next-idx (aref (aref kkc-current-conversions-width 0) 1)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
483 (if (< next-idx (length kkc-current-conversions-width))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
484 (setcar kkc-current-conversions next-idx)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
485 (setcar kkc-current-conversions 1))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
486 (kkc-show-conversion-list-update)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
487 (kkc-update-conversion))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
488 (kkc-setup-current-conversions-width)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
489 (kkc-show-conversion-list-update)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
490
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
491 (defun kkc-show-conversion-list-or-prev-group ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
492 "Show list of available conversions in echo area with index numbers.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
493 If the list is already shown, show the previous group of conversions,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
494 and change the current conversion to the last one in the group."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
495 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
496 (if (< (length kkc-current-conversions) 3)
22888
5bfe86125303 (kkc-lookup-cache): Initialize it to nil.
Kenichi Handa <handa@m17n.org>
parents: 22816
diff changeset
497 (kkc-error "No alternative"))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
498 (if kkc-current-conversions-width
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
499 (let ((this-idx (aref (aref kkc-current-conversions-width 0) 0)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
500 (if (> this-idx 1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
501 (setcar kkc-current-conversions (1- this-idx))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
502 (setcar kkc-current-conversions
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
503 (1- (length kkc-current-conversions-width))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
504 (kkc-show-conversion-list-update)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
505 (kkc-update-conversion))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
506 (kkc-setup-current-conversions-width)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
507 (kkc-show-conversion-list-update)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
508
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
509 ;; Update the conversion list shown in echo area.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
510 (defun kkc-show-conversion-list-update ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
511 (or kkc-current-conversions-width
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
512 (kkc-setup-current-conversions-width))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
513 (let* ((current-idx (car kkc-current-conversions))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
514 (first-slot (aref kkc-current-conversions-width 0))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
515 (this-idx (aref first-slot 0))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
516 (next-idx (aref first-slot 1))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
517 (msg (aref first-slot 2)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
518 (if (< current-idx this-idx)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
519 ;; The currently selected conversion is before the list shown
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
520 ;; previously. We must start calculation of message width
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
521 ;; from the start again.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
522 (setq this-idx 1 msg nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
523 (if (>= current-idx next-idx)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
524 ;; The currently selected conversion is after the list shown
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
525 ;; previously. We start calculation of message width from
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
526 ;; the conversion next of TO.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
527 (setq this-idx next-idx msg nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
528 ;; The current conversion is in MSG. Just clear brackets
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
529 ;; around index number.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
530 (if (string-match "<.>" msg)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
531 (progn
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
532 (aset msg (match-beginning 0) ?\ )
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
533 (aset msg (1- (match-end 0)) ?\ )))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
534 (if (not msg)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
535 (let ((len (length kkc-current-conversions))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
536 (max-width (window-width (minibuffer-window)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
537 (width-table kkc-current-conversions-width)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
538 (width 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
539 (idx this-idx)
22816
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
540 (max-items (length kkc-show-conversion-list-index-chars))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
541 l)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
542 (while (< idx current-idx)
22816
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
543 (if (and (<= (+ width (aref width-table idx)) max-width)
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
544 (< (- idx this-idx) max-items))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
545 (setq width (+ width (aref width-table idx)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
546 (setq this-idx idx width (aref width-table idx)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
547 (setq idx (1+ idx)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
548 l (cdr l)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
549 (aset first-slot 0 this-idx)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
550 (while (and (< idx len)
22816
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
551 (<= (+ width (aref width-table idx)) max-width)
8f9d4edebbdd (kkc-region): Unwind-protect the conversion
Kenichi Handa <handa@m17n.org>
parents: 22794
diff changeset
552 (< (- idx this-idx) max-items))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
553 (setq width (+ width (aref width-table idx))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
554 idx (1+ idx)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
555 l (cdr l)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
556 (aset first-slot 1 (setq next-idx idx))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
557 (setq l (nthcdr this-idx kkc-current-conversions))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
558 (setq msg "")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
559 (setq idx this-idx)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
560 (while (< idx next-idx)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
561 (setq msg (format "%s %c %s "
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
562 msg
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
563 (aref kkc-show-conversion-list-index-chars
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
564 (- idx this-idx))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
565 (car l)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
566 (setq idx (1+ idx)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
567 l (cdr l)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
568 (aset first-slot 2 msg)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
569 (if (> current-idx 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
570 (progn
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
571 ;; Highlight the current conversion by brackets.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
572 (string-match (format " \\(%c\\) "
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
573 (aref kkc-show-conversion-list-index-chars
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
574 (- current-idx this-idx)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
575 msg)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
576 (aset msg (match-beginning 0) ?<)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
577 (aset msg (1- (match-end 0)) ?>)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
578 (message "%s" msg)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
579
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
580 ;; Update the conversion area with the latest conversion selected.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
581 ;; ALL if non nil means to update the whole area, else update only
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
582 ;; inside quail-overlay-head.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
583
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
584 (defun kkc-update-conversion (&optional all)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
585 (goto-char (overlay-start kkc-overlay-head))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
586 (cond ((= (car kkc-current-conversions) 0) ; Hiragana
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
587 (let ((i 0))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
588 (while (< i kkc-length-converted)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
589 (insert (aref kkc-current-key i))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
590 (setq i (1+ i)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
591 ((= (car kkc-current-conversions) -1) ; Katakana
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
592 (let ((i 0))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
593 (while (< i kkc-length-converted)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
594 (insert (japanese-katakana (aref kkc-current-key i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
595 (setq i (1+ i)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
596 (t
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
597 (insert (nth (car kkc-current-conversions) kkc-current-conversions))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
598 (delete-region (point) (overlay-start kkc-overlay-tail))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
599 (if all
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
600 (let ((len (length kkc-current-key))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
601 (i kkc-length-converted))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
602 (delete-region (overlay-start kkc-overlay-tail)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
603 (overlay-end kkc-overlay-head))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
604 (while (< i kkc-length-head)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
605 (if (= (car kkc-current-conversions) -1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
606 (insert (japanese-katakana (aref kkc-current-key i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
607 (insert (aref kkc-current-key i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
608 (setq i (1+ i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
609 (let ((pos (point)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
610 (while (< i len)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
611 (insert (aref kkc-current-key i))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
612 (setq i (1+ i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
613 (move-overlay kkc-overlay-head
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
614 (overlay-start kkc-overlay-head) pos)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
615 (delete-region (point) (overlay-end kkc-overlay-tail)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
616 (goto-char (overlay-end kkc-overlay-tail)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
617
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
618 ;;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
619 (provide 'kkc)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
620
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
621 ;; kkc.el ends here