comparison lisp/skk/skk-tut.el @ 219:262b8bb4a523 r20-4b8

Import from CVS: tag r20-4b8
author cvs
date Mon, 13 Aug 2007 10:09:35 +0200
parents
children
comparison
equal deleted inserted replaced
218:c9f226976f56 219:262b8bb4a523
1 ;; SKK tutorial for SKK version 9.4 and later versions
2 ;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
3 ;; Masahiko Sato <masahiko@kuis.kyoto-u.ac.jp>
4
5 ;; Author: Masahiko Sato <masahiko@kuis.kyoto-u.ac.jp>
6 ;; Maintainer: Mikio Nakajima <minakaji@osaka.email.ne.jp>
7 ;; Version: $Id: skk-tut.el,v 1.1 1997/12/02 08:48:39 steve Exp $
8 ;; Keywords: japanese
9 ;; Last Modified: $Date: 1997/12/02 08:48:39 $
10
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either versions 2, or (at your option)
14 ;; any later version.
15
16 ;; This program is distributed in the hope that it will be useful
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with SKK, see the file COPYING. If not, write to the Free
23 ;; Software Foundation Inc., 59 Temple Place - Suite 330, Boston,
24 ;; MA 02111-1307, USA.
25
26 ;;; Commentary:
27
28 ;; Following people contributed modifications to skk-tut.el
29 ;; (Alphabetical order):
30 ;; Haru'yasu Ueda <hal@sics.se>
31 ;; Hideki Sakurada <sakurada@kusm.kyoto-u.ac.jp>
32 ;; Hitoshi SUZUKI <h-suzuki@ael.fujitsu.co.jp>
33 ;; IIDA Yosiaki <iida@sayla.secom-sis.co.jp>
34 ;; Koji Uchida <uchida@cfd.tytlabs.co.jp>
35 ;; Mikio Nakajima <minakaji@osaka.email.ne.jp>
36 ;; Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
37 ;; Toyonobu Yoshida <toyono-y@is.aist-nara.ac.jp>
38 ;; Wataru Matsui <matsui@gf.hm.rd.sanyo.co.jp>
39 ;; $BD@;VM&(B <jshen@cas.org>
40
41 ;;; Change log:
42 ;; version 4.10 released 1997.2.4
43 ;; version 3.9 released 1996.2.7
44 ;; version 3.8 released 1995.5.13
45 ;; version 3.7 released 1993.5.20
46 ;; version 3.6 released 1992.9.19
47 ;; version 3.5 released 1992.5.31
48 ;; version 3.4 released 1992.4.12
49 ;; version 3.3 released 1991.4.20
50 ;; version 3.2 released 1990.4.15
51 ;; version 2.2 released 1989.4.15
52
53 ;;; Code:
54 (require 'skk-foreword)
55 (require 'skk-vars)
56 (require 'advice)
57
58 ;#SJT# This should be adjusted to XEmacs convention.
59 ; And patches to Murata-san should be SKK convention.
60 (defvar skk-tut-file-alist
61 '(("Japanese" . (expand-file-name "skk/SKK.tut" data-directory))
62 ("English" . (expand-file-name "skk/SKK.tut.E" data-directory)))
63 "*
64 Alist of `(LANGUAGE . TUTORIAL-FILE)' pairs."
65 )
66
67 (defvar skk-tut-file "/usr/local/share/skk/SKK.tut"
68 "*SKK $B%A%e!<%H%j%"%k$N%U%!%$%kL>!#(B
69 The English version is SKK.tut.E." )
70
71 (defvar skktut-japanese-tut
72 (string= (file-name-nondirectory skk-tut-file) "SKK.tut")
73 "Non-nil $B$G$"$l$P!"%A%e!<%H%j%"%k$,F|K\8l$G$"$k$3$H$r<($9!#(B" )
74
75 (defvar skktut-use-face t
76 "*Non-nil $B$G$"$l$P!"%A%e!<%H%j%"%k$G(B face $B$rMxMQ$7$?I=<($r9T$J$&!#(B" )
77
78 (defvar skktut-section-face
79 (and skktut-use-face
80 (cond ((and (eq skk-background-mode 'mono) (skk-terminal-face-p))
81 'bold-italic )
82 ((eq skk-background-mode 'light)
83 (skk-make-face 'yellow/dodgerblue) )
84 (t (skk-make-face 'yellow/slateblue)) ))
85 "*$B%A%e!<%H%j%"%kCf$N%;%/%7%g%s$NI=<(ItJ,$N(B face$B!#(B" )
86
87 (defvar skktut-do-it-face
88 (and skktut-use-face
89 (cond ((and (eq skk-background-mode 'mono) (skk-terminal-face-p))
90 'bold )
91 ((eq skk-background-mode 'light)
92 (skk-make-face 'DarkGoldenrod) )
93 (t (skk-make-face 'LightGoldenrod)) ))
94 "*$B%A%e!<%H%j%"%kCf$N;X<(9`L\$NI=<(ItJ,$N(B face$B!#(B" )
95
96 (defvar skktut-question-face
97 (and skktut-use-face
98 (cond ((and (eq skk-background-mode 'mono) (skk-terminal-face-p))
99 'underline )
100 ((eq skk-background-mode 'light)
101 (skk-make-face 'Blue) )
102 (t (skk-make-face 'LightSkyBlue)) ))
103 "*$B%A%e!<%H%j%"%kCf$NLdBj$NI=<(ItJ,$N(B face$B!#(B" )
104
105 (defvar skktut-key-bind-face
106 (and skktut-use-face
107 (cond ((and (eq skk-background-mode 'mono) (skk-terminal-face-p))
108 'bold )
109 ((eq skk-background-mode 'light)
110 (skk-make-face 'Firebrick) )
111 (t (skk-make-face 'OrangeRed)) ))
112 "*$B%A%e!<%H%j%"%kCf$N%-!<%P%$%s%I$NI=<(ItJ,$N(B face$B!#(B" )
113
114 (defvar skktut-hint-face
115 (and skktut-use-face
116 (cond ((and (eq skk-background-mode 'mono) (skk-terminal-face-p))
117 'italic )
118 ((eq skk-background-mode 'light)
119 (skk-make-face 'CadetBlue) )
120 (t (skk-make-face 'Aquamarine)) ))
121 "*$B%A%e!<%H%j%"%kCf$N%R%s%H$NI=<(ItJ,$N(B face$B!#(B
122 $B8=:_$N$H$3$m!"(BSKK.tut.E $B$G$7$+;HMQ$5$l$F$$$J$$!#(B" )
123
124 (defconst skktut-problem-numbers 37 "SKK $B%A%e!<%H%j%"%k$NLdBj?t!#(B")
125
126 (defconst skktut-tut-jisyo "~/skk-tut-jisyo"
127 "SKK $B%A%e!<%H%j%"%kMQ$N%@%_!<<-=q!#(B" )
128
129 (defconst skktut-init-variables-alist
130 '((skk-init-file . "")
131 (skk-special-midashi-char-list . (?> ?< ??))
132 (skk-mode-hook . nil)
133 (skk-auto-fill-mode-hook . nil)
134 (skk-load-hook . nil)
135 (skk-search-prog-list . ((skk-search-jisyo-file skktut-tut-jisyo 0 t)))
136 (skk-jisyo . "~/skk-tut-jisyo")
137 (skk-keep-record . nil)
138 (skk-kakutei-key . "\C-j")
139 (skk-use-vip . nil)
140 (skk-use-viper . nil)
141 (skk-henkan-okuri-strictly . nil)
142 (skk-henkan-strict-okuri-precedence . nil)
143 (skk-auto-okuri-process . nil)
144 (skk-process-okuri-early . nil)
145 (skk-egg-like-newline . nil)
146 (skk-kakutei-early . t)
147 (skk-delete-implies-kakutei . t)
148 (skk-allow-spaces-newlines-and-tabs . t)
149 (skk-convert-okurigana-into-katakana . nil)
150 (skk-delete-okuri-when-quit . nil)
151 (skk-henkan-show-candidates-keys . (?a ?s ?d ?f ?j ?k ?l))
152 (skk-ascii-mode-string . " SKK")
153 (skk-hirakana-mode-string . " $B$+$J(B")
154 (skk-katakana-mode-string . " $B%+%J(B")
155 (skk-zenkaku-mode-string . " $BA41Q(B")
156 (skk-abbrev-mode-string . " a$B$"(B")
157 (skk-echo . t)
158 (skk-use-numeric-conversion . t)
159 ;;(skk-char-type-vector . nil)
160 ;;(skk-standard-rom-kana-rule-list . nil)
161 (skk-rom-kana-rule-list . nil)
162 (skk-postfix-rule-alist . (("oh" "$B%*(B" . "$B$*(B")))
163 (skk-previous-candidate-char . nil)
164 ;;(skk-input-vector . nil)
165 ;;(skk-zenkaku-vector . nil)
166 ;;(skk-use-face . t)
167 ;;(skk-henkan-face)
168 ;;(skk-use-color-cursor . t)
169 ;;(skk-default-cursor-color . "Black")
170 ;;(skk-hirakana-cursor-color . t)
171 ;;(skk-katakana-cursor-color . t)
172 (skk-zenkaku-cursor-color . "gold")
173 (skk-ascii-cursor-color . "ivory4")
174 (skk-abbrev-cursor-color . "royalblue")
175 (skk-report-set-cursor-error . t)
176 (skk-auto-insert-paren . nil)
177 (skk-japanese-message-and-error . nil)
178 (skk-ascii-mode-map . nil)
179 (skk-j-mode-map . nil)
180 (skk-zenkaku-mode-map . nil)
181 (skk-abbrev-mode-map . nil)
182 (skk-jisyo-save-count . nil)
183 (skk-byte-compile-init-file . nil)
184 (skk-count-private-jisyo-candidates-exactly . nil)
185 (skk-compare-jisyo-size-when-saving . nil)
186 (skk-auto-start-henkan . nil)
187 (skk-insert-new-word-function . nil)
188
189 (skk-date-ad . 1)
190 (skk-number-style . 1)
191 (skk-gadget-load-hook . nil)
192
193 (skk-input-by-code-menu-keys1 . (?a ?s ?d ?f ?g ?h ?q ?w ?e ?r ?t ?y))
194 (skk-input-by-code-menu-keys2 . (?a ?s ?d ?f ?g ?h ?j ?k ?l ?q ?w ?e ?r ?t ?y ?u))
195 (skk-kcode-load-hook . nil)
196
197 ;;(skk-num-type-list . nil)
198 (skk-numeric-conversion-float-num . nil)
199 (skk-uniq-numerals . t)
200 (skk-num-load-hook . nil)
201
202 (skk-dabbrev-like-completion . nil)
203 (skk-comp-load-hook . nil))
204 "skk.el $B$N%f!<%6!<JQ?t$N%j%9%H!#(B" )
205
206 (defvar skktut-right-answer nil "$BLdBj$N@52r$NJ8;zNs!#(B")
207 (defvar skktut-problem-count 0 "SKK $B%A%e!<%H%j%"%k$N8=:_$NLdBjHV9f!#(B")
208 (defvar skktut-tutorial-end nil "SKK $B%A%e!<%H%j%"%k$N=*N;$r<($9%U%i%0!#(B")
209 (defvar skktut-tutorial-map nil "SKK $B%A%e!<%H%j%"%k$N$?$a$N%-!<%^%C%W!#(B")
210
211 (defvar skktut-original-buffer nil
212 "skk-tutorial $B$r8F$s$@$H$-$N%P%C%U%!L>!#(B" )
213
214 (defvar skktut-skk-on nil
215 "Non-nil $B$G$"$l$P!"(Bskk-tutorial $B$r5/F0$7$?$H$-$K(B SKK $B$,4{$K5/F0$5$l$F$$$?$3$H$r<($9!#(B" )
216
217 ;; -- macros
218 (defmacro skktut-message (japanese english &rest arg)
219 ;; skktut-japanese-tut $B$,(B non-nil $B$@$C$?$i(B JAPANESE $B$r(B nil $B$G$"$l$P(B ENGLISH
220 ;; $B$r%(%3!<%(%j%"$KI=<($9$k!#(B
221 ;; ARG $B$O(B message $B4X?t$NBh#20z?t0J9_$N0z?t$H$7$FEO$5$l$k!#(B
222 (append (list 'message (list 'if 'skktut-japanese-tut japanese english))
223 arg ))
224
225 (defmacro skktut-error (japanese english &rest arg)
226 ;; skktut-japanese-tut $B$,(B non-nil $B$@$C$?$i(B JAPANESE $B$r(B nil $B$G$"$l$P(B ENGLISH
227 ;; $B$r%(%3!<%(%j%"$KI=<($7!"%(%i!<$rH/@8$5$;$k!#(B
228 ;; ARG $B$O(B error $B4X?t$NBh#20z?t0J9_$N0z?t$H$7$FEO$5$l$k!#(B
229 (append (list 'error (list 'if 'skktut-japanese-tut japanese english))
230 arg ))
231
232 (defmacro skktut-yes-or-no-p (japanese english)
233 (list 'yes-or-no-p (list 'if 'skktut-japanese-tut japanese english)) )
234
235 ;;;###autoload
236 (defun skk-tutorial (&optional query-language)
237 "SKK $B%A%e!<%H%j%"%k$r5/F0$9$k!#(B"
238 (interactive "P")
239 (if query-language
240 (let ((lang
241 (completing-read "Language: " skk-tut-file-alist)))
242 (setq skk-tut-file (cdr (assoc lang skk-tut-file-alist)))
243 (message "SKK tutorial language set to %s until you exit Emacs."
244 lang)))
245 (let ((inhibit-quit t))
246 (if (not (< 9.4 (string-to-number (skk-version))))
247 (error "skk.el version 9.4 or later is required")
248 (skktut-pre-setup-tutorial)
249 (skktut-setup-jisyo-buffer)
250 (skktut-setup-working-buffer)
251 (skktut-setup-problem-buffer)
252 (skktut-setup-answer-buffer) )))
253
254 (defun skktut-save-buffers-kill-emacs (&optional query)
255 (interactive "P")
256 (if (skktut-yes-or-no-p "Tutorial $B$b(B Emacs $B$b=*N;$7$^$9!#$h$m$7$$$G$9$M!)(B "
257 "Quit tutorial and kill emacs? " )
258 (progn (skktut-quit-tutorial 'now)
259 (save-buffers-kill-emacs query) )))
260
261 (defun skktut-tutorial-again ()
262 (interactive)
263 (if (skktut-yes-or-no-p "$B:G=i$+$i(B Tutorial $B$r$d$jD>$7$^$9!#$h$m$7$$$G$9$M!)(B "
264 "Quit tutorial and start from question 1 again? " )
265 (progn (skktut-quit-tutorial 'now)
266 (skk-tutorial) )))
267
268 (defun skktut-mode ()
269 (interactive)
270 (if (eq skktut-problem-count 1)
271 (skktut-error "$B$3$N%-!<$O$^$@;H$($^$;$s(B"
272 "Cannot use this key yet" )
273 (if skk-mode
274 (skk-j-mode-on)
275 (add-hook 'before-make-frame-hook 'skktut-before-move-to-other-frame)
276 (skk-j-mode-on)
277 (define-key minibuffer-local-map "\C-j" 'skk-mode)
278 ;;(define-key minibuffer-local-map "\C-m" 'skk-newline)
279 )))
280
281 (defun skktut-kakutei (&optional word)
282 (interactive)
283 (if (eq skktut-problem-count 1)
284 (skktut-error "$B$3$N%-!<$O$^$@;H$($^$;$s(B"
285 "Cannot use this key yet" )
286 (skk-kakutei word) ))
287
288 (defun skktut-error-command ()
289 (interactive)
290 (switch-to-buffer-other-window "*$BEz(B*") )
291
292 (defun skktut-quit-tutorial (&optional now)
293 (interactive)
294 (if (or now (skktut-yes-or-no-p "$BK\Ev$K%A%e!<%H%j%"%k$r$d$a$^$9$+(B? "
295 "Quit tutorial? " ))
296 (let ((inhibit-quit t))
297 (delete-other-windows)
298 ;; $B:FEY%A%e!<%H%j%"%k$r;H$($k$h$&$K!"FbItJQ?t$r=i4|2=$7$F$*$/!#(B
299 (setq skktut-japanese-tut nil
300 skktut-problem-count 0
301 skktut-right-answer nil
302 skktut-tutorial-end nil
303 skktut-tutorial-map nil )
304 (remove-hook 'minibuffer-setup-hook 'skktut-localize-and-init-variables)
305 (remove-hook 'before-make-frame-hook
306 'skktut-before-move-to-other-frame )
307 (ad-remove-advice 'other-frame 'before 'skktut-ad)
308 (ad-remove-advice 'select-frame 'before 'skktut-ad)
309 (ad-activate 'other-frame)
310 (ad-activate 'select-frame)
311 (if (featurep 'mule)
312 (if (fboundp 'skktut-save-set-henkan-point)
313 (skktut-change-func-def 'skk-set-henkan-point
314 'skktut-save-set-henkan-point ))
315 (if (fboundp 'skktut-nemacs-set-henkan-point)
316 (skktut-change-func-def 'skk-set-henkan-point
317 'skktut-nemacs-set-henkan-point )))
318 (if (fboundp 'skktut-save-abbrev-mode)
319 (skktut-change-func-def 'skk-abbrev-mode
320 'skktut-save-abbrev-mode ))
321 (fmakunbound 'skktut-save-set-henkan-point)
322 (fmakunbound 'skktut-save-abbrev-mode)
323 (fmakunbound 'skktut-nemacs-set-henkan-point)
324 ;; skk-jisyo ;; for debugging
325 (let ((buff (get-file-buffer skktut-tut-jisyo)))
326 (if buff
327 (progn
328 (set-buffer buff)
329 (set-buffer-modified-p nil)
330 (kill-buffer buff))))
331 (kill-buffer " *skk-tutorial*")
332 (kill-buffer "*$BEz(B*")
333 (kill-buffer "*$BLd(B*")
334 ;;(skk-kill-local-variables)
335 (switch-to-buffer skktut-original-buffer)
336 ;; SKK $B$r5/F0$;$:$K$$$-$J$j(B
337 ;; skk-tutorial $B$r<B9T$7$?$H$-$K(B skk-jisyo $B%P%C%U%!$,:n$i$l$J$$$N$G(B
338 ;; skk-setup-jisyo-buffer $B$G%(%i!<$H$J$j!"(BEmacs $B$N=*N;$,$G$-$J$/(B
339 ;; $B$J$k$N$G(B SKK $B%b!<%I$r0lEY5/$3$7$F$*$/!#(B
340 (skk-mode 1)
341 ;; $B%A%e!<%H%j%"%k5/F0D>A0$K3+$$$F$$$?%P%C%U%!$G!"(Bskk-mode $B$r5/F0$7$F(B
342 ;; $B$$$?$i!"$=$N>uBV$K$7$F!"%A%e!<%H%j%"%k$r=*N;$9$k!#(B
343 ;; skk-jisyo ;; for debugging
344 (or skktut-skk-on
345 (skk-mode -1) ))))
346
347 (defun skktut-answer-window ()
348 (interactive)
349 (let (p)
350 (save-match-data
351 (goto-char (point-max))
352 (search-backward "\n>>")
353 (forward-char 1)
354 (setq skktut-right-answer
355 (skk-buffer-substring (+ 3 (point))
356 (skk-save-point (end-of-line) (point)) ))
357 (switch-to-buffer-other-window "*$BEz(B*")
358 (insert ">> \n\n")
359 (setq p (point))
360 (if skktut-japanese-tut
361 (insert "* $BEz$,$G$-$?$i!X(BC-x n$B!Y(B; $BESCf$G$d$a$k$K$O!X(BC-x q$B!Y(B; "
362 "$B%9%-%C%W$9$k$K$O!X(BC-x s$B!Y(B *" )
363 (insert "* For next question `C-x n'; to quit `C-x q'; "
364 "to skip this question `C-x s' *" ))
365 (if skktut-use-face
366 (put-text-property p (point) 'face skktut-key-bind-face) )
367 (put-text-property p (point) 'read-only t)
368 (goto-char (+ (point-min) 3)) )))
369
370 (defun skktut-next-window ()
371 (interactive)
372 (save-match-data
373 (let (user-ans)
374 (skk-save-point
375 (goto-char (point-min))
376 (end-of-line)
377 (skip-chars-backward " \t")
378 (setq user-ans (skk-buffer-substring (+ 3 (point-min)) (point))) )
379 (if (not (string= skktut-right-answer user-ans))
380 (progn
381 (skktut-message "$BEz$,0c$$$^$9!#$b$&0lEY$d$C$F$_$F2<$5$$(B"
382 "Wrong. Try again")
383 (ding) )
384 (skktut-erase-buffer)
385 (message "")
386 (other-window 1)
387 (setq skktut-problem-count (1+ skktut-problem-count))
388 (skktut-get-page skktut-problem-count)
389 (if (>= skktut-problem-count (1+ skktut-problem-numbers))
390 (skktut-quit-tutorial t)
391 (skktut-answer-window) )))))
392
393 (defun skktut-skip-problem (arg)
394 (interactive "p")
395 (skktut-erase-buffer)
396 (setq skktut-problem-count (+ skktut-problem-count arg))
397 (if (< skktut-problem-count 1) (setq skktut-problem-count 1))
398 (if (> skktut-problem-count skktut-problem-numbers)
399 (setq skktut-problem-count skktut-problem-numbers))
400 (if (and (>= skktut-problem-count 3) (not skk-j-mode))
401 (skktut-mode) )
402 (other-window 1)
403 (skktut-get-page skktut-problem-count)
404 (if skktut-tutorial-end (skktut-quit-tutorial 'now) (skktut-answer-window)) )
405
406 (defun skktut-set-henkan-point-tmp ()
407 (interactive)
408 (if skk-j-mode
409 (skktut-error "$B$+$J(B/$B%+%J%b!<%I$G$O!"1QBgJ8;z$O$^$@;H$($^$;$s(B"
410 "Cannot use upper case character in kana/katakana mode" )
411 (insert (if skk-zenkaku-mode
412 (concat (char-to-string 163)
413 (char-to-string (+ last-command-char 128)))
414 last-command-char))))
415
416 (defun skktut-abbrev-mode-tmp ()
417 (interactive)
418 (if skk-j-mode
419 (skktut-error "$B$3$N%-!<$O$^$@;H$($^$;$s(B"
420 "Cannot use this key yet" )
421 (insert last-command-char)))
422
423 (defun skktut-get-page (page)
424 (save-match-data
425 (with-current-buffer " *skk-tutorial*"
426 (let (pos)
427 (goto-char (point-min))
428 (search-forward "--\n" nil t page)
429 (if (looking-at ";")
430 (progn (forward-char 3)
431 (setq pos (point))
432 (end-of-line)
433 (save-excursion
434 (eval-region pos (point) nil) )
435 (forward-char 1) ))
436 (if (not skktut-tutorial-end)
437 (progn
438 (setq pos (point))
439 (search-forward "\n>>")
440 (end-of-line)
441 (copy-to-buffer "*$BLd(B*" pos (point)) ))))
442 (if (>= page 12)
443 (skktut-enable) )
444 (setq mode-line-buffer-identification
445 (concat "$B#S#K#K%A%e!<%H%j%"%k(B: $B!NLd(B "
446 (int-to-string page)
447 "$B!O(B $B!J;D$j(B "
448 (int-to-string (- skktut-problem-numbers page))
449 "$BLd!K(B"))
450 (set-buffer-modified-p nil)
451 (sit-for 0) ))
452
453 (defun skktut-disable ()
454 (if (not (fboundp 'skktut-save-set-henkan-point))
455 (progn
456 (skktut-change-func-def 'skktut-save-set-henkan-point
457 'skk-set-henkan-point )
458 (skktut-change-func-def 'skk-set-henkan-point
459 'skktut-set-henkan-point-tmp )))
460 (if (not (fboundp 'skktut-save-abbrev-mode))
461 (progn
462 (skktut-change-func-def 'skktut-save-abbrev-mode 'skk-abbrev-mode)
463 (skktut-change-func-def 'skk-abbrev-mode 'skktut-abbrev-mode-tmp) )))
464
465 (defun skktut-enable ()
466 (if (fboundp 'skktut-save-abbrev-mode)
467 (progn (skktut-change-func-def 'skk-abbrev-mode 'skktut-save-abbrev-mode)
468 (fmakunbound 'skktut-save-abbrev-mode) ))
469 (if (fboundp 'skktut-save-set-henkan-point)
470 (progn (skktut-change-func-def 'skk-set-henkan-point
471 'skktut-save-set-henkan-point )
472 (fmakunbound 'skktut-save-set-henkan-point) )))
473
474 (defun skktut-pre-setup-tutorial ()
475 (setq skktut-original-buffer (current-buffer)
476 skktut-skk-on skk-mode
477 skktut-problem-count 1 ))
478
479 (defadvice other-frame (before skktut-ad activate)
480 (skktut-before-move-to-other-frame) )
481
482 (defadvice select-frame (before skktut-ad activate)
483 (skktut-before-move-to-other-frame) )
484
485 (add-hook 'minibuffer-setup-hook 'skktut-localize-and-init-variables)
486
487 (defun skktut-setup-jisyo-buffer ()
488 ;; setup skktut-tut-jisyo buffer.
489 (set-buffer (get-buffer-create " *skk-tut-jisyo*"))
490 (setq case-fold-search nil
491 buffer-file-name (expand-file-name skktut-tut-jisyo) )
492 (buffer-disable-undo (current-buffer))
493 (insert (concat ";; okuri-ari entries.\n"
494 "$B$[$C(Bs /$BM_(B/\n"
495 "$B$D$+(Bt /$B;H(B/\n"
496 "$B$?$C(Bs /$BC#(B/\n"
497 "$B$7(Bt /$BCN(B/\n"
498 "$B$&$4(Bk /$BF0(B/\n"
499 ";; okuri-nasi entries.\n"
500 "Greek /$B&!(B/$B&"(B/$B&#(B/$B&$(B/$B&%(B/$B&&(B/$B&'(B/$B&((B/$B&)(B/$B&*(B/$B&+(B/$B&,(B/$B&-(B/$B&.(B/$B&/(B/$B&0(B/"
501 "$B&1(B/$B&2(B/$B&3(B/$B&4(B/$B&5(B/$B&6(B/$B&7(B/$B&8(B/\n"
502 "Russia /$B'!(B/$B'"(B/$B'#(B/$B'$(B/$B'%(B/$B'&(B/$B''(B/$B'((B/$B')(B/$B'*(B/$B'+(B/$B',(B/$B'-(B/$B'.(B/$B'/(B/$B'0(B/"
503 "$B'1(B/$B'2(B/$B'3(B/$B'4(B/$B'5(B/$B'6(B/$B'7(B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E*(B/$BE((B/$BE)(B/$BE,(B/$BE&(B/\n"
536 "$B$H$&(B /$BEl(B/\n"
537 "$B$H$&$[$/(B /$BElKL(B/\n"
538 "$B$H$&$m$/(B /$BEPO?(B/\n"
539 "$B$H$&$m$/(B /$BEPO?(B/\n"
540 "$B$I$&(B /$BF0(B/\n"
541 "$B$K$e$&$j$g$/(B /$BF~NO(B/\n"
542 "$B$R$3$&$-(B /$BHt9T5!(B/\n"
543 "$B$X$s$+$s(B /$BJQ49(B/\n"
544 "$B$[$/(B /$BKL(B/\n"
545 "$B$_$g$&$8(B /$BL>;z(B/\n"
546 "$B$h$&$$(B /$BMF0W(B/$BMQ0U(B/\n" ))
547 (skk-setup-jisyo-buffer)
548 (skktut-localize-and-init-variables) )
549
550 (defun skktut-setup-working-buffer ()
551 (save-match-data
552 (let (sexp)
553 (set-buffer (get-buffer-create " *skk-tutorial*"))
554 ;; " *skk-tut-jisyo*" $B%P%C%U%!$N(B skk.el $B$NJQ?t$r%P%C%U%!%m!<%+%k2=$7!"(B
555 ;; $B=i4|2=$9$k!#(B
556 (skktut-localize-and-init-variables)
557 (erase-buffer)
558 (insert-file-contents skk-tut-file)
559 (goto-char (point-min))
560 ;; $B%A%e!<%H%j%"%k$,F|K\8l$+1Q8l$+$r%A%'%C%/!#(B
561 (setq skktut-japanese-tut (looking-at ";; SKK Japanese"))
562 (while (re-search-forward "^>> \\((.+)\\)$" nil t nil)
563 (setq sexp (skk-buffer-substring (match-beginning 1) (match-end 1)))
564 (delete-region (match-beginning 1) (match-end 1))
565 (insert (eval (car (read-from-string sexp)))) )
566 (goto-char (point-min))
567 (if skktut-use-face
568 (skktut-colored) ))))
569
570 (defun skktut-setup-problem-buffer ()
571 (switch-to-buffer (get-buffer-create "*$BLd(B*"))
572 (erase-buffer)
573 (setq skktut-tutorial-map (make-keymap))
574 (if (featurep 'xemacs)
575 (map-keymap
576 #'(lambda (key ignored)
577 (define-key skktut-tutorial-map key 'skktut-error-command))
578 skktut-tutorial-map)
579 (fillarray (nth 1 skktut-tutorial-map) 'skktut-error-command))
580 (use-local-map skktut-tutorial-map)
581 (skktut-get-page skktut-problem-count)
582 (delete-other-windows)
583 (split-window-vertically nil)
584 (other-window 1)
585 (enlarge-window (- (window-height (selected-window)) 20)) )
586
587 (defun skktut-setup-answer-buffer ()
588 (switch-to-buffer (get-buffer-create "*$BEz(B*"))
589 ;; "*$BEz(B*" $B%P%C%U%!$N(B skk.el $B$NJQ?t$r%P%C%U%!%m!<%+%k2=$7!"=i4|2=$9$k!#(B
590 (skktut-localize-and-init-variables)
591 (local-set-key "\C-j" 'skktut-kakutei)
592 (local-set-key "\C-x\C-c" 'skktut-save-buffers-kill-emacs)
593 (local-set-key "\C-x\C-j" 'skktut-mode)
594 (local-set-key "\C-xj" 'skktut-error-command)
595 (local-set-key "\C-xn" 'skktut-next-window)
596 (local-set-key "\C-xq" 'skktut-quit-tutorial)
597 (local-set-key "\C-xs" 'skktut-skip-problem)
598 (local-set-key "\C-xt" 'skktut-tutorial-again)
599 (skktut-disable)
600 (auto-fill-mode -1)
601 (switch-to-buffer-other-window "*$BLd(B*")
602 (goto-char (point-max))
603 (beginning-of-line)
604 (skktut-answer-window)
605 (message "") )
606
607 (defun skktut-localize-and-init-variables ()
608 ;; $B%f!<%6!<$,(B skk.el $B$NJQ?t$r%+%9%?%^%$%:$7$F$$$k2DG=@-$,$"$k$N$G!"%+%l%s%H(B
609 ;; $B%P%C%U%!$N(B skk.el $B$NJQ?t$r%P%C%U%!%m!<%+%k2=$7!"=i4|2=$9$k!#(B
610 (mapcar
611 (function
612 (lambda (alist)
613 (let ((v (car alist)))
614 (make-local-variable v)
615 (set v (cdr alist)))))
616 skktut-init-variables-alist)
617 (if (string= (buffer-name) "*$BEz(B*")
618 (load-library "skk"))
619 (make-local-variable 'skk-mode-invoked)
620 (setq skk-mode-invoked 'invoked))
621
622 (defun skktut-erase-buffer ()
623 (let ((inhibit-read-only t))
624 (set-text-properties (point-min) (point-max) nil) )
625 (erase-buffer) )
626
627 (defun skktut-before-move-to-other-frame ()
628 (if (skktut-yes-or-no-p "Tutorial $B$r=*N;$7$^$9!#$h$m$7$$$G$9$M!)(B "
629 "Quit tutorial?" )
630 (skktut-quit-tutorial 'now)
631 (skktut-error "Tutorial $B$r=*N;$;$:$KB>$N%U%l!<%`$K0\$k$3$H$O$G$-$^$;$s!#(B"
632 "Quit tutorial or you cannot move to other frame" )))
633
634 (defun skktut-colored ()
635 (while (re-search-forward "$B"'(B\\([^$B![(B $B$!(B-$B$s%!(B-$B%s(B]+\\)" nil t nil)
636 (put-text-property (match-beginning 1) (match-end 1) 'face
637 'highlight ))
638 (goto-char (point-min))
639 (while (re-search-forward "^==.+==$" nil t nil)
640 (put-text-property (match-beginning 0) (match-end 0)
641 'face skktut-section-face ))
642 (goto-char (point-min))
643 (while (re-search-forward "^!!.+" nil t nil)
644 (put-text-property (match-beginning 0) (match-end 0)
645 'face skktut-do-it-face ))
646 (goto-char (point-min))
647 (while (re-search-forward "^>> \\(.+\\)$" nil t nil)
648 (put-text-property (match-beginning 1) (match-end 1)
649 'face skktut-question-face ))
650 (if skktut-japanese-tut
651 nil
652 (goto-char (point-min))
653 (while (re-search-forward "Hint: .*$" nil t nil)
654 (put-text-property (match-beginning 0) (match-end 0)
655 'face skktut-hint-face ))))
656
657 (defun skktut-change-func-def (old new &optional save)
658 ;; $B4X?t(B OLD $B$NDj5A$r(B NEW $B$GCV$-JQ$($k!#(B
659 ;; $B%*%W%7%g%J%k0z?t$N(B SAVE $B$r;XDj$9$k$H!"(BOLD $B$NDj5A$r(B SAVE $B$KJ]B8$9$k!#(B
660 (if save (defalias save (symbol-function old)))
661 (defalias old (symbol-function new)) )
662
663 ;; The following function is tricky, since they are executed by "eval-region".
664
665 (defun skktut-today ()
666 (save-match-data
667 (let (str p)
668 (widen)
669 (search-forward "\n>> ")
670 (if (re-search-forward "$B!V(B.*$B!W(B" (skk-save-point (end-of-line) (point)) t)
671 (delete-region (match-beginning 0) (match-end 0)) )
672 (setq p (point)
673 str (concat "$B!V$-$g$&$O!"(B" (skk-date) "$B$G$9!#!W(B") )
674 (insert str)
675 (narrow-to-region (point-min) (point))
676 (if skktut-use-face
677 (put-text-property p (point) 'face skktut-question-face) ))))
678
679 (defun skktut-end-tutorial ()
680 (message "")
681 (switch-to-buffer "*$BLd(B*")
682 (delete-other-windows)
683 (erase-buffer)
684 (goto-char (point-min))
685 (if skktut-japanese-tut
686 (insert
687 (concat "SKK $B%A%e!<%H%j%"%k$O$3$l$G=*$j$G$9!#(B\n\n"
688 "SKK $B$K4X$9$k<ALd!"%3%a%s%H!"(Bbug report $BEy$O(B\n\n"
689 "\tskk@kuis.kyoto-u.ac.jp\n\n"
690 "$BKx$*Aw$j2<$5$$!#$J$*!"$3$N%"%I%l%9$O(B SKK $B%a%$%j%s%0%j%9%H$N(B"
691 "$B%"%I%l%9$G$9!#(B\n"
692 "$B2sEz$ODL>o$3$N%"%I%l%9$KBP$7$F$J$5$l$k$N$G!"%a%s%P!<$G$J$$(B"
693 "$BJ}$O$=$N;]$rL@(B\n"
694 "$B5-$7$F%a!<%k$r$*Aw$j$/$@$5$$!#(B SKK $B%a%$%j%s%0%j%9%H$X;22C4u(B"
695 "$BK>$N>l9g$O(B\n\n"
696 "\tskk-join@kuis.kyoto-u.ac.jp\n\n"
697 "$B$X%a!<%k$r$*Aw$j$/$@$5$$(B\n\n"
698 "!! $B:G8e$K(B <return> $B%-!<$r2!$7$F$/$@$5$$!#(B" ))
699 (insert
700 (concat "Now we end the SKK tutorial.\n\n"
701 "Please send comments, questions and bug reports on SKK to:\n\n"
702 "\tskk@kuis.kyoto-u.ac.jp\n\n"
703 "This is the address of the SKK mailing list, and normally the "
704 "responces\n"
705 "will be sent only to the ML members. So, if you are not a ML "
706 "member,\n"
707 "please say so in your mail. If you are interested in joining "
708 "the SKK ML,\n"
709 "send a mail to:\n\n"
710 "\tskk-join@kuis.kyoto-u.ac.jp\n\n"
711 "!! Hit <return> key when you are ready." )))
712 (if skktut-use-face
713 (save-match-data
714 (goto-char (point-min))
715 (re-search-forward "^!!.+" nil t nil)
716 (put-text-property (match-beginning 0) (match-end 0)
717 'face skktut-do-it-face )))
718 (while (not (= ?\C-m (read-char)))
719 (skktut-message "<return> $B%-!<$r2!$7$F$/$@$5$$(B" "Hit <return> key")
720 (ding) )
721 (setq skktut-tutorial-end t) )
722
723 (provide 'skk-tut)
724 ;;; skk-tut.el ends here