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