2 ;;; WL-MK for byte-compile, install, uninstall
4 ;;; Original by OKUNISHI Fujikazu <fuji0924@mbox.kyoto-inet.or.jp>
5 ;;; Modified by Yuuichi Teranishi <teranisi@gohome.org>
7 ;;; Time-stamp: <2000-03-30 15:55:13 teranisi>
9 ;;;;;;;;;;;;;;;;;;;;; DO NOT EDIT THIS FILE ;;;;;;;;;;;;;;;;;;;;;
10 ;;;;;;;;;;;;;;;;;;;;; INTERNAL USE ONLY ;;;;;;;;;;;;;;;;;;;;;
15 (defvar ELMODIR "./elmo")
16 (defvar DOCDIR "./doc")
17 (defvar ICONDIR "./etc/icons")
18 (defvar UTILSDIR "./utils")
19 (defvar SASLDIR "./utils/sasl/lisp")
20 (defvar WL_PREFIX "wl")
21 (defvar ELMO_PREFIX "wl")
23 (defvar COMPRESS-SUFFIX-LIST '("" ".gz" ".Z" ".bz2"))
25 (defvar wl-install-utils nil
26 "if Non-nil, install `wl-utils-modules'.")
27 (defvar wl-install-sasl nil
28 "if Non-nil, install sasl utilities.")
31 (defconst wl-ja-info "wl-ja.info")
32 (defconst wl-ja-texi "wl-ja.texi")
33 (defconst wl-en-info "wl.info")
34 (defconst wl-en-texi "wl.texi")
36 (defvar wl-info-lang "ja"
37 "The language of info file (\"ja\" or \"en\").")
39 ;; for Nemacs (dirty!)
40 (or (fboundp 'file-executable-p)
41 (fset 'file-executable-p 'file-exists-p))
43 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
48 (condition-case () (require 'custom) (error nil))
50 (unless (and (fboundp 'defgroup)
52 ;; ignore broken module
53 (not (featurep 'tinycustom)))
55 (defmacro defgroup (&rest args))
56 (defmacro defcustom (symbol value &optional doc &rest args)
57 (let ((doc (concat "*" (or doc ""))))
58 (` (defvar (, symbol) (, value) (, doc)))))
61 (setq byte-compile-warnings '(free-vars unresolved callargs redefine))
64 (if (or (boundp 'MULE)
65 (fboundp 'nemacs-version))
66 (setq max-lisp-eval-depth 400))
68 (condition-case () (require 'easymenu) (error nil))
70 (defvar config-wl-package-done nil)
72 (defun config-wl-package-subr ()
73 (unless config-wl-package-done
74 (setq config-wl-package-done t)
75 (setq load-path (cons (expand-file-name ".") load-path))
76 (setq load-path (cons (expand-file-name WLDIR)
77 (cons (expand-file-name ELMODIR) load-path)))
78 (setq wl-icon-dir (expand-file-name ICONDIR))
79 ;;; load custom file if exists.
80 (load "./WL-CFG" t nil t)
83 (setq load-path (cons (expand-file-name UTILSDIR) load-path)))
85 (setq load-path (cons (expand-file-name SASLDIR) load-path)))
90 (error (error "No MIME module was detected. Please install SEMI or tm.")))
92 (princ (concat "\nUse SEMI"
93 (if wl-use-luna " with LUNA\n" " without LUNA\n")))
94 (princ "\nUse tm.\n"))))
96 (defun config-wl-package ()
97 (config-wl-package-subr)
99 (let ((elispdir (car command-line-args-left)))
100 (if (string= elispdir "NONE")
101 (defvar LISPDIR (install-detect-elisp-directory))
102 (defvar LISPDIR elispdir)))
103 (princ (format "LISPDIR is %s\n\n" LISPDIR))
104 (setq command-line-args-left (cdr command-line-args-left)))
107 (defun wl-scan-source (path)
112 (setq ret (append (list y (concat y "c")) ret)))
113 (directory-files x nil "\\(.+\\)\\.el$" t)))
118 (defun wl-uninstall (objs path)
119 ;(message (mapconcat 'identity objs " "))
122 (let ((filename (expand-file-name x path)))
123 (if (and (file-exists-p filename)
124 (file-writable-p filename))
126 (princ (format "%s was uninstalled.\n" filename))
127 (delete-file filename)))))
131 (defun compile-wl-package ()
132 ;; For nemacs byte compiler's strange behavior(?).
134 (if (fboundp 'nemacs-version)
135 (load (expand-file-name "wl.el" WLDIR)))
138 (compile-elisp-modules (cdr x) (car x)))
141 (defun install-wl-package ()
143 (let ((wl-install-dir (expand-file-name WL_PREFIX LISPDIR))
144 (elmo-install-dir (expand-file-name ELMO_PREFIX LISPDIR)))
147 (install-elisp-modules (cdr x) (car x)
148 (if (string= (car x) ELMODIR)
154 (defun uninstall-wl-package ()
156 (let ((wl-install-dir (expand-file-name WL_PREFIX
158 (elmo-install-dir (expand-file-name ELMO_PREFIX
160 (wl-uninstall (wl-scan-source (list WLDIR UTILSDIR SASLDIR))
162 (wl-uninstall (wl-scan-source (list ELMODIR))
167 (defun config-wl-package-xmas ()
168 (if (not (featurep 'xemacs))
169 (error "This directive is only for XEmacs."))
170 (config-wl-package-subr)
173 (and (setq package-dir (car command-line-args-left))
174 (if (string= "NONE" package-dir)
176 (if (boundp 'early-packages)
177 (let ((dirs (append (if early-package-load-path
179 (if late-package-load-path
181 (if last-package-load-path
184 (while (not (file-exists-p
185 (setq dir (car dirs))))
186 (setq dirs (cdr dirs)))
188 (defvar PACKAGEDIR package-dir)))
189 (princ (format "PACKAGEDIR is %s\n\n" PACKAGEDIR))
190 (setq command-line-args-left (cdr command-line-args-left))))
193 (defun compile-wl-package-xmas ()
194 (config-wl-package-xmas)
195 (setq autoload-package-name "wl")
196 (add-to-list 'command-line-args-left WLDIR)
197 (batch-update-directory)
198 (add-to-list 'command-line-args-left WLDIR)
199 (Custom-make-dependencies)
200 ;; WL-AUTOLOAD-MODULES
201 (compile-elisp-modules WL-AUTOLOAD-MODULES WLDIR)
204 (compile-elisp-modules (cdr x) (car x)))
207 (defun install-wl-package-xmas ()
208 (compile-wl-package-xmas)
209 (let ((LISPDIR (expand-file-name "wl"
210 (expand-file-name "lisp"
212 (DATADIR (expand-file-name "wl"
213 (expand-file-name "etc"
215 (INFODIR (expand-file-name "info" PACKAGEDIR)))
216 (or (file-exists-p DATADIR)
217 (make-directory DATADIR t))
218 (or (file-exists-p INFODIR)
219 (make-directory INFODIR t))
222 (let* ((src-file-nondirectory (file-name-nondirectory x))
223 (dst-file (expand-file-name src-file-nondirectory
225 (princ (format "%s->%s\n"
228 (copy-file x dst-file t)))
229 (directory-files "etc/icons" t "xpm"))
231 (install-elisp-modules (cdr x) (car x) LISPDIR))
233 ;; WL-AUTOLOAD-MODULES
234 (install-elisp-modules WL-AUTOLOAD-MODULES WLDIR LISPDIR)
237 (wl-texinfo-install)))
240 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
243 (defun wl-texinfo-format-file (lang)
244 (let ((infofile (symbol-value (intern (format "wl-%s-info" lang))))
245 (texifile (symbol-value (intern (format "wl-%s-texi" lang)))))
246 (require 'wl-vars) ;; for 'wl-cs-local
247 (or (file-newer-than-file-p (expand-file-name infofile DOCDIR)
248 (expand-file-name texifile DOCDIR))
250 (find-file (expand-file-name texifile DOCDIR))
251 (setq obuf (current-buffer))
252 ;; texinfmt.el 2.37 or earlier can't format @direntry
254 (unless (fboundp 'texinfo-format-direntry)
255 (goto-char (point-min))
256 (when (re-search-forward "^@direntry" nil t)
257 (replace-match "@ifinfo\nSTART-INFO-DIR-ENTRY"))
258 (when (re-search-forward "^@end direntry" nil t)
259 (replace-match "END-INFO-DIR-ENTRY\n@end ifinfo"))
260 (set-buffer-modified-p nil))
261 ;; We can't know file names if splitted.
262 (texinfo-format-buffer t)
263 ;; Emacs20.2's default is 'raw-text-unix.
264 (and (fboundp 'set-buffer-file-coding-system)
265 (set-buffer-file-coding-system wl-cs-local))
267 (kill-buffer (current-buffer)) ;; info
268 (kill-buffer obuf)) ;; texi
271 (defun wl-texinfo-format ()
273 (setq INFODIR (wl-detect-info-directory)))
274 (cond ((listp wl-info-lang)
275 (mapcar 'wl-texinfo-format-file wl-info-lang))
276 ((stringp wl-info-lang)
277 (wl-texinfo-format-file wl-info-lang))))
279 (defun wl-texinfo-install-file (lang)
280 (let ((infofile (symbol-value (intern (format "wl-%s-info" lang)))))
281 (install-file infofile DOCDIR INFODIR)))
283 (defun wl-texinfo-install ()
284 (cond ((listp wl-info-lang)
285 (mapcar 'wl-texinfo-install-file wl-info-lang))
286 ((stringp wl-info-lang)
287 (wl-texinfo-install-file wl-info-lang))))
289 (defun wl-primary-info-file ()
290 "Get primary info file (for wl-detect-info-directory)."
292 ((listp wl-info-lang)
293 (let ((wl-info-lang (car wl-info-lang)))
294 (wl-primary-info-file)))
295 ((stringp wl-info-lang)
296 (symbol-value (intern (format "wl-%s-info" wl-info-lang))))))
298 (defun wl-detect-info-directory ()
299 (config-wl-package-subr)
300 (if (fboundp 'nemacs-version)
301 (error "Cannot format info on Nemacs. Please use another formatter."))
304 (let ((infodir (car command-line-args-left))
305 (info (wl-primary-info-file))
308 (if (string= infodir "NONE")
310 (exec-installed-p info Info-directory-list
311 COMPRESS-SUFFIX-LIST))
313 ;;(condition-case nil (delete-file previous))
314 (directory-file-name (file-name-directory previous));)
315 (car Info-directory-list))
317 (setq command-line-args-left (cdr command-line-args-left))
318 (princ (format "INFODIR is %s\n\n" INFODIR))
321 (defun install-wl-info ()
323 (wl-texinfo-install))
327 ;;; * MORE refine code (^_^;