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