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 ;;;;;;;;;;;;;;;;;;;;; DO NOT EDIT THIS FILE ;;;;;;;;;;;;;;;;;;;;;
8 ;;;;;;;;;;;;;;;;;;;;; INTERNAL USE ONLY ;;;;;;;;;;;;;;;;;;;;;
13 (defvar ELMODIR "./elmo")
14 (defvar DOCDIR "./doc")
15 (defvar ICONDIR "./etc/icons")
16 (defvar UTILSDIR "./utils")
17 (defvar SASLDIR "./utils/sasl/lisp")
18 (defvar WL_PREFIX "wl")
19 (defvar ELMO_PREFIX "wl")
21 (defvar COMPRESS-SUFFIX-LIST '("" ".gz" ".Z" ".bz2"))
23 (defvar wl-install-utils nil
24 "if Non-nil, install `wl-utils-modules'.")
25 (defvar wl-install-sasl nil
26 "if Non-nil, install sasl utilities.")
29 (defconst wl-ja-info "wl-ja.info")
30 (defconst wl-ja-texi "wl-ja.texi")
31 (defconst wl-en-info "wl.info")
32 (defconst wl-en-texi "wl.texi")
34 (defvar wl-info-lang "ja"
35 "The language of info file (\"ja\" or \"en\").")
37 ;; for Nemacs (dirty!)
38 (or (fboundp 'file-executable-p)
39 (fset 'file-executable-p 'file-exists-p))
41 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
46 (condition-case () (require 'custom) (error nil))
48 (unless (and (fboundp 'defgroup)
50 ;; ignore broken module
51 (not (featurep 'tinycustom)))
53 (defmacro defgroup (&rest args))
54 (defmacro defcustom (symbol value &optional doc &rest args)
55 (let ((doc (concat "*" (or doc ""))))
56 (` (defvar (, symbol) (, value) (, doc)))))
59 (setq byte-compile-warnings '(free-vars unresolved callargs redefine))
62 (if (or (boundp 'MULE)
63 (fboundp 'nemacs-version))
64 (setq max-lisp-eval-depth 400))
66 ;; FIXME: it is currently needed to byte-compile with Emacs 21.
67 (setq recursive-load-depth-limit nil)
69 (condition-case () (require 'easymenu) (error nil))
71 (defvar config-wl-package-done nil)
73 (defun config-wl-package-subr ()
74 (unless config-wl-package-done
75 (setq config-wl-package-done t)
76 (setq load-path (cons (expand-file-name ".") load-path))
77 (setq load-path (cons (expand-file-name WLDIR)
78 (cons (expand-file-name ELMODIR) load-path)))
79 (setq wl-icon-dir (expand-file-name ICONDIR))
80 ;;; load custom file if exists.
81 (load "./WL-CFG" t nil t)
84 (setq load-path (cons (expand-file-name UTILSDIR) load-path)))
86 (setq load-path (cons (expand-file-name SASLDIR) load-path)))
91 (error (error "No MIME module was detected. Please install SEMI or tm.")))
93 (princ (concat "\nUse SEMI"
94 (if wl-use-luna " with LUNA\n" " without LUNA\n")))
95 (princ "\nUse tm.\n"))))
97 (defun config-wl-pixmap-dir (&optional packagedir)
98 "Examine pixmap directory where icon files should go."
99 (let ((pixmap-dir (car command-line-args-left)))
101 (if (string= pixmap-dir "NONE")
103 (expand-file-name "etc/wl/" packagedir)
104 (if (or (featurep 'xemacs)
105 (and (boundp 'emacs-major-version)
106 (>= emacs-major-version 21)))
107 (expand-file-name "wl/icons/" data-directory)))
110 (princ (format "PIXMAPDIR is %s\n" PIXMAPDIR)))
111 (setq command-line-args-left (cdr command-line-args-left)))
113 (defun config-wl-package ()
114 (config-wl-package-subr)
116 (let ((elispdir (car command-line-args-left)))
117 (if (string= elispdir "NONE")
118 (defvar LISPDIR (install-detect-elisp-directory))
119 (defvar LISPDIR elispdir)))
120 (princ (format "LISPDIR is %s\n" LISPDIR))
121 (setq command-line-args-left (cdr command-line-args-left))
123 (config-wl-pixmap-dir)
127 (defun wl-scan-source (path)
132 (setq ret (append (list y (concat y "c")) ret)))
133 (directory-files x nil "\\(.+\\)\\.el$" t)))
138 (defun wl-uninstall (objs path)
139 ;(message (mapconcat 'identity objs " "))
142 (let ((filename (expand-file-name x path)))
143 (if (and (file-exists-p filename)
144 (file-writable-p filename))
146 (princ (format "%s was uninstalled.\n" filename))
147 (delete-file filename)))))
151 (defun compile-wl-package ()
152 ;; For nemacs byte compiler's strange behavior(?).
154 (if (fboundp 'nemacs-version)
155 (load (expand-file-name "wl.el" WLDIR)))
158 (compile-elisp-modules (cdr x) (car x)))
161 (defun install-wl-icons ()
162 (if (not (file-directory-p PIXMAPDIR))
163 (make-directory PIXMAPDIR t))
164 (let* ((case-fold-search t)
165 (icons (directory-files ICONDIR t "\\.x[bp]m$"))
168 (setq icon (car icons)
170 dest (expand-file-name (file-name-nondirectory icon) PIXMAPDIR))
171 (princ (format "%s->%s\n" icon dest))
172 (copy-file icon dest t))))
174 (defun install-wl-package ()
176 (let ((wl-install-dir (expand-file-name WL_PREFIX LISPDIR))
177 (elmo-install-dir (expand-file-name ELMO_PREFIX LISPDIR)))
180 (install-elisp-modules (cdr x) (car x)
181 (if (string= (car x) ELMODIR)
189 (defun uninstall-wl-package ()
191 (let ((wl-install-dir (expand-file-name WL_PREFIX
193 (elmo-install-dir (expand-file-name ELMO_PREFIX
195 (wl-uninstall (wl-scan-source (list WLDIR UTILSDIR SASLDIR))
197 (wl-uninstall (wl-scan-source (list ELMODIR))
200 (let* ((case-fold-search t)
201 (icons (directory-files PIXMAPDIR t "\\.x[bp]m$"))
204 (setq icon (car icons)
206 (if (and (file-exists-p icon)
207 (file-writable-p icon))
209 (princ (format "%s was uninstalled.\n" icon))
210 (delete-file icon)))))))
213 (defun config-wl-package-xmas ()
214 (if (not (featurep 'xemacs))
215 (error "This directive is only for XEmacs."))
216 (config-wl-package-subr)
219 (and (setq package-dir (car command-line-args-left))
220 (if (string= "NONE" package-dir)
222 (if (boundp 'early-packages)
223 (let ((dirs (append (if early-package-load-path
225 (if late-package-load-path
227 (if last-package-load-path
230 (while (not (file-exists-p
231 (setq dir (car dirs))))
232 (setq dirs (cdr dirs)))
234 (defvar PACKAGEDIR package-dir)))
235 (princ (format "PACKAGEDIR is %s\n" PACKAGEDIR))
236 (setq command-line-args-left (cdr command-line-args-left)))
238 (config-wl-pixmap-dir PACKAGEDIR)
242 (defun compile-wl-package-xmas ()
243 (config-wl-package-xmas)
244 (setq autoload-package-name "wl")
245 (add-to-list 'command-line-args-left WLDIR)
246 (batch-update-directory)
247 (add-to-list 'command-line-args-left WLDIR)
248 (Custom-make-dependencies)
249 ;; WL-AUTOLOAD-MODULES
250 (compile-elisp-modules WL-AUTOLOAD-MODULES WLDIR)
253 (compile-elisp-modules (cdr x) (car x)))
256 (defun install-wl-package-xmas ()
257 (compile-wl-package-xmas)
258 (let ((LISPDIR (expand-file-name "wl"
259 (expand-file-name "lisp"
261 (DATADIR (expand-file-name "wl"
262 (expand-file-name "etc"
264 (INFODIR (expand-file-name "info" PACKAGEDIR)))
265 (or (file-exists-p DATADIR)
266 (make-directory DATADIR t))
267 (or (file-exists-p INFODIR)
268 (make-directory INFODIR t))
273 (install-elisp-modules (cdr x) (car x) LISPDIR))
275 ;; WL-AUTOLOAD-MODULES
276 (install-elisp-modules WL-AUTOLOAD-MODULES WLDIR LISPDIR)
279 (wl-texinfo-install)))
282 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
285 (defun wl-texinfo-format-file (lang)
286 (let ((infofile (symbol-value (intern (format "wl-%s-info" lang))))
287 (texifile (symbol-value (intern (format "wl-%s-texi" lang)))))
288 (require 'wl-vars) ;; for 'wl-cs-local
289 (or (file-newer-than-file-p (expand-file-name infofile DOCDIR)
290 (expand-file-name texifile DOCDIR))
292 ;; Support old texinfmt.el
293 (require 'ptexinfmt (expand-file-name "ptexinfmt.el" UTILSDIR))
294 (find-file (expand-file-name texifile DOCDIR))
295 (setq obuf (current-buffer))
296 ;; We can't know file names if splitted.
297 (texinfo-format-buffer t)
298 ;; Emacs20.2's default is 'raw-text-unix.
299 (and (fboundp 'set-buffer-file-coding-system)
300 (set-buffer-file-coding-system wl-cs-local))
302 (kill-buffer (current-buffer)) ;; info
303 (kill-buffer obuf)) ;; texi
306 (defun wl-texinfo-format ()
308 (setq INFODIR (wl-detect-info-directory)))
309 (cond ((listp wl-info-lang)
310 (mapcar 'wl-texinfo-format-file wl-info-lang))
311 ((stringp wl-info-lang)
312 (wl-texinfo-format-file wl-info-lang))))
314 (defun wl-texinfo-install-file (lang)
315 (let ((infofile (symbol-value (intern (format "wl-%s-info" lang)))))
316 (install-file infofile DOCDIR INFODIR)))
318 (defun wl-texinfo-install ()
319 (cond ((listp wl-info-lang)
320 (mapcar 'wl-texinfo-install-file wl-info-lang))
321 ((stringp wl-info-lang)
322 (wl-texinfo-install-file wl-info-lang))))
324 (defun wl-primary-info-file ()
325 "Get primary info file (for wl-detect-info-directory)."
327 ((listp wl-info-lang)
328 (let ((wl-info-lang (car wl-info-lang)))
329 (wl-primary-info-file)))
330 ((stringp wl-info-lang)
331 (symbol-value (intern (format "wl-%s-info" wl-info-lang))))))
333 (defun wl-detect-info-directory ()
334 (config-wl-package-subr)
335 (if (fboundp 'nemacs-version)
336 (error "Cannot format info on Nemacs. Please use another formatter."))
339 (let ((infodir (car command-line-args-left))
340 (info (wl-primary-info-file))
343 (if (string= infodir "NONE")
345 (exec-installed-p info Info-directory-list
346 COMPRESS-SUFFIX-LIST))
348 ;;(condition-case nil (delete-file previous))
349 (directory-file-name (file-name-directory previous));)
350 (car Info-directory-list))
352 (setq command-line-args-left (cdr command-line-args-left))
353 (princ (format "INFODIR is %s\n\n" INFODIR))
356 (defun install-wl-info ()
358 (wl-texinfo-install))
362 ;;; * MORE refine code (^_^;