70
|
1 ;;; canna.el --- Interface to the Canna input method.
|
|
2
|
120
|
3 ;; Copyright (C) 1994 Akira Kon, NEC Corporation.
|
|
4 ;; Copyright (C) 1996,1997 MORIOKA Tomohiko
|
|
5
|
|
6 ;; Author: Akira Kon <kon@d1.bs2.mt.nec.co.jp>
|
|
7 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
|
138
|
8 ;; Version: $Revision: 1.6 $
|
120
|
9 ;; Keywords: Canna, Japanese, input method, mule, multilingual
|
70
|
10
|
120
|
11 ;; This file is not a part of Emacs yet.
|
70
|
12
|
120
|
13 ;; This program is free software; you can redistribute it and/or
|
|
14 ;; modify it under the terms of the GNU General Public License as
|
|
15 ;; published by the Free Software Foundation; either version 2, or (at
|
|
16 ;; your option) any later version.
|
|
17
|
|
18 ;; This program is distributed in the hope that it will be useful, but
|
70
|
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
21 ;; General Public License for more details.
|
|
22
|
|
23 ;; You should have received a copy of the GNU General Public License
|
120
|
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
70
|
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
26 ;; Boston, MA 02111-1307, USA.
|
|
27
|
120
|
28 ;;; Commentary:
|
118
|
29
|
120
|
30 ;; Egg offered some influences to the implementation of Canna on
|
|
31 ;; Nemacs/Mule, and this file contains a few part of Egg which is
|
|
32 ;; written by S.Tomura, Electrotechnical Lab. (tomura@etl.go.jp)
|
116
|
33
|
120
|
34 ;; This program is rewritten for Emacs/mule and XEmacs/mule by MORIOKA
|
|
35 ;; Tomohiko.
|
70
|
36
|
120
|
37 ;;; Code:
|
70
|
38
|
|
39 ;; -*-mode: emacs-lisp-*-
|
|
40
|
120
|
41 ;; by $B<i2,(B $BCNI'(B <morioka@jaist.ac.jp> 1996/11/11
|
|
42 (or (boundp 'CANNA)
|
|
43 (let ((handle (dynamic-link (expand-file-name "canna.so" exec-directory))))
|
|
44 (dynamic-call "emacs_canna_init" handle))
|
|
45 )
|
|
46
|
|
47 (defvar self-insert-after-hook nil)
|
|
48 ;; (defalias 'self-insert-internal 'self-insert-command)
|
|
49 ;; end
|
|
50
|
|
51 (defconst canna-rcs-version
|
138
|
52 "$Id: canna.el,v 1.6 1997/04/27 19:30:30 steve Exp $")
|
70
|
53
|
|
54 (defun canna-version ()
|
120
|
55 "Display version of canna.el in mini-buffer."
|
70
|
56 (interactive)
|
120
|
57 (message (concat
|
|
58 (substring canna-rcs-version
|
|
59 5
|
|
60 (if (string-match "[0-9] [a-z]" canna-rcs-version)
|
|
61 (1+ (match-beginning 0))
|
|
62 ))
|
|
63 " ...")))
|
|
64
|
|
65 (require 'emu)
|
|
66
|
|
67 (if running-xemacs
|
|
68 (defun canna-self-insert-string (string)
|
|
69 (let ((len (length string))
|
|
70 (i 0)
|
|
71 ;; $BA^F~$NESCf$G(B blink $B$,5/$-$k$H$&$C$H$*$7$$$N$G!"(B
|
|
72 ;; $B0l;~E*$K(B blink $B$rM^;_$9$k!#(B
|
|
73 (blink-matching-paren nil))
|
|
74 (while (< i len)
|
|
75 (self-insert-internal (aref canna-kakutei-string i))
|
|
76 (setq i (1+ i))
|
|
77 )))
|
|
78 (defalias 'canna-self-insert-string 'insert)
|
|
79 )
|
|
80
|
70
|
81
|
|
82 ;;; $B$+$s$J$NJQ?t(B
|
|
83
|
|
84 (defvar canna-save-undo-text-predicate nil)
|
|
85 (defvar canna-undo-hook nil)
|
|
86
|
|
87 (defvar canna-do-keybind-for-functionkeys t)
|
|
88 (defvar canna-use-functional-numbers nil)
|
|
89 (defvar canna-use-space-key-as-henkan-region t)
|
|
90
|
|
91 (defvar canna-server nil)
|
|
92 (defvar canna-file nil)
|
|
93
|
|
94 (defvar canna-underline nil)
|
|
95 (defvar canna-with-fences (not canna-underline))
|
|
96
|
|
97 (defvar canna-initialize-minibuffer-state-when-exit nil
|
|
98 "*Non-nil $B$N$H$-$O(B, $B%_%K%P%C%U%!$rH4$1$k;~F|K\8l>uBV$r=i4|2=$9$k(B.")
|
|
99
|
|
100 (defvar canna-inhibit-hankakukana nil
|
|
101 "*Non-nil $B$N;~!";z<oJQ49$GH>3Q$+$J$KJQ49$7$J$$(B")
|
|
102
|
|
103 ;;;
|
|
104 ;;; $B%b!<%I%i%$%s$N=$@0(B
|
|
105 ;;;
|
|
106
|
|
107 (defvar canna:*kanji-mode-string* "[ $B$"(B ]")
|
|
108 (defvar canna:*alpha-mode-string* "$B$+$s$J(B")
|
|
109 (defvar canna:*saved-mode-string* "[ $B$"(B ]")
|
|
110
|
|
111 (defvar mode-line-canna-mode canna:*alpha-mode-string*)
|
|
112 (defvar mode-line-canna-mode-in-minibuffer canna:*alpha-mode-string*)
|
|
113
|
|
114 (defvar display-minibuffer-mode-in-minibuffer nil) ; same name as TAKANA
|
|
115 ; $B$?$+$J$G$O(B t $B$,%G%U%)%k%H$@$1$I!"(Bnil $B$r%G%U%)%k%H$K$7$F$*$3$&$+$J!#(B
|
|
116
|
|
117 (make-variable-buffer-local 'mode-line-canna-mode)
|
|
118
|
|
119 ; select-window-hook $B$O(B mule $B$+$iF~$C$?$s$@$H;W$&$1$I!"(B
|
|
120 ; $B$3$l$,L5$$$H(B preprompt $B$,$"$C$F$b$I$&$7$h$&$b$J$$$N$G$J$$$H$-$O(B
|
|
121 ; display-minibuffer-mode-in-minibuffer $B$r(B nil $B$K$9$k!#(B
|
|
122
|
|
123 (if (not (boundp 'select-window-hook))
|
|
124 (setq display-minibuffer-mode-in-minibuffer nil))
|
|
125
|
|
126 (defun canna:select-window-hook (old new)
|
|
127 (if (and (eq old (minibuffer-window))
|
|
128 (not (eq new (minibuffer-window))))
|
|
129 (save-excursion
|
|
130 (set-buffer (window-buffer (minibuffer-window)))
|
|
131 ;; minibuffer$B$N%G%U%)%k%H$O%"%k%U%!%Y%C%H%b!<%I(B
|
|
132 (setq mode-line-canna-mode-in-minibuffer canna:*alpha-mode-string*
|
|
133 canna:*japanese-mode-in-minibuffer* nil
|
|
134 minibuffer-preprompt nil)))
|
|
135 (if (eq new (minibuffer-window))
|
|
136 (setq minibuffer-window-selected t)
|
|
137 (setq minibuffer-window-selected nil)))
|
|
138
|
|
139 ; egg:select-window-hook $B$G$b==J,$J$N$G!"(Begg:select-window-hook $B$,(B
|
|
140 ; $B@_Dj$5$l$F$$$J$$>l9g$N$_Dj5A$9$k!#(B
|
|
141
|
|
142 ; $BNI$/9M$($F$_$k$H(B display-minibuffer-mode-in-minibuffer $B$,(B t $B$N;~$O(B
|
|
143 ; $B$d$O$j>e5-$N(B canna:select-window-hook $B$,I,MW$@$J$"!#$I$&$7$h$&!#(B
|
|
144
|
|
145 (if (and (boundp 'select-window-hook)
|
|
146 (not (eq select-window-hook 'egg:select-window-hook)))
|
|
147 (setq select-window-hook 'canna:select-window-hook))
|
|
148
|
|
149 (defun mode-line-canna-mode-update (str)
|
|
150 (if (eq (current-buffer) (window-buffer (minibuffer-window)))
|
|
151 (if (and display-minibuffer-mode-in-minibuffer
|
|
152 (boundp 'minibuffer-preprompt))
|
|
153 (setq minibuffer-preprompt str)
|
|
154 ;else
|
|
155 (setq mode-line-canna-mode-in-minibuffer str))
|
120
|
156 (setq mode-line-canna-mode str) )
|
|
157 (set-buffer-modified-p (buffer-modified-p)) )
|
70
|
158
|
|
159 ;; memq $B$r6/D4$9$k$J$i!"0J2<$@$,!"(B
|
|
160 ;(defun canna:memq-recursive (a l)
|
|
161 ; (or (eq a l)
|
|
162 ; (and (consp l)
|
|
163 ; (or (canna:memq-recursive a (car l))
|
|
164 ; (canna:memq-recursive a (cdr l)) ))))
|
|
165 ;; $B<!$NDj5A$r;H$*$&(B...
|
|
166 (defun canna:memq-recursive (a l)
|
|
167 (if (atom l) (eq a l)
|
|
168 (or (canna:memq-recursive a (car l))
|
|
169 (canna:memq-recursive a (cdr l)) )))
|
|
170
|
|
171 (defun canna:create-mode-line ()
|
120
|
172 "Add string of Canna status into mode-line."
|
|
173 (cond (running-xemacs
|
|
174 (or (canna:memq-recursive 'mode-line-canna-mode
|
|
175 default-modeline-format)
|
|
176 (setq-default default-modeline-format
|
138
|
177 (append '("" mode-line-canna-mode)
|
120
|
178 default-modeline-format))
|
|
179 )
|
|
180 (mapcar (function
|
|
181 (lambda (buffer)
|
|
182 (save-excursion
|
|
183 (set-buffer buffer)
|
|
184 (or (canna:memq-recursive 'mode-line-canna-mode
|
|
185 modeline-format)
|
|
186 (setq modeline-format
|
138
|
187 (append '("" mode-line-canna-mode)
|
120
|
188 modeline-format))
|
|
189 )
|
|
190 )))
|
|
191 (buffer-list))
|
|
192 )
|
|
193 (t
|
|
194 (or (canna:memq-recursive 'mode-line-canna-mode mode-line-format)
|
|
195 (setq-default
|
|
196 mode-line-format
|
|
197 (append (list (list 'minibuffer-window-selected
|
|
198 (list 'display-minibuffer-mode-in-minibuffer
|
|
199 "-" "m") "-")
|
|
200 (list 'minibuffer-window-selected
|
|
201 (list 'display-minibuffer-mode-in-minibuffer
|
|
202 'mode-line-canna-mode
|
|
203 'mode-line-canna-mode-in-minibuffer)
|
|
204 'mode-line-canna-mode))
|
|
205 mode-line-format))
|
|
206 )))
|
|
207 (mode-line-canna-mode-update mode-line-canna-mode))
|
70
|
208
|
|
209 (defun canna:mode-line-display ()
|
|
210 (mode-line-canna-mode-update mode-line-canna-mode))
|
|
211
|
|
212 ;;;
|
|
213 ;;; Canna local variables
|
|
214 ;;;
|
|
215
|
|
216 (defvar canna:*japanese-mode* nil "T if canna mode is ``japanese''.")
|
|
217 (make-variable-buffer-local 'canna:*japanese-mode*)
|
|
218 (set-default 'canna:*japanese-mode* nil)
|
|
219
|
|
220 (defvar canna:*japanese-mode-in-minibuffer* nil
|
|
221 "T if canna mode is ``japanese'' in minibuffer.")
|
|
222
|
|
223 (defvar canna:*exit-japanese-mode* nil)
|
|
224 (defvar canna:*fence-mode* nil)
|
|
225 ;(make-variable-buffer-local 'canna:*fence-mode*)
|
|
226 ;(setq-default canna:*fence-mode* nil)
|
|
227
|
|
228 ;;;
|
|
229 ;;; global variables
|
|
230 ;;;
|
|
231
|
|
232 (defvar canna-sys:*global-map* (copy-keymap global-map))
|
|
233 (defvar canna:*region-start* (make-marker))
|
|
234 (defvar canna:*region-end* (make-marker))
|
|
235 (defvar canna:*spos-undo-text* (make-marker))
|
|
236 (defvar canna:*epos-undo-text* (make-marker))
|
|
237 (defvar canna:*undo-text-yomi* nil)
|
|
238 (defvar canna:*local-map-backup* nil)
|
|
239 (defvar canna:*last-kouho* 0)
|
|
240 (defvar canna:*initialized* nil)
|
|
241 (defvar canna:*previous-window* nil)
|
|
242 (defvar canna:*minibuffer-local-map-backup* nil)
|
|
243 (defvar canna:*cursor-was-in-minibuffer* nil)
|
|
244 (defvar canna:*menu-buffer* " *menu*")
|
|
245 (defvar canna:*saved-minibuffer*)
|
|
246 (defvar canna:*saved-redirection* nil)
|
|
247 (defvar canna:*use-region-as-henkan-region* nil)
|
|
248 (make-variable-buffer-local 'canna:*use-region-as-henkan-region*)
|
|
249 (setq-default canna:*use-region-as-henkan-region* nil)
|
|
250
|
|
251 ;;;
|
|
252 ;;; $B?'$N@_Dj(B
|
|
253 ;;;
|
|
254 (defvar canna-use-color nil
|
|
255 "*Non-nil $B$G%+%i!<%G%#%9%W%l%$$G?'$rIU$1$k(B.
|
|
256 t $B$N;~$O%G%U%)%k%H$N?'$r;HMQ$9$k!#(B
|
|
257 $B?'$r;XDj$7$?$$;~$O(B, \"$BFI$_$N?'(B\", \"$BJQ49BP>]$N?'(B\", \"$BA*BrBP>]$N?'(B\" $B$N(B
|
|
258 $B%j%9%H$r@_Dj$9$k(B")
|
|
259 (defvar canna:color-p nil "$B?'$,;H$($k$+(B")
|
|
260 (defvar canna:attr-mode nil "$B8=:_$N%G%#%9%W%l%$%b!<%I(B")
|
|
261 (defvar canna:attr-yomi nil "$BFI$_$N?'B0@-(B")
|
|
262 (defvar canna:attr-taishou nil "$BJQ49BP>]ItJ,$N?'B0@-(B")
|
|
263 (defvar canna:attr-select nil
|
|
264 "$B%_%K%P%C%U%!J,N%;~$N%a%K%e!<$NA*BrBP>]HV9f$N?'B0@-(B")
|
|
265 (defvar canna:attribute-alist ;colored by tagu@ae.keio.ac.jp
|
|
266 '((yomi (normal . "red")
|
|
267 (reverse . "moccasin"))
|
|
268 (taishou (normal . "blue/lavender")
|
|
269 (reverse . "yellow/cadet blue"))
|
|
270 (select (normal . "DarkOliveGreen1/cadet blue")
|
|
271 (reverse . "light sea green/burlywood1")))
|
|
272 "$B$+$s$JJQ49;~$NG[?'$N(Balist")
|
|
273
|
|
274 (make-variable-buffer-local (defvar canna:*yomi-overlay* nil))
|
|
275 (make-variable-buffer-local (defvar canna:*henkan-overlay* nil))
|
|
276 (make-variable-buffer-local (defvar canna:*select-overlay* nil))
|
|
277
|
|
278 ;;;
|
|
279 ;;; $B%-!<%^%C%W%F!<%V%k(B
|
|
280 ;;;
|
|
281
|
|
282 ;; $B%U%'%s%9%b!<%I$G$N%m!<%+%k%^%C%W(B
|
|
283 (defvar canna-mode-map (make-sparse-keymap))
|
|
284
|
|
285 (let ((ch 0))
|
|
286 (while (<= ch 127)
|
|
287 (define-key canna-mode-map (make-string 1 ch) 'canna-functional-insert-command)
|
|
288 (setq ch (1+ ch))))
|
|
289
|
120
|
290 (cond (running-xemacs
|
|
291 (define-key canna-mode-map [up] "\C-p")
|
|
292 (define-key canna-mode-map [(shift up)] "\C-p")
|
|
293 (define-key canna-mode-map [(control up)] "\C-p")
|
|
294 (define-key canna-mode-map [down] "\C-n")
|
|
295 (define-key canna-mode-map [(shift down)] "\C-n")
|
|
296 (define-key canna-mode-map [(control down)] "\C-n")
|
|
297 (define-key canna-mode-map [right] "\C-f")
|
|
298 (define-key canna-mode-map [(shift right)] "\C-f")
|
|
299 (define-key canna-mode-map [(control right)] "\C-f")
|
|
300 (define-key canna-mode-map [left] "\C-b")
|
|
301 (define-key canna-mode-map [(shift left)] "\C-b")
|
|
302 (define-key canna-mode-map [(control left)] "\C-b")
|
|
303 (define-key canna-mode-map [kanji] " ")
|
|
304 (define-key canna-mode-map [(control space)] [(control @)])
|
|
305 )
|
|
306 (t
|
|
307 (define-key canna-mode-map [up] [?\C-p])
|
|
308 (define-key canna-mode-map [S-up] [?\C-p])
|
|
309 (define-key canna-mode-map [C-up] [?\C-p])
|
|
310 (define-key canna-mode-map [down] [?\C-n])
|
|
311 (define-key canna-mode-map [S-down] [?\C-n])
|
|
312 (define-key canna-mode-map [C-down] [?\C-n])
|
|
313 (define-key canna-mode-map [right] [?\C-f])
|
|
314 (define-key canna-mode-map [S-right] [?\C-f])
|
|
315 (define-key canna-mode-map [C-right] [?\C-f])
|
|
316 (define-key canna-mode-map [left] [?\C-b])
|
|
317 (define-key canna-mode-map [S-left] [?\C-b])
|
|
318 (define-key canna-mode-map [C-left] [?\C-b])
|
|
319 (define-key canna-mode-map [kanji] [? ])
|
|
320 (define-key canna-mode-map [?\C- ] [?\C-@])
|
|
321 ))
|
70
|
322
|
|
323 ;; $B%_%K%P%C%U%!$K2?$+$rI=<($7$F$$$k;~$N%m!<%+%k%^%C%W(B
|
|
324 (defvar canna-minibuffer-mode-map (make-sparse-keymap))
|
|
325
|
|
326 (let ((ch 0))
|
|
327 (while (<= ch 127)
|
|
328 (define-key canna-minibuffer-mode-map (make-string 1 ch) 'canna-minibuffer-insert-command)
|
|
329 (setq ch (1+ ch))))
|
|
330
|
120
|
331 (cond (running-xemacs
|
|
332 (define-key canna-minibuffer-mode-map [up] "\C-p")
|
|
333 (define-key canna-minibuffer-mode-map [(shift up)] "\C-p")
|
|
334 (define-key canna-minibuffer-mode-map [(control up)] "\C-p")
|
|
335 (define-key canna-minibuffer-mode-map [down] "\C-n")
|
|
336 (define-key canna-minibuffer-mode-map [(shift down)] "\C-n")
|
|
337 (define-key canna-minibuffer-mode-map [(control down)] "\C-n")
|
|
338 (define-key canna-minibuffer-mode-map [right] "\C-f")
|
|
339 (define-key canna-minibuffer-mode-map [(shift right)] "\C-f")
|
|
340 (define-key canna-minibuffer-mode-map [(control right)] "\C-f")
|
|
341 (define-key canna-minibuffer-mode-map [left] "\C-b")
|
|
342 (define-key canna-minibuffer-mode-map [(shift left)] "\C-b")
|
|
343 (define-key canna-minibuffer-mode-map [(control left)] "\C-b")
|
|
344 (define-key canna-minibuffer-mode-map [kanji] " ")
|
|
345 (define-key canna-minibuffer-mode-map [(control space)] [(control @)])
|
|
346 )
|
|
347 (t
|
|
348 (define-key canna-minibuffer-mode-map [up] [?\C-p])
|
|
349 (define-key canna-minibuffer-mode-map [S-up] [?\C-p])
|
|
350 (define-key canna-minibuffer-mode-map [C-up] [?\C-p])
|
|
351 (define-key canna-minibuffer-mode-map [down] [?\C-n])
|
|
352 (define-key canna-minibuffer-mode-map [S-down] [?\C-n])
|
|
353 (define-key canna-minibuffer-mode-map [C-down] [?\C-n])
|
|
354 (define-key canna-minibuffer-mode-map [right] [?\C-f])
|
|
355 (define-key canna-minibuffer-mode-map [S-right] [?\C-f])
|
|
356 (define-key canna-minibuffer-mode-map [C-right] [?\C-f])
|
|
357 (define-key canna-minibuffer-mode-map [left] [?\C-b])
|
|
358 (define-key canna-minibuffer-mode-map [S-left] [?\C-b])
|
|
359 (define-key canna-minibuffer-mode-map [C-left] [?\C-b])
|
|
360 (define-key canna-minibuffer-mode-map [kanji] [? ])
|
|
361 (define-key canna-minibuffer-mode-map [?\C- ] [?\C-@])
|
|
362 ))
|
70
|
363
|
|
364 ;;;
|
|
365 ;;; $B%0%m!<%P%k4X?t$N=q$-BX$((B
|
|
366 ;;;
|
|
367
|
|
368
|
|
369 ;; Keyboard quit
|
|
370
|
|
371 ;(if (not (fboundp 'canna-sys:keyboard-quit))
|
|
372 ; (fset 'canna-sys:keyboard-quit (symbol-function 'keyboard-quit)) )
|
|
373
|
|
374 ;(defun canna:keyboard-quit ()
|
|
375 ; "See documents for canna-sys:keyboard-quit"
|
|
376 ; (interactive)
|
|
377 ; (if canna:*japanese-mode*
|
|
378 ; (progn
|
|
379 ;; (setq canna:*japanese-mode* nil)
|
|
380 ; (setq canna:*fence-mode* nil)
|
120
|
381 ; (if (boundp 'disable-undo)
|
|
382 ; (setq disable-undo canna:*fence-mode*))
|
70
|
383 ; (canna:mode-line-display) ))
|
|
384 ; (canna-sys:keyboard-quit) )
|
|
385
|
|
386 ;; Abort recursive edit
|
|
387
|
|
388 ;(if (not (fboundp 'canna-sys:abort-recursive-edit))
|
|
389 ; (fset 'canna-sys:abort-recursive-edit
|
|
390 ; (symbol-function 'abort-recursive-edit)) )
|
|
391
|
|
392 ;(defun canna:abort-recursive-edit ()
|
|
393 ; "see documents for canna-sys:abort-recursive-edit"
|
|
394 ; (interactive)
|
|
395 ; (if canna:*japanese-mode*
|
|
396 ; (progn
|
|
397 ; (setq canna:*japanese-mode* nil)
|
|
398 ; (setq canna:*fence-mode* nil)
|
120
|
399 ; (if (boundp 'disable-undo)
|
|
400 ; (setq disable-undo canna:*fence-mode*))
|
70
|
401 ; (canna:mode-line-display) ))
|
|
402 ; (canna-sys:abort-recursive-edit) )
|
|
403
|
|
404 ;; Exit-minibuffer
|
|
405
|
|
406 (defun canna:exit-minibuffer ()
|
|
407 "Exit minibuffer turning off canna Japanese mode.
|
|
408 See also document for canna:saved-exit-minibuffer."
|
|
409 (interactive)
|
|
410 (if canna-initialize-minibuffer-state-when-exit
|
|
411 (setq canna:*japanese-mode-in-minibuffer* nil
|
|
412 mode-line-canna-mode-in-minibuffer canna:*alpha-mode-string*))
|
|
413 )
|
|
414
|
|
415 (add-hook 'minibuffer-exit-hook 'canna:exit-minibuffer)
|
|
416
|
|
417 ;; kill-emacs
|
|
418
|
|
419 (add-hook 'kill-emacs-hook 'canna:finalize)
|
|
420
|
|
421 ;;;
|
|
422 ;;; function for mini-buffer
|
|
423 ;;;
|
|
424
|
|
425 (defun adjust-minibuffer-mode ()
|
|
426 (if (eq (current-buffer) (window-buffer (minibuffer-window)))
|
|
427 (progn
|
|
428 (setq canna:*japanese-mode* canna:*japanese-mode-in-minibuffer*)
|
|
429 t)
|
|
430 nil))
|
|
431
|
|
432 ;;;
|
|
433 ;;; keyboard input for japanese language
|
|
434 ;;;
|
|
435
|
|
436 (defun canna-functional-insert-command (arg)
|
|
437 "Use input character as a key of complex translation input such as\n\
|
|
438 kana-to-kanji translation."
|
|
439 (interactive "*p")
|
98
|
440 (let ((ch))
|
|
441 (if (char-or-char-int-p arg)
|
|
442 (setq ch last-command-char)
|
|
443 (setq ch (event-to-character last-command-event)))
|
|
444 (canna:functional-insert-command2 ch arg) ))
|
70
|
445
|
|
446 (defun canna:functional-insert-command2 (ch arg)
|
|
447 "This function actualy isert a converted Japanese string."
|
|
448 ;; $B$3$N4X?t$OM?$($i$l$?J8;z$rF|K\8lF~NO$N$?$a$N%-!<F~NO$H$7$F<h$j07(B
|
|
449 ;; $B$$!"F|K\8lF~NO$NCf4V7k2L$r4^$a$?=hM}$r(BEmacs$B$N%P%C%U%!$KH?1G$5$;$k(B
|
|
450 ;; $B4X?t$G$"$k!#(B
|
|
451 (canna:display-candidates (canna-key-proc ch)) )
|
|
452
|
|
453 (defun canna:delete-last-preedit ()
|
|
454 (if (not (zerop canna:*last-kouho*))
|
|
455 (progn
|
|
456 (if canna-underline
|
|
457 ; $B$^$:!"B0@-$r>C$9!#(B
|
|
458 (progn
|
|
459 (canna:henkan-attr-off canna:*region-start* canna:*region-end*)
|
|
460 (canna:yomi-attr-off canna:*region-start* canna:*region-end*)))
|
|
461 (delete-region canna:*region-start* canna:*region-end*)
|
|
462 (setq canna:*last-kouho* 0) )))
|
|
463
|
|
464 (defun canna:insert-fixed (strs)
|
|
465 (cond ((> strs 0)
|
|
466 (cond ((and canna-kakutei-yomi
|
|
467 (or (null canna-save-undo-text-predicate)
|
|
468 (funcall canna-save-undo-text-predicate
|
|
469 (cons canna-kakutei-yomi
|
|
470 canna-kakutei-romaji) )))
|
|
471 (setq canna:*undo-text-yomi*
|
|
472 (cons canna-kakutei-yomi canna-kakutei-romaji))
|
|
473 (set-marker canna:*spos-undo-text* (point))
|
|
474 ;;
|
|
475 ;; update kbnes
|
120
|
476 (canna-self-insert-string canna-kakutei-string)
|
70
|
477 ;; $BL$3NDj$NJ8;z$,$J$/!"3NDjJ8;zNs$N:G8e$,JD$83g8L$N(B
|
|
478 ;; $BN`$@$C$?$H$-$O(B blink $B$5$;$k!#(B
|
|
479 (if (and canna-empty-info
|
|
480 (eq (char-syntax (char-before (point))) ?\)) )
|
|
481 (blink-matching-open))
|
|
482
|
|
483 ; (if overwrite-mode
|
|
484 ; (let ((num strs)
|
|
485 ; (kanji-compare 128))
|
|
486 ; (catch 'delete-loop
|
|
487 ; (while (> num 0)
|
|
488 ; (if (eolp)
|
|
489 ; (throw 'delete-loop nil))
|
|
490 ; (if (>= (following-char) kanji-compare)
|
|
491 ; (setq num (1- num)))
|
|
492 ; (delete-char 1)
|
|
493 ; (setq num (1- num))))))
|
|
494 ;; end kbnes
|
|
495 ; (insert canna-kakutei-string)
|
|
496 (if self-insert-after-hook
|
|
497 (funcall self-insert-after-hook
|
|
498 canna:*region-start* canna:*region-end*))
|
|
499 (canna:do-auto-fill)
|
|
500 (set-marker canna:*epos-undo-text* (point)) )
|
|
501 (t
|
|
502 ;;
|
|
503 ;; update kbnes
|
120
|
504 (canna-self-insert-string canna-kakutei-string)
|
70
|
505 ;; $BL$3NDj$NJ8;z$,$J$/!"3NDjJ8;zNs$N:G8e$,JD$83g8L$N(B
|
|
506 ;; $BN`$@$C$?$H$-$O(B blink $B$5$;$k!#(B
|
|
507 (if (and canna-empty-info
|
|
508 (eq (char-syntax (char-before (point))) ?\)) )
|
|
509 (blink-matching-open))
|
|
510
|
|
511 ; (if overwrite-mode
|
|
512 ; (let ((num strs)
|
|
513 ; (kanji-compare 128))
|
|
514 ; (catch 'delete-loop
|
|
515 ; (while (> num 0)
|
|
516 ; (if (eolp)
|
|
517 ; (throw 'delete-loop nil))
|
|
518 ; (if (>= (following-char) kanji-compare)
|
|
519 ; (setq num (1- num)))
|
|
520 ; (delete-char 1)
|
|
521 ; (setq num (1- num))))))
|
|
522 ;; end kbnes
|
|
523 ; (insert canna-kakutei-string)
|
|
524 (if self-insert-after-hook
|
|
525 (funcall self-insert-after-hook
|
|
526 canna:*region-start* canna:*region-end*))
|
|
527 (canna:do-auto-fill) ))
|
|
528 ) ))
|
|
529
|
|
530 (defun canna:insert-preedit ()
|
|
531 (cond ((> canna-henkan-length 0)
|
|
532 (set-marker canna:*region-start* (point))
|
|
533 (if canna-with-fences
|
|
534 (progn
|
|
535 (insert "||")
|
|
536 (set-marker canna:*region-end* (point))
|
|
537 (backward-char 1)
|
|
538 ))
|
|
539 (insert canna-henkan-string)
|
|
540 (if (not canna-with-fences)
|
|
541 (set-marker canna:*region-end* (point)) )
|
|
542 (if canna-underline
|
|
543 (canna:yomi-attr-on canna:*region-start* canna:*region-end*))
|
|
544 (setq canna:*last-kouho* canna-henkan-length)
|
|
545 ))
|
120
|
546
|
|
547 ;; $B8uJdNN0h$G$O6/D4$7$?$$J8;zNs$,B8:_$9$k$b$N$H9M$($i(B
|
|
548 ;; $B$l$k!#6/D4$7$?$$J8;z$O(BEmacs$B$G$O%+!<%=%k%]%8%7%g%s$K$FI=<((B
|
|
549 ;; $B$9$k$3$H$H$9$k!#6/D4$7$?$$J8;z$,$J$$$N$G$"$l$P!"%+!<%=%k(B
|
|
550 ;; $B$O0lHV8e$NItJ,(B($BF~NO$,9T$o$l$k%]%$%s%H(B)$B$KCV$$$F$*$/!#(B
|
|
551
|
|
552 ;; $B%+!<%=%k$r0\F0$9$k!#(B
|
|
553 (if (not canna-underline)
|
|
554 (backward-char
|
|
555 (- canna:*last-kouho*
|
|
556 ;; $B%+!<%=%k0LCV$O!"H?E>I=<(ItJ,$,B8:_$7$J$$$N$G$"$l$P!"(B
|
|
557 ;; $B8uJdJ8;zNs$N:G8e$NItJ,$H$7!"H?E>I=<(ItJ,$,B8:_$9$k$N(B
|
|
558 ;; $B$G$"$l$P!"$=$NItJ,$N;O$a$H$9$k!#(B
|
|
559 (cond ((zerop canna-henkan-revlen)
|
|
560 canna:*last-kouho*)
|
|
561 (t canna-henkan-revpos) )) )
|
|
562 (if (and (> canna-henkan-revlen 0)
|
|
563 (> canna-henkan-length 0))
|
|
564 ; $B8uJd$ND9$5$,(B0$B$G$J$/!"(B
|
|
565 ; $BH?E>I=<($ND9$5$,(B0$B$G$J$1$l$P!"(B
|
|
566 ; $B$=$NItJ,$rJQE>I=<($9$k!#(B
|
|
567 (let ((start (+ canna:*region-start*
|
|
568 (if canna-with-fences 1 0)
|
|
569 canna-henkan-revpos) ))
|
|
570 (if canna-underline
|
|
571 (canna:henkan-attr-on start
|
|
572 (+ start canna-henkan-revlen)))))
|
|
573 ) )
|
70
|
574
|
|
575 (defun canna:display-candidates (strs)
|
|
576 (cond ((stringp strs) ; $B%(%i!<$,5/$3$C$?>l9g(B
|
|
577 (beep)
|
|
578 (message strs) )
|
|
579 (canna-henkan-string
|
|
580 ;; $B$b$78uJdI=<($,A0$N7k2L$+$iJQ$o$C$F$$$J$/$J$$$H$-$O(B......
|
|
581
|
|
582 ;; $B<h$j9g$($::G=i$OA0$K=q$$$F$*$$$?Cf4V7k2L$r>C$9!#(B
|
|
583 (canna:delete-last-preedit)
|
|
584
|
|
585 ;; $B3NDj$7$?J8;zNs$,$"$l$P$=$l$rA^F~$9$k!#(B
|
|
586 (canna:insert-fixed strs)
|
|
587
|
|
588 ;; $B<!$O8uJd$K$D$$$F$N:n6H$G$"$k!#(B
|
|
589
|
|
590 ;; $B8uJd$rA^F~$9$k!#8uJd$O=DK@FsK\$K$F64$^$l$k!#(B
|
|
591 (canna:insert-preedit)
|
|
592 ))
|
|
593
|
|
594 ;; $B%b!<%I$rI=$9J8;zNs$,B8:_$9$l$P$=$l$r%b!<%I$H$7$F<h$j07$&!#(B
|
|
595 (if (stringp canna-mode-string)
|
|
596 (mode-line-canna-mode-update canna-mode-string))
|
|
597
|
|
598 ;; $B8uJdI=<($,$J$1$l$P%U%'%s%9%b!<%I$+$iH4$1$k!#(B
|
|
599 (cond (canna-empty-info (canna:quit-canna-mode)))
|
|
600
|
|
601 ;; $B%_%K%P%C%U%!$K=q$/$3$H$,B8:_$9$k$N$G$"$l$P!"$=$l$r%_%K%P%C%U%!(B
|
|
602 ;; $B$KI=<($9$k!#(B
|
|
603 (cond (canna-ichiran-string
|
|
604 (canna:minibuffer-input canna-ichiran-string
|
|
605 canna-ichiran-length
|
|
606 canna-ichiran-revpos
|
|
607 canna-ichiran-revlen
|
|
608 strs) )
|
|
609 (canna:*cursor-was-in-minibuffer*
|
|
610 ; (select-frame (window-frame (minibuffer-window)))
|
|
611 (select-window (minibuffer-window))
|
|
612 (set-window-buffer (minibuffer-window)
|
|
613 (get-buffer-create canna:*menu-buffer*))
|
|
614 (use-local-map canna-minibuffer-mode-map) ))
|
|
615 )
|
|
616
|
|
617 (defun canna:minibuffer-input (str len revpos revlen nfixed)
|
|
618 "Displaying misc informations for kana-to-kanji input."
|
|
619
|
|
620 ;; $B:n6H$r%_%K%P%C%U%!$K0\$9$N$K:]$7$F!"8=:_$N%&%#%s%I%&$N>pJs$rJ]B8(B
|
|
621 ;; $B$7$F$*$/!#(B
|
|
622 (setq canna:*previous-window* (selected-window))
|
|
623 ; (select-frame (window-frame (minibuffer-window)))
|
|
624
|
|
625 ;; $B<+J,$KMh$kA0$,%_%K%P%C%U%!$+$I$&$+$rJQ?t$K$G$b$$$l$F$*$$$?J}$,$$$$$J$"!#(B
|
|
626
|
|
627 (if (not canna:*cursor-was-in-minibuffer*)
|
|
628 (progn
|
|
629 ;; $B%_%K%P%C%U%!$r%/%j%"$9$k!#(B
|
|
630 ; (if (eq canna:*previous-window* (selected-window))
|
|
631 ; (progn
|
|
632 ; (canna:henkan-attr-off (point-min) (point-max))
|
|
633 ; (canna:delete-last-preedit) ))
|
|
634
|
|
635 ;; $B%_%K%P%C%U%!%&%#%s%I%&$K8uJd0lMwMQ$N%P%C%U%!$r3d$jEv$F$k!#(B
|
|
636 (setq canna:*saved-minibuffer* (window-buffer (minibuffer-window)))
|
|
637 ; (set-window-buffer (minibuffer-window)
|
|
638 ; (get-buffer-create canna:*menu-buffer*))
|
|
639 ;; modified by $B<i2,(B $BCNI'(B <morioka@jaist.ac.jp>, 1996/6/7
|
120
|
640 (unless running-xemacs
|
|
641 ;; $B$H$j$"$($:(B XEmacs $B$G$OF0$+$5$J$$$3$H$K$7$F$*$3$&(B (^_^;
|
|
642 (setq canna:*saved-redirection* (frame-focus (selected-frame)))
|
|
643 (redirect-frame-focus (selected-frame)
|
|
644 (window-frame (minibuffer-window)))
|
|
645 )
|
70
|
646 ;; $B%_%K%P%C%U%!$N%-!<%^%C%W$rJ]B8$7$F$*$/!#(B
|
|
647 (setq canna:*minibuffer-local-map-backup* (current-local-map))
|
|
648 ))
|
|
649 (select-window (minibuffer-window))
|
|
650 (set-window-buffer (minibuffer-window)
|
|
651 (get-buffer-create canna:*menu-buffer*))
|
|
652
|
|
653 (use-local-map canna-minibuffer-mode-map)
|
|
654
|
|
655 ; (canna:yomi-attr-off (point-min) (point-max) )
|
|
656 ; (canna:henkan-attr-off (point-min) (point-max) )
|
|
657 (canna:select-attr-off (point-min) (point-max) )
|
|
658 (setq canna:*cursor-was-in-minibuffer* t)
|
|
659 (delete-region (point-min) (point-max))
|
|
660 (if (not (eq canna:*previous-window* (selected-window)))
|
|
661 (setq minibuffer-window-selected nil))
|
|
662
|
|
663 (insert str)
|
|
664
|
|
665 ;; $B%_%K%P%C%U%!$GH?E>I=<($9$k$Y$-J8;z$N$H$3$m$K%+!<%=%k$r0\F0$9$k!#(B
|
|
666 (cond ((> revlen 0)
|
|
667 (backward-char (- len revpos)) ))
|
|
668 ;;(message "%s" (selected-frame)) (sit-for 3)
|
|
669 (raise-frame (window-frame (minibuffer-window)))
|
|
670 ; (select-frame (window-frame (minibuffer-window)))
|
|
671 (and canna:color-p (not (eobp))
|
|
672 (canna:select-attr-on (point)
|
|
673 (save-excursion (forward-char 1) (point))))
|
|
674
|
|
675 ;; $B%_%K%P%C%U%!$KI=<($9$k$Y$-J8;zNs$,%L%kJ8;zNs$J$N$G$"$l$P!"A0$N%&%#(B
|
|
676 ;; $B%s%I%&$KLa$k!#(B
|
|
677 (if (or (zerop len) canna-empty-info)
|
|
678 (progn
|
|
679 (setq canna:*cursor-was-in-minibuffer* nil)
|
|
680 (use-local-map canna:*minibuffer-local-map-backup*)
|
|
681
|
|
682 ;; $B%_%K%P%C%U%!%&%#%s%I%&$N%P%C%U%!$r85$KLa$9!#(B
|
|
683 (set-window-buffer (minibuffer-window) canna:*saved-minibuffer*)
|
|
684 ; (setq canna:*saved-minibuffer* nil)
|
|
685 ;; modified by $B<i2,(B $BCNI'(B <morioka@jaist.ac.jp>, 1996/6/7
|
120
|
686 (unless running-xemacs
|
|
687 ;; $B$H$j$"$($:(B XEmacs $B$G$OF0$+$5$J$$$h$&$K$7$F$*$3$&(B (^_^;
|
|
688 (redirect-frame-focus (window-frame canna:*previous-window*)
|
|
689 canna:*saved-redirection*)
|
|
690 )
|
|
691 ; $B%_%K%P%C%U%!$GF~NO$7$F$$$?$N$J$i0J2<$b$9$k!#(B
|
70
|
692 ; (if (eq canna:*previous-window* (selected-window))
|
|
693 ; (progn
|
|
694 ; (canna:insert-fixed nfixed)
|
|
695 ; (canna:insert-preedit) ))
|
|
696
|
|
697 (if (and canna-empty-info (> len 0))
|
|
698 (progn
|
|
699 ; (delete-region (point-min) (point-max))
|
|
700 (message str) ))
|
|
701 (select-window canna:*previous-window*) ))
|
|
702 )
|
|
703
|
|
704 (defun canna-minibuffer-insert-command (arg)
|
|
705 "Use input character as a key of complex translation input such as\n\
|
|
706 kana-to-kanji translation, even if you are in the minibuffer."
|
|
707 (interactive "p")
|
|
708 (use-local-map canna:*minibuffer-local-map-backup*)
|
|
709 (set-window-buffer (minibuffer-window) canna:*saved-minibuffer*)
|
|
710 (select-window canna:*previous-window*)
|
98
|
711 (let ((ch))
|
|
712 (if (char-or-char-int-p arg)
|
|
713 (setq ch last-command-char)
|
|
714 (setq ch (event-to-character last-command-event)))
|
|
715 (canna:functional-insert-command2 ch arg) ))
|
70
|
716
|
|
717 ;;;
|
|
718 ;;; $B$+$s$J%b!<%I$N<gLr$O!"<!$N(B canna-self-insert-command $B$G$"$k!#$3$N(B
|
|
719 ;;; $B%3%^%s%I$OA4$F$N%0%i%U%#%C%/%-!<$K%P%$%s%I$5$l$k!#(B
|
|
720 ;;;
|
|
721 ;;; $B$3$N4X?t$G$O!"8=:_$N%b!<%I$,F|K\8lF~NO%b!<%I$+$I$&$+$r%A%'%C%/$7$F!"(B
|
|
722 ;;; $BF|K\8lF~NO%b!<%I$G$J$$$N$G$"$l$P!"%7%9%F%`$N(B self-insert-command
|
|
723 ;;; $B$r8F$V!#F|K\8lF~NO%b!<%I$G$"$l$P!"%U%'%s%9%b!<%I$KF~$j!"(B
|
|
724 ;;; canna-functional-insert-command $B$r8F$V!#(B
|
|
725 ;;;
|
|
726
|
|
727 (if (not (boundp 'MULE)) ; for Nemacs
|
|
728 (defun cancel-undo-boundary ()))
|
|
729
|
|
730 (defun canna-self-insert-command (arg)
|
|
731 "Self insert pressed key and use it to assemble Romaji character."
|
|
732 (interactive "*p")
|
|
733 (adjust-minibuffer-mode)
|
|
734 (if (and canna:*japanese-mode*
|
|
735 ;; $B%U%'%s%9%b!<%I$@$C$?$i$b$&0lEY%U%'%s%9%b!<%I$KF~$C$?$j$7(B
|
|
736 ;; $B$J$$!#(B
|
|
737 (not canna:*fence-mode*) )
|
|
738 (canna:enter-canna-mode-and-functional-insert)
|
|
739 (progn
|
|
740 ;; $B0J2<$NItJ,$O(B egg.el $B$N(B 3.09 $B$N(B egg-self-insert-command $B$NItJ,$+$i(B
|
|
741 ;; $B%3%T!<$7!"<j$rF~$l$F$$$^$9!#(B93.11.5 kon
|
|
742 ;; treat continuous 20 self insert as a single undo chunk.
|
|
743 ;; `20' is a magic number copied from keyboard.c
|
|
744 ; (if (or ;92.12.20 by T.Enami
|
|
745 ; (not (eq last-command 'canna-self-insert-command))
|
|
746 ; (>= canna:*self-insert-non-undo-count* 20))
|
|
747 ; (setq canna:*self-insert-non-undo-count* 1)
|
|
748 ; (cancel-undo-boundary)
|
|
749 ; (setq canna:*self-insert-non-undo-count*
|
|
750 ; (1+ canna:*self-insert-non-undo-count*)))
|
|
751 (if (and (eq last-command 'canna-self-insert-command)
|
|
752 (> last-command-char ? ))
|
|
753 (cancel-undo-boundary))
|
|
754 (self-insert-command arg)
|
|
755 ; (if canna-insert-after-hook
|
|
756 ; (run-hooks 'canna-insert-after-hook))
|
|
757 (if self-insert-after-hook
|
|
758 (if (<= 1 arg)
|
|
759 (funcall self-insert-after-hook
|
|
760 (- (point) arg) (point)))
|
|
761 (if (= last-command-char ? ) (canna:do-auto-fill))))))
|
|
762
|
138
|
763 ;; wire us into pending-delete
|
|
764 (put 'canna-self-insert-command 'pending-delete t)
|
|
765
|
70
|
766 (defun canna-toggle-japanese-mode ()
|
|
767 "Toggle canna japanese mode."
|
|
768 (interactive)
|
|
769 (let ((in-minibuffer (adjust-minibuffer-mode)))
|
|
770 (cond (canna:*japanese-mode*
|
|
771 (setq canna:*japanese-mode* nil)
|
|
772 (canna-abandon-undo-info)
|
|
773 (setq canna:*use-region-as-henkan-region* nil)
|
|
774 (setq canna:*saved-mode-string* mode-line-canna-mode)
|
|
775 (mode-line-canna-mode-update canna:*alpha-mode-string*) )
|
|
776 (t
|
|
777 (setq canna:*japanese-mode* t)
|
|
778 (if (fboundp 'canna-query-mode)
|
|
779 (let ((new-mode (canna-query-mode)))
|
|
780 (if (string-equal new-mode "")
|
|
781 (setq canna:*kanji-mode-string* canna:*saved-mode-string*)
|
|
782 (setq canna:*kanji-mode-string* new-mode)
|
|
783 )) )
|
|
784 (mode-line-canna-mode-update canna:*kanji-mode-string*) ) )
|
|
785 (if in-minibuffer
|
|
786 (setq canna:*japanese-mode-in-minibuffer* canna:*japanese-mode*)) ))
|
|
787
|
|
788 (defun canna:initialize ()
|
|
789 (let ((init-val nil))
|
|
790 (cond (canna:*initialized*) ; initialize $B$5$l$F$$$?$i2?$b$7$J$$(B
|
|
791 (t
|
|
792 (setq canna:*initialized* t)
|
|
793 (setq init-val (canna-initialize
|
|
794 (if canna-underline 0 1)
|
|
795 canna-server canna-file))
|
|
796 (cond ((car (cdr (cdr init-val)))
|
|
797 (canna:output-warnings (car (cdr (cdr init-val)))) ))
|
|
798 (cond ((car (cdr init-val))
|
|
799 (error (car (cdr init-val))) ))
|
|
800 ) )
|
|
801
|
|
802 (if (fboundp 'canna-query-mode)
|
|
803 (progn
|
|
804 (canna-change-mode canna-mode-alpha-mode)
|
|
805 (setq canna:*alpha-mode-string* (canna-query-mode)) ))
|
|
806
|
|
807 (canna-do-function canna-func-japanese-mode)
|
|
808
|
|
809 (if (fboundp 'canna-query-mode)
|
|
810 (setq canna:*kanji-mode-string* (canna-query-mode)))
|
|
811
|
|
812 init-val))
|
|
813
|
|
814 (defun canna:finalize ()
|
|
815 (cond ((null canna:*initialized*)) ; initialize $B$5$l$F$$$J$+$C$?$i2?$b$7$J$$(B
|
|
816 (t
|
|
817 (setq canna:*initialized* nil)
|
|
818 (let ((init-val (canna-finalize)))
|
|
819 (cond ((car (cdr (cdr init-val)))
|
|
820 (canna:output-warnings (car (cdr (cdr init-val)))) ))
|
|
821 (cond ((car (cdr init-val))
|
|
822 (error (car (cdr init-val))) ))
|
|
823 )
|
|
824 (message "$B!X$+$s$J!Y$N<-=q$r%;!<%V$7$^$9!#(B")
|
|
825 )))
|
|
826
|
|
827 (defun canna:enter-canna-mode ()
|
|
828 (if (not canna:*initialized*)
|
|
829 (progn
|
|
830 (message "$B!X$+$s$J!Y$N=i4|2=$r9T$C$F$$$^$9(B....")
|
|
831 (canna:initialize)
|
|
832 (message "$B!X$+$s$J!Y$N=i4|2=$r9T$C$F$$$^$9(B....done")
|
|
833 ))
|
|
834 (canna-set-width (- (window-width (minibuffer-window))
|
|
835 (minibuffer-prompt-width)
|
|
836 (if (and display-minibuffer-mode-in-minibuffer
|
|
837 (eq (selected-window) (minibuffer-window)))
|
|
838 (string-width
|
|
839 (let ((new-mode (canna-query-mode)))
|
|
840 (if (string-equal new-mode "")
|
|
841 canna:*saved-mode-string*
|
|
842 new-mode)))
|
|
843 0)))
|
|
844 (setq canna:*local-map-backup* (current-local-map))
|
|
845 (setq canna:*fence-mode* t)
|
|
846 ;; XEmacs change:
|
|
847 (buffer-disable-undo (current-buffer))
|
120
|
848 ;; (if (boundp 'disable-undo)
|
|
849 ;; (setq disable-undo canna:*fence-mode*))
|
70
|
850 (use-local-map canna-mode-map))
|
|
851
|
|
852 (defun canna:enter-canna-mode-and-functional-insert ()
|
|
853 (canna:enter-canna-mode)
|
|
854 (setq canna:*use-region-as-henkan-region* nil)
|
|
855 (setq unread-command-events (list last-command-event)))
|
|
856
|
|
857 (defun canna:quit-canna-mode ()
|
|
858 (cond (canna:*fence-mode*
|
|
859 (use-local-map canna:*local-map-backup*)
|
|
860 (setq canna:*fence-mode* nil)
|
|
861 (if canna:*exit-japanese-mode*
|
|
862 (progn
|
|
863 (setq canna:*exit-japanese-mode* nil)
|
|
864 (setq canna-mode-string canna:*alpha-mode-string*)
|
|
865 (if canna:*japanese-mode*
|
|
866 (canna-toggle-japanese-mode)
|
|
867 (mode-line-canna-mode-update canna:*alpha-mode-string*) )))
|
|
868 ;; XEmacs change:
|
|
869 (buffer-enable-undo (current-buffer))
|
120
|
870 ;; (if (boundp 'disable-undo)
|
|
871 ;; (setq disable-undo canna:*fence-mode*))
|
70
|
872 ))
|
|
873 (set-marker canna:*region-start* nil)
|
|
874 (set-marker canna:*region-end* nil)
|
|
875 )
|
|
876
|
|
877 (defun canna-touroku ()
|
|
878 "Register a word into a kana-to-kanji dictionary."
|
|
879 (interactive)
|
|
880 ; (if canna:*japanese-mode*
|
|
881 (if (not canna:*fence-mode*)
|
|
882 (progn
|
|
883 (setq canna:*exit-japanese-mode* (not canna:*japanese-mode*))
|
|
884 (canna:enter-canna-mode)
|
|
885 (canna:display-candidates (canna-touroku-string "")) )
|
|
886 (beep)
|
|
887 ))
|
|
888
|
|
889 (defun canna-without-newline (start end)
|
|
890 (and (not (eq start end))
|
|
891 (or
|
|
892 (and (<= end (point))
|
|
893 (save-excursion
|
|
894 (beginning-of-line)
|
|
895 (<= (point) start) ))
|
|
896 (and (<= (point) start)
|
|
897 (save-excursion
|
|
898 (end-of-line)
|
|
899 (<= end (point)) ))
|
|
900 )))
|
|
901
|
|
902 (defun canna-touroku-region (start end)
|
|
903 "Register a word which is indicated by region into a kana-to-kanji\n\
|
|
904 dictionary."
|
|
905 (interactive "r")
|
|
906 (if (canna-without-newline start end)
|
|
907 ; (if canna:*japanese-mode*
|
|
908 (if (not canna:*fence-mode*)
|
|
909 (progn
|
|
910 (setq canna:*use-region-as-henkan-region* nil)
|
|
911 (setq canna:*exit-japanese-mode* (not canna:*japanese-mode*))
|
|
912 (canna:enter-canna-mode)
|
|
913 (canna:display-candidates
|
|
914 (canna-touroku-string (buffer-substring start end))) ))
|
|
915 (message "$B%j!<%8%g%s$,IT@5$G$9!#%L%k%j!<%8%g%s$+!"2~9T$,4^$^$l$F$$$^$9!#(B")
|
|
916 ))
|
|
917
|
|
918 (defun canna-extend-mode ()
|
|
919 "To enter an extend-mode of Canna."
|
|
920 (interactive "*")
|
|
921 ; (if (and (not (eq (window-frame (minibuffer-window)) (selected-frame)))
|
|
922 ; (not canna:*fence-mode*))
|
|
923 ;; $B%_%K%P%C%U%!$rJ,N%$7$F$$$k;~$O0l;~E*$K%U%'%s%9%b!<%I$KF~$k(B
|
|
924 ;; $B$=$&$7$J$$$H%a%K%e!<$rA*$Y$J$$(B
|
|
925 ;; (focus$B$,%_%K%P%C%U%!$K9T$+$J$$$+$i(B)
|
|
926 (if (not canna:*fence-mode*)
|
|
927 (progn
|
|
928 (setq canna:*exit-japanese-mode* (not canna:*japanese-mode*))
|
|
929 (canna:enter-canna-mode)
|
|
930 (canna:display-candidates
|
|
931 (canna-do-function canna-func-extend-mode) ))
|
|
932 (beep)))
|
|
933
|
|
934 (defun canna-kigou-mode ()
|
|
935 "Enter symbol choosing mode."
|
|
936 (interactive "*")
|
|
937 ; (if canna:*japanese-mode*
|
|
938 (if (not canna:*fence-mode*)
|
|
939 (progn
|
|
940 (setq canna:*exit-japanese-mode* (not canna:*japanese-mode*))
|
|
941 (canna:enter-canna-mode)
|
|
942 (canna:display-candidates (canna-change-mode canna-mode-kigo-mode)) )
|
|
943 (beep)
|
|
944 ))
|
|
945
|
|
946 (defun canna-hex-mode ()
|
|
947 "Enter hex code entering mode."
|
|
948 (interactive "*")
|
|
949 ; (if canna:*japanese-mode*
|
|
950 (if (not canna:*fence-mode*)
|
|
951 (progn
|
|
952 (setq canna:*exit-japanese-mode* (not canna:*japanese-mode*))
|
|
953 (canna:enter-canna-mode)
|
|
954 (canna:display-candidates (canna-change-mode canna-mode-hex-mode)) )
|
|
955 (beep)
|
|
956 ))
|
|
957
|
|
958 (defun canna-bushu-mode ()
|
|
959 "Enter special mode to convert by BUSHU name."
|
|
960 (interactive "*")
|
|
961 ; (if canna:*japanese-mode*
|
|
962 (if (not canna:*fence-mode*)
|
|
963 (progn
|
|
964 (setq canna:*exit-japanese-mode* (not canna:*japanese-mode*))
|
|
965 (canna:enter-canna-mode)
|
|
966 (canna:display-candidates (canna-change-mode canna-mode-bushu-mode)) )
|
|
967 (beep)
|
|
968 ))
|
|
969
|
|
970 (defun canna-reset ()
|
|
971 (interactive)
|
|
972 (message "$B!X$+$s$J!Y$N<-=q$r%;!<%V$7$^$9!#(B");
|
|
973 (canna:finalize)
|
|
974 (message "$B!X$+$s$J!Y$N:F=i4|2=$r9T$C$F$$$^$9(B....")
|
|
975 (canna:initialize)
|
|
976 (message "$B!X$+$s$J!Y$N:F=i4|2=$r9T$C$F$$$^$9(B....done")
|
|
977 )
|
|
978
|
|
979
|
|
980 (defun canna ()
|
|
981 (interactive)
|
|
982 (message "$B!X$+$s$J!Y$r=i4|2=$7$F$$$^$9(B....")
|
|
983 (let (init-val)
|
|
984 (cond ((and (fboundp 'canna-initialize) (fboundp 'canna-change-mode) )
|
|
985
|
|
986 ;; canna $B$,;H$($k;~$O<!$N=hM}$r$9$k!#(B
|
|
987
|
|
988 ;; $BG[?'@_Dj(B (by yuuji@ae.keio.ac.jp)
|
|
989 (setq canna:color-p (and canna-use-color
|
|
990 window-system
|
|
991 (x-display-color-p)))
|
|
992 ;;$B%+%i!<$N;~(Bunderline$B%b!<%I$HF1$8>uBV$G=i4|2=$9$kI,MW$,$"$k(B
|
|
993 (setq canna-underline (or canna:color-p canna-underline))
|
|
994 (cond
|
|
995 (canna:color-p
|
|
996 (setq canna:attr-mode
|
|
997 (cond
|
|
998 ((or (and (boundp 'hilit-background-mode)
|
|
999 (eq hilit-background-mode 'dark))
|
|
1000 (string-match
|
|
1001 "on\\|t"
|
116
|
1002 (or (if running-xemacs
|
120
|
1003 (x-get-resource "ReverseVideo"
|
|
1004 "reverseVideo" 'string)
|
116
|
1005 (x-get-resource "ReverseVideo" "reverseVideo"))
|
70
|
1006 "")))
|
|
1007 'reverse) ;$BH?E>$7$F$$$k$J$i(B 'reverse
|
|
1008 (t 'normal)))
|
|
1009 (setq canna:attr-yomi
|
|
1010 (if (listp canna-use-color)
|
|
1011 (car canna-use-color)
|
|
1012 (cdr (assq canna:attr-mode
|
|
1013 (assq 'yomi canna:attribute-alist)))))
|
|
1014 (setq canna:attr-taishou
|
|
1015 (if (listp canna-use-color)
|
|
1016 (car (cdr canna-use-color))
|
|
1017 (setq canna:attr-taishou
|
|
1018 (cdr (assq
|
|
1019 canna:attr-mode
|
|
1020 (assq 'taishou canna:attribute-alist))))))
|
|
1021 (setq canna:attr-select
|
|
1022 (if (listp canna-use-color)
|
|
1023 (car (cdr (cdr canna-use-color)))
|
|
1024 (setq canna:attr-select
|
|
1025 (cdr (assq canna:attr-mode
|
|
1026 (assq 'select canna:attribute-alist))))))
|
|
1027 ;;$B?'$E$1MQ(Bface$B$N:n@.(B
|
|
1028 (mapcar
|
|
1029 (function
|
|
1030 (lambda (face)
|
|
1031 (let* ((color (symbol-value
|
|
1032 (intern (concat "canna:" (symbol-name face)))))
|
|
1033 backp)
|
|
1034 (make-face face)
|
|
1035 (if (stringp color)
|
|
1036 (progn
|
|
1037 (setq backp (string-match "/" color))
|
|
1038 (set-face-foreground
|
|
1039 face (substring color 0 backp))
|
|
1040 (if backp
|
|
1041 (set-face-background
|
|
1042 face (substring color (1+ backp)))))
|
|
1043 (copy-face color face)))))
|
|
1044 '(attr-yomi attr-taishou attr-select))
|
|
1045 ))
|
|
1046 ;;$BG[?'@_Dj=*N;(B
|
|
1047
|
|
1048 ;; $B!X$+$s$J!Y%7%9%F%`$N=i4|2=(B
|
|
1049
|
|
1050 (setq init-val (canna:initialize))
|
|
1051
|
|
1052 ;; $B%-!<$N%P%$%s%G%#%s%0(B
|
|
1053
|
|
1054 (let ((ch 32))
|
|
1055 (while (< ch 127)
|
|
1056 (define-key global-map (make-string 1 ch) 'canna-self-insert-command)
|
|
1057 (setq ch (1+ ch)) ))
|
|
1058
|
|
1059 (cond ((let ((keys (car init-val)) (ok nil))
|
|
1060 (while keys
|
|
1061 (cond ((< (car keys) 128)
|
|
1062 (global-set-key
|
|
1063 (make-string 1 (car keys))
|
|
1064 'canna-toggle-japanese-mode)
|
|
1065 (setq ok t) ))
|
|
1066 (setq keys (cdr keys))
|
|
1067 ) ok))
|
|
1068 (t ; $B%G%U%)%k%H$N@_Dj(B
|
|
1069 (global-set-key "\C-o" 'canna-toggle-japanese-mode) ))
|
|
1070
|
|
1071 (if (not (keymapp (global-key-binding "\e[")))
|
|
1072 (global-unset-key "\e[") )
|
|
1073 (global-set-key "\e[210z" 'canna-toggle-japanese-mode) ; XFER
|
|
1074 (define-key global-map [kanji] 'canna-toggle-japanese-mode)
|
|
1075 (if canna-do-keybind-for-functionkeys
|
|
1076 (progn
|
|
1077 (global-set-key "\e[28~" 'canna-extend-mode) ; HELP on EWS4800
|
|
1078 (global-set-key "\e[2~" 'canna-kigou-mode) ; INS on EWS4800
|
|
1079 (global-set-key "\e[11~" 'canna-kigou-mode)
|
|
1080 (global-set-key "\e[12~" 'canna-hex-mode)
|
|
1081 (global-set-key "\e[13~" 'canna-bushu-mode)
|
|
1082 (define-key global-map [help] 'canna-extend-mode)
|
|
1083 (define-key global-map [insert] 'canna-kigou-mode)
|
|
1084 (define-key global-map [f1] 'canna-kigou-mode)
|
|
1085 (define-key global-map [f2] 'canna-hex-mode)
|
|
1086 (define-key global-map [f3] 'canna-bushu-mode)
|
|
1087 ))
|
|
1088
|
|
1089 (if canna-use-space-key-as-henkan-region
|
|
1090 (progn
|
|
1091 (global-set-key "\C-@" 'canna-set-mark-command)
|
|
1092 ;; X Window $B$O(B C-@ $B$H(B C-SPC $B$r6hJL$9$k$N$G!"$3$l$,I,MW!#(B
|
|
1093 (global-set-key [?\C-\ ] 'canna-set-mark-command)
|
|
1094 (global-set-key " " 'canna-henkan-region-or-self-insert) ))
|
|
1095
|
|
1096 ;; $B%b!<%I9T$N:n@.(B
|
|
1097
|
|
1098 (canna:create-mode-line)
|
|
1099 (mode-line-canna-mode-update canna:*alpha-mode-string*)
|
|
1100
|
|
1101 ;; $B%7%9%F%`4X?t$N=q$-BX$((B
|
|
1102
|
|
1103 ; (fset 'abort-recursive-edit
|
|
1104 ; (symbol-function 'canna:abort-recursive-edit))
|
|
1105 ; (fset 'keyboard-quit
|
|
1106 ; (symbol-function 'canna:keyboard-quit))
|
|
1107
|
|
1108 )
|
|
1109
|
|
1110 ((fboundp 'canna-initialize)
|
|
1111 (beep)
|
|
1112 (with-output-to-temp-buffer "*canna-warning*"
|
|
1113 (princ "$B$3$N(B Mule $B$G$O(B new-canna $B$,;H$($^$;$s(B")
|
|
1114 (terpri)
|
|
1115 (print-help-return-message)) )
|
|
1116
|
|
1117 (t ; $B!X$+$s$J!Y%7%9%F%`$,;H$($J$+$C$?;~$N=hM}(B
|
|
1118 (beep)
|
|
1119 (with-output-to-temp-buffer "*canna-warning*"
|
|
1120 (princ "$B$3$N(B Mule $B$G$O(B canna $B$,;H$($^$;$s(B")
|
|
1121 (terpri)
|
|
1122 (print-help-return-message))
|
|
1123 ))
|
|
1124 (message "$B!X$+$s$J!Y$r=i4|2=$7$F$$$^$9(B....done")
|
|
1125 ) )
|
|
1126
|
|
1127 ;;;
|
|
1128 ;;; auto fill controll (from egg)
|
|
1129 ;;;
|
|
1130
|
|
1131 (defun canna:do-auto-fill ()
|
|
1132 (if (and auto-fill-function (not buffer-read-only)
|
|
1133 (> (current-column) fill-column))
|
|
1134 (let ((ocolumn (current-column)))
|
|
1135 (funcall auto-fill-function)
|
|
1136 (while (and (< fill-column (current-column))
|
|
1137 (< (current-column) ocolumn))
|
|
1138 (setq ocolumn (current-column))
|
|
1139 (funcall auto-fill-function)))))
|
|
1140
|
|
1141 (defun canna:output-warnings (mesg)
|
|
1142 (with-output-to-temp-buffer "*canna-warning*"
|
|
1143 (while mesg
|
|
1144 (princ (car mesg))
|
|
1145 (terpri)
|
|
1146 (setq mesg (cdr mesg)) )
|
|
1147 (print-help-return-message)))
|
|
1148
|
|
1149 (defun canna-undo (&optional arg)
|
|
1150 (interactive "*p")
|
|
1151 (if (and canna:*undo-text-yomi*
|
|
1152 (eq (current-buffer) (marker-buffer canna:*spos-undo-text*))
|
|
1153 ; (canna-without-newline canna:*spos-undo-text*
|
|
1154 ; canna:*epos-undo-text*)
|
|
1155 )
|
|
1156 (progn
|
|
1157 (message "$BFI$_$KLa$7$^$9!*(B")
|
|
1158 ; (switch-to-buffer (marker-buffer canna:*spos-undo-text*))
|
|
1159 (goto-char canna:*spos-undo-text*)
|
|
1160 (delete-region canna:*spos-undo-text*
|
|
1161 canna:*epos-undo-text*)
|
|
1162
|
|
1163 (if (null canna:*japanese-mode*)
|
|
1164 (progn
|
|
1165 (setq canna:*exit-japanese-mode* t) ))
|
|
1166 ; (canna-toggle-japanese-mode) ))
|
|
1167 (if (not canna:*fence-mode*)
|
|
1168 ;; $B%U%'%s%9%b!<%I$@$C$?$i$b$&0lEY%U%'%s%9%b!<%I$KF~$C$?$j$7(B
|
|
1169 ;; $B$J$$!#(B
|
|
1170 (canna:enter-canna-mode) )
|
|
1171 (canna:display-candidates
|
|
1172 (let ((texts (canna-store-yomi (car canna:*undo-text-yomi*)
|
|
1173 (cdr canna:*undo-text-yomi*) )) )
|
|
1174 (cond (canna-undo-hook
|
|
1175 (funcall canna-undo-hook))
|
|
1176 (t texts) )))
|
|
1177 (canna-abandon-undo-info)
|
|
1178 )
|
|
1179 (canna-abandon-undo-info)
|
|
1180 (undo arg) ))
|
|
1181
|
|
1182 (defun canna-abandon-undo-info ()
|
|
1183 (interactive)
|
|
1184 (setq canna:*undo-text-yomi* nil)
|
|
1185 (set-marker canna:*spos-undo-text* nil)
|
|
1186 (set-marker canna:*epos-undo-text* nil) )
|
|
1187
|
|
1188 (defun canna-henkan-region (start end)
|
|
1189 "Convert a text which is indicated by region into a kanji text."
|
|
1190 (interactive "*r")
|
|
1191 (if (null canna:*japanese-mode*)
|
|
1192 (progn
|
|
1193 (setq canna:*exit-japanese-mode* t) ))
|
|
1194 ; (canna-toggle-japanese-mode) ))
|
|
1195 (let ((res nil))
|
|
1196 (setq res (canna-store-yomi (buffer-substring start end)))
|
|
1197 (delete-region start end)
|
|
1198 (canna:enter-canna-mode)
|
|
1199 (if (fboundp 'canna-do-function)
|
|
1200 (setq res (canna-do-function canna-func-henkan)))
|
|
1201 (canna:display-candidates res) ))
|
|
1202
|
|
1203 ;;;
|
|
1204 ;;; $B%^!<%/%3%^%s%I!$(Bcanna-henkan-region-or-self-insert $B$G;H$&$+$b(B
|
|
1205 ;;;
|
|
1206
|
|
1207 (defun canna-set-mark-command (arg)
|
|
1208 "Besides setting mark, set mark as a HENKAN region if it is in\n\
|
|
1209 the japanese mode."
|
|
1210 (interactive "P")
|
|
1211 (set-mark-command arg)
|
|
1212 (if canna:*japanese-mode*
|
|
1213 (progn
|
|
1214 (setq canna:*use-region-as-henkan-region* t)
|
|
1215 (message "Mark set($BJQ49NN0h3+;O(B)") )))
|
|
1216
|
|
1217 (defun canna-henkan-region-or-self-insert (arg)
|
|
1218 "Do kana-to-kanji convert region if HENKAN region is defined,\n\
|
|
1219 self insert otherwise."
|
|
1220 (interactive "*p")
|
|
1221 (if (and canna:*use-region-as-henkan-region*
|
|
1222 ; (< (mark) (point))
|
|
1223 ; (not (save-excursion (beginning-of-line) (< (mark) (point)))) )
|
|
1224 (canna-without-newline (region-beginning) (region-end)))
|
|
1225 (progn
|
|
1226 (setq canna:*use-region-as-henkan-region* nil)
|
|
1227 (canna-henkan-region (region-beginning) (region-end)))
|
|
1228 (canna-self-insert-command arg) ))
|
|
1229
|
|
1230 ;;
|
|
1231 ;; for C-mode
|
|
1232 ;;
|
|
1233
|
|
1234 (defun canna-electric-c-terminator (arg)
|
|
1235 (interactive "P")
|
|
1236 (if canna:*japanese-mode*
|
|
1237 (canna-self-insert-command arg)
|
|
1238 (electric-c-terminator arg) ))
|
|
1239
|
|
1240 (defun canna-electric-c-semi (arg)
|
|
1241 (interactive "P")
|
|
1242 (if canna:*japanese-mode*
|
|
1243 (canna-self-insert-command arg)
|
|
1244 (electric-c-semi arg) ))
|
|
1245
|
|
1246 (defun canna-electric-c-brace (arg)
|
|
1247 (interactive "P")
|
|
1248 (if canna:*japanese-mode*
|
|
1249 (canna-self-insert-command arg)
|
|
1250 (electric-c-brace arg) ))
|
|
1251
|
|
1252 (defun canna-c-mode-hook ()
|
|
1253 (define-key c-mode-map "{" 'canna-electric-c-brace)
|
|
1254 (define-key c-mode-map "}" 'canna-electric-c-brace)
|
|
1255 (define-key c-mode-map ";" 'canna-electric-c-semi)
|
|
1256 (define-key c-mode-map ":" 'canna-electric-c-terminator) )
|
|
1257
|
|
1258 (defun canna-set-fence-mode-format (fence sep underline)
|
|
1259 (setq canna-with-fences fence)
|
|
1260 (canna-set-bunsetsu-kugiri sep)
|
|
1261 (setq canna-underline underline)
|
|
1262 )
|
|
1263
|
|
1264 ;; $B%j!<%8%g%s$K$"$k%m!<%^;z$r!X$+$s$J!Y$K?)$o$9!#(B
|
|
1265 ;; $B7k2L$H$7$F!"!X$+$s$J!Y$NFI$_%b!<%I$K$J$k!#(B
|
|
1266 ;; $B%j!<%8%g%s$KB8:_$7$F$$$k6uGrJ8;z$H@)8fJ8;z$O<N$F$i$l$k!#(B
|
|
1267
|
|
1268 (defun canna-rk-region (start end)
|
|
1269 "Convert region into kana."
|
|
1270 (interactive "*r")
|
|
1271 (let ((str nil) (len 0) (i 0) (res 0))
|
|
1272 (setq str (buffer-substring start end))
|
|
1273 (setq len (length str))
|
|
1274 (while (< i len)
|
|
1275 (let ((ch (elt str i)))
|
|
1276 (if (> ch ? )
|
|
1277 (setq res (canna-do-function canna-func-functional-insert ch)) ))
|
|
1278 (setq i (1+ i)) )
|
|
1279 res))
|
|
1280
|
|
1281 (defun canna-rk-trans-region (start end)
|
|
1282 "Insert alpha-numeric string as it is sent from keyboard."
|
|
1283 (interactive "*r")
|
|
1284 (let ((res))
|
|
1285 (setq res (canna-rk-region start end))
|
|
1286 (delete-region start end)
|
|
1287 (if (null canna:*japanese-mode*)
|
|
1288 (progn
|
|
1289 (setq canna:*exit-japanese-mode* t) ))
|
|
1290 (setq res (canna-do-function canna-func-henkan))
|
|
1291 (canna:enter-canna-mode)
|
|
1292 (canna:display-candidates res) ))
|
|
1293
|
|
1294 ;; $B%+!<%=%k$N:8$K$"$k(B arg $B%o!<%I$N%m!<%^;z$r!X$+$s$J!Y$K?)$o$9!#(B
|
|
1295
|
|
1296 (defun canna-rk-trans (arg)
|
|
1297 (interactive "*p")
|
|
1298 (let ((po (point)))
|
|
1299 (skip-chars-backward "-a-zA-Z.,?!~")
|
|
1300 (if (not (eq (point) po))
|
|
1301 (canna-rk-trans-region (point) po) )))
|
|
1302
|
|
1303 (defun canna-henkan-kakutei-and-self-insert (arg)
|
|
1304 (interactive "*p")
|
|
1305 (if canna:*japanese-mode*
|
|
1306 (canna-functional-insert-command arg)
|
|
1307 (progn
|
|
1308 (setq unread-command-events (list last-command-event))
|
|
1309 (canna-kakutei-to-basic-stat)) ))
|
|
1310
|
|
1311 (defun canna-kakutei-to-basic-stat ()
|
|
1312 (let ((res 0)
|
|
1313 (kakutei canna-henkan-string))
|
|
1314 (while (not canna-empty-info)
|
|
1315 ; (setq res (canna-key-proc ?\C-m)))
|
|
1316 (setq res (canna-do-function canna-func-kakutei)))
|
|
1317 (setq canna-kakutei-string kakutei)
|
|
1318 (canna:display-candidates (length canna-kakutei-string))
|
|
1319 (if (not canna:*japanese-mode*)
|
|
1320 (mode-line-canna-mode-update canna:*alpha-mode-string*))
|
|
1321 ))
|
|
1322
|
|
1323 (defun canna-minibuffer-henkan-kakutei-and-self-insert (arg)
|
|
1324 (interactive "p")
|
|
1325 (set-window-buffer (minibuffer-window) canna:*saved-minibuffer*)
|
|
1326 (select-window canna:*previous-window*)
|
|
1327 (if canna:*japanese-mode*
|
|
1328 (canna:functional-insert-command2 last-command-event arg)
|
|
1329 (progn
|
|
1330 (setq unread-command-events (list last-command-event))
|
|
1331 (canna-kakutei-to-basic-stat)) ))
|
|
1332
|
|
1333 (defun canna-setup-for-being-boiled ()
|
|
1334 (let ((ch (1+ ? )))
|
|
1335 (while (< ch 127)
|
|
1336 (define-key canna-mode-map (make-string 1 ch) 'canna-henkan-kakutei-and-self-insert)
|
|
1337 (define-key canna-minibuffer-mode-map (make-string 1 ch) 'canna-minibuffer-henkan-kakutei-and-self-insert)
|
|
1338 (setq ch (1+ ch)))))
|
|
1339
|
|
1340 (defvar rK-trans-key "\C-j" "for `boil' only")
|
|
1341 (make-variable-buffer-local 'rK-trans-key)
|
|
1342
|
|
1343 (defun canna-boil ()
|
|
1344 "`canna-boil' cooks `canna' as if `boil' does for `egg'."
|
|
1345 (interactive)
|
|
1346 (canna-setup-for-being-boiled)
|
|
1347 (local-set-key rK-trans-key 'canna-rk-trans)
|
|
1348 (message "boiled"))
|
|
1349
|
|
1350 ;;
|
|
1351 ;; $B?'$E$1$N$?$a$N4X?t(B
|
|
1352 ;;
|
|
1353 (defun canna:yomi-attr-on (start end)
|
|
1354 (if (overlayp canna:*yomi-overlay*)
|
|
1355 (move-overlay canna:*yomi-overlay* start end)
|
120
|
1356 (overlay-put (setq canna:*yomi-overlay* (make-overlay start end nil nil t))
|
70
|
1357 'face
|
|
1358 (if canna:color-p 'attr-yomi 'underline))
|
|
1359 )
|
|
1360 )
|
|
1361
|
|
1362 (defun canna:yomi-attr-off (start end);
|
|
1363 (and (overlayp canna:*yomi-overlay*)
|
|
1364 (delete-overlay canna:*yomi-overlay*)
|
|
1365 )
|
|
1366 )
|
|
1367
|
|
1368 (defun canna:henkan-attr-on (start end)
|
|
1369 (if (overlayp canna:*henkan-overlay*)
|
|
1370 (move-overlay canna:*henkan-overlay* start end)
|
120
|
1371 (overlay-put (setq canna:*henkan-overlay*
|
|
1372 (make-overlay start end nil nil t))
|
70
|
1373 'face
|
|
1374 (if canna:color-p 'attr-taishou 'region))
|
|
1375 )
|
|
1376 )
|
|
1377
|
|
1378 (defun canna:henkan-attr-off (start end)
|
|
1379 (and (overlayp canna:*henkan-overlay*)
|
|
1380 (delete-overlay canna:*henkan-overlay*)
|
|
1381 )
|
|
1382 )
|
|
1383
|
|
1384 (defun canna:select-attr-on (start end)
|
|
1385 (if (overlayp canna:*select-overlay*)
|
|
1386 (move-overlay canna:*select-overlay* start end)
|
120
|
1387 (overlay-put (setq canna:*select-overlay*
|
|
1388 (make-overlay start end nil nil t))
|
70
|
1389 'face
|
|
1390 'attr-select))
|
|
1391 )
|
|
1392
|
|
1393 (defun canna:select-attr-off (start end)
|
|
1394 (and (overlayp canna:*select-overlay*)
|
|
1395 (delete-overlay canna:*select-overlay*)
|
|
1396 )
|
|
1397 )
|
|
1398
|
120
|
1399
|
70
|
1400 (provide 'canna)
|
120
|
1401
|
|
1402 ;;; canna.el ends here
|