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