Remove non-free old and crusty clearcase pkg
[packages] / mule-packages / edict / install.edict.096
1 #!/bin/sh
2
3 # Installation Script Copyright (C) 1992 Bob Kerns <rwk@crl.dec.com>
4
5 echo <<GNUHEADER
6
7 Installation script for edict.el, an gnu emacs interface to EDICTJ
8 Public Domain japanese/english dictionary.
9
10 Contents Copyright (c) 1991, 1992 by Per Hammarlund <perham@nada.kth.se>
11 and Copyright (c) 1992 Bob Kerns <rwk@crl.dec.com>
12
13 edict.el written by Per Hammarlund <perham@nada.kth.se>
14 Morphology and private dictionary handling/editing by Bob Kerns <rwk@crl.dec.com>
15 International installation script by Bob Kerns <rwk@crl.dec.com>
16 Helpful remarks from Ken-Ichi Handa <handa@etl.go.jp>.
17 The EDICTJ PD dictionary is maintained by Jim Breen <jwb@monu6.cc.monash.edu.au>
18 Your credits here if you contribute!
19
20   This program is free software; you can redistribute it and/or modify
21   it under the terms of the GNU General Public License as published by
22   the Free Software Foundation; either version 1, or (at your option)
23   any later version.
24
25   This program is distributed in the hope that it will be useful,
26   but WITHOUT ANY WARRANTY; without even the implied warranty of
27   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28   GNU General Public License for more details.
29
30   You should have received a copy of the GNU General Public License
31   along with this program; if not, write to the Free Software
32   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33
34 GNUHEADER
35
36 export EPATH
37 EPATH="/tmp/edict.$$"
38
39 export PATH
40 PATH=$EPATH:/bin:/usr/bin:$PATH
41 export PWD
42 PWD=`pwd`
43 export DATE
44 DATE=`date`
45
46 # Script for installing the edict nemacs library.
47
48 if [ -d $EPATH ] || [ -f $EPATH ]; then
49         rm -rf $EPATH
50 fi
51
52 trap "rm -rf $EPATH" 0
53 mkdir $EPATH
54
55 if [ -f $EPATH/failure ]; then
56         rm -f $EPATH/failure
57 fi
58
59 cat <<'ENDMSG' >$EPATH/msg
60 #!/bin/sh
61 X=$LN
62
63 if [ ! X = 'EN' ]; then
64         if  egrep "^$X[         ]?$1[   ]?" $EPATH/text >/dev/null; then
65         : ;
66         else
67                 X='EN'
68         fi
69 fi
70
71 egrep "^$X[     ]?$1[   ]?" $EPATH/text >/dev/null ||
72         {
73         echo "Could not find $X message $1"
74         exit 1
75         }
76
77 # Do this to get variable substitution in messages.
78 # Some /bin/sh's aren't 8-bit clean, and all of them will screw up
79 # due to the the '$' chars in the JIS KI/KO sequences.
80 # So we have to do things the hard way.  Instead of allowing arbitrary
81 # variable substitutions, we substitute for a fixed set of vars.
82 # If you add a variable to this list, be sure it's exported!
83
84 sed -e "s!@PWD!$PWD!;
85         s!@DISTDIR!$DISTDIR!;
86         s!@EMACSDIR!$EMACSDIR!;
87         s!@HOME!$HOME!;
88         s!@DATE!$DATE!;
89         s!@LN!$LN!;
90         s!@INSTDIR!$INSTDIR!" $EPATH/text |
91   sed -n -e "s/^$X[     ][      ]*$1[   ][      ]*//p"
92 ENDMSG
93 chmod a+x $EPATH/msg
94
95 cat <<'ENDLOG' >$EPATH/log
96 #!/bin/sh
97 export LN
98 # Log the user's responses & the program's actions & discoveries.
99
100 msg $1 >>/tmp/edict.log.$LN
101
102 # For the sake of bug reports, log it in english as well.
103
104 case "$LN" in
105 EN)     ;;
106 *)      LN='EN'
107         msg $1 >>/tmp/edict.log.$LN
108         ;;
109 esac
110
111 ENDLOG
112 chmod a+x $EPATH/log
113
114 cat <<'ENDLOGAPPEND' >$EPATH/logappend
115 #!/bin/sh
116
117 # Append a file to the log file(s)
118
119 cat $1 >>/tmp/edict.log.EN
120
121 case "$LN" in
122 EN)     ;;
123 *)      cat $1 >>/tmp/edict.log.$LN
124         ;;
125 esac
126 rm $1
127 ENDLOGAPPEND
128 chmod a+x $EPATH/logappend
129
130 cat <<'ENDCOPY' >$EPATH/copy
131 #!/bin/sh
132
133 # Copy a file, logging and echoing that fact.
134
135 touch $EPATH/mv.out
136 echo "mv $2  $2.orig"
137 if [ -f $2 ]; then
138         echo "mv $2 $2.orig"
139         mv $2 $2.orig >>$EPATH/mv.out 2>&1 || 
140                 {
141                 cat $EPATH/mv.out
142                 touch $EPATH/failure
143                 }
144 fi
145 echo "mv $2 $2.orig" >>$EPATH/copy.out
146 cat $EPATH/mv.out >>$EPATH/copy.out
147 rm $EPATH/mv.out
148
149 touch $EPATH/cp.out
150 echo "cp -p $1 $2"
151 cp -p $1 $2 >>$EPATH/cp.out 2>&1 || 
152         {
153         cat $EPATH/cp.out
154         touch $EPATH/failure
155         }
156 echo "cp -p $1 $2" >>$EPATH/copy.out
157 cat $EPATH/cp.out >>$EPATH/copy.out
158 rm $EPATH/cp.out
159
160 touch $EPATH/chmod.out
161 echo "chmod 0644 $2"
162 chmod 0644 $2 >>$EPATH/chmod.out 2>&1 || 
163         {
164         cat $EPATH/chmod.out
165         touch $EPATH/failure
166         }
167 echo "chmod 0644 $2" >>$EPATH/copy.out
168 cat $EPATH/chmod.out >>$EPATH/copy.out
169 rm $EPATH/chmod.out
170
171 logappend $EPATH/copy.out
172
173 ENDCOPY
174 chmod a+x $EPATH/copy
175
176 # Build our database of textual messages
177 # First item is the two-character language code.
178 # Second item is the message name.  A multiline message is
179 # formed by having multiple lines with that name.
180 # The remainder of the line is the text which should be printed.
181 cat <<'END' >$EPATH/text
182 # It is OK to have comments in here.
183 # If a translation for a message does not exist, the english version will be used.
184 EN LANGUAGE     Using english messages.
185 JA LANGUAGE     ÆüËܸì¤ò»È¤Ã¤Æ¤¤¤Þ¤¹¡£
186 SW LANGUAGE     Anv{nder svenska meddelanden.
187 EN DISTDIR      What directory has the edict files? [@PWD]
188 JA DISTDIR      edict¤Î¥Õ¥¡¥¤¥ë¤ÎÅÐÏ¿Êí¤Ï¤É¤³¤Ç¤¹¤«¡© [@PWD]
189 SW DISTDIR      Var finns edictprogrammets filer? [@PWD]
190 EN XDISTDIR     The edict files are in @DISTDIR
191 JA XDISTDIR     edict ¤Î¥Õ¥¡¥¤¥ë¤ÎÅÐÏ¿Êí¤Ï @DISTDIR ¤Ë¤¢¤ê¤Þ¤¹¡£
192 SW XDISTDIR     Edictprogrammets filer finns i @DISTDIR.
193 EN EDICTJDIR    What directory has the edictj dictionary? [@DISTDIR]
194 JA EDICTJDIR    edictj ¤È¤¤¤¦ÅŻҼ­Åµ¤Ï¤É¤³¤Ç¤¹¤«¡© [@DISTDIR]
195 SW EDICTJDIR    Var finns lexikonet EDICTJ? [@DISTDIR]
196 EN XEDICTJDIR   The edictj dictionary is in @DISTDIR.
197 JA XEDICTJDIR   edictj¤Ï@DISTDIR¤Ë¤¢¤ê¤Þ¤¹¡£
198 SW XEDICTJDIR   Lexikonet EDICTJ finns i @DISTDIR.
199 EN INSTDIR      Normally, this software should be placed in the directory
200 EN INSTDIR      which holds your site's emacs libraries.  However, you do
201 EN INSTDIR      not have write access to that directory, so you will need to
202 EN INSTDIR      place them somewhere else.
203 EN INSTDIR      
204 EN INSTDIR      In what directory should I put the edict files? [leave in @DISTDIR]
205 JA INSTDIR      Æüº¢¡¢¤³¤Î¥½¥Õ¥È¥¦¥§¥¢¤Ï¥µ¥¤¥È¤Înemacs¤Î¥é¥¤¥Ö¥é¥ê¤ÎÅÐÏ¿Êí¤Ë
206 JA INSTDIR      ³ÊǼ¤¹¤ë¤â¤Î¤Ç¤¹¡£¤Ç¤â¡¢¤¢¤Ê¤¿¤Ï¤½¤ÎÅÐÏ¿Êí¤ò½ñ¤±¤Þ¤»¤ó¡£¤³¤ì¤«¤é¡¢
207 JA INSTDIR      ¥½¥Õ¥È¥¦¥§¥¢¤Ï;½ê¤Ë³ÊǼ¤·¤Þ¤·¤ç¤¦¡£
208 JA INSTDIR
209 JA INSTDIR      edict ¤Ï¡¢¤É¤ÎÅÐÏ¿Êí¤Ë³ÊǼ¤·¤Æ¤ª¤­¤Þ¤·¤ç¤¦¤«¡©  [@DISTDIR]
210 SW INSTDIR      Egentligen skall edictprogrammets filer placeras i katalogen
211 SW INSTDIR      som har emacs |vriga filer; emacs "bibliotek".  Men iom att
212 SW INSTDIR      du inte har skrivr{ttigheter d{r, s} m}ste du l{gga dem
213 SW INSTDIR      n}gon annanstans.
214 SW INSTDIR
215 SW INSTDIR      I vilken katalog ska jag placera edictprogrammets filer? [@DISTDIR]
216 EN XINSTDIR     The installation will be in @INSTDIR
217 JA XINSTDIR     ¥½¥Õ¥È¥¦¥§¥¢¤Ï@INSTDIR¤Ë³ÊǼ¤·¤Þ¤¦¤¹¡£
218 SW XINSTDIR     Edictprogrammet kommer att installeras i @INSTDIR.
219 EN BYTECOMP     Emacs byte-compiling @DISTDIR/edict.el and
220 EN BYTECOMP     @DISTDIR/edict-test.el.
221 SW BYTECOMP     Emacs byte-compiling @DISTDIR/edict.el och
222 SW BYTECOMP     @DISTDIR/edict-test.el.  (Detta ger dig
223 SW BYTECOMP     en "snabbare", kompilerad, version av programmen.)
224 JA BYTECOMP     emacs ¤Ç @DISTDIR/edict.el ¤È
225 JA BYTECOMP     @DISTDIR/edict-test.el ¤ò byte-compile ¤·¤Æ¤¤¤Þ¤¹¡£
226 EN DEFAULTS     In the following questions, if a default value may appear between
227 EN DEFAULTS     square brackets. []  If you type Return, I will use that value.
228 SW DEFAULTS     I de f|ljande fr}gorna s} kan det finnas ett standardsvar, givet mellan
229 SW DEFAULTS     hakparenteser ([]), om du bara trycker RETURN kommer detta standardsvar att
230 SW DEFAULTS     anv{ndas.
231 EN DOTEMACSQ    Should I add the default key bindings and setup to your .emacs file?
232 EN DOTEMACSQ    You may type SHOW to see what will be inserted.
233 EN DOTEMACSQ    Please type yes, no, or show.
234 SW DOTEMACSQ    Ska jag l{gga till n|dv{ndig initieringskod till din .emacs-fil?
235 SW DOTEMACSQ    Om du skriver VISA visar jag vad som kommer att l{ggas till.
236 SW DOTEMACSQ    Svara JA, NEJ, eller VISA.
237 EN DOTEMACSADD  @HOME/.emacs updated.
238 SW DOTEMACSADD  @HOME/.emacs uppdaterad.
239 EN YESORNO      Please answer yes, no, or show.
240 JA YESORNO      ¡Ö¤Ï¤¤¡×¤«¡Ö¤¤¤¤¤¨¡×¤«¡Ö¼¨¤·¤Æ¡×¤«¤ÈÅú¤¨¤Æ²¼¤µ¤¤¡£¥í¥Þ»ú¤Ê¤É¤¤¤¤¤Ç¤¹¡£
241 JA YESORNO      ±Ñ¸ì¤â¤¤¤¤¤Ç¤¹¡£
242 SW YESORNO      Svara JA, NEJ eller VISA.
243 EN YESNOCONV    cat
244 JA YESNOCONV    sed 's/HAI/YES/; s/IIE/NO/; s/SHIME.*/SHOW/;\
245 JA YESNOCONV            s/¤Ï¤¤/YES/; s/¤¤¤¤¤¨/NO/; s/¼¨.*/SHOW/; s/¤·¤á.*/SHOW/'
246 SW YESNOCONV    sed 's/JA/YES/; s/NEJ/NO/; s/VISA/SHOW/'
247 EN LOGHEADER    ----------------------------------------------------------------
248 EN LOGHEADER    Installation at @DATE.
249 SW LOGHEADER    ----------------------------------------------------------------
250 SW LOGHEADER    Installering gjord @DATE.
251 EN LOGBEGIN2    A log file is being kept in english in /tmp/edict.log.EN
252 SW LOGBEGIN2    En logfil med engelsk inneh}ll kommer att skapas och underh}llas.
253 SW LOGBEGIN2    Filen heter /tmp/edict.log.EN.
254 EN LOGBEGIN     A log file is being kept in /tmp/edict.log.@LN.
255 SW LOGBEGIN     En logfil som visar vad jag g|r finns.  Den heter /tmp/edict.log.@LN.
256 EN SUCCESS      Installation successfully completed.
257 SW SUCCESS      Installationen gick bra.
258 EN FAILURE      Installation encountered errors.
259 SW FAILURE      Installationen gick inte bra, n}got fel intr{ffade.
260 EN NOCPYEDIR    The emacs libraries are already in the right locations.
261 SW NOCPYEDIR    Emacsbiblioteken finns redan p} r{tt plats.
262 EN NOCPYEJDIR   The edictj dictionary file is already in the right location.
263 SW NOCPYEJDIR   Lexikonet EDICTJ finns redan p} r{tt st{lle.
264 EN EJUSEDEMO    Using the demo version of the EDICTJ file.
265 EN EJUSEDEMO    Please place the real one in @INSTDIR/edictj
266 JA EJUSEDEMO    ¤¤¤Þ¡¢¥Ç¥âedict¤ò»È¤Ã¤Æ¤¤¤Þ¤¹. ¤¢¤ÎÂÅÅöedictj¤¬¥¤¥ó¥¹¥È¥ë²¼¤µ¤¤¡£
267 SW EJUSEDEMO    Jag kommer att anv{nde en demoversion av lexikonet
268 SW EJUSEDEMO    EDICTJ.  Installera det riktiga lexikonet som
269 SW EJUSEDEMO    @INSTDIR/edictj
270 EN .EMACSCOMNT  ;;; This sets up the standard key bindings for edict commands to
271 EN .EMACSCOMNT  ;;; autoload from @INSTDIR.
272 EN .EMACSCOMNT  ;;; 
273 EN .EMACSCOMNT  ;;; Place this in your $HOME/.emacs file.
274 EN .EMACSCOMNT  ;;; Edit the global-set-key forms if you wish to change the key assignments.
275 EN .EMACSCOMNT  ;;; The default key assignments are as follows (m- is the same as ESC-)
276 EN .EMACSCOMNT  ;;;   m-*       edict-search-english    Search for an english word.
277 EN .EMACSCOMNT  ;;;   m-&       edict-search-kanji      Search for a Japanese word.
278 EN .EMACSCOMNT  ;;;   m-+       edict-insert            Insert the last match.
279 JA .EMACSCOMNT  ;;; ¤³¤ì¤Ï¡¢edict ¤Îɸ½à¤Î¥­¡¼¥Ð¥¤¥ó¥Ç¥£¥ó¥°¤ò¹þ¤ßΩ¤Æ¤Þ¤¹¡£
280 JA .EMACSCOMNT  ;;; ¤½¤Îµ¡Ç½¤¬ @INSTDIR ¤«¤éautoload ¼«Æ°¥í¡¼¥É¤¹¤ë¤Î¤ò¹þ¤ßΩ¤Æ¤Þ¤¹¡£
281 JA .EMACSCOMNT  ;;; 
282 JA .EMACSCOMNT  ;;; ¤³¤Î¥³¡¼¥É¤Ï $HOME/.emacs ¤ËÃÖ¤¤¤Æ²¼¤µ¤¤¡£
283 JA .EMACSCOMNT  ;;; ¥­¡¼¥Ð¥¤¥ó¥Ç¥£¥ó¥°¤òÊѹ¹¤¹¤ë¤È¡¢global-set-key ¤Î·Á¤òÊÔ½¸¤·¤Æ²¼¤µ¤¤¡£
284 JA .EMACSCOMNT  ;;; °Ê²¼¡¢¥Ç¥Õ¥¡¡¼¥ë¥È¥­¡¼¥Ð¥¤¥ó¥Ç¥£¥ó¥°¤¬¤¢¤ê¤Þ¤¹¡£
285 JA .EMACSCOMNT  ;;; (¡Öm-¡×¤È ¡ÖESC-¡×¤ÏƱ¤¸¤Ç¤¹¡£)
286 JA .EMACSCOMNT  ;;;   m-*       edict-search-english    ±Ñ¸ì¤Î¸ÀÍÕ¤òõ¤»
287 JA .EMACSCOMNT  ;;;   m-&       edict-search-kanji      ÆüËܸì¤Î¸ÀÍÕ¤òõ¤»
288 JA .EMACSCOMNT  ;;;   m-+       edict-insert            °ìºò°ìÃפòÁÞÆþ¤·¤í
289 SW .EMACSCOMNT  ;;; F|ljande kod ser till att edictprogrammet laddas automatiskt
290 SW .EMACSCOMNT  ;;; fr}n @INSTDIR.
291 SW .EMACSCOMNT  ;;;
292 SW .EMACSCOMNT  ;;; Skriv in detta i din $HOME/.emacs fil.
293 SW .EMACSCOMNT  ;;; [ndra global-set-key anropen om du vill att kommandona
294 SW .EMACSCOMNT  ;;; skall anropas fr}n andra tangenter.
295 SW .EMACSCOMNT  ;;; Detta {r standardtangentmappningarna (m- {r samma som ESC-)
296 SW .EMACSCOMNT  ;;;   m-*       edict-search-english    S|k med ett engelskt ord.
297 SW .EMACSCOMNT  ;;;   m-&       edict-search-kanji      S|k med ett japanskt ord.
298 SW .EMACSCOMNT  ;;;   m-+       edict-insert            Skriv in senaste hittade ord.
299 END
300
301 # deduce which tr we have: v6 or v7
302 case "`echo B | tr A-Z a-z `" in
303 b)      trversion=v7 ;;
304 B)      trversion=v6 ;;                 # or System V
305 esac
306 export trversion
307
308 # Some systems use LANG, not LANGUAGE (i.e. ultrix)
309
310 export LN
311 LN=$LANGUAGE
312 [ $LN ] || LN=$LANG
313
314 LN=`echo $LN | sed -n -e 's/^\(..\).*/\1/p'`
315 LN=`echo $LN | case "$trversion" in 
316                 v6)     tr [a-z] [A-Z] ;;
317                 v7)     tr a-z A-Z     ;;
318                esac`
319
320 case "$LN" in
321 JP)             :       ;;
322 JP|EN|JA)       :       ;;
323 SW)             :       ;;
324 *)
325         echo 'What language should I use?'
326         echo '(EN = English, JA = Japanese, SW = Swedish) [EN]'
327         read LN
328         ;;
329 esac
330
331 LN=`echo $LN | case "$trversion" in 
332                 v6)     tr [a-z] [A-Z] ;;
333                 v7)     tr a-z A-Z     ;;
334                esac`
335
336 # Handle any common aliases for the language identifiers, such as the native terms
337 # or country names.
338 case "$LN" in
339 '')     LN='EN' ;;
340 EN|ENGLISH|BRITISH|BRITAIN|ENGLAND|US|AMERICAN)  LN='EN' ;;
341 JA|'ÆüËÜ'|'ÆüËܸì'|JAPANESE|NIHONGO|JP|NIHON|JAPAN)     LN='JA' ;;
342 SW|SWEDISH|SWEDEN|SWE|SE|SVENSKA|SVERIGE)       LN='SW' ;;
343 *)      echo "I don't understand the language $LN."
344         LN='EN'
345         ;;
346 esac
347
348 log LOGHEADER
349
350 case "$LN" in
351 EN)     log LOGBEGIN2
352         msg LOGBEGIN2
353         ;;
354 *)      log LOGBEGIN
355         msg LOGBEGIN
356         log LOGBEGIN2
357         msg LOGBEGIN2
358         ;;
359 esac
360
361 msg LANGUAGE
362 log LANGUAGE
363 echo
364 msg DEFAULTS
365 echo
366
367 export DISTDIR
368 msg DISTDIR
369 read DISTDIR
370 [ $DISTDIR ] || DISTDIR=`pwd`
371
372 export EDICTJDIR
373 msg EDICTJDIR
374 read EDICTJDIR
375
376 [ $EDICTJDIR ] || EDICTJDIR=$DISTDIR
377
378 log XEDICTJDIR
379
380 echo "# Values extracted from nemacs." >$EPATH/emacs.vars
381
382 cat <<END >$EPATH/emacs.info
383 (setq epath (reverse load-path))
384 (setq edir (expand-file-name (car epath)))
385 (if (string-match "/$" edir)
386     (setq edir (substring edir 0 (- (length edir) 1))))
387 (princ (format "export EMACSDIR\nEMACSDIR=%s\n" edir))
388 (princ (format "export EMACSPATH\nEMACSPATH=%s" (car epath)))
389 (let ((path (cdr epath)))
390   (while path  
391      (princ (format ":%s" (car path)))
392      (setq path (cdr path))))
393 (princ "\n")
394 END
395
396 nemacs -batch -load $EPATH/emacs.info >>$EPATH/emacs.vars
397 . $EPATH/emacs.vars
398
399 echo "# End of values extracted from nemacs." >>$EPATH/emacs.vars
400
401 logappend $EPATH/emacs.vars
402
403 # OK, let's see if we can install it into the normal location.
404
405 if [ -w $EMACSDIR ]; then
406         # Yes!
407         export INSTDIR
408         INSTDIR=$EMACSDIR
409 else
410         # No, gotta ask.
411         export INSTDIR
412         msg INSTDIR
413         read INSTDIR
414         [ $INSTDIR ] || INSTDIR=$DISTDIR
415 fi
416
417 msg XINSTDIR
418 log XINSTDIR
419
420 # Byte compile the program.
421 log BYTECOMP
422 msg BYTECOMP
423
424 cat <<END >$EPATH/emacs.comp
425 (load-library "bytecomp")
426
427 ;;; Fix emacs byte compiler bug...
428 ;;; This used to blow out if given anything with a non-symbol
429 ;;; in the CAR.  Emacs 18.57 has a different form of the bug,
430 ;;; where &optional or &rest in the argument list of a lambda
431 ;;; combination silently mis-compiles.  --RWK
432 (defun byte-compile-form (form)
433   (setq form (macroexpand form byte-compile-macro-environment))
434   (cond ((eq form 'nil)
435          (byte-compile-constant form))
436         ((eq form 't)
437          (byte-compile-constant form))
438         ((symbolp form)
439          (byte-compile-variable-ref 'byte-varref form))
440         ((not (consp form))
441          (byte-compile-constant form))
442         ((symbolp (car form))
443          (let ((handler (get (car form) 'byte-compile)))
444            (if handler
445                (funcall handler form)
446              (byte-compile-normal-call form))))
447         ((and (consp (car form))
448               (eq (car (car form)) 'lambda))
449          ;; It's a lambda combination.  Turn it into a LET.
450          (let* ((lambda-expr (car form))
451                 (arglist (nth 1 lambda-expr))
452                 (body (nthcdr 2 lambda-expr))
453                 (params (cdr form))
454                 (original-arglist arglist) ; For error reporting
455                 (original-params params)   ; For error reporting
456                 (state nil)             ;Last &-keyword seen.
457                 (binding-list nil)      ;LET's binding list.
458                 (arg nil))
459            ;; Parse the argument list, and build the binding list.
460            ;; Check for invalid arglist syntax as we go.
461            (while arglist
462              (setq arg (car arglist)
463                    arglist (cdr arglist))
464              (cond
465               ((eq arg '&optional )
466                (when state
467                  (error "Illegal argument list syntax:  &optional after %s."
468                         state))
469                (setq state arg))
470               ((eq arg '&rest )
471                (cond
472                  ((or (eq state nil)
473                       (eq state '&optional)))
474                  (t (error "Illegal argument list syntax: &rest after %s."
475                            state)))
476                (setq arg (car arglist)
477                      arglist (cdr arglist))
478                (setq binding-list
479                      (cons (list arg (list* 'list params))
480                            binding-list)
481                      params nil
482                      state arg))
483               (t (cond ((eq state '&rest)
484                         (error "Extra junk after &rest parameter: %s."
485                                (cons arg arglist))))
486                  (unless (eq state '&optional)
487                    (unless params
488                      (error "Insufficient arguments.  Arglist=%s\nParameters=%s"
489                             original-arglist original-params)))
490                  (setq binding-list
491                        (cons (list arg (car params))
492                              binding-list)
493                        params (cdr params)))))
494            (when params
495              (error "Too many arguments.  Arglist=%s\nParameters=%s"
496                     original-arglist original-params))
497            (setq binding-list (nreverse binding-list))
498            (byte-compile-form
499             (list* 'let binding-list body))))
500         ;; Things like autoload, macro, mock-lisp.
501         ((consp (car form)) (byte-compile-normal-call form))
502         (t (error "Illegal form: %s" form)))
503   (setq byte-compile-maxdepth
504         (max byte-compile-maxdepth
505              (setq byte-compile-depth (1+ byte-compile-depth)))))
506
507 ;;; Now here's another compiler fix:  Add eval-when !!
508
509 (defmacro eval-when (when &rest forms)
510   (and (or (member 'eval when)
511             (member ':execute when))
512        (mapcar (function eval) forms))
513   (and (or (member 'load when)
514            (member ':load-toplevel when))
515        (cons 'progn forms)))
516
517 (defun macro-function (name)
518   (and (fboundp name)
519        (let ((fun (symbol-function name)))
520          (and (not (atom fun))
521               (eq (car fun) 'macro)
522               (cdr fun)))))
523
524 (defun macroexpand-1 (form)
525   (if (atom form) form
526     (if (listp (car form)) form
527       (let ((expander (macro-function (car form))))
528         (apply expander (cdr form))))))
529
530 (defun byte-compile-file-form (form)
531   (let ((expander nil))
532     (cond ((not (listp form))
533            form)
534           ((memq (car form) '(defun defmacro))
535            (let* ((name (car (cdr form)))
536                   (tem (assq name byte-compile-macro-environment)))
537              (if (eq (car form) 'defun)
538                  (progn
539                    (message "Compiling %s (%s)..." filename (nth 1 form))
540                    (cond (tem (setcdr tem nil))
541                          ((and (fboundp name)
542                                (eq (car-safe (symbol-function name)) 'macro))
543                           ;; shadow existing macro definition
544                           (setq byte-compile-macro-environment
545                                 (cons (cons name nil)
546                                       byte-compile-macro-environment))))
547                    (prog1 (cons 'defun (byte-compile-lambda (cdr form)))
548                      (if (not noninteractive)
549                          (message "Compiling %s..." filename))))
550                ;; defmacro
551                (if tem
552                    (setcdr tem (cons 'lambda (cdr (cdr form))))
553                  (setq byte-compile-macro-environment
554                        (cons (cons name (cons 'lambda (cdr (cdr form))))
555                              byte-compile-macro-environment)))
556                (cons 'defmacro (byte-compile-lambda (cdr form))))))
557           ((eq (car form) 'progn)
558            (cons 'progn
559                  (mapcar (function byte-compile-file-form) (cdr form))))
560           ((listp (car form)) form)
561           ((setq expander (macro-function (car form)))
562            (byte-compile-file-form (macroexpand-1 form)))
563           ((setq expander (get (car form) 'byte-compile-top-level-handler))
564            (byte-compile-file-form (funcall expander form)))
565           ((eq (car form) 'require)
566            (eval form)
567            form)
568           (t form))))
569
570 (put 'eval-when 'eval-when-top-level-handler 'byte-compile-top-level-handler)
571 (defun eval-when-top-level-handler (form)
572   (let ((when (nth 1 form))
573         (body (nthcdr 2 form)))
574     (princ (format "Eval-when %s...\n" when))
575     (and (or (member 'compile when)
576              (member ':compile-toplevel when))
577          (mapcar (function print) body)
578          (mapcar (function eval) body))
579     (and (or (member 'load when)
580              (member ':load-toplevel when))
581          (cons 'progn body))))
582
583 ;;; Now compile our two files.
584 (byte-compile-file "$DISTDIR/edict.el")
585 (byte-compile-file "$DISTDIR/edict-test.el")
586 END
587
588 nemacs -batch -load $EPATH/emacs.comp | tee $EPATH/emacs.comp.out
589
590 logappend $EPATH/emacs.comp
591 logappend $EPATH/emacs.comp.out
592
593 # Now copy, if they're not already there.
594 if [ $DISTDIR = $INSTDIR ]; then
595         msg NOCPYEDIR
596         log NOCPYEDIR
597 else
598         copy $DISTDIR/edict.ChangeLog $INSTDIR/edict.ChangeLog
599         copy $DISTDIR/edict.el $INSTDIR/edict.el
600         copy $DISTDIR/edict.elc $INSTDIR/edict.elc
601         copy $DISTDIR/edict-test.el $INSTDIR/edict-test.el
602         copy $DISTDIR/edict-test.elc $INSTDIR/edict-test.elc
603         copy $DISTDIR/edict.texinfo $INSTDIR/edict.texinfo
604 fi
605
606 if [ $EDICTJDIR = $INSTDIR ]; then
607         if [ -f $INSTDIR/edictj ]; then
608                 msg NOCPYEJDIR
609                 log NOCPYEJDIR
610         else
611                 msg EJUSEDEMO
612                 log EJUSEDEMO
613                 copy $DISTDIR/edictj.demo $INSTDIR/edictj
614         fi
615 else
616         if [ -r $EDICTJDIR/edictj ]; then
617                 copy $EDICTJDIR/edictj $INSTDIR/edictj
618         elif [ -f $INSTDIR/edictj ]; then
619                 : ;
620         else
621                 copy $DISTDIR/edictj.demo $INSTDIR/edictj
622         fi
623 fi
624
625 if [ "$INSTDIR" = "$EMACSDIR" ]; then
626         LOADFILE=edict
627 else
628         LOADFILE=$INSTDIR/edict
629 fi
630
631 # Build a file of suggested .emacs setup.
632 echo >$INSTDIR/edict.emacs
633 # Start it off with a language-specific explanatory comment.
634 msg .EMACSCOMNT >>$INSTDIR/edict.emacs
635
636 sed -e "s!@LOADFILE!$LOADFILE!; s!@INSTDIR!$INSTDIR!" <<'EMACSEND' >>$INSTDIR/edict.emacs
637
638 (cond ((fboundp 'convert-region-kanji-code)
639        (autoload 'edict-search-english "@LOADFILE"
640                  "Search for a translation of an English word")
641        (global-set-key "\e*" 'edict-search-english)
642
643        (autoload 'edict-search-kanji "@LOADFILE"
644                  "Search for a translation of a Kanji sequence")
645        (global-set-key "\e&" 'edict-search-kanji)
646
647        (autoload 'edict-add-english "@LOADFILE"
648                  "Add a translation of an English word")
649
650        (autoload 'edict-add-kanji "@LOADFILE"
651                  "Add a translation of a Kanji sequence")
652
653        (autoload 'edict-insert "@LOADFILE"
654                  "Insert the last item looked up in edict.")
655
656        (global-set-key "\e+" 'edict-insert)
657
658        (autoload 'edict-insert-english "@LOADFILE"
659                  "Insert the last item looked up in edict.")
660        (autoload 'edict-insert-ÆüËܸì "@LOADFILE"
661                  "Insert the last item looked up in edict.")
662
663        (setq *edict-files* '("@INSTDIR/edictj"))))
664
665 EMACSEND
666
667 # Extract the script for canonicalizing yes or no from whatever natural language.
668 msg YESNOCONV >$EPATH/yesnoconv
669
670 while [ "ALWAYS" ]; do
671         msg DOTEMACSQ
672         read DOTEMACSQ
673         DOTEMACSQ=`echo $DOTEMACSQ | case "$trversion" in 
674                                         v6)     tr [a-z] [A-Z] ;;
675                                         v7)     tr a-z A-Z     ;;
676                                         esac`
677
678         DOTEMACSQ=`echo $DOTEMACSQ | (. $EPATH/yesnoconv)`
679         case $DOTEMACSQ in
680         Y|YES)
681                 sed -e '/;;; Start of EDICT/,/;;; End of EDICT/ D' $HOME/.emacs >$EPATH/.emacs.out
682                 echo ";;; Start of EDICT's automatically-added stuff." >>$EPATH/.emacs.out
683                 cat $INSTDIR/edict.emacs >>$EPATH/.emacs.out
684                 echo ";;; End of EDICT's automatically-added stuff." >>$EPATH/.emacs.out
685                 [ -f $HOME/.emacs ] && mv $HOME/.emacs $HOME/.emacs.orig
686                 mv $EPATH/.emacs.out $HOME/.emacs
687                 msg DOTEMACSADD
688                 log DOTEMACSADD
689                 break
690                 ;;
691         N|NO)
692                 break
693                 ;;
694         SHOW)
695                 echo more $INSTDIR/edict.emacs
696                 more $INSTDIR/edict.emacs
697                 ;;
698         *)      msg YESORNO
699                  ;;
700         esac
701 done
702
703 if [ -f $EPATH/failure ]; then
704         log FAILURE
705         msg FAILURE
706 else
707         log SUCCESS
708         msg SUCCESS
709 fi