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" "en")
32 "The language of info file (\"ja\" or \"en\").")
34 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
39 (condition-case () (require 'custom) (error nil))
41 (unless (and (fboundp 'defgroup)
43 ;; ignore broken module
44 (not (featurep 'tinycustom)))
45 (when (and (boundp 'emacs-major-version)
46 (eq emacs-major-version 19)
47 (>= emacs-minor-version 29))
49 Warning: You don't seem to have \"new custom\" package installed.
50 See README file of APEL package for more information.
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))))))
58 (load "bytecomp" nil t)
60 (unless (fboundp 'byte-compile-file-form-custom-declare-variable)
61 ;; Bind defcustom'ed variables.
62 (put 'custom-declare-variable 'byte-hunk-handler
63 'byte-compile-file-form-custom-declare-variable)
64 (defun byte-compile-file-form-custom-declare-variable (form)
65 (if (memq 'free-vars byte-compile-warnings)
66 (setq byte-compile-bound-variables
67 (cons (nth 1 (nth 1 form)) byte-compile-bound-variables)))
72 (wrong-number-of-arguments
73 ;; Optimize byte code for `char-after'.
74 (put 'char-after 'byte-optimizer 'byte-optimize-char-after)
75 (defun byte-optimize-char-after (form)
80 (setq byte-compile-warnings '(free-vars unresolved callargs redefine))
84 (setq max-lisp-eval-depth 400))
86 ;; FIXME: it is currently needed to byte-compile with Emacs 21.
87 (setq recursive-load-depth-limit nil)
89 (condition-case () (require 'easymenu) (error nil))
91 (defvar config-wl-package-done nil)
93 (defun config-wl-package-subr ()
94 (unless config-wl-package-done
95 (setq config-wl-package-done t)
96 (setq load-path (cons (expand-file-name ".") load-path))
97 (setq load-path (cons (expand-file-name WLDIR)
98 (cons (expand-file-name ELMODIR) load-path)))
99 ;; load custom file if exists. `WL-CFG.el' override for committer.
100 (load "./WL-CFG" t nil nil)
103 (setq load-path (cons (expand-file-name UTILSDIR) load-path)))
105 (load "./WL-ELS" nil nil t)
107 (require 'mime-setup)
108 (error (error "No MIME module was detected. Please install SEMI.")))
109 ;; smtp.el version check.
111 (if (not (fboundp 'smtp-send-buffer))
112 (error "Please install new FLIM. See INSTALL or INSTALL.ja."))))
114 (defun config-wl-pixmap-dir (&optional packagedir)
115 "Examine pixmap directory where icon files should go."
116 (let ((pixmap-dir (car command-line-args-left)))
118 (if (string= pixmap-dir "NONE")
120 (expand-file-name "etc/wl/" packagedir)
121 (expand-file-name "wl/icons/" data-directory))
124 (princ (format "PIXMAPDIR is %s\n" PIXMAPDIR)))
125 (setq command-line-args-left (cdr command-line-args-left)))
127 (defun config-wl-package ()
128 (config-wl-package-subr)
130 (let ((elispdir (car command-line-args-left)))
131 (if (string= elispdir "NONE")
132 (defvar LISPDIR (install-detect-elisp-directory))
133 (defvar LISPDIR elispdir)))
134 (princ (format "LISPDIR is %s\n" LISPDIR))
135 (setq command-line-args-left (cdr command-line-args-left))
137 (config-wl-pixmap-dir)
141 "Run test suite for developer."
144 (let ((files (directory-files "tests" t "^test-.*\\.el$"))
145 (suite (lunit-make-test-suite)))
147 (if (file-regular-p (car files))
149 (load-file (car files))
150 (lunit-test-suite-add-test
151 suite (lunit-make-test-suite-from-class
152 (intern (file-name-sans-extension
153 (file-name-nondirectory (car files))))))))
154 (setq files (cdr files)))
158 "Check user environment. Not for developer."
161 (let ((files (directory-files "tests" t "^check-.*\\.el$"))
162 (suite (lunit-make-test-suite)))
164 (if (file-regular-p (car files))
166 (load-file (car files))
167 (lunit-test-suite-add-test
168 suite (lunit-make-test-suite-from-class
169 (intern (file-name-sans-extension
170 (file-name-nondirectory (car files))))))))
171 (setq files (cdr files)))
174 (defun wl-scan-source (path)
179 (setq ret (append (list y (concat y "c")) ret)))
180 (directory-files x nil "\\(.+\\)\\.el$" t)))
185 (defun wl-uninstall (objs path)
186 ;(message (mapconcat 'identity objs " "))
189 (let ((filename (expand-file-name x path)))
190 (if (and (file-exists-p filename)
191 (file-writable-p filename))
193 (princ (format "%s was uninstalled.\n" filename))
194 (delete-file filename)))))
198 (defun compile-wl-package ()
202 (compile-elisp-modules (cdr x) (car x)))
205 (defun install-wl-icons ()
206 (if (not (file-directory-p PIXMAPDIR))
207 (make-directory PIXMAPDIR t))
208 (let* ((case-fold-search t)
209 (icons (directory-files ICONDIR t
210 (cond ((or (featurep 'xemacs)
211 (and (boundp 'emacs-major-version)
212 (>= emacs-major-version 21)))
215 "\\.img$\\|\\.xbm$"))))
218 (setq icon (car icons)
220 dest (expand-file-name (file-name-nondirectory icon) PIXMAPDIR))
221 (princ (format "%s->%s\n" icon dest))
222 (copy-file icon dest t))))
224 (defun install-wl-package ()
226 (let ((wl-install-dir (expand-file-name WL_PREFIX LISPDIR))
227 (elmo-install-dir (expand-file-name ELMO_PREFIX LISPDIR)))
230 (install-elisp-modules (cdr x) (car x)
231 (if (string= (car x) ELMODIR)
239 (defun uninstall-wl-package ()
241 (let ((wl-install-dir (expand-file-name WL_PREFIX
243 (elmo-install-dir (expand-file-name ELMO_PREFIX
245 (wl-uninstall (wl-scan-source (list WLDIR UTILSDIR))
247 (wl-uninstall (wl-scan-source (list ELMODIR))
250 (let* ((case-fold-search t)
251 (icons (directory-files PIXMAPDIR t "\\.x[bp]m$"))
254 (setq icon (car icons)
256 (if (and (file-exists-p icon)
257 (file-writable-p icon))
259 (princ (format "%s was uninstalled.\n" icon))
260 (delete-file icon)))))))
263 (defun config-wl-package-xmas ()
264 (if (not (featurep 'xemacs))
265 (error "This directive is only for XEmacs."))
266 (config-wl-package-subr)
269 (and (setq package-dir (car command-line-args-left))
270 (if (string= "NONE" package-dir)
272 (if (boundp 'early-packages)
273 (let ((dirs (append (if early-package-load-path
275 (if late-package-load-path
277 (if last-package-load-path
280 (while (not (file-exists-p
281 (setq dir (car dirs))))
282 (setq dirs (cdr dirs)))
284 (defvar PACKAGEDIR package-dir)))
285 (princ (format "PACKAGEDIR is %s\n" PACKAGEDIR))
286 (setq command-line-args-left (cdr command-line-args-left)))
288 (config-wl-pixmap-dir PACKAGEDIR)
292 (defun compile-wl-package-xmas ()
293 (config-wl-package-xmas)
294 (setq autoload-package-name "wl")
295 (add-to-list 'command-line-args-left WLDIR)
296 (batch-update-directory)
297 (add-to-list 'command-line-args-left WLDIR)
298 (Custom-make-dependencies)
299 ;; WL-AUTOLOAD-MODULES
300 (compile-elisp-modules WL-AUTOLOAD-MODULES WLDIR)
303 (compile-elisp-modules (cdr x) (car x)))
306 (defun install-wl-package-xmas ()
307 (compile-wl-package-xmas)
308 (let ((LISPDIR (expand-file-name "wl"
309 (expand-file-name "lisp"
311 (DATADIR (expand-file-name "wl"
312 (expand-file-name "etc"
314 (INFODIR (expand-file-name "info" PACKAGEDIR)))
315 (or (file-exists-p DATADIR)
316 (make-directory DATADIR t))
317 (or (file-exists-p INFODIR)
318 (make-directory INFODIR t))
323 (install-elisp-modules (cdr x) (car x) LISPDIR))
325 ;; WL-AUTOLOAD-MODULES
326 (install-elisp-modules WL-AUTOLOAD-MODULES WLDIR LISPDIR)
329 (wl-texinfo-install)))
332 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
335 (defun wl-texinfo-format-file (lang)
336 (let ((infofile (symbol-value (intern (format "wl-%s-info" lang))))
337 (texifile (symbol-value (intern (format "wl-%s-texi" lang)))))
338 (require 'wl-vars) ;; for 'wl-cs-local
339 (or (file-newer-than-file-p (expand-file-name infofile DOCDIR)
340 (expand-file-name texifile DOCDIR))
342 ;; Support old texinfmt.el
343 (require 'ptexinfmt (expand-file-name "ptexinfmt.el" UTILSDIR))
344 (find-file (expand-file-name texifile DOCDIR))
345 (setq obuf (current-buffer))
346 ;; We can't know file names if splitted.
347 (texinfo-format-buffer t)
348 ;; Emacs20.2's default is 'raw-text-unix.
349 (and (fboundp 'set-buffer-file-coding-system)
350 (set-buffer-file-coding-system wl-cs-local))
352 (kill-buffer (current-buffer)) ;; info
353 (kill-buffer obuf)) ;; texi
356 (defun wl-texinfo-format ()
358 (setq INFODIR (wl-detect-info-directory)))
359 (cond ((listp wl-info-lang)
360 (mapcar 'wl-texinfo-format-file wl-info-lang))
361 ((stringp wl-info-lang)
362 (wl-texinfo-format-file wl-info-lang))))
364 (defun wl-texinfo-install-file (lang)
365 (let ((infofile (symbol-value (intern (format "wl-%s-info" lang)))))
366 (install-file infofile DOCDIR INFODIR)))
368 (defun wl-texinfo-install ()
369 (cond ((listp wl-info-lang)
370 (mapcar 'wl-texinfo-install-file wl-info-lang))
371 ((stringp wl-info-lang)
372 (wl-texinfo-install-file wl-info-lang))))
374 (defun wl-primary-info-file ()
375 "Get primary info file (for wl-detect-info-directory)."
377 ((listp wl-info-lang)
378 (let ((wl-info-lang (car wl-info-lang)))
379 (wl-primary-info-file)))
380 ((stringp wl-info-lang)
381 (symbol-value (intern (format "wl-%s-info" wl-info-lang))))))
383 (defun wl-detect-info-directory ()
384 (config-wl-package-subr)
387 (if (fboundp 'info-initialize)
389 (let ((infodir (car command-line-args-left))
390 (info (wl-primary-info-file))
393 (if (string= infodir "NONE")
395 (exec-installed-p info Info-directory-list
396 COMPRESS-SUFFIX-LIST))
398 ;;(condition-case nil (delete-file previous))
399 (directory-file-name (file-name-directory previous));)
400 (car Info-directory-list))
402 (setq command-line-args-left (cdr command-line-args-left))
403 (princ (format "INFODIR is %s\n\n" INFODIR))
406 (defun install-wl-info ()
408 (wl-texinfo-install))
412 ;;; * MORE refine code (^_^;