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 It is recommended to use \"new custom\" package if you are using
58 old Emacs, such as Mule 2.3.
59 Get it from http://www.dina.kvl.dk/~abraham/custom/ and then apply
60 the patch which is included in README file of APEL package.
62 (defmacro defgroup (&rest args))
63 (defmacro defcustom (symbol value &optional doc &rest args)
64 (let ((doc (concat "*" (or doc ""))))
65 (` (defvar (, symbol) (, value) (, doc))))))
68 (unless (fboundp 'byte-compile-file-form-custom-declare-variable)
69 ;; Bind defcustom'ed variables.
70 (put 'custom-declare-variable 'byte-hunk-handler
71 'byte-compile-file-form-custom-declare-variable)
72 (defun byte-compile-file-form-custom-declare-variable (form)
73 (if (memq 'free-vars byte-compile-warnings)
74 (setq byte-compile-bound-variables
75 (cons (nth 1 (nth 1 form)) byte-compile-bound-variables)))
78 (setq byte-compile-warnings '(free-vars unresolved callargs redefine))
81 (if (or (boundp 'MULE)
82 (fboundp 'nemacs-version))
83 (setq max-lisp-eval-depth 400))
85 ;; FIXME: it is currently needed to byte-compile with Emacs 21.
86 (setq recursive-load-depth-limit nil)
88 (condition-case () (require 'easymenu) (error nil))
90 (defvar config-wl-package-done nil)
92 (defun config-wl-package-subr ()
93 (unless config-wl-package-done
94 (setq config-wl-package-done t)
95 (setq load-path (cons (expand-file-name ".") load-path))
96 (setq load-path (cons (expand-file-name WLDIR)
97 (cons (expand-file-name ELMODIR) load-path)))
98 (setq wl-icon-dir (expand-file-name ICONDIR))
99 ;;; load custom file if exists.
100 (load "./WL-CFG" t nil t)
103 (setq load-path (cons (expand-file-name UTILSDIR) load-path)))
105 (setq load-path (cons (expand-file-name SASLDIR) load-path)))
109 (require 'mime-setup)
110 (error (error "No MIME module was detected. Please install SEMI or tm.")))
112 (princ (concat "\nUse SEMI"
113 (if wl-use-luna " with LUNA\n" " without LUNA\n")))
114 (princ "\nUse tm.\n"))))
116 (defun config-wl-pixmap-dir (&optional packagedir)
117 "Examine pixmap directory where icon files should go."
118 (let ((pixmap-dir (car command-line-args-left)))
120 (if (string= pixmap-dir "NONE")
122 (expand-file-name "etc/wl/" packagedir)
123 (if (or (featurep 'xemacs)
124 (and (boundp 'emacs-major-version)
125 (>= emacs-major-version 21)))
126 (expand-file-name "wl/icons/" data-directory)))
129 (princ (format "PIXMAPDIR is %s\n" PIXMAPDIR)))
130 (setq command-line-args-left (cdr command-line-args-left)))
132 (defun config-wl-package ()
133 (config-wl-package-subr)
135 (let ((elispdir (car command-line-args-left)))
136 (if (string= elispdir "NONE")
137 (defvar LISPDIR (install-detect-elisp-directory))
138 (defvar LISPDIR elispdir)))
139 (princ (format "LISPDIR is %s\n" LISPDIR))
140 (setq command-line-args-left (cdr command-line-args-left))
142 (config-wl-pixmap-dir)
146 (defun wl-scan-source (path)
151 (setq ret (append (list y (concat y "c")) ret)))
152 (directory-files x nil "\\(.+\\)\\.el$" t)))
157 (defun wl-uninstall (objs path)
158 ;(message (mapconcat 'identity objs " "))
161 (let ((filename (expand-file-name x path)))
162 (if (and (file-exists-p filename)
163 (file-writable-p filename))
165 (princ (format "%s was uninstalled.\n" filename))
166 (delete-file filename)))))
170 (defun compile-wl-package ()
171 ;; For nemacs byte compiler's strange behavior(?).
173 (if (fboundp 'nemacs-version)
174 (load (expand-file-name "wl.el" WLDIR)))
177 (compile-elisp-modules (cdr x) (car x)))
180 (defun install-wl-icons ()
181 (if (not (file-directory-p PIXMAPDIR))
182 (make-directory PIXMAPDIR t))
183 (let* ((case-fold-search t)
184 (icons (directory-files ICONDIR t "\\.x[bp]m$"))
187 (setq icon (car icons)
189 dest (expand-file-name (file-name-nondirectory icon) PIXMAPDIR))
190 (princ (format "%s->%s\n" icon dest))
191 (copy-file icon dest t))))
193 (defun install-wl-package ()
195 (let ((wl-install-dir (expand-file-name WL_PREFIX LISPDIR))
196 (elmo-install-dir (expand-file-name ELMO_PREFIX LISPDIR)))
199 (install-elisp-modules (cdr x) (car x)
200 (if (string= (car x) ELMODIR)
208 (defun uninstall-wl-package ()
210 (let ((wl-install-dir (expand-file-name WL_PREFIX
212 (elmo-install-dir (expand-file-name ELMO_PREFIX
214 (wl-uninstall (wl-scan-source (list WLDIR UTILSDIR SASLDIR))
216 (wl-uninstall (wl-scan-source (list ELMODIR))
219 (let* ((case-fold-search t)
220 (icons (directory-files PIXMAPDIR t "\\.x[bp]m$"))
223 (setq icon (car icons)
225 (if (and (file-exists-p icon)
226 (file-writable-p icon))
228 (princ (format "%s was uninstalled.\n" icon))
229 (delete-file icon)))))))
232 (defun config-wl-package-xmas ()
233 (if (not (featurep 'xemacs))
234 (error "This directive is only for XEmacs."))
235 (config-wl-package-subr)
238 (and (setq package-dir (car command-line-args-left))
239 (if (string= "NONE" package-dir)
241 (if (boundp 'early-packages)
242 (let ((dirs (append (if early-package-load-path
244 (if late-package-load-path
246 (if last-package-load-path
249 (while (not (file-exists-p
250 (setq dir (car dirs))))
251 (setq dirs (cdr dirs)))
253 (defvar PACKAGEDIR package-dir)))
254 (princ (format "PACKAGEDIR is %s\n" PACKAGEDIR))
255 (setq command-line-args-left (cdr command-line-args-left)))
257 (config-wl-pixmap-dir PACKAGEDIR)
261 (defun compile-wl-package-xmas ()
262 (config-wl-package-xmas)
263 (setq autoload-package-name "wl")
264 (add-to-list 'command-line-args-left WLDIR)
265 (batch-update-directory)
266 (add-to-list 'command-line-args-left WLDIR)
267 (Custom-make-dependencies)
268 ;; WL-AUTOLOAD-MODULES
269 (compile-elisp-modules WL-AUTOLOAD-MODULES WLDIR)
272 (compile-elisp-modules (cdr x) (car x)))
275 (defun install-wl-package-xmas ()
276 (compile-wl-package-xmas)
277 (let ((LISPDIR (expand-file-name "wl"
278 (expand-file-name "lisp"
280 (DATADIR (expand-file-name "wl"
281 (expand-file-name "etc"
283 (INFODIR (expand-file-name "info" PACKAGEDIR)))
284 (or (file-exists-p DATADIR)
285 (make-directory DATADIR t))
286 (or (file-exists-p INFODIR)
287 (make-directory INFODIR t))
292 (install-elisp-modules (cdr x) (car x) LISPDIR))
294 ;; WL-AUTOLOAD-MODULES
295 (install-elisp-modules WL-AUTOLOAD-MODULES WLDIR LISPDIR)
298 (wl-texinfo-install)))
301 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
304 (defun wl-texinfo-format-file (lang)
305 (let ((infofile (symbol-value (intern (format "wl-%s-info" lang))))
306 (texifile (symbol-value (intern (format "wl-%s-texi" lang)))))
307 (require 'wl-vars) ;; for 'wl-cs-local
308 (or (file-newer-than-file-p (expand-file-name infofile DOCDIR)
309 (expand-file-name texifile DOCDIR))
311 ;; Support old texinfmt.el
312 (require 'ptexinfmt (expand-file-name "ptexinfmt.el" UTILSDIR))
313 (find-file (expand-file-name texifile DOCDIR))
314 (setq obuf (current-buffer))
315 ;; We can't know file names if splitted.
316 (texinfo-format-buffer t)
317 ;; Emacs20.2's default is 'raw-text-unix.
318 (and (fboundp 'set-buffer-file-coding-system)
319 (set-buffer-file-coding-system wl-cs-local))
321 (kill-buffer (current-buffer)) ;; info
322 (kill-buffer obuf)) ;; texi
325 (defun wl-texinfo-format ()
327 (setq INFODIR (wl-detect-info-directory)))
328 (cond ((listp wl-info-lang)
329 (mapcar 'wl-texinfo-format-file wl-info-lang))
330 ((stringp wl-info-lang)
331 (wl-texinfo-format-file wl-info-lang))))
333 (defun wl-texinfo-install-file (lang)
334 (let ((infofile (symbol-value (intern (format "wl-%s-info" lang)))))
335 (install-file infofile DOCDIR INFODIR)))
337 (defun wl-texinfo-install ()
338 (cond ((listp wl-info-lang)
339 (mapcar 'wl-texinfo-install-file wl-info-lang))
340 ((stringp wl-info-lang)
341 (wl-texinfo-install-file wl-info-lang))))
343 (defun wl-primary-info-file ()
344 "Get primary info file (for wl-detect-info-directory)."
346 ((listp wl-info-lang)
347 (let ((wl-info-lang (car wl-info-lang)))
348 (wl-primary-info-file)))
349 ((stringp wl-info-lang)
350 (symbol-value (intern (format "wl-%s-info" wl-info-lang))))))
352 (defun wl-detect-info-directory ()
353 (config-wl-package-subr)
354 (if (fboundp 'nemacs-version)
355 (error "Cannot format info on Nemacs. Please use another formatter."))
358 (let ((infodir (car command-line-args-left))
359 (info (wl-primary-info-file))
362 (if (string= infodir "NONE")
364 (exec-installed-p info Info-directory-list
365 COMPRESS-SUFFIX-LIST))
367 ;;(condition-case nil (delete-file previous))
368 (directory-file-name (file-name-directory previous));)
369 (car Info-directory-list))
371 (setq command-line-args-left (cdr command-line-args-left))
372 (princ (format "INFODIR is %s\n\n" INFODIR))
375 (defun install-wl-info ()
377 (wl-texinfo-install))
381 ;;; * MORE refine code (^_^;