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 WL_PREFIX "wl")
18 (defvar ELMO_PREFIX "wl")
20 (defvar COMPRESS-SUFFIX-LIST '("" ".gz" ".Z" ".bz2"))
22 (defvar wl-install-utils nil
23 "if Non-nil, install `wl-utils-modules'.")
26 (defconst wl-ja-info "wl-ja.info")
27 (defconst wl-ja-texi "wl-ja.texi")
28 (defconst wl-en-info "wl.info")
29 (defconst wl-en-texi "wl.texi")
31 (defvar wl-info-lang "ja"
32 "The language of info file (\"ja\" or \"en\").")
34 ;; for Nemacs (dirty!)
35 (if (not (fboundp 'file-executable-p))
36 (fset 'file-executable-p 'file-exists-p))
38 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
43 (condition-case () (require 'custom) (error nil))
45 (unless (and (fboundp 'defgroup)
47 ;; ignore broken module
48 (not (featurep 'tinycustom)))
49 (when (and (boundp 'emacs-major-version)
50 (eq emacs-major-version 19)
51 (>= emacs-minor-version 29))
53 Warning: You don't seem to have \"new custom\" package installed.
54 See README file of APEL package for more information.
57 (defmacro defgroup (&rest args))
58 (defmacro defcustom (symbol value &optional doc &rest args)
59 (let ((doc (concat "*" (or doc ""))))
60 (` (defvar (, symbol) (, value) (, doc))))))
62 (load "bytecomp" nil t)
64 (unless (fboundp 'byte-compile-file-form-custom-declare-variable)
65 ;; Bind defcustom'ed variables.
66 (put 'custom-declare-variable 'byte-hunk-handler
67 'byte-compile-file-form-custom-declare-variable)
68 (defun byte-compile-file-form-custom-declare-variable (form)
69 (if (memq 'free-vars byte-compile-warnings)
70 (setq byte-compile-bound-variables
71 (cons (nth 1 (nth 1 form)) byte-compile-bound-variables)))
76 (wrong-number-of-arguments
77 ;; Optimize byte code for `char-after'.
78 (put 'char-after 'byte-optimizer 'byte-optimize-char-after)
79 (defun byte-optimize-char-after (form)
84 (setq byte-compile-warnings '(free-vars unresolved callargs redefine))
87 (if (or (boundp 'MULE)
88 (fboundp 'nemacs-version))
89 (setq max-lisp-eval-depth 400))
91 ;; FIXME: it is currently needed to byte-compile with Emacs 21.
92 (setq recursive-load-depth-limit nil)
94 (condition-case () (require 'easymenu) (error nil))
96 (defvar config-wl-package-done nil)
98 (defun config-wl-package-subr ()
99 (unless config-wl-package-done
100 (setq config-wl-package-done t)
101 (setq load-path (cons (expand-file-name ".") load-path))
102 (setq load-path (cons (expand-file-name WLDIR)
103 (cons (expand-file-name ELMODIR) load-path)))
104 (setq wl-icon-dir (expand-file-name ICONDIR))
105 ;; load custom file if exists. `WL-CFG.el' override for committer.
106 (load "./WL-CFG" t nil nil)
109 (setq load-path (cons (expand-file-name UTILSDIR) load-path)))
111 (load "./WL-ELS" nil nil t)
113 (require 'mime-setup)
114 (error (error "No MIME module was detected. Please install SEMI or tm.")))
115 ;; smtp.el version check.
117 (if (not (fboundp 'smtp-send-buffer))
118 (error "Please install FLIM 1.14.0 or later."))))
120 (defun config-wl-pixmap-dir (&optional packagedir)
121 "Examine pixmap directory where icon files should go."
122 (let ((pixmap-dir (car command-line-args-left)))
124 (if (string= pixmap-dir "NONE")
126 (expand-file-name "etc/wl/" packagedir)
127 (if (or (featurep 'xemacs)
128 (and (boundp 'emacs-major-version)
129 (>= emacs-major-version 21)))
130 (expand-file-name "wl/icons/" data-directory)))
133 (princ (format "PIXMAPDIR is %s\n" PIXMAPDIR)))
134 (setq command-line-args-left (cdr command-line-args-left)))
136 (defun config-wl-package ()
137 (config-wl-package-subr)
139 (let ((elispdir (car command-line-args-left)))
140 (if (string= elispdir "NONE")
141 (defvar LISPDIR (install-detect-elisp-directory))
142 (defvar LISPDIR elispdir)))
143 (princ (format "LISPDIR is %s\n" LISPDIR))
144 (setq command-line-args-left (cdr command-line-args-left))
146 (config-wl-pixmap-dir)
152 (let ((files (directory-files "tests" t "^test-.*\\.el$"))
153 (suite (lunit-make-test-suite)))
155 (if (file-regular-p (car files))
157 (load-file (car files))
158 (lunit-test-suite-add-test
159 suite (lunit-make-test-suite-from-class
160 (intern (file-name-sans-extension
161 (file-name-nondirectory (car files))))))))
162 (setq files (cdr files)))
165 (defun wl-scan-source (path)
170 (setq ret (append (list y (concat y "c")) ret)))
171 (directory-files x nil "\\(.+\\)\\.el$" t)))
176 (defun wl-uninstall (objs path)
177 ;(message (mapconcat 'identity objs " "))
180 (let ((filename (expand-file-name x path)))
181 (if (and (file-exists-p filename)
182 (file-writable-p filename))
184 (princ (format "%s was uninstalled.\n" filename))
185 (delete-file filename)))))
189 (defun compile-wl-package ()
190 ;; For nemacs byte compiler's strange behavior(?).
192 (if (fboundp 'nemacs-version)
193 (load (expand-file-name "wl.el" WLDIR)))
196 (compile-elisp-modules (cdr x) (car x)))
199 (defun install-wl-icons ()
200 (if (not (file-directory-p PIXMAPDIR))
201 (make-directory PIXMAPDIR t))
202 (let* ((case-fold-search t)
203 (icons (directory-files ICONDIR t "\\.x[bp]m$"))
206 (setq icon (car icons)
208 dest (expand-file-name (file-name-nondirectory icon) PIXMAPDIR))
209 (princ (format "%s->%s\n" icon dest))
210 (copy-file icon dest t))))
212 (defun install-wl-package ()
214 (let ((wl-install-dir (expand-file-name WL_PREFIX LISPDIR))
215 (elmo-install-dir (expand-file-name ELMO_PREFIX LISPDIR)))
218 (install-elisp-modules (cdr x) (car x)
219 (if (string= (car x) ELMODIR)
227 (defun uninstall-wl-package ()
229 (let ((wl-install-dir (expand-file-name WL_PREFIX
231 (elmo-install-dir (expand-file-name ELMO_PREFIX
233 (wl-uninstall (wl-scan-source (list WLDIR UTILSDIR))
235 (wl-uninstall (wl-scan-source (list ELMODIR))
238 (let* ((case-fold-search t)
239 (icons (directory-files PIXMAPDIR t "\\.x[bp]m$"))
242 (setq icon (car icons)
244 (if (and (file-exists-p icon)
245 (file-writable-p icon))
247 (princ (format "%s was uninstalled.\n" icon))
248 (delete-file icon)))))))
251 (defun config-wl-package-xmas ()
252 (if (not (featurep 'xemacs))
253 (error "This directive is only for XEmacs."))
254 (config-wl-package-subr)
257 (and (setq package-dir (car command-line-args-left))
258 (if (string= "NONE" package-dir)
260 (if (boundp 'early-packages)
261 (let ((dirs (append (if early-package-load-path
263 (if late-package-load-path
265 (if last-package-load-path
268 (while (not (file-exists-p
269 (setq dir (car dirs))))
270 (setq dirs (cdr dirs)))
272 (defvar PACKAGEDIR package-dir)))
273 (princ (format "PACKAGEDIR is %s\n" PACKAGEDIR))
274 (setq command-line-args-left (cdr command-line-args-left)))
276 (config-wl-pixmap-dir PACKAGEDIR)
280 (defun compile-wl-package-xmas ()
281 (config-wl-package-xmas)
282 (setq autoload-package-name "wl")
283 (add-to-list 'command-line-args-left WLDIR)
284 (batch-update-directory)
285 (add-to-list 'command-line-args-left WLDIR)
286 (Custom-make-dependencies)
287 ;; WL-AUTOLOAD-MODULES
288 (compile-elisp-modules WL-AUTOLOAD-MODULES WLDIR)
291 (compile-elisp-modules (cdr x) (car x)))
294 (defun install-wl-package-xmas ()
295 (compile-wl-package-xmas)
296 (let ((LISPDIR (expand-file-name "wl"
297 (expand-file-name "lisp"
299 (DATADIR (expand-file-name "wl"
300 (expand-file-name "etc"
302 (INFODIR (expand-file-name "info" PACKAGEDIR)))
303 (or (file-exists-p DATADIR)
304 (make-directory DATADIR t))
305 (or (file-exists-p INFODIR)
306 (make-directory INFODIR t))
311 (install-elisp-modules (cdr x) (car x) LISPDIR))
313 ;; WL-AUTOLOAD-MODULES
314 (install-elisp-modules WL-AUTOLOAD-MODULES WLDIR LISPDIR)
317 (wl-texinfo-install)))
320 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
323 (defun wl-texinfo-format-file (lang)
324 (let ((infofile (symbol-value (intern (format "wl-%s-info" lang))))
325 (texifile (symbol-value (intern (format "wl-%s-texi" lang)))))
326 (require 'wl-vars) ;; for 'wl-cs-local
327 (or (file-newer-than-file-p (expand-file-name infofile DOCDIR)
328 (expand-file-name texifile DOCDIR))
330 ;; Support old texinfmt.el
331 (require 'ptexinfmt (expand-file-name "ptexinfmt.el" UTILSDIR))
332 (find-file (expand-file-name texifile DOCDIR))
333 (setq obuf (current-buffer))
334 ;; We can't know file names if splitted.
335 (texinfo-format-buffer t)
336 ;; Emacs20.2's default is 'raw-text-unix.
337 (and (fboundp 'set-buffer-file-coding-system)
338 (set-buffer-file-coding-system wl-cs-local))
340 (kill-buffer (current-buffer)) ;; info
341 (kill-buffer obuf)) ;; texi
344 (defun wl-texinfo-format ()
346 (setq INFODIR (wl-detect-info-directory)))
347 (cond ((listp wl-info-lang)
348 (mapcar 'wl-texinfo-format-file wl-info-lang))
349 ((stringp wl-info-lang)
350 (wl-texinfo-format-file wl-info-lang))))
352 (defun wl-texinfo-install-file (lang)
353 (let ((infofile (symbol-value (intern (format "wl-%s-info" lang)))))
354 (install-file infofile DOCDIR INFODIR)))
356 (defun wl-texinfo-install ()
357 (cond ((listp wl-info-lang)
358 (mapcar 'wl-texinfo-install-file wl-info-lang))
359 ((stringp wl-info-lang)
360 (wl-texinfo-install-file wl-info-lang))))
362 (defun wl-primary-info-file ()
363 "Get primary info file (for wl-detect-info-directory)."
365 ((listp wl-info-lang)
366 (let ((wl-info-lang (car wl-info-lang)))
367 (wl-primary-info-file)))
368 ((stringp wl-info-lang)
369 (symbol-value (intern (format "wl-%s-info" wl-info-lang))))))
371 (defun wl-detect-info-directory ()
372 (config-wl-package-subr)
373 (if (fboundp 'nemacs-version)
374 (error "Cannot format info on Nemacs. Please use another formatter."))
377 (if (fboundp 'info-initialize)
379 (let ((infodir (car command-line-args-left))
380 (info (wl-primary-info-file))
383 (if (string= infodir "NONE")
385 (exec-installed-p info Info-directory-list
386 COMPRESS-SUFFIX-LIST))
388 ;;(condition-case nil (delete-file previous))
389 (directory-file-name (file-name-directory previous));)
390 (car Info-directory-list))
392 (setq command-line-args-left (cdr command-line-args-left))
393 (princ (format "INFODIR is %s\n\n" INFODIR))
396 (defun install-wl-info ()
398 (wl-texinfo-install))
402 ;;; * MORE refine code (^_^;