Remove `member-if' compiler macro.
[gnus] / lisp / dgnushack.el
1 ;;; dgnushack.el --- a hack to set the load path for byte-compiling
2 ;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000
3 ;;        Free Software Foundation, Inc.
4
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Version: 4.19
7 ;; Keywords: news, path
8
9 ;; This file is part of GNU Emacs.
10
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)
14 ;; any later version.
15
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.
20
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.
25
26 ;;; Commentary:
27
28 ;;; Code:
29
30 (fset 'facep 'ignore)
31
32 (require 'cl)
33
34 (defvar srcdir (or (getenv "srcdir") "."))
35
36 (push (or (getenv "lispdir") 
37           "/usr/share/emacs/site-lisp")
38       load-path)
39 (push (or (getenv "W3DIR") (expand-file-name "../../w3/lisp/" srcdir)) 
40       load-path)
41
42 (unless (featurep 'xemacs)
43   (define-compiler-macro last (&whole form x &optional n)
44     (if (and (fboundp 'last)
45              (subrp (symbol-function 'last)))
46         form
47       (if n
48           `(let* ((x ,x)
49                   (n ,n)
50                   (m 0)
51                   (p x))
52              (while (consp p)
53                (incf m)
54                (pop p))
55              (if (<= n 0)
56                  p
57                (if (< n m)
58                    (nthcdr (- m n) x)
59                  x)))
60         `(let ((x ,x))
61            (while (consp (cdr x))
62              (pop x))
63            x))))
64
65   (define-compiler-macro mapcon (&whole form fn seq &rest rest)
66     (if (and (fboundp 'mapcon)
67              (subrp (symbol-function 'mapcon)))
68         form
69       (if rest
70           `(let (res
71                  (args (list ,seq ,@rest))
72                  p)
73              (while (not (memq nil args))
74                (push (apply ,fn args) res)
75                (setq p args)
76                (while p
77                  (setcar p (cdr (pop p)))
78                  ))
79              (apply (function nconc) (nreverse res)))
80         `(let (res
81                (arg ,seq))
82            (while arg
83              (push (funcall ,fn arg) res)
84              (setq arg (cdr arg)))
85            (apply (function nconc) (nreverse res))))))
86
87   (define-compiler-macro union (&whole form list1 list2)
88     (if (and (fboundp 'union)
89              (subrp (symbol-function 'union)))
90         form
91       `(let ((a ,list1)
92              (b ,list2))
93          (cond ((null a) b)
94                ((null b) a)
95                ((equal a b) a)
96                (t
97                 (or (>= (length a) (length b))
98                     (setq a (prog1 b (setq b a))))
99                 (while b
100                   (or (memq (car b) a)
101                       (push (car b) a))
102                   (pop b))
103                 a)))))
104   )
105
106 ;; If we are building w3 in a different directory than the source
107 ;; directory, we must read *.el from source directory and write *.elc
108 ;; into the building directory.  For that, we define this function
109 ;; before loading bytecomp.  Bytecomp doesn't overwrite this function.
110 (defun byte-compile-dest-file (filename)
111   "Convert an Emacs Lisp source file name to a compiled file name.
112  In addition, remove directory name part from FILENAME."
113   (setq filename (byte-compiler-base-file-name filename))
114   (setq filename (file-name-sans-versions filename))
115   (setq filename (file-name-nondirectory filename))
116   (if (memq system-type '(win32 w32 mswindows windows-nt))
117       (setq filename (downcase filename)))
118   (cond ((eq system-type 'vax-vms)
119          (concat (substring filename 0 (string-match ";" filename)) "c"))
120         ((string-match emacs-lisp-file-regexp filename)
121          (concat (substring filename 0 (match-beginning 0)) ".elc"))
122         (t (concat filename ".elc"))))
123
124 (require 'bytecomp)
125
126 (push srcdir load-path)
127 ;(push "/usr/share/emacs/site-lisp" load-path)
128 (load (expand-file-name "lpath.el" srcdir) nil t)
129
130 (defalias 'device-sound-enabled-p 'ignore)
131 (defalias 'play-sound-file 'ignore)
132 (defalias 'nndb-request-article 'ignore)
133 (defalias 'efs-re-read-dir 'ignore)
134 (defalias 'ange-ftp-re-read-dir 'ignore)
135 (defalias 'define-mail-user-agent 'ignore)
136
137 (eval-and-compile
138   (unless (string-match "XEmacs" emacs-version)
139     (fset 'get-popup-menu-response 'ignore)
140     (fset 'event-object 'ignore)
141     (fset 'x-defined-colors 'ignore)
142     (fset 'read-color 'ignore)))
143
144 (defun dgnushack-compile (&optional warn)
145   ;;(setq byte-compile-dynamic t)
146   (unless warn
147     (setq byte-compile-warnings
148           '(free-vars unresolved callargs redefine)))
149   (unless (locate-library "cus-edit")
150     (error "You do not seem to have Custom installed.
151 Fetch it from <URL:http://www.dina.kvl.dk/~abraham/custom/>.
152 You also then need to add the following to the lisp/dgnushack.el file:
153
154      (push \"~/lisp/custom\" load-path)
155
156 Modify to suit your needs."))
157   (let ((files (directory-files srcdir nil "^[^=].*\\.el$"))
158         (xemacs (string-match "XEmacs" emacs-version))
159         ;;(byte-compile-generate-call-tree t)
160         file elc)
161     (condition-case ()
162         (require 'w3-forms)
163       (error
164        (dolist (file '("nnweb.el" "nnlistserv.el" "nnultimate.el"
165                        "nnslashdot.el" "nnwarchive.el" "webmail.el"))
166          (setq files (delete file files)))))
167     (while (setq file (pop files))
168       (setq file (expand-file-name file srcdir))
169       (when (or (and (not xemacs)
170                      (not (member (file-name-nondirectory file)
171                                   '("gnus-xmas.el" "gnus-picon.el"
172                                     "messagexmas.el" "nnheaderxm.el"
173                                     "smiley.el" "x-overlay.el"))))
174                 (and xemacs
175                      (not (member file '("md5.el")))))
176         (when (or (not (file-exists-p (setq elc (concat file "c"))))
177                   (file-newer-than-file-p file elc))
178           (ignore-errors
179             (byte-compile-file file)))))))
180
181 (defun dgnushack-recompile ()
182   (require 'gnus)
183   (byte-recompile-directory "." 0))
184
185 ;;; dgnushack.el ends here
186