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.
59 (defmacro defgroup (&rest args))
60 (defmacro defcustom (symbol value &optional doc &rest args)
61 (let ((doc (concat "*" (or doc ""))))
62 (` (defvar (, symbol) (, value) (, doc))))))
64 (load "bytecomp" nil t)
65 (unless (fboundp 'byte-compile-file-form-custom-declare-variable)
66 ;; Bind defcustom'ed variables.
67 (put 'custom-declare-variable 'byte-hunk-handler
68 'byte-compile-file-form-custom-declare-variable)
69 (defun byte-compile-file-form-custom-declare-variable (form)
70 (if (memq 'free-vars byte-compile-warnings)
71 (setq byte-compile-bound-variables
72 (cons (nth 1 (nth 1 form)) byte-compile-bound-variables)))
75 (setq byte-compile-warnings '(free-vars unresolved callargs redefine))
78 (if (or (boundp 'MULE)
79 (fboundp 'nemacs-version))
80 (setq max-lisp-eval-depth 400))
82 ;; FIXME: it is currently needed to byte-compile with Emacs 21.
83 (setq recursive-load-depth-limit nil)
85 (condition-case () (require 'easymenu) (error nil))
87 (defvar config-wl-package-done nil)
89 (defun config-wl-package-subr ()
90 (unless config-wl-package-done
91 (setq config-wl-package-done t)
92 (setq load-path (cons (expand-file-name ".") load-path))
93 (setq load-path (cons (expand-file-name WLDIR)
94 (cons (expand-file-name ELMODIR) load-path)))
95 (setq wl-icon-dir (expand-file-name ICONDIR))
96 ;;; load custom file if exists.
97 (load "./WL-CFG" t nil t)
100 (setq load-path (cons (expand-file-name UTILSDIR) load-path)))
102 (setq load-path (cons (expand-file-name SASLDIR) load-path)))
106 (require 'mime-setup)
107 (error (error "No MIME module was detected. Please install SEMI or tm.")))
109 (princ (concat "\nUse SEMI"
110 (if wl-use-luna " with LUNA\n" " without LUNA\n")))
111 (princ "\nUse tm.\n"))))
113 (defun config-wl-pixmap-dir (&optional packagedir)
114 "Examine pixmap directory where icon files should go."
115 (let ((pixmap-dir (car command-line-args-left)))
117 (if (string= pixmap-dir "NONE")
119 (expand-file-name "etc/wl/" packagedir)
120 (if (or (featurep 'xemacs)
121 (and (boundp 'emacs-major-version)
122 (>= emacs-major-version 21)))
123 (expand-file-name "wl/icons/" data-directory)))
126 (princ (format "PIXMAPDIR is %s\n" PIXMAPDIR)))
127 (setq command-line-args-left (cdr command-line-args-left)))
129 (defun config-wl-package ()
130 (config-wl-package-subr)
132 (let ((elispdir (car command-line-args-left)))
133 (if (string= elispdir "NONE")
134 (defvar LISPDIR (install-detect-elisp-directory))
135 (defvar LISPDIR elispdir)))
136 (princ (format "LISPDIR is %s\n" LISPDIR))
137 (setq command-line-args-left (cdr command-line-args-left))
139 (config-wl-pixmap-dir)
143 (defun wl-scan-source (path)
148 (setq ret (append (list y (concat y "c")) ret)))
149 (directory-files x nil "\\(.+\\)\\.el$" t)))
154 (defun wl-uninstall (objs path)
155 ;(message (mapconcat 'identity objs " "))
158 (let ((filename (expand-file-name x path)))
159 (if (and (file-exists-p filename)
160 (file-writable-p filename))
162 (princ (format "%s was uninstalled.\n" filename))
163 (delete-file filename)))))
167 (defun compile-wl-package ()
168 ;; For nemacs byte compiler's strange behavior(?).
170 (if (fboundp 'nemacs-version)
171 (load (expand-file-name "wl.el" WLDIR)))
174 (compile-elisp-modules (cdr x) (car x)))
177 (defun install-wl-icons ()
178 (if (not (file-directory-p PIXMAPDIR))
179 (make-directory PIXMAPDIR t))
180 (let* ((case-fold-search t)
181 (icons (directory-files ICONDIR t "\\.x[bp]m$"))
184 (setq icon (car icons)
186 dest (expand-file-name (file-name-nondirectory icon) PIXMAPDIR))
187 (princ (format "%s->%s\n" icon dest))
188 (copy-file icon dest t))))
190 (defun install-wl-package ()
192 (let ((wl-install-dir (expand-file-name WL_PREFIX LISPDIR))
193 (elmo-install-dir (expand-file-name ELMO_PREFIX LISPDIR)))
196 (install-elisp-modules (cdr x) (car x)
197 (if (string= (car x) ELMODIR)
205 (defun uninstall-wl-package ()
207 (let ((wl-install-dir (expand-file-name WL_PREFIX
209 (elmo-install-dir (expand-file-name ELMO_PREFIX
211 (wl-uninstall (wl-scan-source (list WLDIR UTILSDIR SASLDIR))
213 (wl-uninstall (wl-scan-source (list ELMODIR))
216 (let* ((case-fold-search t)
217 (icons (directory-files PIXMAPDIR t "\\.x[bp]m$"))
220 (setq icon (car icons)
222 (if (and (file-exists-p icon)
223 (file-writable-p icon))
225 (princ (format "%s was uninstalled.\n" icon))
226 (delete-file icon)))))))
229 (defun config-wl-package-xmas ()
230 (if (not (featurep 'xemacs))
231 (error "This directive is only for XEmacs."))
232 (config-wl-package-subr)
235 (and (setq package-dir (car command-line-args-left))
236 (if (string= "NONE" package-dir)
238 (if (boundp 'early-packages)
239 (let ((dirs (append (if early-package-load-path
241 (if late-package-load-path
243 (if last-package-load-path
246 (while (not (file-exists-p
247 (setq dir (car dirs))))
248 (setq dirs (cdr dirs)))
250 (defvar PACKAGEDIR package-dir)))
251 (princ (format "PACKAGEDIR is %s\n" PACKAGEDIR))
252 (setq command-line-args-left (cdr command-line-args-left)))
254 (config-wl-pixmap-dir PACKAGEDIR)
258 (defun compile-wl-package-xmas ()
259 (config-wl-package-xmas)
260 (setq autoload-package-name "wl")
261 (add-to-list 'command-line-args-left WLDIR)
262 (batch-update-directory)
263 (add-to-list 'command-line-args-left WLDIR)
264 (Custom-make-dependencies)
265 ;; WL-AUTOLOAD-MODULES
266 (compile-elisp-modules WL-AUTOLOAD-MODULES WLDIR)
269 (compile-elisp-modules (cdr x) (car x)))
272 (defun install-wl-package-xmas ()
273 (compile-wl-package-xmas)
274 (let ((LISPDIR (expand-file-name "wl"
275 (expand-file-name "lisp"
277 (DATADIR (expand-file-name "wl"
278 (expand-file-name "etc"
280 (INFODIR (expand-file-name "info" PACKAGEDIR)))
281 (or (file-exists-p DATADIR)
282 (make-directory DATADIR t))
283 (or (file-exists-p INFODIR)
284 (make-directory INFODIR t))
289 (install-elisp-modules (cdr x) (car x) LISPDIR))
291 ;; WL-AUTOLOAD-MODULES
292 (install-elisp-modules WL-AUTOLOAD-MODULES WLDIR LISPDIR)
295 (wl-texinfo-install)))
298 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
301 (defun wl-texinfo-format-file (lang)
302 (let ((infofile (symbol-value (intern (format "wl-%s-info" lang))))
303 (texifile (symbol-value (intern (format "wl-%s-texi" lang)))))
304 (require 'wl-vars) ;; for 'wl-cs-local
305 (or (file-newer-than-file-p (expand-file-name infofile DOCDIR)
306 (expand-file-name texifile DOCDIR))
308 ;; Support old texinfmt.el
309 (require 'ptexinfmt (expand-file-name "ptexinfmt.el" UTILSDIR))
310 (find-file (expand-file-name texifile DOCDIR))
311 (setq obuf (current-buffer))
312 ;; We can't know file names if splitted.
313 (texinfo-format-buffer t)
314 ;; Emacs20.2's default is 'raw-text-unix.
315 (and (fboundp 'set-buffer-file-coding-system)
316 (set-buffer-file-coding-system wl-cs-local))
318 (kill-buffer (current-buffer)) ;; info
319 (kill-buffer obuf)) ;; texi
322 (defun wl-texinfo-format ()
324 (setq INFODIR (wl-detect-info-directory)))
325 (cond ((listp wl-info-lang)
326 (mapcar 'wl-texinfo-format-file wl-info-lang))
327 ((stringp wl-info-lang)
328 (wl-texinfo-format-file wl-info-lang))))
330 (defun wl-texinfo-install-file (lang)
331 (let ((infofile (symbol-value (intern (format "wl-%s-info" lang)))))
332 (install-file infofile DOCDIR INFODIR)))
334 (defun wl-texinfo-install ()
335 (cond ((listp wl-info-lang)
336 (mapcar 'wl-texinfo-install-file wl-info-lang))
337 ((stringp wl-info-lang)
338 (wl-texinfo-install-file wl-info-lang))))
340 (defun wl-primary-info-file ()
341 "Get primary info file (for wl-detect-info-directory)."
343 ((listp wl-info-lang)
344 (let ((wl-info-lang (car wl-info-lang)))
345 (wl-primary-info-file)))
346 ((stringp wl-info-lang)
347 (symbol-value (intern (format "wl-%s-info" wl-info-lang))))))
349 (defun wl-detect-info-directory ()
350 (config-wl-package-subr)
351 (if (fboundp 'nemacs-version)
352 (error "Cannot format info on Nemacs. Please use another formatter."))
355 (let ((infodir (car command-line-args-left))
356 (info (wl-primary-info-file))
359 (if (string= infodir "NONE")
361 (exec-installed-p info Info-directory-list
362 COMPRESS-SUFFIX-LIST))
364 ;;(condition-case nil (delete-file previous))
365 (directory-file-name (file-name-directory previous));)
366 (car Info-directory-list))
368 (setq command-line-args-left (cdr command-line-args-left))
369 (princ (format "INFODIR is %s\n\n" INFODIR))
372 (defun install-wl-info ()
374 (wl-texinfo-install))
378 ;;; * MORE refine code (^_^;