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