Mercurial > hg > xemacs-beta
comparison lisp/egg/egg.el @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | |
children | 0d2f883870bc |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
1 ;; Japanese Character Input Package for Egg | |
2 ;; Coded by S.Tomura, Electrotechnical Lab. (tomura@etl.go.jp) | |
3 | |
4 ;; This file is part of Egg on Mule (Multilingal Environment) | |
5 | |
6 ;; Egg is free software; you can redistribute it and/or modify | |
7 ;; it under the terms of the GNU General Public License as published by | |
8 ;; the Free Software Foundation; either version 2, or (at your option) | |
9 ;; any later version. | |
10 | |
11 ;; Egg is distributed in the hope that it will be useful, | |
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 ;; GNU General Public License for more details. | |
15 | |
16 ;; You should have received a copy of the GNU General Public License | |
17 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
18 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
19 | |
20 ;;;================================================================== | |
21 ;;; | |
22 ;;; $BF|K\8l4D6-(B $B!V$?$^$4!W(B $BBh#3HG(B | |
23 ;;; | |
24 ;;;=================================================================== | |
25 | |
26 ;;; | |
27 ;;;$B!V$?$^$4!W$O%M%C%H%o!<%/$+$J4A;zJQ49%5!<%P$rMxMQ$7!"(BMule $B$G$NF|K\(B | |
28 ;;; $B8l4D6-$rDs6!$9$k%7%9%F%`$G$9!#!V$?$^$4!WBh#2HG$G$O(B Wnn V3 $B$*$h$S(B | |
29 ;;; Wnn V4 $B$N$+$J4A;zJQ49%5!<%P$r;HMQ$7$F$$$^$9!#(B | |
30 ;;; | |
31 | |
32 ;;; $BL>A0$O(B $B!VBt;3(B/$BBT$?$;$F(B/$B$4$a$s$J$5$$!W$N3FJ8@a$N@hF,#12;$G$"$k!V$?!W(B | |
33 ;;; $B$H!V$^!W$H!V$4!W$r<h$C$F!"!V$?$^$4!W$H8@$$$^$9!#EE;R5;=QAm9g8&5f=j(B | |
34 ;;; $B$N6S8+(B $BH~5.;R;a$NL?L>$K0M$k$b$N$G$9!#(Begg $B$O!V$?$^$4!W$N1QLu$G$9!#(B | |
35 | |
36 ;;; | |
37 ;;; $B;HMQK!$O(B info/egg-jp $B$r8+$F2<$5$$!#(B | |
38 ;;; | |
39 | |
40 ;;; | |
41 ;;; $B!V$?$^$4!W$K4X$9$kDs0F!"Cn>pJs$O(B tomura@etl.go.jp $B$K$*Aw$j2<$5$$!#(B | |
42 ;;; | |
43 | |
44 ;;; | |
45 ;;; $B")(B 305 $B0q>k8)$D$/$P;TG_1`(B1-1-4 | |
46 ;;; $BDL;:>J9)6H5;=Q1!EE;R5;=QAm9g8&5f=j(B | |
47 ;;; $B>pJs%"!<%-%F%/%A%cIt8@8l%7%9%F%`8&5f<<(B | |
48 ;;; | |
49 ;;; $B8MB<(B $BE/(B | |
50 | |
51 ;;; | |
52 ;;; ($BCm0U(B)$B$3$N%U%!%$%k$O4A;z%3!<%I$r4^$s$G$$$^$9!#(B | |
53 ;;; | |
54 ;;; $BBh#3HG(B $B#1#9#9#1G/#27n(B $B#4F|(B | |
55 ;;; $BBh#2HG(B $B#1#9#8#9G/#67n(B $B#1F|(B | |
56 ;;; $BBh#1HG(B $B#1#9#8#8G/#77n#1#4F|(B | |
57 ;;; $B;CDjHG(B $B#1#9#8#8G/#67n#2#4F|(B | |
58 | |
59 ;;;=================================================================== | |
60 ;;; | |
61 ;;; (eval-when (load) (require 'wnn-client)) | |
62 ;;; | |
63 | |
64 (defvar egg-version "3.09" "Version number of this version of Egg. ") | |
65 ;;; Last modified date: Fri Sep 25 12:59:00 1992 | |
66 | |
67 ;;;; $B=$@5MW5a%j%9%H(B | |
68 | |
69 ;;;; read-hiragana-string, read-kanji-string $B$G;HMQ$9$kJ?2>L>F~NO%^%C%W$r(B roma-kana $B$K8GDj$7$J$$$GM_$7$$!%(B | |
70 | |
71 ;;;; $B=$@5%a%b(B | |
72 | |
73 ;;; 95.6.5 modified by S.Tomura <tomura@etl.go.jp> | |
74 ;;; $BJQ49D>8e$KO"B3$7$FJQ49$9$k>l9g$rG'<1$9$k$?$a$K!"(B"-in-cont" $B$K4XO"$7$?(B | |
75 ;;; $BItJ,$rDI2C$7$?!#!J$3$NItJ,$O>-Mh:F=$@5$9$kM=Dj!#!K(B | |
76 | |
77 ;;; 93.6.19 modified by T.Shingu <shingu@cpr.canon.co.jp> | |
78 ;;; egg:*in-fence-mode* should be buffer local. | |
79 | |
80 ;;; 93.6.4 modified by T.Shingu <shingu@cpr.canon.co.jp> | |
81 ;;; In its-defrule**, length is called instead of chars-in-string. | |
82 | |
83 ;;; 93.3.15 modified by T.Enami <enami@sys.ptg.sony.co.jp> | |
84 ;;; egg-self-insert-command simulates the original more perfectly. | |
85 | |
86 ;;; 92.12.20 modified by S.Tomura <tomura@etl.go.jp> | |
87 ;;; In its:simulate-input, sref is called instead of aref. | |
88 | |
89 ;;; 92.12.20 modified by T.Enami <enami@sys.ptg.sony.co.jp> | |
90 ;;; egg-self-insert-command calls cancel-undo-boundary to simulate original. | |
91 | |
92 ;;; 92.11.4 modified by M.Higashida <manabu@sigmath.osaka-u.ac.jp> | |
93 ;;; read-hiragana-string sets minibuffer-preprompt correctly. | |
94 | |
95 ;;; 92.10.26, 92.10.30 modified by T.Saneto sanewo@pdp.crl.sony.co.jp | |
96 ;;; typo fixed. | |
97 | |
98 ;;; 92.10.18 modified by K. Handa <handa@etl.go.jp> | |
99 ;;; special-symbol-input $BMQ$N%F!<%V%k$r(B autoload $B$K!#(B | |
100 ;;; busyu.el $B$N(B autoload $B$N;XDj$r(B mule-init.el $B$+$i(B egg.el $B$K0\$9!#(B | |
101 | |
102 ;;; 92.9.20 modified by S. Tomura | |
103 ;;;; hiragana-region $B$NCn$N=$@5(B | |
104 | |
105 ;;;; 92.9.19 modified by Y. Kawabe | |
106 ;;;; some typos | |
107 | |
108 ;;;; 92.9.19 modified by Y. Kawabe<kawabe@sramhc.sra.co.jp> | |
109 ;;;; menu $B$NI=<(4X78$N(B lenght $B$r(B string-width $B$KCV$-49$($k!%(B | |
110 | |
111 ;;; 92.8.19 modified for Mule Ver.0.9.6 by K.Handa <handa@etl.go.jp> | |
112 ;;;; menu:select-from-menu calls string-width instead of length. | |
113 | |
114 ;;;; 92.8.1 modified by S. Tomura | |
115 ;;;; internal mode $B$rDI2C!%(Bits:*internal-mode-alist* $BDI2C!%(B | |
116 | |
117 ;;;; 92.7.31 modified by S. Tomura | |
118 ;;;; its-mode-map $B$,(B super mode map $B$r;}$D$h$&$KJQ99$7$?!%$3$l$K$h$j(B | |
119 ;;;; mode map $B$,6&M-$G$-$k!%(B its-define-mode, get-next-map $B$J$I$rJQ99!%(B | |
120 ;;;; get-next-map-locally $B$rDI2C!%(Bits-defrule** $B$rJQ99!%(B | |
121 | |
122 ;;;; 92.7.31 modified by S. Tomura | |
123 ;;;; its:make-kanji-buffer , its:*kanji* $B4XO"%3!<%I$r:o=|$7$?!%(B | |
124 | |
125 ;;;; 92.7.31 modified by S. Tomura | |
126 ;;;; egg:select-window-hook $B$r=$@5$7!$(Bminibuffer $B$+$i(B exit $B$9$k$H$-$K!$(B | |
127 ;;;; $B3F<oJQ?t$r(B default-value $B$KLa$9$h$&$K$7$?!%$3$l$K$h$C$F(B | |
128 ;;;; minibufffer $B$KF~$kA0$K3F<o@_Dj$,2DG=$H$J$k!%(B | |
129 | |
130 ;;; 92.7.14 modified for Mule Ver.0.9.5 by T.Ito <toshi@his.cpl.melco.co.jp> | |
131 ;;; Attribute bold can be used. | |
132 ;;; Unnecessary '*' in comments of variables deleted. | |
133 ;;; 92.7.8 modified for Mule Ver.0.9.5 by Y.Kawabe <kawabe@sra.co.jp> | |
134 ;;; special-symbol-input keeps the position selected last. | |
135 ;;; 92.7.8 modified for Mule Ver.0.9.5 by T.Shingu <shingu@cpr.canon.co.jp> | |
136 ;;; busyu-input and kakusuu-input are added in *symbol-input-menu*. | |
137 ;;; 92.7.7 modified for Mule Ver.0.9.5 by K.Handa <handa@etl.go.jp> | |
138 ;;; In egg:quit-mode, overwrite-mode is supported correctly. | |
139 ;;; egg:*overwrite-mode-deleted-chars* is not used now. | |
140 ;;; 92.6.26 modified for Mule Ver.0.9.5 by K.Handa <handa@etl.go.jp> | |
141 ;;; Funtion dump-its-mode-map gets obsolete. | |
142 ;;; 92.6.26 modified for Mule Ver.0.9.5 by M.Shikida <shikida@cs.titech.ac.jp> | |
143 ;;; Backquote ` is registered in *hankaku-alist* and *zenkaku-alist*. | |
144 ;;; 92.6.17 modified for Mule Ver.0.9.5 by T.Shingu <shingu@cpr.canon.co.jp> | |
145 ;;; Bug in make-jis-second-level-code-alist fixed. | |
146 ;;; 92.6.14 modified for Mule Ver.0.9.5 by T.Enami <enami@sys.ptg.sony.co.jp> | |
147 ;;; menu:select-from-menu is replaced with new version. | |
148 ;;; 92.5.18 modified for Mule Ver.0.9.4 by T.Shingu <shingu@cpr.canon.co.jp> | |
149 ;;; lisp/wnn-egg.el is devided into two parts: this file and wnn*-egg.el. | |
150 | |
151 ;;;; | |
152 ;;;; Mule Ver.0.9.3 $B0JA0(B | |
153 ;;;; | |
154 | |
155 ;;;; April-15-92 for Mule Ver.0.9.3 | |
156 ;;;; by T.Enami <enami@sys.ptg.sony.co.jp> and K.Handa <handa@etl.go.jp> | |
157 ;;;; notify-internal calls 'message' with correct argument. | |
158 | |
159 ;;;; April-11-92 for Mule Ver.0.9.3 | |
160 ;;;; by T.Enami <enami@sys.ptg.sony.co.jp> and K.Handa <handa@etl.go.jp> | |
161 ;;;; minibuffer $B$+$iH4$1$k;~(B egg:select-window-hook $B$G(B egg:*input-mode* $B$r(B | |
162 ;;;; t $B$K$9$k!#(Bhook $B$N7A$rBgI}=$@5!#(B | |
163 | |
164 ;;;; April-3-92 for Mule Ver.0.9.2 by T.Enami <enami@sys.ptg.sony.co.jp> | |
165 ;;;; minibuffer $B$+$iH4$1$k;~(B egg:select-window-hook $B$,(B new-buffer $B$N(B | |
166 ;;;; egg:*mode-on* $B$J$I$r(B nil $B$K$7$F$$$k$N$r=$@5!#(B | |
167 | |
168 ;;;; Mar-22-92 by K.Handa | |
169 ;;;; etags $B$,:n$k(B TAGS $B$KITI,MW$J$b$N$rF~$l$J$$$h$&$K$9$k$?$a4X?tL>JQ99(B | |
170 ;;;; define-its-mode -> its-define-mode, defrule -> its-defrule | |
171 | |
172 ;;;; Mar-16-92 by K.Handa | |
173 ;;;; global-map $B$X$N(B define-key $B$r(B mule-keymap $B$KJQ99!#(B | |
174 | |
175 ;;;; Mar-13-92 by K.Handa | |
176 ;;;; Language specific part $B$r(B japanese.el,... $B$K0\$7$?!#(B | |
177 | |
178 ;;;; Feb-*-92 by K. Handa | |
179 ;;;; nemacs 4 $B$G$O(B minibuffer-window-selected $B$,GQ;_$K$J$j!$4XO"$9$k%3!<%I$r:o=|$7$?!%(B | |
180 | |
181 ;;;; Jan-13-92 by S. Tomura | |
182 ;;;; mc-emacs or nemacs 4 $BBP1~:n6H3+;O!%(B | |
183 | |
184 ;;;; Aug-9-91 by S. Tomura | |
185 ;;;; ?\^ $B$r(B ?^ $B$K=$@5!%(B | |
186 | |
187 ;;;; menu $B$r(B key map $B$r8+$k$h$&$K$9$k!%(B | |
188 | |
189 ;;;; Jul-6-91 by S. Tomura | |
190 ;;;; setsysdict $B$N(B error $B%a%C%;!<%8$rJQ99!%(B | |
191 | |
192 ;;;; Jun-11-91 by S. Tomura | |
193 ;;;; its:*defrule-verbose* $B$rDI2C!%(B | |
194 ;;;; | |
195 | |
196 ;;;; Mar-25-91 by S. Tomura | |
197 ;;;; reset-its-mode $B$rGQ;_(B | |
198 | |
199 ;;;; Mar-23-91 by S. Tomura | |
200 ;;;; read-hiragana-string $B$r=$@5!$(B read-kanji-string $B$rDI2C!$(B | |
201 ;;;; isearch:read-kanji-string $B$r@_Dj!%(B | |
202 | |
203 ;;;; Mar-22-91 by S. Tomura | |
204 ;;;; defrule-conditional, defrule-select-mode-temporally $B$rDI2C!#(B | |
205 ;;;; for-each $B$N4J0WHG$H$7$F(B dolist $B$rDI2C!#(B | |
206 ;;;; enable-double-n-syntax $B$r3hMQ!%$[$+$K(B use-kuten-for-comma, use-touten-for-period $B$rDI2C(B | |
207 | |
208 ;;;; Mar-5-91 by S. Tomura | |
209 ;;;; roma-kana-word, henkan-word, roma-kanji-word $B$rDI2C$7$?!%(B | |
210 | |
211 ;;;; Jan-14-91 by S. Tomura | |
212 ;;;; $BF~NOJ8;zJQ497O(B ITS(Input character Translation System) $B$r2~B$$9$k!%(B | |
213 ;;;; $BJQ49$O:G:8:GD9JQ49$r9T$J$$!$JQ49$N$J$$$b$N$O$b$H$N$^$^$H$J$k!%(B | |
214 ;;;; $B2~B$$NF05!$ON)LZ!w7D1~$5$s$N%O%s%0%kJ8;z$NF~NOMW5a$G$"$k!%(B | |
215 ;;;; its:* $B$rDI2C$7$?!%$^$?=>Mh(B fence-self-insert-command $B$H(B roma-kana-region | |
216 ;;;; $BFs2U=j$K$o$+$l$F$$$?%3!<%I$r(B its:translate-region $B$K$h$C$F0lK\2=$7$?!%(B | |
217 | |
218 ;;;; July-30-90 by S. Tomura | |
219 ;;;; henkan-region $B$r(Boverwrite-mode $B$KBP1~$5$;$k!%JQ?t(B | |
220 ;;;; egg:*henkan-fence-mode*, egg:*overwrite-mode-deleted-chars* | |
221 ;;;; $B$rDI2C$7!$(Bhenkan-fence-region, henkan-region-internal, | |
222 ;;;; quit-egg-mode $B$rJQ99$9$k!%(B | |
223 | |
224 ;;;; Mar-4-90 by K.Handa | |
225 ;;;; New variable alphabet-mode-indicator, transparent-mode-indicator, | |
226 ;;;; and henkan-mode-indicator. | |
227 | |
228 ;;;; Feb-27-90 by enami@ptgd.sony.co.jp | |
229 ;;;; menu:select-from-menu $B$G#22U=j$"$k(B ((and (<= ?0 ch) (<= ch ?9)... | |
230 ;;;; $B$N0lJ}$r(B ((and (<= ?0 ch) (<= ch ?9)... $B$K=$@5(B | |
231 | |
232 ;;;; Feb-07-89 | |
233 ;;;; bunsetu-length-henko $B$NCf$N(B egg:*attribute-off $B$N0LCV$r(B KKCP $B$r8F$VA0$K(B | |
234 ;;;; $BJQ99$9$k!#(B wnn-client $B$G$O(B KKCP $B$r8F$V$HJ8@a>pJs$,JQ2=$9$k!#(B | |
235 | |
236 ;;;; Feb-01-89 | |
237 ;;;; henkan-goto-kouho $B$N(B egg:set-bunsetu-attribute $B$N0z?t(B | |
238 ;;;; $B$N=gHV$,4V0c$C$F$$$?$N$r=$@5$7$?!#!J(Btoshi@isvax.isl.melco.co.jp | |
239 ;;;; (Toshiyuki Ito)$B$N;XE&$K$h$k!#!K(B | |
240 | |
241 ;;;; Dec-25-89 | |
242 ;;;; meta-flag t $B$N>l9g$NBP1~$r:F=$@5$9$k!#(B | |
243 ;;;; overwrite-mode $B$G$N(B undo $B$r2~A1$9$k!#(B | |
244 | |
245 ;;;; Dec-21-89 | |
246 ;;;; bug fixed by enami@ptdg.sony.co.jp | |
247 ;;;; (fboundp 'minibuffer-window-selected ) | |
248 ;;;; -->(boundp 'minibuffer-window-selected ) | |
249 ;;;; self-insert-after-hook $B$r(B buffer local $B$K$7$FDj5A$r(B kanji.el $B$X0\F0!#(B | |
250 | |
251 ;;;; Dec-15-89 | |
252 ;;;; kill-all-local-variables $B$NDj5A$r(B kanji.el $B$X0\F0$9$k!#(B | |
253 | |
254 ;;;; Dec-14-89 | |
255 ;;;; meta-flag t $B$N>l9g$N=hM}$r=$@5$9$k(B | |
256 ;;;; overwrite-mode $B$KBP1~$9$k!#(B | |
257 | |
258 ;;;; Dec-12-89 | |
259 ;;;; egg:*henkan-open*, egg:*henkan-close* $B$rDI2C!#(B | |
260 ;;;; egg:*henkan-attribute* $B$rDI2C(B | |
261 ;;;; set-egg-fence-mode-format, set-egg-henkan-mode-format $B$rDI2C(B | |
262 | |
263 ;;;; Dec-12-89 | |
264 ;;;; *bunpo-code* $B$K(B 1000: "$B$=$NB>(B" $B$rDI2C(B | |
265 | |
266 ;;;; Dec-11-89 | |
267 ;;;; egg:*fence-attribute* $B$r?7@_(B | |
268 ;;;; egg:*bunsetu-attribute* $B$r?7@_(B | |
269 | |
270 ;;;; Dec-11-89 | |
271 ;;;; attribute-*-region $B$rMxMQ$9$k$h$&$KJQ99$9$k!#(B | |
272 ;;;; menu:make-selection-list $B$O(B width $B$,>.$5$$;~$K(Bloop $B$9$k!#$3$l$r=$@5$7$?!#(B | |
273 | |
274 ;;;; Dec-10-89 | |
275 ;;;; set-marker-type $B$rMxMQ$9$kJ}<0$KJQ99!#(B | |
276 | |
277 ;;;; Dec-07-89 | |
278 ;;;; egg:search-path $B$rDI2C!#(B | |
279 ;;;; egg-default-startup-file $B$rDI2C$9$k!#(B | |
280 | |
281 ;;;; Nov-22-89 | |
282 ;;;; egg-startup-file $B$rDI2C$9$k!#(B | |
283 ;;;; eggrc-search-path $B$r(B egg-startup-file-search-path $B$KL>A0JQ99!#(B | |
284 | |
285 ;;;; Nov-21-89 | |
286 ;;;; Nemacs 3.2 $B$KBP1~$9$k!#(Bkanji-load* $B$rGQ;_$9$k!#(B | |
287 ;;;; wnnfns.c $B$KBP1~$7$?=$@5$r2C$($k!#(B | |
288 ;;;; *Notification* buffer $B$r8+$($J$/$9$k!#(B | |
289 | |
290 ;;;; Oct-2-89 | |
291 ;;;; *zenkaku-alist* $B$N(B $BJ8;zDj?t$N=q$-J}$,4V0c$C$F$$$?!#(B | |
292 | |
293 ;;;; Sep-19-89 | |
294 ;;;; toggle-egg-mode $B$N=$@5!J(Bkanji-flag$B!K(B | |
295 ;;;; egg-self-insert-command $B$N=$@5(B $B!J(Bkanji-flag$B!K(B | |
296 | |
297 ;;;; Sep-18-89 | |
298 ;;;; self-insert-after-hook $B$NDI2C(B | |
299 | |
300 ;;;; Sep-15-89 | |
301 ;;;; EGG:open-wnn bug fix | |
302 ;;;; provide wnn-egg feature | |
303 | |
304 ;;;; Sep-13-89 | |
305 ;;;; henkan-kakutei-before-point $B$r=$@5$7$?!#(B | |
306 ;;;; enter-fence-mode $B$NDI2C!#(B | |
307 ;;;; egg-exit-hook $B$NDI2C!#(B | |
308 ;;;; henkan-region-internal $B$NDI2C!#(Bhenkan-region$B$O(B point $B$r(Bmark $B$9$k!#(B | |
309 ;;;; eggrc-search-path $B$NDI2C!#(B | |
310 | |
311 ;;;; Aug-30-89 | |
312 ;;;; kanji-kanji-1st $B$rD{@5$7$?!#(B | |
313 | |
314 ;;;; May-30-89 | |
315 ;;;; EGG:open-wnn $B$O(B get-wnn-host-name $B$,(B nil $B$N>l9g!"(B(system-name) $B$r;HMQ$9$k!#(B | |
316 | |
317 ;;;; May-9-89 | |
318 ;;;; KKCP:make-directory added. | |
319 ;;;; KKCP:file-access bug fixed. | |
320 ;;;; set-default-usr-dic-directory modified. | |
321 | |
322 ;;;; Mar-16-89 | |
323 ;;;; minibuffer-window-selected $B$r;H$C$F(B minibuffer $B$N(B egg-mode$BI=<(5!G=DI2C(B | |
324 | |
325 ;;;; Mar-13-89 | |
326 ;;;; mode-line-format changed. | |
327 | |
328 ;;;; Feb-27-89 | |
329 ;;;; henkan-saishou-bunsetu added | |
330 ;;;; henkan-saichou-bunsetu added | |
331 ;;;; M-< henkan-saishou-bunsetu | |
332 ;;;; M-> henkan-saichou-bunsetu | |
333 | |
334 ;;;; Feb-14-89 | |
335 ;;;; C-h in henkan mode: help-command added | |
336 | |
337 ;;;; Feb-7-89 | |
338 ;;;; egg-insert-after-hook is added. | |
339 | |
340 ;;;; M-h fence-hiragana | |
341 ;;;; M-k fence-katakana | |
342 ;;;; M-> fence-zenkaku | |
343 ;;;; M-< fence-hankaku | |
344 | |
345 ;;;; Dec-19-88 henkan-hiragana, henkan-katakara$B$rDI2C!'(B | |
346 ;;;; M-h henkan-hiragana | |
347 ;;;; M-k henkan-katakana | |
348 | |
349 ;;;; Ver. 2.00 kana2kanji.c $B$r;H$o$:(B wnn-client.el $B$r;HMQ$9$k$h$&$KJQ99!#(B | |
350 ;;;; $B4XO"$7$F0lIt4X?t$rJQ99(B | |
351 | |
352 ;;;; Dec-2-88 special-symbol-input $B$rDI2C!((B | |
353 ;;;; C-^ special-symbol-input | |
354 | |
355 ;;;; Nov-18-88 henkan-mode-map $B0lItJQ99!((B | |
356 ;;;; M-i henkan-inspect-bunsetu | |
357 ;;;; M-s henkan-select-kouho | |
358 ;;;; C-g henkan-quit | |
359 | |
360 ;;;; Nov-18-88 jserver-henkan-kakutei $B$N;EMMJQ99$KH<$$!"(Bkakutei $B$N%3!<(B | |
361 ;;;; $B%I$rJQ99$7$?!#(B | |
362 | |
363 ;;;; Nov-17-88 kakutei-before-point $B$G(B point $B0J9_$N4V0c$C$?ItJ,$NJQ49(B | |
364 ;;;; $B$,IQEY>pJs$KEPO?$5$l$J$$$h$&$K=$@5$7$?!#$3$l$K$O(BKKCC:henkan-end | |
365 ;;;; $B$N0lIt;EMM$HBP1~$9$k(Bkana2kanji.c$B$bJQ99$7$?!#(B | |
366 | |
367 ;;;; Nov-17-88 henkan-inspect-bunsetu $B$rDI2C$7$?!#(B | |
368 | |
369 ;;;; Nov-17-88 $B?7$7$$(B kana2kanji.c $B$KJQ99$9$k!#(B | |
370 | |
371 ;;;; Sep-28-88 defrule$B$,CM$H$7$F(Bnil$B$rJV$9$h$&$KJQ99$7$?!#(B | |
372 | |
373 ;;;; Aug-25-88 $BJQ493X=,$r@5$7$/9T$J$&$h$&$KJQ99$7$?!#(B | |
374 ;;;; KKCP:henkan-kakutei$B$O(BKKCP:jikouho-list$B$r8F$s$@J8@a$KBP$7$F$N$_E,(B | |
375 ;;;; $BMQ$G$-!"$=$l0J30$N>l9g$N7k2L$OJ]>Z$5$l$J$$!#$3$N>r7o$rK~$?$9$h$&(B | |
376 ;;;; $B$K(BKKCP:jikouho-list$B$r8F$s$G$$$J$$J8@a$KBP$7$F$O(B | |
377 ;;;; KKCP:henkan-kakutei$B$r8F$P$J$$$h$&$K$7$?!#(B | |
378 | |
379 ;;;; Aug-25-88 egg:do-auto-fill $B$r=$@5$7!"J#?t9T$K$o$?$k(Bauto-fill$B$r@5(B | |
380 ;;;; $B$7$/9T$J$&$h$&$K=$@5$7$?!#(B | |
381 | |
382 ;;;; Aug-25-88 menu command$B$K(B\C-l: redraw $B$rDI2C$7$?!#(B | |
383 | |
384 ;;;; Aug-25-88 toroku-region$B$GEPO?$9$kJ8;zNs$+$i(Bno graphic character$B$r(B | |
385 ;;;; $B<+F0E*$K=|$/$3$H$K$7$?!#(B | |
386 | |
387 ;; XEmacs addition: (and remove disable-undo variable) | |
388 ;; For Emacs V18/Nemacs compatibility | |
389 (and (not (fboundp 'buffer-disable-undo)) | |
390 (fboundp 'buffer-flush-undo) | |
391 (defalias 'buffer-disable-undo 'buffer-flush-undo)) | |
392 | |
393 (eval-when-compile (require 'egg-jsymbol)) | |
394 | |
395 ;;;---------------------------------------------------------------------- | |
396 ;;; | |
397 ;;; Version control routine | |
398 ;;; | |
399 ;;;---------------------------------------------------------------------- | |
400 | |
401 (and (equal (user-full-name) "Satoru Tomura") | |
402 (defun egg-version-update (arg) | |
403 (interactive "P") | |
404 (if (equal (buffer-name (current-buffer)) "wnn-egg.el") | |
405 (save-excursion | |
406 (goto-char (point-min)) | |
407 (re-search-forward "(defvar egg-version \"[0-9]+\\.") | |
408 (let ((point (point)) | |
409 (minor)) | |
410 (search-forward "\"") | |
411 (backward-char 1) | |
412 (setq minor (string-to-int (buffer-substring point (point)))) | |
413 (delete-region point (point)) | |
414 (if (<= minor 8) (insert "0")) | |
415 (insert (int-to-string (1+ minor))) | |
416 (search-forward "Egg last modified date: ") | |
417 (kill-line) | |
418 (insert (current-time-string))) | |
419 (save-buffer) | |
420 (if arg (byte-compile-file (buffer-file-name))) | |
421 ))) | |
422 ) | |
423 ;;; | |
424 ;;;---------------------------------------------------------------------- | |
425 ;;; | |
426 ;;; Utilities | |
427 ;;; | |
428 ;;;---------------------------------------------------------------------- | |
429 | |
430 ;;; | |
431 ;;;; | |
432 | |
433 (defun characterp (form) | |
434 (numberp form)) | |
435 | |
436 (defun coerce-string (form) | |
437 (cond((stringp form) form) | |
438 ((characterp form) (char-to-string form)))) | |
439 | |
440 (defun coerce-internal-string (form) | |
441 (cond((stringp form) | |
442 (if (= (chars-in-string form) 1) | |
443 (string-to-char form) | |
444 form)) | |
445 ((characterp form) form))) | |
446 | |
447 ;;; kill-all-local-variables $B$+$iJ]8n$9$k(B local variables $B$r;XDj$G$-$k(B | |
448 ;;; $B$h$&$KJQ99$9$k!#(B | |
449 | |
450 (put 'egg:*input-mode* 'permanent-local t) | |
451 (put 'egg:*mode-on* 'permanent-local t) | |
452 (put 'its:*current-map* 'permanent-local t) | |
453 (put 'mode-line-egg-mode 'permanent-local t) | |
454 | |
455 ;;;---------------------------------------------------------------------- | |
456 ;;; | |
457 ;;; 16$B?JI=8=$N(BJIS $B4A;z%3!<%I$r(B minibuffer $B$+$iFI$_9~$`(B | |
458 ;;; | |
459 ;;;---------------------------------------------------------------------- | |
460 | |
461 ;;; | |
462 ;;; User entry: jis-code-input | |
463 ;;; | |
464 | |
465 (defun jis-code-input () | |
466 (interactive) | |
467 (insert-jis-code-from-minibuffer "JIS $B4A;z%3!<%I(B(16$B?J?tI=8=(B): ")) | |
468 | |
469 (defun insert-jis-code-from-minibuffer (prompt) | |
470 (let ((str (read-from-minibuffer prompt)) val) | |
471 (while (null (setq val (read-jis-code-from-string str))) | |
472 (beep) | |
473 (setq str (read-from-minibuffer prompt str))) | |
474 (insert (make-character lc-jp (car val) (cdr val))))) | |
475 | |
476 (defun hexadigit-value (ch) | |
477 (cond((and (<= ?0 ch) (<= ch ?9)) | |
478 (- ch ?0)) | |
479 ((and (<= ?a ch) (<= ch ?f)) | |
480 (+ (- ch ?a) 10)) | |
481 ((and (<= ?A ch) (<= ch ?F)) | |
482 (+ (- ch ?A) 10)))) | |
483 | |
484 (defun read-jis-code-from-string (str) | |
485 (if (and (= (length str) 4) | |
486 (<= 2 (hexadigit-value (aref str 0))) | |
487 (hexadigit-value (aref str 1)) | |
488 (<= 2 (hexadigit-value (aref str 2))) | |
489 (hexadigit-value (aref str 3))) | |
490 (cons (+ (* 16 (hexadigit-value (aref str 0))) | |
491 (hexadigit-value (aref str 1))) | |
492 (+ (* 16 (hexadigit-value (aref str 2))) | |
493 (hexadigit-value (aref str 3)))))) | |
494 | |
495 ;;;---------------------------------------------------------------------- | |
496 ;;; | |
497 ;;; $B!V$?$^$4!W(B Notification System | |
498 ;;; | |
499 ;;;---------------------------------------------------------------------- | |
500 | |
501 (defconst *notification-window* " *Notification* ") | |
502 | |
503 ;;;(defmacro notify (str &rest args) | |
504 ;;; (list 'notify-internal | |
505 ;;; (cons 'format (cons str args)))) | |
506 | |
507 (defun notify (str &rest args) | |
508 (notify-internal (apply 'format (cons str args)))) | |
509 | |
510 (defun notify-internal (message &optional noerase) | |
511 (save-excursion | |
512 (let ((notify-buff (get-buffer-create *notification-window*))) | |
513 (set-buffer notify-buff) | |
514 (goto-char (point-max)) | |
515 (setq buffer-read-only nil) | |
516 (insert (substring (current-time-string) 4 19) ":: " message ?\n ) | |
517 (setq buffer-read-only t) | |
518 (bury-buffer notify-buff) | |
519 (message "%s" message) ; 92.4.15 by T.Enami | |
520 (if noerase nil | |
521 (sleep-for 1) (message ""))))) | |
522 | |
523 ;;;(defmacro notify-yes-or-no-p (str &rest args) | |
524 ;;; (list 'notify-yes-or-no-p-internal | |
525 ;;; (cons 'format (cons str args)))) | |
526 | |
527 (defun notify-yes-or-no-p (str &rest args) | |
528 (notify-yes-or-no-p-internal (apply 'format (cons str args)))) | |
529 | |
530 (defun notify-yes-or-no-p-internal (message) | |
531 (save-window-excursion | |
532 (pop-to-buffer *notification-window*) | |
533 (goto-char (point-max)) | |
534 (setq buffer-read-only nil) | |
535 (insert (substring (current-time-string) 4 19) ":: " message ?\n ) | |
536 (setq buffer-read-only t) | |
537 (yes-or-no-p "$B$$$$$G$9$+!)(B"))) | |
538 | |
539 (defun notify-y-or-n-p (str &rest args) | |
540 (notify-y-or-n-p-internal (apply 'format (cons str args)))) | |
541 | |
542 (defun notify-y-or-n-p-internal (message) | |
543 (save-window-excursion | |
544 (pop-to-buffer *notification-window*) | |
545 (goto-char (point-max)) | |
546 (setq buffer-read-only nil) | |
547 (insert (substring (current-time-string) 4 19) ":: " message ?\n ) | |
548 (setq buffer-read-only t) | |
549 (y-or-n-p "$B$$$$$G$9$+!)(B"))) | |
550 | |
551 (defun select-notification () | |
552 (interactive) | |
553 (pop-to-buffer *notification-window*) | |
554 (setq buffer-read-only t)) | |
555 | |
556 ;;;---------------------------------------------------------------------- | |
557 ;;; | |
558 ;;; $B!V$?$^$4!W(B Menu System | |
559 ;;; | |
560 ;;;---------------------------------------------------------------------- | |
561 | |
562 ;;; | |
563 ;;; minibuffer $B$K(B menu $B$rI=<(!&A*Br$9$k(B | |
564 ;;; | |
565 | |
566 ;;; | |
567 ;;; menu $B$N;XDjJ}K!!'(B | |
568 ;;; | |
569 ;;; <menu item> ::= ( menu <prompt string> <menu-list> ) | |
570 ;;; <menu list> ::= ( <menu element> ... ) | |
571 ;;; <menu element> ::= ( <string> . <value> ) | <string> | |
572 ;;; ( <char> . <value> ) | <char> | |
573 | |
574 ;;; select-menu-in-minibuffer | |
575 | |
576 (defvar menu:*select-items* nil) | |
577 (defvar menu:*select-menus* nil) | |
578 (defvar menu:*select-item-no* nil) | |
579 (defvar menu:*select-menu-no* nil) | |
580 (defvar menu:*select-menu-stack* nil) | |
581 (defvar menu:*select-start* nil) | |
582 (defvar menu:*select-positions* nil) | |
583 | |
584 (defvar menu-mode-map (make-keymap)) | |
585 | |
586 (define-key menu-mode-map "\C-a" 'menu:begining-of-menu) | |
587 (define-key menu-mode-map "\C-e" 'menu:end-of-menu) | |
588 (define-key menu-mode-map "\C-f" 'menu:next-item) | |
589 (define-key menu-mode-map "\C-b" 'menu:previous-item) | |
590 (define-key menu-mode-map "\C-n" 'menu:next-item-old) | |
591 (define-key menu-mode-map "\C-g" 'menu:quit) | |
592 (define-key menu-mode-map "\C-p" 'menu:previous-item-old) | |
593 (define-key menu-mode-map "\C-l" 'menu:refresh) | |
594 ;;; 0 .. 9 a .. z A .. z | |
595 (define-key menu-mode-map "\C-m" 'menu:select) | |
596 (define-key menu-mode-map [return] 'menu:select) | |
597 (define-key menu-mode-map [left] 'menu:previous-item) | |
598 (define-key menu-mode-map [right] 'menu:next-item) | |
599 (define-key menu-mode-map [up] 'menu:previous-item-old) | |
600 (define-key menu-mode-map [down] 'menu:next-item-old) | |
601 | |
602 ;; 92.6.14 by T.Enami -- This function was completely modified. | |
603 (defun menu:select-from-menu (menu &optional initial position) | |
604 (let ((echo-keystrokes 0) | |
605 (inhibit-quit t) | |
606 (menubuffer (get-buffer-create " *menu*")) | |
607 (minibuffer (window-buffer (minibuffer-window))) | |
608 value) | |
609 (save-window-excursion | |
610 (if (fboundp 'redirect-frame-focus) | |
611 (redirect-frame-focus (selected-frame) | |
612 (window-frame (minibuffer-window)))) | |
613 (set-window-buffer (minibuffer-window) menubuffer) | |
614 (select-window (minibuffer-window)) | |
615 (set-buffer menubuffer) | |
616 (delete-region (point-min) (point-max)) | |
617 (insert (nth 1 menu)) | |
618 (let* ((window-width (window-width (selected-window))) | |
619 (finished nil)) | |
620 (setq menu:*select-menu-stack* nil | |
621 menu:*select-positions* nil | |
622 menu:*select-start* (point) | |
623 menu:*select-menus* | |
624 (menu:make-selection-list (nth 2 menu) | |
625 (- window-width | |
626 ;;; 92.8.19 by K.Handa | |
627 (string-width (nth 1 menu))))) | |
628 ;; 92.7.8 by Y.Kawabe | |
629 (cond | |
630 ((and (numberp initial) | |
631 (<= 0 initial) | |
632 (< initial (length (nth 2 menu)))) | |
633 (menu:select-goto-item-position initial)) | |
634 ((and (listp initial) (car initial) | |
635 (<= 0 (car initial)) | |
636 (< (car initial) (length (nth 2 menu)))) | |
637 (menu:select-goto-item-position (car initial)) | |
638 (while (and (setq initial (cdr initial)) | |
639 (setq value (menu:item-value (nth menu:*select-item-no* | |
640 menu:*select-items*))) | |
641 (listp value) (eq (car value) 'menu)) | |
642 (setq menu:*select-positions* | |
643 (cons (menu:select-item-position) menu:*select-positions*)) | |
644 (setq menu:*select-menu-stack* | |
645 (cons (list menu:*select-items* menu:*select-menus* | |
646 menu:*select-item-no* menu:*select-menu-no* | |
647 menu) | |
648 menu:*select-menu-stack*)) | |
649 (setq menu value) | |
650 (delete-region (point-min) (point-max)) (insert (nth 1 menu)) | |
651 (setq menu:*select-start* (point)) | |
652 (setq menu:*select-menus* | |
653 (menu:make-selection-list | |
654 ;;; 92.9.19 by Y. Kawabe | |
655 (nth 2 menu) (- window-width (string-width (nth 1 menu))))) | |
656 (if (and (numberp (car initial)) | |
657 (<= 0 (car initial)) | |
658 (< (car initial) (length (nth 2 menu)))) | |
659 (menu:select-goto-item-position (car initial)) | |
660 (setq menu:*select-item-no* 0) | |
661 (menu:select-goto-menu 0))) | |
662 (setq value nil)) | |
663 (t | |
664 (setq menu:*select-item-no* 0) | |
665 (menu:select-goto-menu 0)) | |
666 ) | |
667 ;; end of patch | |
668 (while (not finished) | |
669 (let ((ch (read-event))) | |
670 (setq quit-flag nil) | |
671 (cond | |
672 ((eq ch ?\C-a) | |
673 (menu:select-goto-item 0)) | |
674 ((eq ch ?\C-e) | |
675 (menu:select-goto-item (1- (length menu:*select-items*)))) | |
676 ((or (eq ch ?\C-f) (eq ch 'right)) | |
677 ;;(menu:select-goto-item (1+ menu:*select-item-no*)) | |
678 (menu:select-next-item) | |
679 ) | |
680 ((or (eq ch ?\C-b) (eq ch 'left)) | |
681 ;;(menu:select-goto-item (1- menu:*select-item-no*)) | |
682 (menu:select-previous-item) | |
683 ) | |
684 ((or (eq ch ?\C-n) (eq ch 'down)) | |
685 (menu:select-goto-menu (1+ menu:*select-menu-no*))) | |
686 ((eq ch ?\C-g) | |
687 (if menu:*select-menu-stack* | |
688 (let ((save (car menu:*select-menu-stack*))) | |
689 (setq menu:*select-menu-stack* | |
690 (cdr menu:*select-menu-stack*)) | |
691 (setq menu:*select-items* (nth 0 save);92.10.26 by T.Saneto | |
692 menu:*select-menus* (nth 1 save) | |
693 menu:*select-item-no* (nth 2 save) | |
694 menu:*select-menu-no* (nth 3 save) | |
695 menu (nth 4 save)) | |
696 (setq menu:*select-positions* | |
697 (cdr menu:*select-positions*)) | |
698 (delete-region (point-min) (point-max)) | |
699 (insert (nth 1 menu)) | |
700 (setq menu:*select-start* (point)) | |
701 (menu:select-goto-menu menu:*select-menu-no*) | |
702 (menu:select-goto-item menu:*select-item-no*) | |
703 ) | |
704 (setq finished t | |
705 value nil))) | |
706 ((or (eq ch ?\C-p) (eq ch 'up)) | |
707 (menu:select-goto-menu (1- menu:*select-menu-no*))) | |
708 ((eq ch ?\C-l) ;;; redraw menu | |
709 (menu:select-goto-menu menu:*select-menu-no*)) | |
710 ((and (numberp ch) (<= ?0 ch) (<= ch ?9) | |
711 (<= ch (+ ?0 (1- (length menu:*select-items*))))) | |
712 (menu:select-goto-item (- ch ?0))) | |
713 ((and (numberp ch) (<= ?a ch) (<= ch ?z) | |
714 (<= (+ 10 ch) (+ ?a (1- (length menu:*select-items*))))) | |
715 (menu:select-goto-item (+ 10 (- ch ?a)))) | |
716 ((and (numberp ch) (<= ?A ch) (<= ch ?Z) | |
717 (<= (+ 10 ch) (+ ?A (1- (length menu:*select-items*))))) | |
718 (menu:select-goto-item (+ 10 (- ch ?A)))) | |
719 ((or (eq ch ?\C-m) (eq ch 'return)) | |
720 (setq value (menu:item-value (nth menu:*select-item-no* | |
721 menu:*select-items*))) | |
722 (setq menu:*select-positions* | |
723 (cons (menu:select-item-position) | |
724 menu:*select-positions*)) | |
725 (if (and (listp value) | |
726 (eq (car value) 'menu)) | |
727 (progn | |
728 (setq menu:*select-menu-stack* | |
729 (cons | |
730 (list menu:*select-items* menu:*select-menus* | |
731 menu:*select-item-no* menu:*select-menu-no* | |
732 menu) | |
733 menu:*select-menu-stack*)) | |
734 (setq menu value) | |
735 (delete-region (point-min) (point-max)) | |
736 (insert (nth 1 menu)) | |
737 (setq menu:*select-start* (point)) | |
738 (setq menu:*select-menus* | |
739 ;;; 92.9.19 by Y. Kawabe | |
740 (menu:make-selection-list | |
741 (nth 2 menu) | |
742 (- window-width | |
743 (string-width (nth 1 menu))))) | |
744 (setq menu:*select-item-no* 0) | |
745 (menu:select-goto-menu 0) | |
746 (setq value nil) | |
747 ) | |
748 (setq finished t))) | |
749 (t (beep)))))) | |
750 (delete-region (point-min) (point-max)) | |
751 (setq menu:*select-positions* | |
752 (nreverse menu:*select-positions*)) | |
753 (set-window-buffer (minibuffer-window) minibuffer) | |
754 (if (null value) | |
755 (setq quit-flag t) | |
756 (if position | |
757 (cons value menu:*select-positions*) | |
758 value))))) | |
759 | |
760 (defun menu:select-item-position () | |
761 (let ((p 0) (m 0)) | |
762 (while (< m menu:*select-menu-no*) | |
763 (setq p (+ p (length (nth m menu:*select-menus*)))) | |
764 (setq m (1+ m))) | |
765 (+ p menu:*select-item-no*))) | |
766 | |
767 (defun menu:select-goto-item-position (pos) | |
768 (let ((m 0) (i 0) (p 0)) | |
769 (while (<= (+ p (length (nth m menu:*select-menus*))) pos) | |
770 (setq p (+ p (length (nth m menu:*select-menus*)))) | |
771 (setq m (1+ m))) | |
772 (setq menu:*select-item-no* (- pos p)) | |
773 (menu:select-goto-menu m))) | |
774 | |
775 (defun menu:select-goto-menu (no) | |
776 (setq menu:*select-menu-no* | |
777 (check-number-range no 0 (1- (length menu:*select-menus*)))) | |
778 (setq menu:*select-items* (nth menu:*select-menu-no* menu:*select-menus*)) | |
779 (delete-region menu:*select-start* (point-max)) | |
780 (if (<= (length menu:*select-items*) menu:*select-item-no*) | |
781 (setq menu:*select-item-no* (1- (length menu:*select-items*)))) | |
782 (goto-char menu:*select-start*) | |
783 (let ((l menu:*select-items*) (i 0)) | |
784 (while l | |
785 (insert (if (<= i 9) (format " %d." i) | |
786 (format " %c." (+ (- i 10) ?a))) | |
787 (menu:item-string (car l))) | |
788 (setq l (cdr l) | |
789 i (1+ i)))) | |
790 (menu:select-goto-item menu:*select-item-no*)) | |
791 | |
792 (defun menu:select-goto-item (no) | |
793 (setq menu:*select-item-no* | |
794 (check-number-range no 0 | |
795 (1- (length menu:*select-items*)))) | |
796 (let ((p (+ 2 menu:*select-start*)) (i 0)) | |
797 (while (< i menu:*select-item-no*) | |
798 (setq p (+ p (length (menu:item-string (nth i menu:*select-items*))) 4)) | |
799 (setq i (1+ i))) | |
800 (goto-char p))) | |
801 | |
802 (defun menu:select-next-item () | |
803 (if (< menu:*select-item-no* (1- (length menu:*select-items*))) | |
804 (menu:select-goto-item (1+ menu:*select-item-no*)) | |
805 (progn | |
806 (setq menu:*select-item-no* 0) | |
807 (menu:select-goto-menu (1+ menu:*select-menu-no*))))) | |
808 | |
809 (defun menu:select-previous-item () | |
810 (if (< 0 menu:*select-item-no*) | |
811 (menu:select-goto-item (1- menu:*select-item-no*)) | |
812 (progn | |
813 (setq menu:*select-item-no* 1000) | |
814 (menu:select-goto-menu (1- menu:*select-menu-no*))))) | |
815 | |
816 (defvar menu:*display-item-value* nil) | |
817 | |
818 (defun menu:item-string (item) | |
819 (cond((stringp item) item) | |
820 ((numberp item) (char-to-string item)) | |
821 ((consp item) | |
822 (if menu:*display-item-value* | |
823 (format "%s [%s]" | |
824 (cond ((stringp (car item)) (car item)) | |
825 ((numberp (car item)) (char-to-string (car item))) | |
826 (t "")) | |
827 (cdr item)) | |
828 (cond ((stringp (car item)) | |
829 (car item)) | |
830 ((numberp (car item)) | |
831 (char-to-string (car item))) | |
832 (t "")))) | |
833 (t ""))) | |
834 | |
835 (defun menu:item-value (item) | |
836 (cond((stringp item) item) | |
837 (t (cdr item)))) | |
838 | |
839 (defun menu:make-selection-list (items width) | |
840 (let ((whole nil) (line nil) (size 0)) | |
841 (while items | |
842 ;;; 92.9.19 by Y. Kawabe | |
843 (if (<= width (+ size 4 (string-width (menu:item-string(car items))))) | |
844 (if line | |
845 (setq whole (cons (reverse line) whole) | |
846 line nil | |
847 size 0) | |
848 (setq whole (cons (list (car items)) whole) | |
849 size 0 | |
850 items (cdr items))) | |
851 ;;; 92.9.19 by Y. Kawabe | |
852 (setq line (cons (car items) line) | |
853 size (+ size 4 (string-width(menu:item-string (car items)))) | |
854 items (cdr items)))) | |
855 (if line | |
856 (reverse (cons (reverse line) whole)) | |
857 (reverse whole)))) | |
858 | |
859 | |
860 ;;;---------------------------------------------------------------------- | |
861 ;;; | |
862 ;;; $B0l3g7?JQ495!G=(B | |
863 ;;; | |
864 ;;;---------------------------------------------------------------------- | |
865 | |
866 (defvar ascii-char "[\40-\176]") | |
867 | |
868 (defvar ascii-space "[ \t]") | |
869 (defvar ascii-symbols "[\40-\57\72-\100\133-\140\173-\176]") | |
870 (defvar ascii-numeric "[\60-\71]") | |
871 (defvar ascii-English-Upper "[\101-\132]") | |
872 (defvar ascii-English-Lower "[\141-\172]") | |
873 | |
874 (defvar ascii-alphanumeric "[\60-\71\101-\132\141-\172]") | |
875 | |
876 (defvar kanji-char "\\cj") | |
877 (defvar kanji-space "$B!!(B") | |
878 (defvar kanji-symbols "\\cS") | |
879 (defvar kanji-numeric "[$B#0(B-$B#9(B]") | |
880 (defvar kanji-English-Upper "[$B#A(B-$B#Z(B]") | |
881 (defvar kanji-English-Lower "[$B#a(B-$B#z(B]") | |
882 ;;; Bug fixed by Yoshida@CSK on 88-AUG-24 | |
883 (defvar kanji-hiragana "\\cH") | |
884 (defvar kanji-katakana "\\cK") | |
885 ;;; | |
886 (defvar kanji-Greek-Upper "[$B&!(B-$B&8(B]") | |
887 (defvar kanji-Greek-Lower "[$B&A(B-$B&X(B]") | |
888 (defvar kanji-Russian-Upper "[$B'!(B-$B'A(B]") | |
889 (defvar kanji-Russian-Lower "[$B'Q(B-$B'q(B]") | |
890 (defvar kanji-Kanji-1st-Level "[$B0!(B-$BOS(B]") | |
891 (defvar kanji-Kanji-2nd-Level "[$BP!(B-$Bt$(B]") | |
892 | |
893 (defvar kanji-kanji-char "\\(\\cH\\|\\cK\\|\\cC\\)") | |
894 | |
895 (defvar aletter (concat "\\(" ascii-char "\\|" kanji-char "\\)")) | |
896 | |
897 ;;; | |
898 ;;; $B$R$i$,$JJQ49(B | |
899 ;;; | |
900 | |
901 (defun hiragana-region (start end) | |
902 (interactive "r") | |
903 (goto-char start) | |
904 (while (re-search-forward kanji-katakana end end) | |
905 (let ((ch (preceding-char))) | |
906 (cond( (<= ch ?$B%s(B) | |
907 (delete-char -1) | |
908 (insert (make-character lc-jp ?\244 (char-component ch 2)))))))) | |
909 | |
910 (defun hiragana-paragraph () | |
911 "hiragana paragraph at or after point." | |
912 (interactive ) | |
913 (save-excursion | |
914 (forward-paragraph) | |
915 (let ((end (point))) | |
916 (backward-paragraph) | |
917 (hiragana-region (point) end )))) | |
918 | |
919 (defun hiragana-sentence () | |
920 "hiragana sentence at or after point." | |
921 (interactive ) | |
922 (save-excursion | |
923 (forward-sentence) | |
924 (let ((end (point))) | |
925 (backward-sentence) | |
926 (hiragana-region (point) end )))) | |
927 | |
928 ;;; | |
929 ;;; $B%+%?%+%JJQ49(B | |
930 ;;; | |
931 | |
932 (defun katakana-region (start end) | |
933 (interactive "r") | |
934 (let ((point (point))) | |
935 (goto-char start) | |
936 (while (re-search-forward kanji-hiragana end end) | |
937 (let ((ch (char-component (preceding-char) 2))) | |
938 (delete-char -1) | |
939 (insert (make-character lc-jp ?\245 ch)))))) | |
940 | |
941 (defun katakana-paragraph () | |
942 "katakana paragraph at or after point." | |
943 (interactive ) | |
944 (save-excursion | |
945 (forward-paragraph) | |
946 (let ((end (point))) | |
947 (backward-paragraph) | |
948 (katakana-region (point) end )))) | |
949 | |
950 (defun katakana-sentence () | |
951 "katakana sentence at or after point." | |
952 (interactive ) | |
953 (save-excursion | |
954 (forward-sentence) | |
955 (let ((end (point))) | |
956 (backward-sentence) | |
957 (katakana-region (point) end )))) | |
958 | |
959 ;;; | |
960 ;;; $BH>3QJQ49(B | |
961 ;;; | |
962 | |
963 (defun hankaku-region (start end) | |
964 (interactive "r") | |
965 (save-restriction | |
966 (narrow-to-region start end) | |
967 (goto-char (point-min)) | |
968 (while (re-search-forward "\\cS\\|\\cA" (point-max) (point-max)) | |
969 (let* ((ch (preceding-char)) | |
970 (ch1 (char-component ch 1)) | |
971 (ch2 (char-component ch 2))) | |
972 (cond ((= ?\241 ch1) | |
973 (let ((val (cdr (assq ch2 *hankaku-alist*)))) | |
974 (if val (progn | |
975 (delete-char -1) | |
976 (insert val))))) | |
977 ((= ?\243 ch1) | |
978 (delete-char -1) | |
979 (insert (- ch2 ?\200 )))))))) | |
980 | |
981 (defun hankaku-paragraph () | |
982 "hankaku paragraph at or after point." | |
983 (interactive ) | |
984 (save-excursion | |
985 (forward-paragraph) | |
986 (let ((end (point))) | |
987 (backward-paragraph) | |
988 (hankaku-region (point) end )))) | |
989 | |
990 (defun hankaku-sentence () | |
991 "hankaku sentence at or after point." | |
992 (interactive ) | |
993 (save-excursion | |
994 (forward-sentence) | |
995 (let ((end (point))) | |
996 (backward-sentence) | |
997 (hankaku-region (point) end )))) | |
998 | |
999 (defun hankaku-word (arg) | |
1000 (interactive "p") | |
1001 (let ((start (point))) | |
1002 (forward-word arg) | |
1003 (hankaku-region start (point)))) | |
1004 | |
1005 (defvar *hankaku-alist* | |
1006 '(( 161 . ?\ ) | |
1007 ( 170 . ?\! ) | |
1008 ( 201 . ?\" ) | |
1009 ( 244 . ?\# ) | |
1010 ( 240 . ?\$ ) | |
1011 ( 243 . ?\% ) | |
1012 ( 245 . ?\& ) | |
1013 ( 199 . ?\' ) | |
1014 ( 202 . ?\( ) | |
1015 ( 203 . ?\) ) | |
1016 ( 246 . ?\* ) | |
1017 ( 220 . ?\+ ) | |
1018 ( 164 . ?\, ) | |
1019 ( 221 . ?\- ) | |
1020 ( 165 . ?\. ) | |
1021 ( 191 . ?\/ ) | |
1022 ( 167 . ?\: ) | |
1023 ( 168 . ?\; ) | |
1024 ( 227 . ?\< ) | |
1025 ( 225 . ?\= ) | |
1026 ( 228 . ?\> ) | |
1027 ( 169 . ?\? ) | |
1028 ( 247 . ?\@ ) | |
1029 ( 206 . ?\[ ) | |
1030 ( 239 . ?\\ ) | |
1031 ( 207 . ?\] ) | |
1032 ( 176 . ?^ ) | |
1033 ( 178 . ?\_ ) | |
1034 ( 208 . ?\{ ) | |
1035 ( 195 . ?\| ) | |
1036 ( 209 . ?\} ) | |
1037 ( 177 . ?\~ ) | |
1038 ( 198 . ?` ) ; 92.6.26 by M.Shikida | |
1039 )) | |
1040 | |
1041 ;;; | |
1042 ;;; $BA43QJQ49(B | |
1043 ;;; | |
1044 | |
1045 (defun zenkaku-region (start end) | |
1046 (interactive "r") | |
1047 (save-restriction | |
1048 (narrow-to-region start end) | |
1049 (goto-char (point-min)) | |
1050 (while (re-search-forward "[ -~]" (point-max) (point-max)) | |
1051 (let ((ch (preceding-char))) | |
1052 (if (and (<= ? ch) (<= ch ?~)) | |
1053 (progn | |
1054 (delete-char -1) | |
1055 (let ((zen (cdr (assq ch *zenkaku-alist*)))) | |
1056 (if zen (insert zen) | |
1057 (insert (make-character lc-jp ?\243 (+ ?\200 ch))))))))))) | |
1058 | |
1059 (defun zenkaku-paragraph () | |
1060 "zenkaku paragraph at or after point." | |
1061 (interactive ) | |
1062 (save-excursion | |
1063 (forward-paragraph) | |
1064 (let ((end (point))) | |
1065 (backward-paragraph) | |
1066 (zenkaku-region (point) end )))) | |
1067 | |
1068 (defun zenkaku-sentence () | |
1069 "zenkaku sentence at or after point." | |
1070 (interactive ) | |
1071 (save-excursion | |
1072 (forward-sentence) | |
1073 (let ((end (point))) | |
1074 (backward-sentence) | |
1075 (zenkaku-region (point) end )))) | |
1076 | |
1077 (defun zenkaku-word (arg) | |
1078 (interactive "p") | |
1079 (let ((start (point))) | |
1080 (forward-word arg) | |
1081 (zenkaku-region start (point)))) | |
1082 | |
1083 (defvar *zenkaku-alist* | |
1084 '((? . "$B!!(B") | |
1085 (?! . "$B!*(B") | |
1086 (?\" . "$B!I(B") | |
1087 (?# . "$B!t(B") | |
1088 (?$ . "$B!p(B") | |
1089 (?% . "$B!s(B") | |
1090 (?& . "$B!u(B") | |
1091 (?' . "$B!G(B") | |
1092 (?( . "$B!J(B") | |
1093 (?) . "$B!K(B") | |
1094 (?* . "$B!v(B") | |
1095 (?+ . "$B!\(B") | |
1096 (?, . "$B!$(B") | |
1097 (?- . "$B!](B") | |
1098 (?. . "$B!%(B") | |
1099 (?/ . "$B!?(B") | |
1100 (?: . "$B!'(B") | |
1101 (?\; . "$B!((B") | |
1102 (?< . "$B!c(B") | |
1103 (?= . "$B!a(B") | |
1104 (?> . "$B!d(B") | |
1105 (?? . "$B!)(B") | |
1106 (?@ . "$B!w(B") | |
1107 (?[ . "$B!N(B") | |
1108 (?\\ . "$B!o(B") | |
1109 (?] . "$B!O(B") | |
1110 (?^ . "$B!0(B") | |
1111 (?_ . "$B!2(B") | |
1112 (?{ . "$B!P(B") | |
1113 (?| . "$B!C(B") | |
1114 (?} . "$B!Q(B") | |
1115 (?~ . "$B!1(B") | |
1116 (?` . "$B!F(B"))) ; 92.6.26 by M.Shikida | |
1117 | |
1118 ;;; | |
1119 ;;; $B%m!<%^;z$+$JJQ49(B | |
1120 ;;; | |
1121 | |
1122 (defun roma-kana-region (start end ) | |
1123 (interactive "r") | |
1124 (its:translate-region start end nil (its:get-mode-map "roma-kana"))) | |
1125 | |
1126 (defun roma-kana-paragraph () | |
1127 "roma-kana paragraph at or after point." | |
1128 (interactive ) | |
1129 (save-excursion | |
1130 (forward-paragraph) | |
1131 (let ((end (point))) | |
1132 (backward-paragraph) | |
1133 (roma-kana-region (point) end )))) | |
1134 | |
1135 (defun roma-kana-sentence () | |
1136 "roma-kana sentence at or after point." | |
1137 (interactive ) | |
1138 (save-excursion | |
1139 (forward-sentence) | |
1140 (let ((end (point))) | |
1141 (backward-sentence) | |
1142 (roma-kana-region (point) end )))) | |
1143 | |
1144 (defun roma-kana-word () | |
1145 "roma-kana word at or after point." | |
1146 (interactive) | |
1147 (save-excursion | |
1148 (re-search-backward "\\b\\w" nil t) | |
1149 (let ((start (point))) | |
1150 (re-search-forward "\\w\\b" nil t) | |
1151 (roma-kana-region start (point))))) | |
1152 | |
1153 ;;; | |
1154 ;;; $B%m!<%^;z4A;zJQ49(B | |
1155 ;;; | |
1156 | |
1157 (defun roma-kanji-region (start end) | |
1158 (interactive "r") | |
1159 (roma-kana-region start end) | |
1160 (save-restriction | |
1161 (narrow-to-region start (point)) | |
1162 (goto-char (point-min)) | |
1163 (replace-regexp "\\($B!!(B\\| \\)" "") | |
1164 (goto-char (point-max))) | |
1165 (henkan-region-internal start (point))) | |
1166 | |
1167 (defun roma-kanji-paragraph () | |
1168 "roma-kanji paragraph at or after point." | |
1169 (interactive ) | |
1170 (save-excursion | |
1171 (forward-paragraph) | |
1172 (let ((end (point))) | |
1173 (backward-paragraph) | |
1174 (roma-kanji-region (point) end )))) | |
1175 | |
1176 (defun roma-kanji-sentence () | |
1177 "roma-kanji sentence at or after point." | |
1178 (interactive ) | |
1179 (save-excursion | |
1180 (forward-sentence) | |
1181 (let ((end (point))) | |
1182 (backward-sentence) | |
1183 (roma-kanji-region (point) end )))) | |
1184 | |
1185 (defun roma-kanji-word () | |
1186 "roma-kanji word at or after point." | |
1187 (interactive) | |
1188 (save-excursion | |
1189 (re-search-backward "\\b\\w" nil t) | |
1190 (let ((start (point))) | |
1191 (re-search-forward "\\w\\b" nil t) | |
1192 (roma-kanji-region start (point))))) | |
1193 | |
1194 | |
1195 ;;;---------------------------------------------------------------------- | |
1196 ;;; | |
1197 ;;; $B!V$?$^$4!WF~NOJ8;zJQ497O(B ITS | |
1198 ;;; | |
1199 ;;;---------------------------------------------------------------------- | |
1200 | |
1201 (defun egg:member (elt list) | |
1202 (while (not (or (null list) (equal elt (car list)))) | |
1203 (setq list (cdr list))) | |
1204 list) | |
1205 | |
1206 ;;; | |
1207 ;;; Mode name --> map | |
1208 ;;; | |
1209 ;;; ITS mode name: string | |
1210 | |
1211 (defvar its:*mode-alist* nil) | |
1212 (defvar its:*internal-mode-alist* nil) | |
1213 | |
1214 (defun its:get-mode-map (name) | |
1215 (or (cdr (assoc name its:*mode-alist*)) | |
1216 (cdr (assoc name its:*internal-mode-alist*)))) | |
1217 | |
1218 (defun its:set-mode-map (name map &optional internalp) | |
1219 (let ((place (assoc name | |
1220 (if internalp its:*internal-mode-alist* | |
1221 its:*mode-alist*)))) | |
1222 (if place (let ((mapplace (cdr place))) | |
1223 (setcar mapplace (car map)) | |
1224 (setcdr mapplace (cdr map))) | |
1225 (progn (setq place (cons name map)) | |
1226 (if internalp | |
1227 (setq its:*internal-mode-alist* | |
1228 (append its:*internal-mode-alist* (list place))) | |
1229 (setq its:*mode-alist* | |
1230 (append its:*mode-alist* (list place)))))))) | |
1231 | |
1232 ;;; | |
1233 ;;; ITS mode indicators | |
1234 ;;; Mode name --> indicator | |
1235 ;;; | |
1236 | |
1237 (defun its:get-mode-indicator (name) | |
1238 (let ((map (its:get-mode-map name))) | |
1239 (if map (map-indicator map) | |
1240 name))) | |
1241 | |
1242 (defun its:set-mode-indicator (name indicator) | |
1243 (let ((map (its:get-mode-map name))) | |
1244 (if map | |
1245 (map-set-indicator map indicator) | |
1246 (its-define-mode name indicator)))) | |
1247 | |
1248 ;;; | |
1249 ;;; ITS mode declaration | |
1250 ;;; | |
1251 | |
1252 (defvar its:*processing-map* nil) | |
1253 | |
1254 (defun its-define-mode (name &optional indicator reset supers internalp) | |
1255 "its-mode NAME $B$rDj5AA*Br$9$k!%B>$N(B its-mode $B$,A*Br$5$l$k$^$G$O(B | |
1256 its-defrule $B$J$I$O(B NAME $B$KBP$7$F5,B'$rDI2C$9$k!%(BINDICATOR $B$,(B non-nil | |
1257 $B$N;~$K$O(B its-mode NAME $B$rA*Br$9$k$H(B mode-line $B$KI=<($5$l$k!%(BRESET $B$,(B | |
1258 non-nil $B$N;~$K$O(B its-mode $B$NDj5A$,6u$K$J$k!%(BSUPERS $B$O>e0L$N(B its-mode | |
1259 $BL>$r%j%9%H$G;XDj$9$k!%(BINTERNALP $B$O(B mode name $B$rFbItL>$H$9$k!%(B | |
1260 its-defrule, its-defrule-conditional, defule-select-mode-temporally $B$r(B | |
1261 $B;2>H(B" | |
1262 | |
1263 (if (null(its:get-mode-map name)) | |
1264 (progn | |
1265 (setq its:*processing-map* | |
1266 (make-map nil (or indicator name) nil (mapcar 'its:get-mode-map supers))) | |
1267 (its:set-mode-map name its:*processing-map* internalp) | |
1268 ) | |
1269 (progn (setq its:*processing-map* (its:get-mode-map name)) | |
1270 (if indicator | |
1271 (map-set-indicator its:*processing-map* indicator)) | |
1272 (if reset | |
1273 (progn | |
1274 (map-set-state its:*processing-map* nil) | |
1275 (map-set-alist its:*processing-map* nil) | |
1276 )) | |
1277 (if supers | |
1278 (progn | |
1279 (map-set-supers its:*processing-map* (mapcar 'its:get-mode-map supers)))))) | |
1280 nil) | |
1281 | |
1282 ;;; | |
1283 ;;; defrule related utilities | |
1284 ;;; | |
1285 | |
1286 (put 'for-each 'lisp-indent-hook 1) | |
1287 | |
1288 (defmacro for-each (vars &rest body) | |
1289 "(for-each ((VAR1 LIST1) ... (VARn LISTn)) . BODY) $B$OJQ?t(B VAR1 $B$NCM(B | |
1290 $B$r%j%9%H(B LIST1 $B$NMWAG$KB+G{$7!$!%!%!%JQ?t(B VARn $B$NCM$r%j%9%H(B LISTn $B$NMW(B | |
1291 $BAG$KB+G{$7$F(B BODY $B$r<B9T$9$k!%(B" | |
1292 | |
1293 (for-each* vars (cons 'progn body))) | |
1294 | |
1295 (defun for-each* (vars body) | |
1296 (cond((null vars) body) | |
1297 (t (let((tvar (make-symbol "temp")) | |
1298 (var (car (car vars))) | |
1299 (val (car (cdr (car vars))))) | |
1300 (list 'let (list (list tvar val) | |
1301 var) | |
1302 (list 'while tvar | |
1303 (list 'setq var (list 'car tvar)) | |
1304 (for-each* (cdr vars) body) | |
1305 (list 'setq tvar (list 'cdr tvar)))))))) | |
1306 | |
1307 (put 'dolist 'lisp-indent-hook 1) | |
1308 | |
1309 (defmacro dolist (pair &rest body) | |
1310 "(dolist (VAR LISTFORM) . BODY) $B$O(BVAR $B$K=g<!(B LISTFORM $B$NMWAG$rB+G{$7(B | |
1311 $B$F(B BODY $B$r<B9T$9$k(B" | |
1312 | |
1313 (for-each* (list pair) (cons 'progn body))) | |
1314 | |
1315 ;;; | |
1316 ;;; defrule | |
1317 ;;; | |
1318 | |
1319 (defun its:make-standard-action (output next) | |
1320 "OUTPUT $B$H(B NEXT $B$+$i$J$k(B standard-action $B$r:n$k!%(B" | |
1321 | |
1322 (if (and (stringp output) (string-equal output "")) | |
1323 (setq output nil)) | |
1324 (if (and (stringp next) (string-equal next "")) | |
1325 (setq next nil)) | |
1326 (cond((null output) | |
1327 (cond ((null next) nil) | |
1328 (t (list nil next)))) | |
1329 ((consp output) | |
1330 ;;; alternative output | |
1331 (list (cons 0 output) next)) | |
1332 ((null next) output) | |
1333 (t | |
1334 (list output next)))) | |
1335 | |
1336 (defun its:standard-actionp (action) | |
1337 "ACITION $B$,(B standard-action $B$G$"$k$+$I$&$+$rH=Dj$9$k!%(B" | |
1338 (or (stringp action) | |
1339 (and (consp action) | |
1340 (or (stringp (car action)) | |
1341 (and (consp (car action)) | |
1342 (numberp (car (car action)))) | |
1343 (null (car action))) | |
1344 (or (null (car (cdr action))) | |
1345 (stringp (car (cdr action))))))) | |
1346 | |
1347 (defvar its:make-terminal-state 'its:default-make-terminal-state | |
1348 "$B=*C<$N>uBV$G$NI=<($r:n@.$9$k4X?t$r;XDj$9$k(B. $B4X?t$O(B map input | |
1349 action state $B$r0z?t$H$7$F8F$P$l!$>uBVI=<($NJ8;zNs$rJV$9!%(B") | |
1350 | |
1351 (defun its:default-make-terminal-state (map input action state) | |
1352 (cond(state state) | |
1353 (t input))) | |
1354 | |
1355 (defun its:make-terminal-state-hangul (map input action state) | |
1356 (cond((its:standard-actionp action) (action-output action)) | |
1357 (t nil))) | |
1358 | |
1359 (defvar its:make-non-terminal-state 'its:default-make-standard-non-terminal-state | |
1360 "$BHs=*C<$N>uBV$G$NI=<($r:n@.$9$k4X?t$r;XDj$9$k!%4X?t$O(B map input $B$r(B | |
1361 $B0z?t$H$7$F8F$P$l!$>uBVI=<($NJ8;zNs$rJV$9(B" ) | |
1362 | |
1363 (defun its:default-make-standard-non-terminal-state (map input) | |
1364 " ****" | |
1365 (concat | |
1366 (map-state-string map) | |
1367 (char-to-string (aref input (1- (length input)))))) | |
1368 | |
1369 (defun its-defrule (input output &optional next state map) | |
1370 | |
1371 "INPUT $B$,F~NO$5$l$k$H(B OUTPUT $B$KJQ49$9$k!%(BNEXT $B$,(B nil $B$G$J$$$H$-$OJQ(B | |
1372 $B49$7$?8e$K(B NEXT $B$,F~NO$5$l$?$h$&$KJQ49$rB3$1$k!%(BINPUT$B$,F~NO$5$l$?;~E@(B | |
1373 $B$GJQ49$,3NDj$7$F$$$J$$;~$O(B STATE $B$r%U%'%s%9>e$KI=<($9$k!%JQ49$,3NDj$7(B | |
1374 $B$F$$$J$$;~$KI=<($9$kJ8;zNs$OJQ?t(B its:make-terminal-state $B$*$h$S(B $BJQ?t(B | |
1375 its:make-non-terminal-state $B$K;X<($5$l$?4X?t$K$h$C$F@8@.$5$l$k!%JQ495,(B | |
1376 $BB'$O(B MAP $B$G;XDj$5$l$?JQ49I=$KEPO?$5$l$k!%(BMAP $B$,(B nil $B$N>l9g$O$b$C$H$b:G(B | |
1377 $B6a$K(B its-define-mode $B$5$l$?JQ49I=$KEPO?$5$l$k!%$J$*(B OUTPUT $B$,(B nil $B$N>l(B | |
1378 $B9g$O(B INPUT $B$KBP$9$kJQ495,B'$,:o=|$5$l$k!%(B" | |
1379 | |
1380 (its-defrule* input | |
1381 (its:make-standard-action output next) state | |
1382 (if (stringp map) map | |
1383 its:*processing-map*))) | |
1384 | |
1385 (defmacro its-defrule-conditional (input &rest conds) | |
1386 "(its-defrule-conditional INPUT ((COND1 OUTPUT1) ... (CONDn OUTPUTn)))$B$O(B | |
1387 INPUT $B$,F~NO$5$l$?;~$K>r7o(B CONDi $B$r=g<!D4$Y!$@.N)$7$?;~$K$O(B OUTPUTi $B$r(B | |
1388 $B=PNO$9$k!%(B" | |
1389 (list 'its-defrule* input (list 'quote (cons 'cond conds)))) | |
1390 | |
1391 (defmacro its-defrule-conditional* (input state map &rest conds) | |
1392 "(its-defrule-conditional INPUT STATE MAP ((COND1 OUTPUT1) ... (CONDn | |
1393 OUTPUTn)))$B$O(B INPUT $B$,F~NO$5$l$?;~$K>uBV(B STATE $B$rI=<($7!$>r7o(B CONDi $B$r(B | |
1394 $B=g<!D4$Y!$@.N)$7$?;~$K$O(B OUTPUTi $B$r=PNO$9$k!%(B" | |
1395 (list 'its-defrule* input (list 'quote (cons 'cond conds)) state map)) | |
1396 | |
1397 (defun its-defrule-select-mode-temporally (input name) | |
1398 "INPUT $B$,F~NO$5$l$k$H(B temporally-mode $B$H$7$F(B NAME $B$,A*Br$5$l$k!%(B" | |
1399 | |
1400 (its-defrule* input (list 'quote (list 'its:select-mode-temporally name)))) | |
1401 | |
1402 (defun its-defrule* (input action &optional state map) | |
1403 (its:resize (length input)) | |
1404 (setq map (cond((stringp map) (its:get-mode-map map)) | |
1405 ((null map) its:*processing-map*) | |
1406 (t map))) | |
1407 (its-defrule** 0 input action state map) | |
1408 map) | |
1409 | |
1410 (defvar its:*defrule-verbose* t "nil$B$N>l9g(B, its-defrule $B$N7Y9p$rM^@)$9$k(B") | |
1411 | |
1412 (defun its-defrule** (i input action state map) | |
1413 (cond((= (length input) i) ;93.6.4 by T.Shingu | |
1414 (map-set-state | |
1415 map | |
1416 (coerce-internal-string | |
1417 (funcall its:make-terminal-state map input action state))) | |
1418 (if (and its:*defrule-verbose* (map-action map)) | |
1419 (if action | |
1420 (notify "(its-defrule \"%s\" \"%s\" ) $B$r:FDj5A$7$^$7$?!%(B" | |
1421 input action) | |
1422 (notify "(its-defrule \"%s\" \"%s\" )$B$r:o=|$7$^$7$?!%(B" | |
1423 input (map-action map)))) | |
1424 (if (and (null action) (map-terminalp map)) nil | |
1425 (progn (map-set-action map action) | |
1426 map))) | |
1427 (t | |
1428 (let((newmap | |
1429 (or (get-next-map-locally map (sref input i)) | |
1430 (make-map (funcall its:make-non-terminal-state | |
1431 map | |
1432 (substring input 0 (+ i (char-bytes (sref input i))))))))) | |
1433 (set-next-map map (sref input i) | |
1434 (its-defrule** (+ i (char-bytes (sref input i))) input action state newmap))) | |
1435 (if (and (null (map-action map)) | |
1436 (map-terminalp map)) | |
1437 nil | |
1438 map)))) | |
1439 | |
1440 ;;; | |
1441 ;;; map: | |
1442 ;;; | |
1443 ;;; <map-alist> ::= ( ( <char> . <map> ) ... ) | |
1444 ;;; <topmap> ::= ( nil <indicator> <map-alist> <supers> ) | |
1445 ;;; <supers> ::= ( <topmap> .... ) | |
1446 ;;; <map> ::= ( <state> <action> <map-alist> ) | |
1447 ;;; <action> ::= <output> | ( <output> <next> ) .... | |
1448 | |
1449 (defun make-map (&optional state action alist supers) | |
1450 (list state action alist supers)) | |
1451 | |
1452 (defun map-topmap-p (map) | |
1453 (null (map-state map))) | |
1454 | |
1455 (defun map-supers (map) | |
1456 (nth 3 map)) | |
1457 | |
1458 (defun map-set-supers (map val) | |
1459 (setcar (nthcdr 3 map) val)) | |
1460 | |
1461 (defun map-terminalp (map) | |
1462 (null (map-alist map))) | |
1463 | |
1464 (defun map-state (map) | |
1465 (nth 0 map)) | |
1466 | |
1467 (defun map-state-string (map) | |
1468 (coerce-string (map-state map))) | |
1469 | |
1470 (defun map-set-state (map val) | |
1471 (setcar (nthcdr 0 map) val)) | |
1472 | |
1473 (defun map-indicator (map) | |
1474 (map-action map)) | |
1475 (defun map-set-indicator (map indicator) | |
1476 (map-set-action map indicator)) | |
1477 | |
1478 (defun map-action (map) | |
1479 (nth 1 map)) | |
1480 (defun map-set-action (map val) | |
1481 (setcar (nthcdr 1 map) val)) | |
1482 | |
1483 (defun map-alist (map) | |
1484 (nth 2 map)) | |
1485 | |
1486 (defun map-set-alist (map alist) | |
1487 (setcar (nthcdr 2 map) alist)) | |
1488 | |
1489 (defun get-action (map) | |
1490 (if (null map) nil | |
1491 (let ((action (map-action map))) | |
1492 (cond((its:standard-actionp action) | |
1493 action) | |
1494 ((symbolp action) (condition-case nil | |
1495 (funcall action) | |
1496 (error nil))) | |
1497 (t (condition-case nil | |
1498 (eval action) | |
1499 (error nil))))))) | |
1500 | |
1501 (defun action-output (action) | |
1502 (cond((stringp action) action) | |
1503 (t (car action)))) | |
1504 | |
1505 (defun action-next (action) | |
1506 (cond((stringp action) nil) | |
1507 (t (car (cdr action))))) | |
1508 | |
1509 (defun get-next-map (map ch) | |
1510 (or (cdr (assq ch (map-alist map))) | |
1511 (if (map-topmap-p map) | |
1512 (let ((supers (map-supers map)) | |
1513 (result nil)) | |
1514 (while supers | |
1515 (setq result (get-next-map (car supers) ch)) | |
1516 (if result | |
1517 (setq supers nil) | |
1518 (setq supers (cdr supers)))) | |
1519 result)))) | |
1520 | |
1521 (defun get-next-map-locally (map ch) | |
1522 (cdr (assq ch (map-alist map)))) | |
1523 | |
1524 (defun set-next-map (map ch val) | |
1525 (let ((place (assq ch (map-alist map)))) | |
1526 (if place | |
1527 (if val | |
1528 (setcdr place val) | |
1529 (map-set-alist map (delq place (map-alist map)))) | |
1530 (if val | |
1531 (map-set-alist map (cons (cons ch val) | |
1532 (map-alist map))) | |
1533 val)))) | |
1534 | |
1535 (defun its:simple-actionp (action) | |
1536 (stringp action)) | |
1537 | |
1538 (defun collect-simple-action (map) | |
1539 (if (map-terminalp map) | |
1540 (if (its:simple-actionp (map-action map)) | |
1541 (list (map-action map)) | |
1542 nil) | |
1543 (let ((alist (map-alist map)) | |
1544 (result nil)) | |
1545 (while alist | |
1546 (setq result | |
1547 ;;; 92.9.19 by Y. Kawabe | |
1548 (append (collect-simple-action (cdr (car alist))) | |
1549 result)) | |
1550 (setq alist (cdr alist))) | |
1551 result))) | |
1552 | |
1553 ;;;---------------------------------------------------------------------- | |
1554 ;;; | |
1555 ;;; Runtime translators | |
1556 ;;; | |
1557 ;;;---------------------------------------------------------------------- | |
1558 | |
1559 (defun its:simulate-input (i j input map) | |
1560 (while (<= i j) | |
1561 (setq map (get-next-map map (sref input i))) ;92.12.26 by S.Tomura | |
1562 (setq i (+ i (char-bytes (sref input i))))) ;92.12.26 by S.Tomura | |
1563 map) | |
1564 | |
1565 ;;; meta-flag $B$,(B on $B$N;~$K$O!"F~NO%3!<%I$K(B \200 $B$r(B or $B$7$?$b$N$,F~NO$5(B | |
1566 ;;; $B$l$k!#$3$NItJ,$N;XE&$OEl9)Bg$NCf@n(B $B5.G7$5$s$K$h$k!#(B | |
1567 ;;; pointted by nakagawa@titisa.is.titech.ac.jp Dec-11-89 | |
1568 ;;; | |
1569 ;;; emacs $B$G$O(B $BJ8;z%3!<%I$O(B 0-127 $B$G07$&!#(B | |
1570 ;;; | |
1571 | |
1572 (defvar its:*buff-s* (make-marker)) | |
1573 (defvar its:*buff-e* (set-marker-type (make-marker) t)) | |
1574 | |
1575 ;;; STATE unread | |
1576 ;;; |<-s p->|<- e ->| | |
1577 ;;; s : ch0 state0 map0 | |
1578 ;;; +1: ch1 state1 map1 | |
1579 ;;; .... | |
1580 ;;; (point): | |
1581 | |
1582 ;;; longest matching region : [s m] | |
1583 ;;; suspending region: [m point] | |
1584 ;;; unread region : [point e] | |
1585 | |
1586 | |
1587 (defvar its:*maxlevel* 10) | |
1588 (defvar its:*maps* (make-vector its:*maxlevel* nil)) | |
1589 (defvar its:*actions* (make-vector its:*maxlevel* nil)) | |
1590 (defvar its:*inputs* (make-vector its:*maxlevel* 0)) | |
1591 (defvar its:*level* 0) | |
1592 | |
1593 (defun its:resize (size) | |
1594 (if (<= its:*maxlevel* size) | |
1595 (setq its:*maxlevel* size | |
1596 its:*maps* (make-vector size nil) | |
1597 its:*actions* (make-vector size nil) | |
1598 its:*inputs* (make-vector size 0)))) | |
1599 | |
1600 (defun its:reset-maps (&optional init) | |
1601 (setq its:*level* 0) | |
1602 (if init | |
1603 (aset its:*maps* its:*level* init))) | |
1604 | |
1605 (defun its:current-map () (aref its:*maps* its:*level*)) | |
1606 (defun its:previous-map () (aref its:*maps* (max 0 (1- its:*level*)))) | |
1607 | |
1608 (defun its:level () its:*level*) | |
1609 | |
1610 (defun its:enter-newlevel (map ch output) | |
1611 (setq its:*level* (1+ its:*level*)) | |
1612 (aset its:*maps* its:*level* map) | |
1613 (aset its:*inputs* its:*level* ch) | |
1614 (aset its:*actions* its:*level* output)) | |
1615 | |
1616 (defvar its:*char-from-buff* nil) | |
1617 (defvar its:*interactive* t) | |
1618 | |
1619 (defun its:reset-input () | |
1620 (setq its:*char-from-buff* nil)) | |
1621 | |
1622 (defun its:flush-input-before-point (from) | |
1623 (save-excursion | |
1624 (while (<= from its:*level*) | |
1625 (its:insert-char (aref its:*inputs* from)) | |
1626 (setq from (1+ from))))) | |
1627 | |
1628 (defun its:peek-char () | |
1629 (if (= (point) its:*buff-e*) | |
1630 (if its:*interactive* | |
1631 (setq unread-command-events (list (read-event))) | |
1632 nil) | |
1633 (following-char))) | |
1634 | |
1635 (defun its:read-char () | |
1636 (if (= (point) its:*buff-e*) | |
1637 (progn | |
1638 (setq its:*char-from-buff* nil) | |
1639 (if its:*interactive* | |
1640 (read-event) | |
1641 nil)) | |
1642 (let ((ch (following-char))) | |
1643 (setq its:*char-from-buff* t) | |
1644 (delete-char 1) | |
1645 ch))) | |
1646 | |
1647 (defun its:push-char (ch) | |
1648 (if its:*char-from-buff* | |
1649 (save-excursion | |
1650 (its:insert-char ch)) | |
1651 (if ch (setq unread-command-events (list ch))))) | |
1652 | |
1653 (defun its:insert-char (ch) | |
1654 (insert ch)) | |
1655 | |
1656 (defun its:ordinal-charp (ch) | |
1657 (and (numberp ch) (<= ch 127) | |
1658 (eq (lookup-key fence-mode-map (char-to-string ch)) 'fence-self-insert-command))) | |
1659 | |
1660 (defun its:delete-charp (ch) | |
1661 (and (numberp ch) (<= ch 127) | |
1662 (eq (lookup-key fence-mode-map (char-to-string ch)) 'fence-backward-delete-char))) | |
1663 | |
1664 (defun fence-self-insert-command () | |
1665 (interactive) | |
1666 (cond((or (not egg:*input-mode*) | |
1667 (null (get-next-map its:*current-map* last-command-event))) | |
1668 (insert last-command-event)) | |
1669 (t | |
1670 (insert last-command-event) | |
1671 (its:translate-region (1- (point)) (point) t)))) | |
1672 | |
1673 ;;; | |
1674 ;;; its: completing-read system | |
1675 ;;; | |
1676 | |
1677 (defun its:all-completions (string alist &optional pred) | |
1678 "A variation of all-completions.\n\ | |
1679 Arguments are STRING, ALIST and optional PRED. ALIST must be no obarray." | |
1680 (let ((tail alist) (allmatches nil)) | |
1681 (while tail | |
1682 (let* ((elt (car tail)) | |
1683 (eltstring (car elt))) | |
1684 (setq tail (cdr tail)) | |
1685 (if (and (stringp eltstring) | |
1686 (<= (length string) (length eltstring)) | |
1687 ;;;(not (= (aref eltstring 0) ? )) | |
1688 (string-equal string (substring eltstring 0 (length string)))) | |
1689 (if (or (and pred | |
1690 (if (if (eq pred 'commandp) | |
1691 (commandp elt) | |
1692 (funcall pred elt)))) | |
1693 (null pred)) | |
1694 (setq allmatches (cons elt allmatches)))))) | |
1695 (nreverse allmatches))) | |
1696 | |
1697 (defun its:temp-echo-area-contents (message) | |
1698 (let ((inhibit-quit inhibit-quit) | |
1699 (point-max (point-max))) | |
1700 (goto-char point-max) | |
1701 (insert message) | |
1702 (goto-char point-max) | |
1703 (setq inhibit-quit t) | |
1704 (sit-for 2 nil) | |
1705 ;;; 92.9.19 by Y. Kawabe, 92.10.30 by T.Saneto | |
1706 (delete-region (point) (point-max)) | |
1707 (if quit-flag | |
1708 (progn | |
1709 (setq quit-flag nil) | |
1710 (setq unread-command-events (list ?\^G)))))) | |
1711 | |
1712 (defun car-string-lessp (item1 item2) | |
1713 (string-lessp (car item1) (car item2))) | |
1714 | |
1715 (defun its:minibuffer-completion-help () | |
1716 "Display a list of possible completions of the current minibuffer contents." | |
1717 (interactive) | |
1718 (let ((completions)) | |
1719 (message "Making completion list...") | |
1720 (setq completions (its:all-completions (buffer-string) | |
1721 minibuffer-completion-table | |
1722 minibuffer-completion-predicate)) | |
1723 (if (null completions) | |
1724 (progn | |
1725 ;;; 92.9.19 by Y. Kawabe | |
1726 (beep) | |
1727 (its:temp-echo-area-contents " [No completions]")) | |
1728 (with-output-to-temp-buffer "*Completions*" | |
1729 (display-completion-list | |
1730 (sort completions 'car-string-lessp)))) | |
1731 nil)) | |
1732 | |
1733 (defconst its:minibuffer-local-completion-map | |
1734 (copy-keymap minibuffer-local-completion-map)) | |
1735 (define-key its:minibuffer-local-completion-map "?" 'its:minibuffer-completion-help) | |
1736 (define-key its:minibuffer-local-completion-map " " 'its:minibuffer-completion-help) | |
1737 | |
1738 (defconst its:minibuffer-local-must-match-map | |
1739 (copy-keymap minibuffer-local-must-match-map)) | |
1740 (define-key its:minibuffer-local-must-match-map "?" 'its:minibuffer-completion-help) | |
1741 (define-key its:minibuffer-local-must-match-map " " 'its:minibuffer-completion-help) | |
1742 | |
1743 (fset 'si:all-completions (symbol-function 'all-completions)) | |
1744 (fset 'si:minibuffer-completion-help (symbol-function 'minibuffer-completion-help)) | |
1745 | |
1746 (defun its:completing-read (prompt table &optional predicate require-match initial-input) | |
1747 "See completing-read" | |
1748 (let ((minibuffer-local-completion-map its:minibuffer-local-completion-map) | |
1749 (minibuffer-local-must-match-map its:minibuffer-local-must-match-map) | |
1750 (completion-auto-help nil)) | |
1751 (completing-read prompt table predicate t initial-input))) | |
1752 | |
1753 (defvar its:*completing-input-menu* '(menu "Which?" nil)) ;92.10.26 by T.Saneto | |
1754 | |
1755 (defun its:completing-input (map) | |
1756 ;;; | |
1757 (let ((action (get-action map))) | |
1758 (cond((and (null action) | |
1759 (= (length (map-alist map)) 1)) | |
1760 (its:completing-input (cdr (nth 0 (map-alist map))))) | |
1761 (t | |
1762 (setcar (nthcdr 2 its:*completing-input-menu*) | |
1763 (map-alist map)) | |
1764 (let ((values | |
1765 (menu:select-from-menu its:*completing-input-menu* | |
1766 0 t))) | |
1767 (cond((consp values) | |
1768 ;;; get input char from menu | |
1769 ) | |
1770 (t | |
1771 (its:completing-input map)))))))) | |
1772 | |
1773 (defvar its:*make-menu-from-map-result* nil) | |
1774 | |
1775 (defun its:make-menu-from-map (map) | |
1776 (let ((its:*make-menu-from-map-result* nil)) | |
1777 (its:make-menu-from-map* map "") | |
1778 (list 'menu "Which?" (reverse its:*make-menu-from-map-result*) ))) | |
1779 | |
1780 (defun its:make-menu-from-map* (map string) | |
1781 (let ((action (get-action map))) | |
1782 (if action | |
1783 (setq its:*make-menu-from-map-result* | |
1784 (cons (format "%s[%s]" string (action-output action)) | |
1785 its:*make-menu-from-map-result*))) | |
1786 (let ((alist (map-alist map))) | |
1787 (while alist | |
1788 (its:make-menu-from-map* | |
1789 (cdr (car alist)) | |
1790 (concat string (char-to-string (car (car alist))))) | |
1791 (setq alist (cdr alist)))))) | |
1792 | |
1793 (defvar its:*make-alist-from-map-result* nil) | |
1794 | |
1795 (defun its:make-alist-from-map (map &optional string) | |
1796 (let ((its:*make-alist-from-map-result* nil)) | |
1797 (its:make-alist-from-map* map (or string "")) | |
1798 (reverse its:*make-alist-from-map-result*))) | |
1799 | |
1800 (defun its:make-alist-from-map* (map string) | |
1801 (let ((action (get-action map))) | |
1802 (if action | |
1803 (setq its:*make-alist-from-map-result* | |
1804 (cons (list string | |
1805 (let ((action-output (action-output action))) | |
1806 (cond((and (consp action-output) | |
1807 (numberp (car action-output))) | |
1808 (format "%s..." | |
1809 (nth (car action-output) (cdr action-output)))) | |
1810 ((stringp action-output) | |
1811 action-output) | |
1812 (t | |
1813 (format "%s" action-output))))) | |
1814 its:*make-alist-from-map-result*))) | |
1815 (let ((alist (map-alist map))) | |
1816 (while alist | |
1817 (its:make-alist-from-map* | |
1818 (cdr (car alist)) | |
1819 (concat string (char-to-string (car (car alist))))) | |
1820 (setq alist (cdr alist)))))) | |
1821 | |
1822 (defvar its:*select-alternative-output-menu* '(menu "Which?" nil)) | |
1823 | |
1824 (defun its:select-alternative-output (action-output) | |
1825 ;;;; action-output : (pos item1 item2 item3 ....) | |
1826 (let ((point (point)) | |
1827 (output (cdr action-output)) | |
1828 (ch 0)) | |
1829 (while (not (eq ch ?\^L)) | |
1830 (insert "<" (nth (car action-output)output) ">") | |
1831 (setq ch (read-event)) | |
1832 (cond ((eq ch ?\^N) | |
1833 (setcar action-output | |
1834 (mod (1+ (car action-output)) (length output)))) | |
1835 ((eq ch ?\^P) | |
1836 (setcar action-output | |
1837 (if (= 0 (car action-output)) | |
1838 (1- (length output)) | |
1839 (1- (car action-output))))) | |
1840 ((eq ch ?\^M) | |
1841 (setcar (nthcdr 2 its:*select-alternative-output-menu* ) | |
1842 output) | |
1843 (let ((values | |
1844 (menu:select-from-menu its:*select-alternative-output-menu* | |
1845 (car action-output) | |
1846 t))) | |
1847 (cond((consp values) | |
1848 (setcar action-output (nth 1 values)) | |
1849 (setq ch ?\^L))))) | |
1850 ((eq ch ?\^L) | |
1851 ) | |
1852 (t | |
1853 (beep) | |
1854 )) | |
1855 (delete-region point (point))) | |
1856 (if its:*insert-output-string* | |
1857 (funcall its:*insert-output-string* (nth (car action-output) output)) | |
1858 (insert (nth (car action-output) output))))) | |
1859 | |
1860 | |
1861 | |
1862 ;;; translate until | |
1863 ;;; interactive --> not ordinal-charp | |
1864 ;;; or | |
1865 ;;; not interactive --> end of input | |
1866 | |
1867 (defvar its:*insert-output-string* nil) | |
1868 (defvar its:*display-status-string* nil) | |
1869 | |
1870 (defun its:translate-region (start end its:*interactive* &optional topmap) | |
1871 (set-marker its:*buff-s* start) | |
1872 (set-marker its:*buff-e* end) | |
1873 (its:reset-input) | |
1874 (goto-char its:*buff-s*) | |
1875 (let ((topmap (or topmap its:*current-map*)) | |
1876 (map nil) | |
1877 (ch nil) | |
1878 (action nil) | |
1879 (newmap nil) | |
1880 (inhibit-quit t) | |
1881 (its-quit-flag nil) | |
1882 (echo-keystrokes 0)) | |
1883 (setq map topmap) | |
1884 (its:reset-maps topmap) | |
1885 (while (not its-quit-flag) | |
1886 (setq ch (its:read-char)) | |
1887 (setq newmap (get-next-map map ch)) | |
1888 (setq action (get-action newmap)) | |
1889 | |
1890 (cond | |
1891 ((and its:*interactive* (not its:*char-from-buff*) (numberp ch) (= ch ?\^@)) | |
1892 (delete-region its:*buff-s* (point)) | |
1893 (let ((i 1)) | |
1894 (while (<= i its:*level*) | |
1895 (insert (aref its:*inputs* i)) | |
1896 (setq i (1+ i)))) | |
1897 (let ((inputs (its:completing-read "ITS:>" | |
1898 (its:make-alist-from-map topmap) | |
1899 nil | |
1900 t | |
1901 (buffer-substring its:*buff-s* (point))))) | |
1902 (delete-region its:*buff-s* (point)) | |
1903 (save-excursion (insert inputs)) | |
1904 (its:reset-maps) | |
1905 (setq map topmap) | |
1906 )) | |
1907 ((or (null newmap) | |
1908 (and (map-terminalp newmap) | |
1909 (null action))) | |
1910 | |
1911 (cond((and its:*interactive* (its:delete-charp ch)) | |
1912 (delete-region its:*buff-s* (point)) | |
1913 (cond((= its:*level* 0) | |
1914 (setq its-quit-flag t)) | |
1915 ((= its:*level* 1) | |
1916 (its:insert-char (aref its:*inputs* 1)) | |
1917 (setq its-quit-flag t)) | |
1918 (t | |
1919 (its:flush-input-before-point (1+ its:*level*)) | |
1920 (setq its:*level* (1- its:*level*)) | |
1921 (setq map (its:current-map)) | |
1922 (if (and its:*interactive* | |
1923 its:*display-status-string*) | |
1924 (funcall its:*display-status-string* (map-state map)) | |
1925 (insert (map-state map))) | |
1926 ))) | |
1927 | |
1928 (t | |
1929 (let ((output nil)) | |
1930 (let ((i its:*level*) (newlevel (1+ its:*level*))) | |
1931 (aset its:*inputs* newlevel ch) | |
1932 (while (and (< 0 i) (null output)) | |
1933 (if (and (aref its:*actions* i) | |
1934 (its:simulate-input (1+ i) newlevel its:*inputs* topmap)) | |
1935 (setq output i)) | |
1936 (setq i (1- i))) | |
1937 (if (null output) | |
1938 (let ((i its:*level*)) | |
1939 (while (and (< 0 i) (null output)) | |
1940 (if (aref its:*actions* i) | |
1941 (setq output i)) | |
1942 (setq i (1- i))))) | |
1943 | |
1944 (cond(output | |
1945 (delete-region its:*buff-s* (point)) | |
1946 (cond((its:standard-actionp (aref its:*actions* output)) | |
1947 (let ((action-output (action-output (aref its:*actions* output)))) | |
1948 (if (and (not its:*interactive*) | |
1949 (consp action-output)) | |
1950 (setq action-output (nth (car action-output) (cdr action-output)))) | |
1951 (cond((stringp action-output) | |
1952 (if (and its:*interactive* | |
1953 its:*insert-output-string*) | |
1954 (funcall its:*insert-output-string* action-output) | |
1955 (insert action-output))) | |
1956 ((consp action-output) | |
1957 (its:select-alternative-output action-output) | |
1958 ) | |
1959 (t | |
1960 (beep) (beep) | |
1961 ))) | |
1962 (set-marker its:*buff-s* (point)) | |
1963 (its:push-char ch) | |
1964 (its:flush-input-before-point (1+ output)) | |
1965 (if (action-next (aref its:*actions* output)) | |
1966 (save-excursion | |
1967 (insert (action-next (aref its:*actions* output))))) | |
1968 ) | |
1969 ((symbolp (aref its:*actions* output)) | |
1970 (its:push-char ch) | |
1971 (funcall (aref its:*actions* output)) | |
1972 (its:reset-maps its:*current-map*) | |
1973 (setq topmap its:*current-map*) | |
1974 (set-marker its:*buff-s* (point))) | |
1975 (t | |
1976 (its:push-char ch) | |
1977 ;92.10.26 by T.Saneto | |
1978 (eval (aref its:*actions* output)) | |
1979 (its:reset-maps its:*current-map*) | |
1980 (setq topmap its:*current-map*) | |
1981 (set-marker its:*buff-s* (point)) | |
1982 )) | |
1983 ) | |
1984 ((= 0 its:*level*) | |
1985 (cond ((or (its:ordinal-charp ch) | |
1986 its:*char-from-buff*) | |
1987 (its:insert-char ch)) | |
1988 (t (setq its-quit-flag t)))) | |
1989 | |
1990 ((< 0 its:*level*) | |
1991 (delete-region its:*buff-s* (point)) | |
1992 (its:insert-char (aref its:*inputs* 1)) | |
1993 (set-marker its:*buff-s* (point)) | |
1994 (its:push-char ch) | |
1995 (its:flush-input-before-point 2))))) | |
1996 | |
1997 (cond((null ch) | |
1998 (setq its-quit-flag t)) | |
1999 ((not its-quit-flag) | |
2000 (its:reset-maps) | |
2001 (set-marker its:*buff-s* (point)) | |
2002 (setq map topmap)))))) | |
2003 | |
2004 ((map-terminalp newmap) | |
2005 (its:enter-newlevel (setq map newmap) ch action) | |
2006 (delete-region its:*buff-s* (point)) | |
2007 (let ((output nil) (m nil) (i (1- its:*level*))) | |
2008 (while (and (< 0 i) (null output)) | |
2009 (if (and (aref its:*actions* i) | |
2010 (setq m (its:simulate-input (1+ i) its:*level* its:*inputs* topmap)) | |
2011 (not (map-terminalp m))) | |
2012 (setq output i)) | |
2013 (setq i (1- i))) | |
2014 | |
2015 (cond((null output) | |
2016 (cond ((its:standard-actionp action) | |
2017 (let ((action-output (action-output action))) | |
2018 (if (and (not its:*interactive*) | |
2019 (consp action-output)) | |
2020 (setq action-output (nth (car action-output) (cdr action-output)))) | |
2021 (cond((stringp action-output) | |
2022 (if (and its:*interactive* | |
2023 its:*insert-output-string*) | |
2024 (funcall its:*insert-output-string* action-output) | |
2025 (insert action-output))) | |
2026 ((consp action-output) | |
2027 (its:select-alternative-output action-output) | |
2028 ) | |
2029 (t | |
2030 (beep) (beep) | |
2031 ))) | |
2032 (cond((null (action-next action)) | |
2033 (cond ((and (= (point) its:*buff-e*) | |
2034 its:*interactive* | |
2035 (its:delete-charp (its:peek-char))) | |
2036 nil) | |
2037 (t | |
2038 (set-marker its:*buff-s* (point)) | |
2039 (its:reset-maps) | |
2040 (setq map topmap) | |
2041 ))) | |
2042 (t | |
2043 (save-excursion (insert (action-next action))) | |
2044 (set-marker its:*buff-s* (point)) | |
2045 (its:reset-maps) | |
2046 (setq map topmap)))) | |
2047 ((symbolp action) | |
2048 (funcall action) | |
2049 (its:reset-maps its:*current-map*) | |
2050 (setq topmap its:*current-map*) | |
2051 (setq map topmap) | |
2052 (set-marker its:*buff-s* (point))) | |
2053 (t | |
2054 (eval action) | |
2055 (its:reset-maps its:*current-map*) | |
2056 (setq topmap its:*current-map*) | |
2057 (setq map topmap) | |
2058 (set-marker its:*buff-s* (point))))) | |
2059 (t | |
2060 (if (and its:*interactive* | |
2061 its:*display-status-string*) | |
2062 (funcall its:*display-status-string* (map-state map)) | |
2063 (insert (map-state map))))))) | |
2064 | |
2065 ((null action) | |
2066 (delete-region its:*buff-s* (point)) | |
2067 (if (and its:*interactive* | |
2068 its:*display-status-string*) | |
2069 (funcall its:*display-status-string* (map-state newmap)) | |
2070 (insert (map-state newmap))) | |
2071 (its:enter-newlevel (setq map newmap) | |
2072 ch action)) | |
2073 | |
2074 (t | |
2075 (its:enter-newlevel (setq map newmap) ch action) | |
2076 (delete-region its:*buff-s* (point)) | |
2077 (if (and its:*interactive* | |
2078 its:*display-status-string*) | |
2079 (funcall its:*display-status-string* (map-state map)) | |
2080 (insert (map-state map)))))) | |
2081 | |
2082 (set-marker its:*buff-s* nil) | |
2083 (set-marker its:*buff-e* nil) | |
2084 (if (and its:*interactive* ch) (setq unread-command-events (list ch))) | |
2085 )) | |
2086 | |
2087 ;;;---------------------------------------------------------------------- | |
2088 ;;; | |
2089 ;;; ITS-map dump routine: | |
2090 ;;; | |
2091 ;;;---------------------------------------------------------------------- | |
2092 | |
2093 ;;;;; | |
2094 ;;;;; User entry: dump-its-mode-map | |
2095 ;;;;; | |
2096 | |
2097 ;; 92.6.26 by K.Handa | |
2098 (defun dump-its-mode-map (name filename) | |
2099 "Obsolete." | |
2100 (interactive) | |
2101 (message "This function is obsolete in the current version of Mule.")) | |
2102 ;;; | |
2103 ;;; EGG mode variables | |
2104 ;;; | |
2105 | |
2106 (defvar egg:*mode-on* nil "T if egg mode is on.") | |
2107 (make-variable-buffer-local 'egg:*mode-on*) | |
2108 (set-default 'egg:*mode-on* nil) | |
2109 | |
2110 (defvar egg:*input-mode* t "T if egg map is active.") | |
2111 (make-variable-buffer-local 'egg:*input-mode*) | |
2112 (set-default 'egg:*input-mode* t) | |
2113 | |
2114 (defvar egg:*in-fence-mode* nil "T if in fence mode.") | |
2115 (make-variable-buffer-local 'egg:*in-fence-mode*) | |
2116 (set-default 'egg:*in-fence-mode* nil) | |
2117 | |
2118 ;;(load-library "its-dump/roma-kana") ;;;(define-its-mode "roma-kana" " a$B$"(B") | |
2119 ;;(load-library "its-dump/roma-kata") ;;;(define-its-mode "roma-kata" " a$B%"(B") | |
2120 ;;(load-library "its-dump/downcase") ;;;(define-its-mode "downcase" " a a") | |
2121 ;;(load-library "its-dump/upcase") ;;;(define-its-mode "upcase" " a A") | |
2122 ;;(load-library "its-dump/zenkaku-downcase") ;;;(define-its-mode "zenkaku-downcase" " a$B#a(B") | |
2123 ;;(load-library "its-dump/zenkaku-upcase") ;;;(define-its-mode "zenkaku-upcase" " a$B#A(B") | |
2124 ;; 92.3.13 by K.Handa | |
2125 ;; (load "its-hira") | |
2126 ;; (load-library "its-kata") | |
2127 ;; (load-library "its-hankaku") | |
2128 ;; (load-library "its-zenkaku") | |
2129 | |
2130 | |
2131 (defvar its:*current-map* nil) | |
2132 (make-variable-buffer-local 'its:*current-map*) | |
2133 ;; 92.3.13 by K.Handa | |
2134 ;; moved to each language specific setup files (japanese.el, ...) | |
2135 ;; (setq-default its:*current-map* (its:get-mode-map "roma-kana")) | |
2136 | |
2137 (defvar its:*previous-map* nil) | |
2138 (make-variable-buffer-local 'its:*previous-map*) | |
2139 (setq-default its:*previous-map* nil) | |
2140 | |
2141 ;;;---------------------------------------------------------------------- | |
2142 ;;; | |
2143 ;;; Mode line control functions; | |
2144 ;;; | |
2145 ;;;---------------------------------------------------------------------- | |
2146 | |
2147 (defconst mode-line-egg-mode "--") | |
2148 (make-variable-buffer-local 'mode-line-egg-mode) | |
2149 | |
2150 (defvar mode-line-egg-mode-in-minibuffer "--" "global variable") | |
2151 | |
2152 (defun egg:find-symbol-in-tree (item tree) | |
2153 (if (consp tree) | |
2154 (or (egg:find-symbol-in-tree item (car tree)) | |
2155 (egg:find-symbol-in-tree item (cdr tree))) | |
2156 (equal item tree))) | |
2157 | |
2158 ;;; | |
2159 ;;; nemacs Ver. 3.0 $B$G$O(B Fselect_window $B$,JQ99$K$J$j!"(Bminibuffer-window | |
2160 ;;; $BB>$N(B window $B$H$N4V$G=PF~$j$,$"$k$H!"(Bmode-line $B$N99?7$r9T$J$$!"JQ?t(B | |
2161 ;;; minibuffer-window-selected $B$NCM$,99?7$5$l$k(B | |
2162 ;;; | |
2163 | |
2164 ;;; nemacs Ver. 4 $B$G$O(B Fselect_window $B$,JQ99$K$J$j!$(Bselect-window-hook | |
2165 ;;; $B$,Dj5A$5$l$?!%$3$l$K$H$b$J$$=>Mh!$:FDj5A$7$F$$$?(B select-window, | |
2166 ;;; other-window, keyborad-quit, abort-recursive-edit, exit-minibuffer | |
2167 ;;; $B$r:o=|$7$?!%(B | |
2168 | |
2169 (defconst display-minibuffer-mode-in-minibuffer t) | |
2170 | |
2171 (defvar minibuffer-window-selected nil) | |
2172 | |
2173 (defun egg:select-window-hook (old new) | |
2174 (if (and (eq old (minibuffer-window)) | |
2175 (not (eq new (minibuffer-window)))) | |
2176 (save-excursion | |
2177 (set-buffer (window-buffer (minibuffer-window))) | |
2178 (setq minibuffer-preprompt nil | |
2179 egg:*mode-on* (default-value 'egg:*mode-on*) | |
2180 egg:*input-mode* (default-value 'egg:*input-mode*) | |
2181 egg:*in-fence-mode* (default-value 'egg:*in-fence-mode*)))) | |
2182 (if (eq new (minibuffer-window)) | |
2183 (setq minibuffer-window-selected t) | |
2184 (setq minibuffer-window-selected nil))) | |
2185 | |
2186 (setq select-window-hook 'egg:select-window-hook) | |
2187 | |
2188 ;;; | |
2189 ;;; | |
2190 ;;; | |
2191 | |
2192 (defvar its:*reset-mode-line-format* nil) | |
2193 | |
2194 (if its:*reset-mode-line-format* | |
2195 (setq-default mode-line-format | |
2196 (cdr mode-line-format))) | |
2197 | |
2198 (if (not (egg:find-symbol-in-tree 'mode-line-egg-mode mode-line-format)) | |
2199 (setq-default | |
2200 mode-line-format | |
2201 (cons (list 'mc-flag | |
2202 (list 'display-minibuffer-mode-in-minibuffer | |
2203 ;;; minibuffer mode in minibuffer | |
2204 (list | |
2205 (list 'its:*previous-map* "<" "[") | |
2206 'mode-line-egg-mode | |
2207 (list 'its:*previous-map* ">" "]") | |
2208 ) | |
2209 ;;;; minibuffer mode in mode line | |
2210 (list | |
2211 (list 'minibuffer-window-selected | |
2212 (list 'display-minibuffer-mode | |
2213 "m" | |
2214 " ") | |
2215 " ") | |
2216 (list 'its:*previous-map* "<" "[") | |
2217 (list 'minibuffer-window-selected | |
2218 (list 'display-minibuffer-mode | |
2219 'mode-line-egg-mode-in-minibuffer | |
2220 'mode-line-egg-mode) | |
2221 'mode-line-egg-mode) | |
2222 (list 'its:*previous-map* ">" "]") | |
2223 ))) | |
2224 mode-line-format))) | |
2225 | |
2226 ;;; | |
2227 ;;; minibuffer $B$G$N%b!<%II=<($r$9$k$?$a$K(B nemacs 4 $B$GDj5A$5$l$?(B | |
2228 ;;; minibuffer-preprompt $B$rMxMQ$9$k!%(B | |
2229 ;;; | |
2230 | |
2231 (defconst egg:minibuffer-preprompt '("[" nil "]")) | |
2232 | |
2233 (defun mode-line-egg-mode-update (str) | |
2234 (if (eq (current-buffer) (window-buffer (minibuffer-window))) | |
2235 (if display-minibuffer-mode-in-minibuffer | |
2236 (progn | |
2237 (aset (nth 0 egg:minibuffer-preprompt) 0 | |
2238 (if its:*previous-map* ?\< ?\[)) | |
2239 (setcar (nthcdr 1 egg:minibuffer-preprompt) | |
2240 str) | |
2241 (aset (nth 2 egg:minibuffer-preprompt) 0 | |
2242 (if its:*previous-map* ?\> ?\])) | |
2243 (setq minibuffer-preprompt | |
2244 egg:minibuffer-preprompt)) | |
2245 (setq display-minibuffer-mode t | |
2246 mode-line-egg-mode-in-minibuffer str)) | |
2247 (setq display-minibuffer-mode nil | |
2248 mode-line-egg-mode str)) | |
2249 (redraw-modeline t)) | |
2250 | |
2251 (mode-line-egg-mode-update mode-line-egg-mode) | |
2252 | |
2253 ;;; | |
2254 ;;; egg mode line display | |
2255 ;;; | |
2256 | |
2257 (defvar alphabet-mode-indicator "aA") | |
2258 (defvar transparent-mode-indicator "--") | |
2259 | |
2260 (defun egg:mode-line-display () | |
2261 (mode-line-egg-mode-update | |
2262 (cond((and egg:*in-fence-mode* (not egg:*input-mode*)) | |
2263 alphabet-mode-indicator) | |
2264 ((and egg:*mode-on* egg:*input-mode*) | |
2265 (map-indicator its:*current-map*)) | |
2266 (t transparent-mode-indicator)))) | |
2267 | |
2268 (defun egg:toggle-egg-mode-on-off () | |
2269 (interactive) | |
2270 (setq egg:*mode-on* (not egg:*mode-on*)) | |
2271 (egg:mode-line-display)) | |
2272 | |
2273 (defun its:select-mode (name) | |
2274 (interactive (list (completing-read "ITS mode: " its:*mode-alist*))) | |
2275 (if (its:get-mode-map name) | |
2276 (progn | |
2277 (setq its:*current-map* (its:get-mode-map name)) | |
2278 (egg:mode-line-display)) | |
2279 (beep)) | |
2280 ) | |
2281 | |
2282 (defvar its:*select-mode-menu* '(menu "Mode:" nil)) | |
2283 | |
2284 (defun its:select-mode-from-menu () | |
2285 (interactive) | |
2286 (setcar (nthcdr 2 its:*select-mode-menu*) its:*mode-alist*) | |
2287 (setq its:*current-map* (menu:select-from-menu its:*select-mode-menu*)) | |
2288 (egg:mode-line-display)) | |
2289 | |
2290 (defvar its:*standard-modes* nil | |
2291 "List of standard mode-map of EGG." | |
2292 ;; 92.3.13 by K.Handa | |
2293 ;; moved to each language specific setup files (japanese.el, ...) | |
2294 ;; (list (its:get-mode-map "roma-kana") | |
2295 ;; (its:get-mode-map "roma-kata") | |
2296 ;; (its:get-mode-map "downcase") | |
2297 ;; (its:get-mode-map "upcase") | |
2298 ;; (its:get-mode-map "zenkaku-downcase") | |
2299 ;; (its:get-mode-map "zenkaku-upcase")) | |
2300 ) | |
2301 | |
2302 (defun its:find (map list) | |
2303 (let ((n 0)) | |
2304 (while (and list (not (eq map (car list)))) | |
2305 (setq list (cdr list) | |
2306 n (1+ n))) | |
2307 (if list n nil))) | |
2308 | |
2309 (defun its:next-mode () | |
2310 (interactive) | |
2311 (let ((pos (its:find its:*current-map* its:*standard-modes*))) | |
2312 (setq its:*current-map* | |
2313 (nth (% (1+ pos) (length its:*standard-modes*)) | |
2314 its:*standard-modes*)) | |
2315 (egg:mode-line-display))) | |
2316 | |
2317 (defun its:previous-mode () | |
2318 (interactive) | |
2319 (let ((pos (its:find its:*current-map* its:*standard-modes*))) | |
2320 (setq its:*current-map* | |
2321 (nth (1- (if (= pos 0) (length its:*standard-modes*) pos)) | |
2322 its:*standard-modes*)) | |
2323 (egg:mode-line-display))) | |
2324 | |
2325 (defun its:select-hiragana () (interactive) (its:select-mode "roma-kana")) | |
2326 (defun its:select-katakana () (interactive) (its:select-mode "roma-kata")) | |
2327 (defun its:select-downcase () (interactive) (its:select-mode "downcase")) | |
2328 (defun its:select-upcase () (interactive) (its:select-mode "upcase")) | |
2329 (defun its:select-zenkaku-downcase () (interactive) (its:select-mode "zenkaku-downcase")) | |
2330 (defun its:select-zenkaku-upcase () (interactive) (its:select-mode "zenkaku-upcase")) | |
2331 | |
2332 (defun its:select-mode-temporally (name) | |
2333 (interactive (list (completing-read "ITS mode: " its:*mode-alist*))) | |
2334 (let ((map (its:get-mode-map name))) | |
2335 (if map | |
2336 (progn | |
2337 (if (null its:*previous-map*) | |
2338 (setq its:*previous-map* its:*current-map*)) | |
2339 (setq its:*current-map* map) | |
2340 (egg:mode-line-display)) | |
2341 (beep)))) | |
2342 | |
2343 (defun its:select-previous-mode () | |
2344 (interactive) | |
2345 (if (null its:*previous-map*) | |
2346 (beep) | |
2347 (setq its:*current-map* its:*previous-map* | |
2348 its:*previous-map* nil) | |
2349 (egg:mode-line-display))) | |
2350 | |
2351 | |
2352 (defun toggle-egg-mode () | |
2353 (interactive) | |
2354 (if mc-flag | |
2355 (if egg:*mode-on* (fence-toggle-egg-mode) | |
2356 (progn | |
2357 (setq egg:*mode-on* t) | |
2358 (egg:mode-line-display))))) | |
2359 | |
2360 (defun fence-toggle-egg-mode () | |
2361 (interactive) | |
2362 (if its:*current-map* | |
2363 (progn | |
2364 (setq egg:*input-mode* (not egg:*input-mode*)) | |
2365 (egg:mode-line-display)) | |
2366 (beep))) | |
2367 | |
2368 ;;; | |
2369 ;;; Changes on Global map | |
2370 ;;; | |
2371 | |
2372 (defvar si:*global-map* (copy-keymap global-map)) | |
2373 | |
2374 (substitute-key-definition 'self-insert-command | |
2375 'egg-self-insert-command | |
2376 global-map) | |
2377 | |
2378 ;;; | |
2379 ;;; Currently entries C-\ and C-^ at global-map are undefined. | |
2380 ;;; | |
2381 | |
2382 (define-key global-map "\C-\\" 'toggle-egg-mode) | |
2383 (define-key global-map "\C-x " 'henkan-region) | |
2384 | |
2385 ;; 92.3.16 by K.Handa | |
2386 ;; global-map => mule-keymap | |
2387 (define-key mule-keymap "m" 'its:select-mode-from-menu) | |
2388 (define-key mule-keymap ">" 'its:next-mode) | |
2389 (define-key mule-keymap "<" 'its:previous-mode) | |
2390 (define-key mule-keymap "h" 'its:select-hiragana) | |
2391 (define-key mule-keymap "k" 'its:select-katakana) | |
2392 (define-key mule-keymap "q" 'its:select-downcase) | |
2393 (define-key mule-keymap "Q" 'its:select-upcase) | |
2394 (define-key mule-keymap "z" 'its:select-zenkaku-downcase) | |
2395 (define-key mule-keymap "Z" 'its:select-zenkaku-upcase) | |
2396 | |
2397 ;;; | |
2398 ;;; auto fill controll | |
2399 ;;; | |
2400 | |
2401 (defun egg:do-auto-fill () | |
2402 (if (and auto-fill-function (not buffer-read-only) | |
2403 (> (current-column) fill-column)) | |
2404 (let ((ocolumn (current-column))) | |
2405 (funcall auto-fill-function) | |
2406 (while (and (< fill-column (current-column)) | |
2407 (< (current-column) ocolumn)) | |
2408 (setq ocolumn (current-column)) | |
2409 (funcall auto-fill-function))))) | |
2410 | |
2411 ;;;---------------------------------------------------------------------- | |
2412 ;;; | |
2413 ;;; Egg fence mode | |
2414 ;;; | |
2415 ;;;---------------------------------------------------------------------- | |
2416 | |
2417 (defconst egg:*fence-open* "|" "*$B%U%'%s%9$N;OE@$r<($9J8;zNs(B") | |
2418 (defconst egg:*fence-close* "|" "*$B%U%'%s%9$N=*E@$r<($9J8;zNs(B") | |
2419 (defconst egg:*fence-face* nil "*$B%U%'%s%9I=<($KMQ$$$k(B face $B$^$?$O(B nil") | |
2420 (make-variable-buffer-local | |
2421 (defvar egg:*fence-overlay* nil "$B%U%'%s%9I=<(MQ(B overlay")) | |
2422 | |
2423 (defvar egg:*face-alist* | |
2424 '(("nil" . nil) | |
2425 ("highlight" . highlight) ("modeline" . modeline) | |
2426 ("inverse" . modeline) ("underline" . underline) ("bold" . bold) | |
2427 ("region" . region))) | |
2428 | |
2429 (defun set-egg-fence-mode-format (open close &optional face) | |
2430 "fence mode $B$NI=<(J}K!$r@_Dj$9$k!#(BOPEN $B$O%U%'%s%9$N;OE@$r<($9J8;zNs$^$?$O(B nil$B!#(B\n\ | |
2431 CLOSE$B$O%U%'%s%9$N=*E@$r<($9J8;zNs$^$?$O(B nil$B!#(B\n\ | |
2432 $BBh(B3$B0z?t(B FACE $B$,;XDj$5$l$F(B nil $B$G$J$1$l$P!"%U%'%s%96h4V$NI=<($K$=$l$r;H$&!#(B" | |
2433 (interactive (list (read-string "$B%U%'%s%93+;OJ8;zNs(B: ") | |
2434 (read-string "$B%U%'%s%9=*N;J8;zNs(B: ") | |
2435 (cdr (assoc (completing-read "$B%U%'%s%9I=<(B0@-(B: " egg:*face-alist*) | |
2436 egg:*face-alist*)))) | |
2437 | |
2438 (if (and (or (stringp open) (null open)) | |
2439 (or (stringp close) (null close)) | |
2440 (or (null face) (memq face (face-list)))) | |
2441 (progn | |
2442 (setq egg:*fence-open* (or open "") | |
2443 egg:*fence-close* (or close "") | |
2444 egg:*fence-face* face) | |
2445 (if (overlayp egg:*fence-overlay*) | |
2446 (overlay-put egg:*fence-overlay* 'face egg:*fence-face*)) | |
2447 t) | |
2448 (error "Wrong type of argument: %s %s %s" open close face))) | |
2449 | |
2450 ;(defconst egg:*region-start* (make-marker)) | |
2451 ;(defconst egg:*region-end* (set-marker-type (make-marker) t)) | |
2452 (defvar egg:*region-start* nil) | |
2453 (defvar egg:*region-end* nil) | |
2454 (make-variable-buffer-local 'egg:*region-start*) | |
2455 (make-variable-buffer-local 'egg:*region-end*) | |
2456 (set-default 'egg:*region-start* nil) | |
2457 (set-default 'egg:*region-end* nil) | |
2458 (defvar egg:*global-map-backup* nil) | |
2459 (defvar egg:*local-map-backup* nil) | |
2460 | |
2461 | |
2462 ;;; Moved to kanji.el | |
2463 ;;; (defvar self-insert-after-hook nil | |
2464 ;;; "Hook to run when extended self insertion command exits. Should take | |
2465 ;;; two arguments START and END correspoding to character position.") | |
2466 | |
2467 (defvar egg:*self-insert-non-undo-count* 0 | |
2468 "counter to hold repetition of egg-self-insert-command.") | |
2469 | |
2470 (defun egg-self-insert-command (arg) | |
2471 (interactive "p") | |
2472 (if (and (not buffer-read-only) | |
2473 mc-flag | |
2474 egg:*mode-on* egg:*input-mode* | |
2475 (not egg:*in-fence-mode*) ;;; inhibit recursive fence mode | |
2476 (not (= last-command-event ? ))) | |
2477 (egg:enter-fence-mode-and-self-insert) | |
2478 (progn | |
2479 ;; treat continuous 20 self insert as a single undo chunk. | |
2480 ;; `20' is a magic number copied from keyboard.c | |
2481 (if (or ;92.12.20 by T.Enami | |
2482 (not (eq last-command 'egg-self-insert-command)) | |
2483 (>= egg:*self-insert-non-undo-count* 20)) | |
2484 (setq egg:*self-insert-non-undo-count* 1) | |
2485 (cancel-undo-boundary) | |
2486 (setq egg:*self-insert-non-undo-count* | |
2487 (1+ egg:*self-insert-non-undo-count*))) | |
2488 (self-insert-command arg) | |
2489 (if egg-insert-after-hook | |
2490 (run-hooks 'egg-insert-after-hook)) | |
2491 (if self-insert-after-hook | |
2492 (if (<= 1 arg) | |
2493 (funcall self-insert-after-hook | |
2494 (- (point) arg) (point))) | |
2495 (if (= last-command-event ? ) (egg:do-auto-fill)))))) | |
2496 | |
2497 ;; | |
2498 ;; $BA03NDjJQ49=hM}4X?t(B | |
2499 ;; | |
2500 (defvar egg:*fence-open-backup* nil) | |
2501 (defvar egg:*fence-close-backup* nil) | |
2502 (defvar egg:*fence-face-backup* nil) | |
2503 | |
2504 (defconst egg:*fence-open-in-cont* "+" "*$BA03NDj>uBV$G$N(B *fence-open*") | |
2505 (defconst egg:*fence-close-in-cont* t "*$BA03NDj>uBV$G$N(B *fence-close*") | |
2506 (defconst egg:*fence-face-in-cont* t | |
2507 "*$BA03NDj>uBV$G$N(B *fence-face*") | |
2508 | |
2509 (defun set-egg-fence-mode-format-in-cont (open close face) | |
2510 "$BA03NDj>uBV$G$N(B fence mode $B$NI=<(J}K!$r@_Dj$9$k!#(BOPEN $B$O%U%'%s%9$N;OE@$r<($9J8(B | |
2511 $B;zNs!"(Bt $B$^$?$O(B nil$B!#(B\n\ | |
2512 CLOSE$B$O%U%'%s%9$N=*E@$r<($9J8;zNs!"(Bt $B$^$?$O(B nil$B!#(B\n\ | |
2513 FACE $B$O(B nil $B$G$J$1$l$P!"%U%'%s%96h4V$NI=<($K$=$l$r;H$&!#(B\n\ | |
2514 $B$=$l$>$l$NCM$,(B t $B$N>l9g!"DL>o$N(B egg:*fence-open* $BEy$NCM$r0z$-7Q$0!#(B" | |
2515 (interactive (list (read-string "$B%U%'%s%93+;OJ8;zNs(B: ") | |
2516 (read-string "$B%U%'%s%9=*N;J8;zNs(B: ") | |
2517 (cdr (assoc (completing-read "$B%U%'%s%9I=<(B0@-(B: " egg:*face | |
2518 -alist*) | |
2519 egg:*face-alist*)))) | |
2520 | |
2521 (if (and (or (stringp open) (eq open t) (null open)) | |
2522 (or (stringp close) (eq close t) (null close)) | |
2523 (or (null face) (eq face t) (memq face (face-list)))) | |
2524 (progn | |
2525 (setq egg:*fence-open-in-cont* (or open "") | |
2526 egg:*fence-close-in-cont* (or close "") | |
2527 egg:*fence-face-in-cont* face) | |
2528 (if (overlayp egg:*fence-overlay*) | |
2529 (overlay-put egg:*fence-overlay* 'face egg:*fence-face*)) | |
2530 t) | |
2531 (error "Wrong type of argument: %s %s %s" open close face))) | |
2532 | |
2533 (defvar *in-cont-flag* nil | |
2534 "$BD>A0$KJQ49$7$?D>8e$NF~NO$+$I$&$+$r<($9!#(B") | |
2535 | |
2536 (defvar *in-cont-backup-flag* nil) | |
2537 | |
2538 (defun egg:check-fence-in-cont () | |
2539 (if *in-cont-flag* | |
2540 (progn | |
2541 (setq *in-cont-backup-flag* t) | |
2542 (setq egg:*fence-open-backup* egg:*fence-open*) | |
2543 (setq egg:*fence-close-backup* egg:*fence-close*) | |
2544 (setq egg:*fence-face-backup* egg:*fence-face*) | |
2545 (or (eq egg:*fence-open-in-cont* t) | |
2546 (setq egg:*fence-open* egg:*fence-open-in-cont*)) | |
2547 (or (eq egg:*fence-close-in-cont* t) | |
2548 (setq egg:*fence-close* egg:*fence-close-in-cont*)) | |
2549 (or (eq egg:*fence-face-in-cont* t) | |
2550 (setq egg:*fence-face* egg:*fence-face-in-cont*))))) | |
2551 | |
2552 (defun egg:restore-fence-in-cont () | |
2553 "Restore egg:*fence-open* and egg:*fence-close*" | |
2554 (if *in-cont-backup-flag* | |
2555 (progn | |
2556 (setq egg:*fence-open* egg:*fence-open-backup*) | |
2557 (setq egg:*fence-close* egg:*fence-close-backup*) | |
2558 (setq egg:*fence-face* egg:*fence-face-backup*))) | |
2559 (setq *in-cont-backup-flag* nil) | |
2560 ) | |
2561 | |
2562 (defun egg:enter-fence-mode-and-self-insert () | |
2563 (setq *in-cont-flag* | |
2564 (memq last-command '(henkan-kakutei henkan-kakutei-and-self-insert))) | |
2565 (enter-fence-mode) | |
2566 (setq unread-command-events (list last-command-event))) | |
2567 | |
2568 (defun egg:fence-face-on () | |
2569 (if egg:*fence-face* | |
2570 (progn | |
2571 (if (overlayp egg:*fence-overlay*) | |
2572 nil | |
2573 (setq egg:*fence-overlay* (make-overlay 1 1 nil t)) | |
2574 (if egg:*fence-face* (overlay-put egg:*fence-overlay* 'face egg:*fence-face*))) | |
2575 (move-overlay egg:*fence-overlay* egg:*region-start* egg:*region-end* ) ))) | |
2576 | |
2577 (defun egg:fence-face-off () | |
2578 (and egg:*fence-face* | |
2579 (overlayp egg:*fence-overlay*) | |
2580 (delete-overlay egg:*fence-overlay*) )) | |
2581 | |
2582 (defun enter-fence-mode () | |
2583 ;; XEmacs change: | |
2584 (buffer-disable-undo (current-buffer)) | |
2585 (setq egg:*in-fence-mode* t) | |
2586 (egg:mode-line-display) | |
2587 ;;;(setq egg:*global-map-backup* (current-global-map)) | |
2588 (setq egg:*local-map-backup* (current-local-map)) | |
2589 ;;;(use-global-map fence-mode-map) | |
2590 ;;;(use-local-map nil) | |
2591 (use-local-map fence-mode-map) | |
2592 (egg:check-fence-in-cont) ; for Wnn6 | |
2593 (insert egg:*fence-open*) | |
2594 (or (markerp egg:*region-start*) (setq egg:*region-start* (make-marker))) | |
2595 (set-marker egg:*region-start* (point)) | |
2596 (insert egg:*fence-close*) | |
2597 (or (markerp egg:*region-end*) (setq egg:*region-end* (set-marker-type (make-marker) t))) | |
2598 (set-marker egg:*region-end* egg:*region-start*) | |
2599 (egg:fence-face-on) | |
2600 (goto-char egg:*region-start*) | |
2601 ) | |
2602 | |
2603 (defun henkan-fence-region-or-single-space () | |
2604 (interactive) | |
2605 (if egg:*input-mode* | |
2606 (henkan-fence-region) | |
2607 (insert ? ))) | |
2608 | |
2609 (defvar egg:*henkan-fence-mode* nil) | |
2610 | |
2611 (defun henkan-fence-region () | |
2612 (interactive) | |
2613 (setq egg:*henkan-fence-mode* t) | |
2614 (egg:fence-face-off) | |
2615 (henkan-region-internal egg:*region-start* egg:*region-end* )) | |
2616 | |
2617 (defun fence-katakana () | |
2618 (interactive) | |
2619 (katakana-region egg:*region-start* egg:*region-end* )) | |
2620 | |
2621 (defun fence-hiragana () | |
2622 (interactive) | |
2623 (hiragana-region egg:*region-start* egg:*region-end*)) | |
2624 | |
2625 (defun fence-hankaku () | |
2626 (interactive) | |
2627 (hankaku-region egg:*region-start* egg:*region-end*)) | |
2628 | |
2629 (defun fence-zenkaku () | |
2630 (interactive) | |
2631 (zenkaku-region egg:*region-start* egg:*region-end*)) | |
2632 | |
2633 (defun fence-backward-char () | |
2634 (interactive) | |
2635 (if (< egg:*region-start* (point)) | |
2636 (backward-char) | |
2637 (beep))) | |
2638 | |
2639 (defun fence-forward-char () | |
2640 (interactive) | |
2641 (if (< (point) egg:*region-end*) | |
2642 (forward-char) | |
2643 (beep))) | |
2644 | |
2645 (defun fence-beginning-of-line () | |
2646 (interactive) | |
2647 (goto-char egg:*region-start*)) | |
2648 | |
2649 (defun fence-end-of-line () | |
2650 (interactive) | |
2651 (goto-char egg:*region-end*)) | |
2652 | |
2653 (defun fence-transpose-chars (arg) | |
2654 (interactive "P") | |
2655 (if (and (< egg:*region-start* (point)) | |
2656 (< (point) egg:*region-end*)) | |
2657 (transpose-chars arg) | |
2658 (beep))) | |
2659 | |
2660 (defun egg:exit-if-empty-region () | |
2661 (if (= egg:*region-start* egg:*region-end*) | |
2662 (fence-exit-mode))) | |
2663 | |
2664 (defun fence-delete-char () | |
2665 (interactive) | |
2666 (if (< (point) egg:*region-end*) | |
2667 (progn | |
2668 (delete-char 1) | |
2669 (egg:exit-if-empty-region)) | |
2670 (beep))) | |
2671 | |
2672 (defun fence-backward-delete-char () | |
2673 (interactive) | |
2674 (if (< egg:*region-start* (point)) | |
2675 (progn | |
2676 (delete-char -1) | |
2677 (egg:exit-if-empty-region)) | |
2678 (beep))) | |
2679 | |
2680 (defun fence-kill-line () | |
2681 (interactive) | |
2682 (delete-region (point) egg:*region-end*) | |
2683 (egg:exit-if-empty-region)) | |
2684 | |
2685 (defun fence-exit-mode () | |
2686 (interactive) | |
2687 (delete-region (- egg:*region-start* (length egg:*fence-open*)) egg:*region-start*) | |
2688 (delete-region egg:*region-end* (+ egg:*region-end* (length egg:*fence-close*))) | |
2689 (egg:fence-face-off) | |
2690 (if its:*previous-map* | |
2691 (setq its:*current-map* its:*previous-map* | |
2692 its:*previous-map* nil)) | |
2693 (egg:quit-egg-mode)) | |
2694 | |
2695 (defvar egg-insert-after-hook nil) | |
2696 (make-variable-buffer-local 'egg-insert-after-hook) | |
2697 | |
2698 (defvar egg-exit-hook nil | |
2699 "Hook to run when egg exits. Should take two arguments START and END | |
2700 correspoding to character position.") | |
2701 | |
2702 (defun egg:quit-egg-mode () | |
2703 ;;;(use-global-map egg:*global-map-backup*) | |
2704 (use-local-map egg:*local-map-backup*) | |
2705 (setq egg:*in-fence-mode* nil) | |
2706 (egg:mode-line-display) | |
2707 (if overwrite-mode | |
2708 (let ((str (buffer-substring egg:*region-end* egg:*region-start*))) | |
2709 (delete-text-in-column nil (+ (current-column) (string-width str))))) | |
2710 (egg:restore-fence-in-cont) ; for Wnn6 | |
2711 (setq egg:*henkan-fence-mode* nil) | |
2712 (if self-insert-after-hook | |
2713 (funcall self-insert-after-hook egg:*region-start* egg:*region-end*) | |
2714 (if egg-exit-hook | |
2715 (funcall egg-exit-hook egg:*region-start* egg:*region-end*) | |
2716 (if (not (= egg:*region-start* egg:*region-end*)) | |
2717 (egg:do-auto-fill)))) | |
2718 (set-marker egg:*region-start* nil) | |
2719 (set-marker egg:*region-end* nil) | |
2720 ;; XEmacs change: | |
2721 (buffer-enable-undo (current-buffer)) | |
2722 (if egg-insert-after-hook | |
2723 (run-hooks 'egg-insert-after-hook)) | |
2724 ) | |
2725 | |
2726 (defun fence-cancel-input () | |
2727 (interactive) | |
2728 (delete-region egg:*region-start* egg:*region-end*) | |
2729 (fence-exit-mode)) | |
2730 | |
2731 (defun fence-mode-help-command () | |
2732 "Display documentation for fence-mode." | |
2733 (interactive) | |
2734 (let ((buf "*Help*")) | |
2735 (if (eq (get-buffer buf) (current-buffer)) | |
2736 (henkan-quit) | |
2737 (with-output-to-temp-buffer buf | |
2738 (princ (substitute-command-keys "The keys that are defined for the fence mode here are:\\{fence-mode-map}")) | |
2739 (print-help-return-message))))) | |
2740 | |
2741 (defvar fence-mode-map (make-keymap)) | |
2742 | |
2743 (substitute-key-definition 'self-insert-command | |
2744 'fence-self-insert-command | |
2745 fence-mode-map global-map) | |
2746 | |
2747 (define-key fence-mode-map "\eh" 'fence-hiragana) | |
2748 (define-key fence-mode-map "\ek" 'fence-katakana) | |
2749 (define-key fence-mode-map "\e<" 'fence-hankaku) | |
2750 (define-key fence-mode-map "\e>" 'fence-zenkaku) | |
2751 (define-key fence-mode-map "\e\C-h" 'its:select-hiragana) | |
2752 (define-key fence-mode-map "\e\C-k" 'its:select-katakana) | |
2753 (define-key fence-mode-map "\eq" 'its:select-downcase) | |
2754 (define-key fence-mode-map "\eQ" 'its:select-upcase) | |
2755 (define-key fence-mode-map "\ez" 'its:select-zenkaku-downcase) | |
2756 (define-key fence-mode-map "\eZ" 'its:select-zenkaku-upcase) | |
2757 (define-key fence-mode-map " " 'henkan-fence-region-or-single-space) | |
2758 (define-key fence-mode-map "\C-@" 'henkan-fence-region) | |
2759 (define-key fence-mode-map [(control \ )] 'henkan-fence-region) | |
2760 (define-key fence-mode-map "\C-a" 'fence-beginning-of-line) | |
2761 (define-key fence-mode-map "\C-b" 'fence-backward-char) | |
2762 (define-key fence-mode-map "\C-c" 'fence-cancel-input) | |
2763 (define-key fence-mode-map "\C-d" 'fence-delete-char) | |
2764 (define-key fence-mode-map "\C-e" 'fence-end-of-line) | |
2765 (define-key fence-mode-map "\C-f" 'fence-forward-char) | |
2766 (define-key fence-mode-map "\C-g" 'fence-cancel-input) | |
2767 (define-key fence-mode-map "\C-h" 'fence-mode-help-command) | |
2768 (define-key fence-mode-map "\C-k" 'fence-kill-line) | |
2769 (define-key fence-mode-map "\C-l" 'fence-exit-mode) | |
2770 (define-key fence-mode-map "\C-m" 'fence-exit-mode) ;;; RET | |
2771 (define-key fence-mode-map [return] 'fence-exit-mode) | |
2772 (define-key fence-mode-map "\C-q" 'its:select-previous-mode) | |
2773 (define-key fence-mode-map "\C-t" 'fence-transpose-chars) | |
2774 (define-key fence-mode-map "\C-w" 'henkan-fence-region) | |
2775 (define-key fence-mode-map "\C-z" 'eval-expression) | |
2776 (define-key fence-mode-map "\C-\\" 'fence-toggle-egg-mode) | |
2777 (define-key fence-mode-map "\C-_" 'jis-code-input) | |
2778 (define-key fence-mode-map "\177" 'fence-backward-delete-char) | |
2779 (define-key fence-mode-map [delete] 'fence-backward-delete-char) | |
2780 (define-key fence-mode-map [backspace] 'fence-backward-delete-char) | |
2781 (define-key fence-mode-map [right] 'fence-forward-char) | |
2782 (define-key fence-mode-map [left] 'fence-backward-char) | |
2783 | |
2784 | |
2785 ;;;---------------------------------------------------------------------- | |
2786 ;;; | |
2787 ;;; Read hiragana from minibuffer | |
2788 ;;; | |
2789 ;;;---------------------------------------------------------------------- | |
2790 | |
2791 (defvar egg:*minibuffer-local-hiragana-map* (copy-keymap minibuffer-local-map)) | |
2792 | |
2793 (substitute-key-definition 'self-insert-command | |
2794 'fence-self-insert-command | |
2795 egg:*minibuffer-local-hiragana-map* | |
2796 minibuffer-local-map) | |
2797 | |
2798 (defun read-hiragana-string (prompt &optional initial-input) | |
2799 (save-excursion | |
2800 (let ((minibuff (window-buffer (minibuffer-window)))) | |
2801 (set-buffer minibuff) | |
2802 (setq egg:*input-mode* t | |
2803 egg:*mode-on* t | |
2804 its:*current-map* (its:get-mode-map "roma-kana")) | |
2805 (mode-line-egg-mode-update (its:get-mode-indicator its:*current-map*)))) | |
2806 (read-from-minibuffer prompt initial-input | |
2807 egg:*minibuffer-local-hiragana-map*)) | |
2808 | |
2809 (defun read-kanji-string (prompt &optional initial-input) | |
2810 (save-excursion | |
2811 (let ((minibuff (window-buffer (minibuffer-window)))) | |
2812 (set-buffer minibuff) | |
2813 (setq egg:*input-mode* t | |
2814 egg:*mode-on* t | |
2815 its:*current-map* (its:get-mode-map "roma-kana")) | |
2816 (mode-line-egg-mode-update (its:get-mode-indicator "roma-kana")))) | |
2817 (read-from-minibuffer prompt initial-input)) | |
2818 | |
2819 (defconst isearch:read-kanji-string 'read-kanji-string) | |
2820 | |
2821 ;;; $B5-9fF~NO(B | |
2822 | |
2823 (defvar special-symbol-input-point nil) | |
2824 | |
2825 (defun special-symbol-input () | |
2826 (interactive) | |
2827 (require 'egg-jsymbol) | |
2828 ;; 92.7.8 by Y.Kawabe | |
2829 (let ((item (menu:select-from-menu | |
2830 *symbol-input-menu* special-symbol-input-point t)) | |
2831 (code t)) | |
2832 (and (listp item) | |
2833 (setq code (car item) special-symbol-input-point (cdr item))) | |
2834 ;; end of patch | |
2835 (cond((stringp code) (insert code)) | |
2836 ((consp code) (eval code)) | |
2837 ))) | |
2838 | |
2839 (define-key global-map "\C-^" 'special-symbol-input) | |
2840 | |
2841 (autoload 'busyu-input "busyu" nil t) ;92.10.18 by K.Handa | |
2842 (autoload 'kakusuu-input "busyu" nil t) ;92.10.18 by K.Handa | |
2843 | |
2844 ;;; egg.el ends here |