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