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)))
52 (when (and (boundp 'emacs-major-version)
53 (eq emacs-major-version 19)
54 (>= emacs-minor-version 29))
56 Warning: You don't seem to have \"new custom\" package installed.
57 See README file of APEL package for more information.
60 (defmacro defgroup (&rest args))
61 (defmacro defcustom (symbol value &optional doc &rest args)
62 (let ((doc (concat "*" (or doc ""))))
63 (` (defvar (, symbol) (, value) (, doc))))))
65 (load "bytecomp" nil t)
66 (unless (fboundp 'byte-compile-file-form-custom-declare-variable)
67 ;; Bind defcustom'ed variables.
68 (put 'custom-declare-variable 'byte-hunk-handler
69 'byte-compile-file-form-custom-declare-variable)
70 (defun byte-compile-file-form-custom-declare-variable (form)
71 (if (memq 'free-vars byte-compile-warnings)
72 (setq byte-compile-bound-variables
73 (cons (nth 1 (nth 1 form)) byte-compile-bound-variables)))
76 (setq byte-compile-warnings '(free-vars unresolved callargs redefine))
79 (if (or (boundp 'MULE)
80 (fboundp 'nemacs-version))
81 (setq max-lisp-eval-depth 400))
83 ;; FIXME: it is currently needed to byte-compile with Emacs 21.
84 (setq recursive-load-depth-limit nil)
86 (condition-case () (require 'easymenu) (error nil))
88 (defvar config-wl-package-done nil)
90 (defun config-wl-package-subr ()
91 (unless config-wl-package-done
92 (setq config-wl-package-done t)
93 (setq load-path (cons (expand-file-name ".") load-path))
94 (setq load-path (cons (expand-file-name WLDIR)
95 (cons (expand-file-name ELMODIR) load-path)))
96 (setq wl-icon-dir (expand-file-name ICONDIR))
97 ;;; load custom file if exists.
98 (load "./WL-CFG" t nil t)
101 (setq load-path (cons (expand-file-name UTILSDIR) load-path)))
103 (setq load-path (cons (expand-file-name SASLDIR) load-path)))
107 (require 'mime-setup)
108 (error (error "No MIME module was detected. Please install SEMI or tm.")))
109 (princ (concat "\nMIME module is " (if wl-use-semi "SEMI" "tm-8") ".\n"))))
111 (defun config-wl-pixmap-dir (&optional packagedir)
112 "Examine pixmap directory where icon files should go."
113 (let ((pixmap-dir (car command-line-args-left)))
115 (if (string= pixmap-dir "NONE")
117 (expand-file-name "etc/wl/" packagedir)
118 (if (or (featurep 'xemacs)
119 (and (boundp 'emacs-major-version)
120 (>= emacs-major-version 21)))
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 (defun wl-scan-source (path)
146 (setq ret (append (list y (concat y "c")) ret)))
147 (directory-files x nil "\\(.+\\)\\.el$" t)))
152 (defun wl-uninstall (objs path)
153 ;(message (mapconcat 'identity objs " "))
156 (let ((filename (expand-file-name x path)))
157 (if (and (file-exists-p filename)
158 (file-writable-p filename))
160 (princ (format "%s was uninstalled.\n" filename))
161 (delete-file filename)))))
165 (defun compile-wl-package ()
166 ;; For nemacs byte compiler's strange behavior(?).
168 (if (fboundp 'nemacs-version)
169 (load (expand-file-name "wl.el" WLDIR)))
172 (compile-elisp-modules (cdr x) (car x)))
175 (defun install-wl-icons ()
176 (if (not (file-directory-p PIXMAPDIR))
177 (make-directory PIXMAPDIR t))
178 (let* ((case-fold-search t)
179 (icons (directory-files ICONDIR t "\\.x[bp]m$"))
182 (setq icon (car icons)
184 dest (expand-file-name (file-name-nondirectory icon) PIXMAPDIR))
185 (princ (format "%s->%s\n" icon dest))
186 (copy-file icon dest t))))
188 (defun install-wl-package ()
190 (let ((wl-install-dir (expand-file-name WL_PREFIX LISPDIR))
191 (elmo-install-dir (expand-file-name ELMO_PREFIX LISPDIR)))
194 (install-elisp-modules (cdr x) (car x)
195 (if (string= (car x) ELMODIR)
203 (defun uninstall-wl-package ()
205 (let ((wl-install-dir (expand-file-name WL_PREFIX
207 (elmo-install-dir (expand-file-name ELMO_PREFIX
209 (wl-uninstall (wl-scan-source (list WLDIR UTILSDIR SASLDIR))
211 (wl-uninstall (wl-scan-source (list ELMODIR))
214 (let* ((case-fold-search t)
215 (icons (directory-files PIXMAPDIR t "\\.x[bp]m$"))
218 (setq icon (car icons)
220 (if (and (file-exists-p icon)
221 (file-writable-p icon))
223 (princ (format "%s was uninstalled.\n" icon))
224 (delete-file icon)))))))
227 (defun config-wl-package-xmas ()
228 (if (not (featurep 'xemacs))
229 (error "This directive is only for XEmacs."))
230 (config-wl-package-subr)
233 (and (setq package-dir (car command-line-args-left))
234 (if (string= "NONE" package-dir)
236 (if (boundp 'early-packages)
237 (let ((dirs (append (if early-package-load-path
239 (if late-package-load-path
241 (if last-package-load-path
244 (while (not (file-exists-p
245 (setq dir (car dirs))))
246 (setq dirs (cdr dirs)))
248 (defvar PACKAGEDIR package-dir)))
249 (princ (format "PACKAGEDIR is %s\n" PACKAGEDIR))
250 (setq command-line-args-left (cdr command-line-args-left)))
252 (config-wl-pixmap-dir PACKAGEDIR)
256 (defun compile-wl-package-xmas ()
257 (config-wl-package-xmas)
258 (setq autoload-package-name "wl")
259 (add-to-list 'command-line-args-left WLDIR)
260 (batch-update-directory)
261 (add-to-list 'command-line-args-left WLDIR)
262 (Custom-make-dependencies)
263 ;; WL-AUTOLOAD-MODULES
264 (compile-elisp-modules WL-AUTOLOAD-MODULES WLDIR)
267 (compile-elisp-modules (cdr x) (car x)))
270 (defun install-wl-package-xmas ()
271 (compile-wl-package-xmas)
272 (let ((LISPDIR (expand-file-name "wl"
273 (expand-file-name "lisp"
275 (DATADIR (expand-file-name "wl"
276 (expand-file-name "etc"
278 (INFODIR (expand-file-name "info" PACKAGEDIR)))
279 (or (file-exists-p DATADIR)
280 (make-directory DATADIR t))
281 (or (file-exists-p INFODIR)
282 (make-directory INFODIR t))
287 (install-elisp-modules (cdr x) (car x) LISPDIR))
289 ;; WL-AUTOLOAD-MODULES
290 (install-elisp-modules WL-AUTOLOAD-MODULES WLDIR LISPDIR)
293 (wl-texinfo-install)))
296 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
299 (defun wl-texinfo-format-file (lang)
300 (let ((infofile (symbol-value (intern (format "wl-%s-info" lang))))
301 (texifile (symbol-value (intern (format "wl-%s-texi" lang)))))
302 (require 'wl-vars) ;; for 'wl-cs-local
303 (or (file-newer-than-file-p (expand-file-name infofile DOCDIR)
304 (expand-file-name texifile DOCDIR))
306 ;; Support old texinfmt.el
307 (require 'ptexinfmt (expand-file-name "ptexinfmt.el" UTILSDIR))
308 (find-file (expand-file-name texifile DOCDIR))
309 (setq obuf (current-buffer))
310 ;; We can't know file names if splitted.
311 (texinfo-format-buffer t)
312 ;; Emacs20.2's default is 'raw-text-unix.
313 (and (fboundp 'set-buffer-file-coding-system)
314 (set-buffer-file-coding-system wl-cs-local))
316 (kill-buffer (current-buffer)) ;; info
317 (kill-buffer obuf)) ;; texi
320 (defun wl-texinfo-format ()
322 (setq INFODIR (wl-detect-info-directory)))
323 (cond ((listp wl-info-lang)
324 (mapcar 'wl-texinfo-format-file wl-info-lang))
325 ((stringp wl-info-lang)
326 (wl-texinfo-format-file wl-info-lang))))
328 (defun wl-texinfo-install-file (lang)
329 (let ((infofile (symbol-value (intern (format "wl-%s-info" lang)))))
330 (install-file infofile DOCDIR INFODIR)))
332 (defun wl-texinfo-install ()
333 (cond ((listp wl-info-lang)
334 (mapcar 'wl-texinfo-install-file wl-info-lang))
335 ((stringp wl-info-lang)
336 (wl-texinfo-install-file wl-info-lang))))
338 (defun wl-primary-info-file ()
339 "Get primary info file (for wl-detect-info-directory)."
341 ((listp wl-info-lang)
342 (let ((wl-info-lang (car wl-info-lang)))
343 (wl-primary-info-file)))
344 ((stringp wl-info-lang)
345 (symbol-value (intern (format "wl-%s-info" wl-info-lang))))))
347 (defun wl-detect-info-directory ()
348 (config-wl-package-subr)
349 (if (fboundp 'nemacs-version)
350 (error "Cannot format info on Nemacs. Please use another formatter."))
353 (let ((infodir (car command-line-args-left))
354 (info (wl-primary-info-file))
357 (if (string= infodir "NONE")
359 (exec-installed-p info Info-directory-list
360 COMPRESS-SUFFIX-LIST))
362 ;;(condition-case nil (delete-file previous))
363 (directory-file-name (file-name-directory previous));)
364 (car Info-directory-list))
366 (setq command-line-args-left (cdr command-line-args-left))
367 (princ (format "INFODIR is %s\n\n" INFODIR))
370 (defun install-wl-info ()
372 (wl-texinfo-install))
376 ;;; * MORE refine code (^_^;