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