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)
63 (unless (fboundp 'byte-compile-file-form-custom-declare-variable)
64 ;; Bind defcustom'ed variables.
65 (put 'custom-declare-variable 'byte-hunk-handler
66 'byte-compile-file-form-custom-declare-variable)
67 (defun byte-compile-file-form-custom-declare-variable (form)
68 (if (memq 'free-vars byte-compile-warnings)
69 (setq byte-compile-bound-variables
70 (cons (nth 1 (nth 1 form)) byte-compile-bound-variables)))
73 (setq byte-compile-warnings '(free-vars unresolved callargs redefine))
76 (if (or (boundp 'MULE)
77 (fboundp 'nemacs-version))
78 (setq max-lisp-eval-depth 400))
80 ;; FIXME: it is currently needed to byte-compile with Emacs 21.
81 (setq recursive-load-depth-limit nil)
83 (condition-case () (require 'easymenu) (error nil))
85 (defvar config-wl-package-done nil)
87 (defun config-wl-package-subr ()
88 (unless config-wl-package-done
89 (setq config-wl-package-done t)
90 (setq load-path (cons (expand-file-name ".") load-path))
91 (setq load-path (cons (expand-file-name WLDIR)
92 (cons (expand-file-name ELMODIR) load-path)))
93 (setq wl-icon-dir (expand-file-name ICONDIR))
94 ;; load custom file if exists. `WL-CFG.el' override for committer.
95 (load "./WL-CFG" t nil nil)
98 (setq load-path (cons (expand-file-name UTILSDIR) load-path)))
100 (load "./WL-ELS" nil nil t)
102 (require 'mime-setup)
103 (error (error "No MIME module was detected. Please install SEMI or tm.")))
104 ;; smtp.el version check.
106 (if (not (fboundp 'smtp-send-buffer))
107 (error "Please install FLIM 1.14.0 or later."))))
109 (defun config-wl-pixmap-dir (&optional packagedir)
110 "Examine pixmap directory where icon files should go."
111 (let ((pixmap-dir (car command-line-args-left)))
113 (if (string= pixmap-dir "NONE")
115 (expand-file-name "etc/wl/" packagedir)
116 (if (or (featurep 'xemacs)
117 (and (boundp 'emacs-major-version)
118 (>= emacs-major-version 21)))
119 (expand-file-name "wl/icons/" data-directory)))
122 (princ (format "PIXMAPDIR is %s\n" PIXMAPDIR)))
123 (setq command-line-args-left (cdr command-line-args-left)))
125 (defun config-wl-package ()
126 (config-wl-package-subr)
128 (let ((elispdir (car command-line-args-left)))
129 (if (string= elispdir "NONE")
130 (defvar LISPDIR (install-detect-elisp-directory))
131 (defvar LISPDIR elispdir)))
132 (princ (format "LISPDIR is %s\n" LISPDIR))
133 (setq command-line-args-left (cdr command-line-args-left))
135 (config-wl-pixmap-dir)
139 (defun wl-scan-source (path)
144 (setq ret (append (list y (concat y "c")) ret)))
145 (directory-files x nil "\\(.+\\)\\.el$" t)))
150 (defun wl-uninstall (objs path)
151 ;(message (mapconcat 'identity objs " "))
154 (let ((filename (expand-file-name x path)))
155 (if (and (file-exists-p filename)
156 (file-writable-p filename))
158 (princ (format "%s was uninstalled.\n" filename))
159 (delete-file filename)))))
163 (defun compile-wl-package ()
164 ;; For nemacs byte compiler's strange behavior(?).
166 (if (fboundp 'nemacs-version)
167 (load (expand-file-name "wl.el" WLDIR)))
170 (compile-elisp-modules (cdr x) (car x)))
173 (defun install-wl-icons ()
174 (if (not (file-directory-p PIXMAPDIR))
175 (make-directory PIXMAPDIR t))
176 (let* ((case-fold-search t)
177 (icons (directory-files ICONDIR t "\\.x[bp]m$"))
180 (setq icon (car icons)
182 dest (expand-file-name (file-name-nondirectory icon) PIXMAPDIR))
183 (princ (format "%s->%s\n" icon dest))
184 (copy-file icon dest t))))
186 (defun install-wl-package ()
188 (let ((wl-install-dir (expand-file-name WL_PREFIX LISPDIR))
189 (elmo-install-dir (expand-file-name ELMO_PREFIX LISPDIR)))
192 (install-elisp-modules (cdr x) (car x)
193 (if (string= (car x) ELMODIR)
201 (defun uninstall-wl-package ()
203 (let ((wl-install-dir (expand-file-name WL_PREFIX
205 (elmo-install-dir (expand-file-name ELMO_PREFIX
207 (wl-uninstall (wl-scan-source (list WLDIR UTILSDIR))
209 (wl-uninstall (wl-scan-source (list ELMODIR))
212 (let* ((case-fold-search t)
213 (icons (directory-files PIXMAPDIR t "\\.x[bp]m$"))
216 (setq icon (car icons)
218 (if (and (file-exists-p icon)
219 (file-writable-p icon))
221 (princ (format "%s was uninstalled.\n" icon))
222 (delete-file icon)))))))
225 (defun config-wl-package-xmas ()
226 (if (not (featurep 'xemacs))
227 (error "This directive is only for XEmacs."))
228 (config-wl-package-subr)
231 (and (setq package-dir (car command-line-args-left))
232 (if (string= "NONE" package-dir)
234 (if (boundp 'early-packages)
235 (let ((dirs (append (if early-package-load-path
237 (if late-package-load-path
239 (if last-package-load-path
242 (while (not (file-exists-p
243 (setq dir (car dirs))))
244 (setq dirs (cdr dirs)))
246 (defvar PACKAGEDIR package-dir)))
247 (princ (format "PACKAGEDIR is %s\n" PACKAGEDIR))
248 (setq command-line-args-left (cdr command-line-args-left)))
250 (config-wl-pixmap-dir PACKAGEDIR)
254 (defun compile-wl-package-xmas ()
255 (config-wl-package-xmas)
256 (setq autoload-package-name "wl")
257 (add-to-list 'command-line-args-left WLDIR)
258 (batch-update-directory)
259 (add-to-list 'command-line-args-left WLDIR)
260 (Custom-make-dependencies)
261 ;; WL-AUTOLOAD-MODULES
262 (compile-elisp-modules WL-AUTOLOAD-MODULES WLDIR)
265 (compile-elisp-modules (cdr x) (car x)))
268 (defun install-wl-package-xmas ()
269 (compile-wl-package-xmas)
270 (let ((LISPDIR (expand-file-name "wl"
271 (expand-file-name "lisp"
273 (DATADIR (expand-file-name "wl"
274 (expand-file-name "etc"
276 (INFODIR (expand-file-name "info" PACKAGEDIR)))
277 (or (file-exists-p DATADIR)
278 (make-directory DATADIR t))
279 (or (file-exists-p INFODIR)
280 (make-directory INFODIR t))
285 (install-elisp-modules (cdr x) (car x) LISPDIR))
287 ;; WL-AUTOLOAD-MODULES
288 (install-elisp-modules WL-AUTOLOAD-MODULES WLDIR LISPDIR)
291 (wl-texinfo-install)))
294 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
297 (defun wl-texinfo-format-file (lang)
298 (let ((infofile (symbol-value (intern (format "wl-%s-info" lang))))
299 (texifile (symbol-value (intern (format "wl-%s-texi" lang)))))
300 (require 'wl-vars) ;; for 'wl-cs-local
301 (or (file-newer-than-file-p (expand-file-name infofile DOCDIR)
302 (expand-file-name texifile DOCDIR))
304 ;; Support old texinfmt.el
305 (require 'ptexinfmt (expand-file-name "ptexinfmt.el" UTILSDIR))
306 (find-file (expand-file-name texifile DOCDIR))
307 (setq obuf (current-buffer))
308 ;; We can't know file names if splitted.
309 (texinfo-format-buffer t)
310 ;; Emacs20.2's default is 'raw-text-unix.
311 (and (fboundp 'set-buffer-file-coding-system)
312 (set-buffer-file-coding-system wl-cs-local))
314 (kill-buffer (current-buffer)) ;; info
315 (kill-buffer obuf)) ;; texi
318 (defun wl-texinfo-format ()
320 (setq INFODIR (wl-detect-info-directory)))
321 (cond ((listp wl-info-lang)
322 (mapcar 'wl-texinfo-format-file wl-info-lang))
323 ((stringp wl-info-lang)
324 (wl-texinfo-format-file wl-info-lang))))
326 (defun wl-texinfo-install-file (lang)
327 (let ((infofile (symbol-value (intern (format "wl-%s-info" lang)))))
328 (install-file infofile DOCDIR INFODIR)))
330 (defun wl-texinfo-install ()
331 (cond ((listp wl-info-lang)
332 (mapcar 'wl-texinfo-install-file wl-info-lang))
333 ((stringp wl-info-lang)
334 (wl-texinfo-install-file wl-info-lang))))
336 (defun wl-primary-info-file ()
337 "Get primary info file (for wl-detect-info-directory)."
339 ((listp wl-info-lang)
340 (let ((wl-info-lang (car wl-info-lang)))
341 (wl-primary-info-file)))
342 ((stringp wl-info-lang)
343 (symbol-value (intern (format "wl-%s-info" wl-info-lang))))))
345 (defun wl-detect-info-directory ()
346 (config-wl-package-subr)
347 (if (fboundp 'nemacs-version)
348 (error "Cannot format info on Nemacs. Please use another formatter."))
351 (if (fboundp 'info-initialize)
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 (^_^;