1 ;;; dgnushack.el --- a hack to set the load path for byte-compiling
2 ;; Copyright (C) 1994-2000 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: news, path
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
33 (unless (featurep 'xemacs)
34 (define-compiler-macro last (&whole form x &optional n)
35 (if (and (fboundp 'last)
36 (subrp (symbol-function 'last)))
52 (while (consp (cdr x))
56 (define-compiler-macro mapcon (&whole form fn seq &rest rest)
57 (if (and (fboundp 'mapcon)
58 (subrp (symbol-function 'mapcon)))
62 (args (list ,seq ,@rest))
64 (while (not (memq nil args))
65 (push (apply ,fn args) res)
68 (setcar p (cdr (pop p)))
70 (apply (function nconc) (nreverse res)))
74 (push (funcall ,fn arg) res)
76 (apply (function nconc) (nreverse res))))))
78 (define-compiler-macro member-if (&whole form pred list)
79 (if (and (fboundp 'member-if)
80 (subrp (symbol-function 'member-if)))
85 (not (funcall fn (car seq))))
89 (define-compiler-macro union (&whole form list1 list2)
90 (if (and (fboundp 'union)
91 (subrp (symbol-function 'union)))
99 (or (>= (length a) (length b))
100 (setq a (prog1 b (setq b a))))
108 ;; If we are building w3 in a different directory than the source
109 ;; directory, we must read *.el from source directory and write *.elc
110 ;; into the building directory. For that, we define this function
111 ;; before loading bytecomp. Bytecomp doesn't overwrite this function.
112 (defun byte-compile-dest-file (filename)
113 "Convert an Emacs Lisp source file name to a compiled file name.
114 In addition, remove directory name part from FILENAME."
115 (setq filename (byte-compiler-base-file-name filename))
116 (setq filename (file-name-sans-versions filename))
117 (setq filename (file-name-nondirectory filename))
118 (if (memq system-type '(win32 w32 mswindows windows-nt))
119 (setq filename (downcase filename)))
120 (cond ((eq system-type 'vax-vms)
121 (concat (substring filename 0 (string-match ";" filename)) "c"))
122 ((string-match emacs-lisp-file-regexp filename)
123 (concat (substring filename 0 (match-beginning 0)) ".elc"))
124 (t (concat filename ".elc"))))
128 (defvar srcdir (or (getenv "srcdir") "."))
130 (push srcdir load-path)
131 ;(push "/usr/share/emacs/site-lisp" load-path)
132 (load (expand-file-name "lpath.el" srcdir) nil t)
134 (defalias 'device-sound-enabled-p 'ignore)
135 (defalias 'play-sound-file 'ignore)
136 (defalias 'nndb-request-article 'ignore)
137 (defalias 'efs-re-read-dir 'ignore)
138 (defalias 'ange-ftp-re-read-dir 'ignore)
139 (defalias 'define-mail-user-agent 'ignore)
142 (unless (string-match "XEmacs" emacs-version)
143 (fset 'get-popup-menu-response 'ignore)
144 (fset 'event-object 'ignore)
145 (fset 'x-defined-colors 'ignore)
146 (fset 'read-color 'ignore)))
148 (defun dgnushack-compile (&optional warn)
149 ;;(setq byte-compile-dynamic t)
151 (setq byte-compile-warnings
152 '(free-vars unresolved callargs redefine)))
153 (unless (locate-library "cus-edit")
154 (error "You do not seem to have Custom installed.
155 Fetch it from <URL:http://www.dina.kvl.dk/~abraham/custom/>.
156 You also then need to add the following to the lisp/dgnushack.el file:
158 (push \"~/lisp/custom\" load-path)
160 Modify to suit your needs."))
161 (let ((files (directory-files srcdir nil "^[^=].*\\.el$"))
162 (xemacs (string-match "XEmacs" emacs-version))
163 ;;(byte-compile-generate-call-tree t)
168 (dolist (file '("nnweb.el" "nnlistserv.el" "nnultimate.el"
169 "nnslashdot.el" "nnwarchive.el" "webmail.el"))
170 (setq files (delete file files)))))
171 (while (setq file (pop files))
172 (setq file (expand-file-name file srcdir))
173 (when (or (and (not xemacs)
174 (not (member (file-name-nondirectory file)
175 '("gnus-xmas.el" "gnus-picon.el"
176 "messagexmas.el" "nnheaderxm.el"
177 "smiley.el" "x-overlay.el"))))
179 (not (member file '("md5.el")))))
180 (when (or (not (file-exists-p (setq elc (concat file "c"))))
181 (file-newer-than-file-p file elc))
183 (byte-compile-file file)))))))
185 (defun dgnushack-recompile ()
187 (byte-recompile-directory "." 0))
189 ;;; dgnushack.el ends here