1 ;;; dgnushack.el --- a hack to set the load path for byte-compiling
2 ;; Copyright (C) 1994,95,96,97,98,99 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; Katsumi Yamaoka <yamaoka@jpl.org>
7 ;; Keywords: news, path
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
34 (push "~/lisp/custom" load-path)
36 (load "./lpath.el" nil t)
38 (defalias 'device-sound-enabled-p 'ignore)
39 (defalias 'play-sound-file 'ignore)
40 (defalias 'nndb-request-article 'ignore)
41 (defalias 'efs-re-read-dir 'ignore)
42 (defalias 'ange-ftp-re-read-dir 'ignore)
43 (defalias 'define-mail-user-agent 'ignore)
46 (unless (string-match "XEmacs" emacs-version)
47 (fset 'get-popup-menu-response 'ignore)
48 (fset 'event-object 'ignore)
49 (fset 'x-defined-colors 'ignore)
50 (fset 'read-color 'ignore)))
53 (put 'buffer-string 'byte-optimizer 'byte-optimize-buffer-string)
54 (defun byte-optimize-buffer-string (form)
56 (list 'buffer-substring (list 'point-min)(list 'point-max))
59 (put 'backward-char 'byte-optimizer 'byte-optimize-backward-char)
60 (defun byte-optimize-backward-char (form)
62 (list 'forward-char -1)
63 (list 'forward-char (list '- (nth 1 form)))))
65 (when (or (featurep 'xemacs)
66 (and (= emacs-major-version 20)
67 (> emacs-minor-version 2)))
68 ;; this optimization is not safe under Emacs 20.2 and before.
69 (put 'char-before 'byte-optimizer 'byte-optimize-char-before)
70 (defun byte-optimize-char-before (form)
72 (list 'char-after (list '1- (list 'point)))
73 (list 'char-after (list '1- (nth 1 form)))))))
75 (defun dgnushack-compile (&optional warn)
76 ;;(setq byte-compile-dynamic t)
78 (setq byte-compile-warnings
79 '(free-vars unresolved callargs redefine)))
80 (unless (locate-library "cus-edit")
81 (error "You do not seem to have Custom installed.
82 Fetch it from <URL:http://www.dina.kvl.dk/~abraham/custom/>.
83 You also then need to add the following to the lisp/dgnushack.el file:
85 (push \"~/lisp/custom\" load-path)
87 Modify to suit your needs."))
88 (let ((files (directory-files "." nil "^[^=].*\\.el$"))
89 (xemacs (string-match "XEmacs" emacs-version))
90 ;;(byte-compile-generate-call-tree t)
94 (error (setq files (delete "nnweb.el" (delete "nnlistserv.el" files)))))
97 (error (setq files (delete "gnus-bbdb.el"
98 (delete "mess-bbdb.el" files)))))
99 (while (setq file (pop files))
100 (when (or (and (not xemacs)
101 (not (member file '("gnus-xmas.el" "gnus-picon.el"
102 "messagexmas.el" "nnheaderxm.el"
103 "smiley.el" "x-overlay.el"))))
105 (not (member file '("md5.el")))))
106 (when (or (not (file-exists-p (setq elc (concat file "c"))))
107 (file-newer-than-file-p file elc))
109 (byte-compile-file file)))))))
111 (defun dgnushack-recompile ()
113 (byte-recompile-directory "." 0))
116 ;; Avoid byte-compile warnings.
117 (defvar gnus-product-name)
118 (defvar early-package-load-path)
119 (defvar early-packages)
120 (defvar last-package-load-path)
121 (defvar last-packages)
122 (defvar late-package-load-path)
123 (defvar late-packages)
125 (defconst dgnushack-info-file-regexp
126 "^\\(gnus\\|message\\|gnus-ja\\|message-ja\\)\\.info\\(-[0-9]+\\)?$")
128 (defconst dgnushack-texi-file-regexp
129 "^\\(gnus\\|message\\|gnus-ja\\|message-ja\\)\\.texi$")
131 (defun dgnushack-make-package ()
133 (let* ((product-name (downcase gnus-product-name))
134 (lisp-dir (concat "lisp/" product-name "/"))
137 (message "Updating autoloads for directory %s..." default-directory)
138 (let ((generated-autoload-file "auto-autoloads.el")
140 (update-autoloads-from-directory default-directory))
141 (byte-compile-file "auto-autoloads.el")
144 (let ((standard-output (current-buffer)))
145 (Custom-make-dependencies "."))
146 (message (buffer-string)))
148 (byte-compile-file "custom-load.el")
150 (message "Generating MANIFEST.%s for the package..." product-name)
152 (insert "pkginfo/MANIFEST." product-name "\n"
156 (sort (directory-files "." nil "\\.elc?$")
158 (concat "\n" lisp-dir))
162 (sort (directory-files "../texi/"
163 nil dgnushack-info-file-regexp)
167 (write-file (concat "../MANIFEST." product-name)))))
169 (defun dgnushack-install-package ()
170 (let ((package-dir (car command-line-args-left))
171 dirs info-dir pkginfo-dir product-name lisp-dir manifest files)
173 (when (boundp 'early-packages)
174 (setq dirs (delq nil (append (when early-package-load-path
176 (when late-package-load-path
178 (when last-package-load-path
180 (while (and dirs (not package-dir))
181 (when (file-exists-p (car dirs))
182 (setq package-dir (car dirs)
186 You must specify the name of the package path as follows:
188 % make install-package PACKAGEDIR=/usr/local/lib/xemacs/xemacs-packages
191 (setq info-dir (expand-file-name "info/" package-dir)
192 pkginfo-dir (expand-file-name "pkginfo/" package-dir))
194 (setq product-name (downcase gnus-product-name)
195 lisp-dir (expand-file-name (concat "lisp/" product-name "/")
197 manifest (concat "MANIFEST." product-name))
199 (unless (file-directory-p lisp-dir)
200 (make-directory lisp-dir t))
201 (unless (file-directory-p info-dir)
202 (make-directory info-dir))
203 (unless (file-directory-p pkginfo-dir)
204 (make-directory pkginfo-dir))
206 (setq files (sort (directory-files "." nil "\\.elc?$") 'string-lessp))
209 (unless (member file files)
210 (setq file (expand-file-name file lisp-dir))
211 (message "Removing %s..." file)
215 (directory-files lisp-dir nil nil nil t))
218 (message "Copying %s to %s..." file lisp-dir)
219 (copy-file file (expand-file-name file lisp-dir) t t))
224 (message "Copying ../texi/%s to %s..." file info-dir)
225 (copy-file (expand-file-name file "../texi/")
226 (expand-file-name file info-dir)
228 (sort (directory-files "../texi/" nil dgnushack-info-file-regexp)
231 (message "Copying ../%s to %s..." manifest pkginfo-dir)
232 (copy-file (expand-file-name manifest "../")
233 (expand-file-name manifest pkginfo-dir) t t)
237 (defun dgnushack-add-info-suffix-maybe ()
238 ;; This function must be invoked from lisp directory.
239 (setq default-directory "../texi/")
240 (let ((coding-system-for-read 'raw-text)
241 (coding-system-for-write 'raw-text)
242 (files (directory-files "." nil dgnushack-texi-file-regexp))
243 file make-backup-files)
244 (while (setq file (pop files))
246 (when (and (re-search-forward
247 "^@setfilename[\t ]+\\([^\t\n ]+\\)" nil t)
248 (not (string-match "\\.info$" (match-string 1))))
249 (copy-file file (concat file "_") nil t)
252 (kill-buffer (current-buffer)))))
254 ;;; dgnushack.el ends here