1 ;;; install.el --- Lookup installer
2 ;; Copyright (C) 1999 NISHIDA Keisuke <knishida@ring.aist.go.jp>
4 ;; $Id: install.el,v 1.1 1999-07-23 09:16:11 steveb Exp $
6 ;; This program is free software; you can redistribute it and/or
7 ;; modify it under the terms of the GNU General Public License
8 ;; as published by the Free Software Foundation; either version 2
9 ;; of the License, or (at your option) any later version.
11 ;; This program 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.
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with this program; if not, write to the Free Software
18 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 (if (string< emacs-version "19.29")
23 (setq command-line-args-left (cdr command-line-args-left)))
25 (defconst install-elisp-files
26 '("evi.el" "evi-mule.el" "lookup.el" "lookup-utils.el" "lookup-types.el"
27 "lookup-vars.el" "lookup-vse.el" "lookup-package.el"
28 "lookup-entry.el" "lookup-content.el" "lookup-select.el"
29 "ndic.el" "ndeb.el" "ndtp.el" "ndict.el" "ndkks.el" "ndsrd.el"
30 "ndspell.el" "ndcookie.el" "ndmisc.el" "sdicf.el" "stem-english.el"))
32 (defconst install-info-files
33 '("lookup.info" "lookup-guide.info"))
35 (defvar install-lisp-directory nil)
36 (defvar install-info-directory nil)
37 (defvar install-lookup-version "unknown")
39 (defun install-check-directory (directory)
40 (and (not (file-exists-p directory))
41 (y-or-n-p (format "Directory %s is not exist. Creat it? " directory))
42 (make-directory directory t))
43 (if (not (file-directory-p directory))
44 (error "%s is not directory" directory))
45 (directory-file-name (expand-file-name directory)))
47 (or (fboundp 'with-current-buffer)
48 (defmacro with-current-buffer (buffer &rest body)
49 (` (save-current-buffer
50 (set-buffer (, buffer))
53 ;; get the version number of lookup
54 (with-current-buffer (get-buffer-create " *work lookup-version*")
56 (setq install-lookup-version
59 (insert-file-contents "VERSION")
60 (goto-char (point-min))
61 (buffer-substring (point-min) (progn (end-of-line) (point))))
63 (kill-buffer (current-buffer)))
67 (if noninteractive nil
68 (switch-to-buffer (generate-new-buffer "*Lookup Installer*"))
69 (insert "Lookup
\e$B%$%s%9%H!<%i
\e(B\n")
70 (insert "===================\n\n")
71 (insert "Lookup
\e$B$N%$%s%9%H!<%k$r;O$a$^$9!#
\e(B")
72 (insert "
\e$BESCf$GCfCG$9$k$K$O
\e(B C-g
\e$B$r2!$7$F2<$5$$!#
\e(B\n\n"))
76 (if noninteractive nil
77 (insert "
\e$B%G%#%l%/%H%j$N7hDj
\e(B\n")
78 (insert "------------------\n\n")
79 (insert "elisp
\e$B%U%!%$%k$N%G%#%l%/%H%j$rF~NO$7$F2<$5$$
\e(B:\n"))
80 (let ((default "~/emacs/lisp/lookup/"))
81 (setq install-lisp-directory
82 (install-check-directory
84 (or (car command-line-args-left) default)
85 (read-file-name "Lisp directory: " default default)))))
86 (if noninteractive nil
87 (insert " -> " install-lisp-directory "\n\n") (sit-for 0))
89 (if noninteractive nil
90 (insert "info
\e$B%U%!%$%k$N%G%#%l%/%H%j$rF~NO$7$F2<$5$$
\e(B:\n"))
91 (let ((default "~/emacs/info/"))
92 (setq install-info-directory
93 (install-check-directory
95 (or (car (cdr command-line-args-left)) default)
96 (read-file-name "Info directory: " default default)))))
97 (if noninteractive nil
98 (insert " -> " install-info-directory "\n\n") (sit-for 0))
102 (if noninteractive nil
103 (insert "
\e$B%$%s%9%H!<%k$N<B9T
\e(B\n")
104 (insert "------------------\n\n")
105 (insert "lookup-vars.el.in
\e$B$+$i
\e(B lookup-vars.el
\e$B$r@8@.Cf
\e(B...") (sit-for 0))
106 (with-current-buffer (find-file-noselect "lisp/lookup-vars.el.in" t)
107 (if (search-forward "@VERSION@")
108 (replace-match install-lookup-version))
109 (if (search-forward "@pkgemacsdir@") ;needs to be fixed to the correct one
110 (replace-match install-lisp-directory))
111 (write-file "lookup-vars.el")
112 (kill-buffer (current-buffer))
114 (message "Copied lookup-vars.el.in to lookup-vars.el")
115 (if (not noninteractive) (insert "done\n"))
119 (if noninteractive nil
120 (insert "elisp
\e$B%U%!%$%k$N%3%s%Q%$%kCf
\e(B...") (sit-for 0))
121 (let* ((default-directory (expand-file-name "lisp/"))
122 (lookup-compile-directory default-directory)
123 (command-line-args-left (if (string< emacs-version "19.29")
124 (cons nil install-elisp-files)
125 install-elisp-files)))
126 (load (expand-file-name "lookup-compile.el")))
127 (if (not noninteractive) (insert "done\n"))
131 (if noninteractive nil
132 (insert "elisp
\e$B%U%!%$%k$N%$%s%9%H!<%kCf
\e(B...") (sit-for 0))
133 (mapcar (lambda (file)
134 (copy-file (expand-file-name file "lisp/")
135 (expand-file-name file install-lisp-directory) t)
136 (message "Installed %s to %s" file install-lisp-directory)
137 (setq file (byte-compile-dest-file file))
138 (copy-file (expand-file-name file "lisp/")
139 (expand-file-name file install-lisp-directory) t)
140 (message "Installed %s to %s" file install-lisp-directory))
142 (if (not noninteractive) (insert "done\n"))
144 (if noninteractive nil
145 (insert "info
\e$B%U%!%$%k$N%U%)!<%^%C%HCf
\e(B...") (sit-for 0))
146 (mapcar (lambda (info)
147 (if (file-readable-p (expand-file-name info "texi/"))
149 ;; the pre-formatted .info file does not exist; format it here
150 (let ((texi (concat (file-name-sans-extension info) ".texi")))
152 (let ((buf (find-file-noselect
153 (expand-file-name texi "texi/") t)))
155 (texinfo-format-buffer t) ; t for nosplit
157 (kill-buffer (current-buffer))
158 (kill-buffer buf))))))
160 (if (not noninteractive) (insert "done\n"))
162 (if noninteractive nil
163 (insert "info
\e$B%U%!%$%k$N%$%s%9%H!<%kCf
\e(B...") (sit-for 0))
164 (mapcar (lambda (info)
165 (mapcar (lambda (file)
166 (copy-file (expand-file-name file "texi/")
167 (expand-file-name file install-info-directory)
169 (message "Installed %s to %s" file install-info-directory))
170 (directory-files "texi/" nil info)))
172 (if (not noninteractive) (insert "done\n"))
176 (if noninteractive nil
177 (insert "
\e$B0l;~%U%!%$%k$N:o=|Cf
\e(B...") (sit-for 0))
178 (let ((default-directory (expand-file-name "lisp/")))
179 (delete-file "lookup-vars.el")
180 (mapcar (lambda (file)
181 (delete-file (byte-compile-dest-file (expand-file-name file))))
182 install-elisp-files))
183 (message "Removed lookup-vars.el, *.elc")
184 (if (not noninteractive) (insert "done\n"))
188 (if noninteractive nil
189 (insert "Lookup
\e$B$N=i4|2=Cf
\e(B...")
193 (kill-buffer (current-buffer)))
198 (message "\nSee etc/SETUP for the setup after installation")
199 (switch-to-buffer (generate-new-buffer "*Congratulations!*"))
200 (insert-file-contents "etc/SETUP")
201 (if (search-forward "@install-lisp-directory@")
202 (replace-match install-lisp-directory))
203 (if (search-forward "@install-info-directory@")
204 (replace-match install-info-directory))
205 (goto-char (point-min))
206 (set-buffer-modified-p nil)
208 (local-set-key "\C-c\C-c" 'install-open-info))
210 (defun install-open-info ()
213 (Info-find-node (expand-file-name "lookup-guide" install-info-directory)
216 ;;; install.el ends here