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