* mm-util.el (mm-mime-mule-charset-alist): Support UTF-8 in
[gnus] / lisp / dgnushack.el
1 ;;; dgnushack.el --- a hack to set the load path for byte-compiling
2 ;; Copyright (C) 1994-2000 Free Software Foundation, Inc.
3
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; Version: 4.19
6 ;; Keywords: news, path
7
8 ;; This file is part of GNU Emacs.
9
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)
13 ;; any later version.
14
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.
19
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.
24
25 ;;; Commentary:
26
27 ;;; Code:
28
29 (fset 'facep 'ignore)
30
31 (require 'cl)
32
33 (unless (featurep 'xemacs)
34   (define-compiler-macro last (&whole form x &optional n)
35     (if (and (fboundp 'last)
36              (subrp (symbol-function 'last)))
37         form
38       (if n
39           `(let* ((x ,x)
40                   (n ,n)
41                   (m 0)
42                   (p x))
43              (while (consp p)
44                (incf m)
45                (pop p))
46              (if (<= n 0)
47                  p
48                (if (< n m)
49                    (nthcdr (- m n) x)
50                  x)))
51         `(let ((x ,x))
52            (while (consp (cdr x))
53              (pop x))
54            x))))
55
56   (define-compiler-macro mapcon (&whole form fn seq &rest rest)
57     (if (and (fboundp 'mapcon)
58              (subrp (symbol-function 'mapcon)))
59         form
60       (if rest
61           `(let (res
62                  (args (list ,seq ,@rest))
63                  p)
64              (while (not (memq nil args))
65                (push (apply ,fn args) res)
66                (setq p args)
67                (while p
68                  (setcar p (cdr (pop p)))
69                  ))
70              (apply (function nconc) (nreverse res)))
71         `(let (res
72                (arg ,seq))
73            (while arg
74              (push (funcall ,fn arg) res)
75              (setq arg (cdr arg)))
76            (apply (function nconc) (nreverse res))))))
77
78   (define-compiler-macro member-if (&whole form pred list)
79     (if (and (fboundp 'member-if)
80              (subrp (symbol-function 'member-if)))
81         form
82       `(let ((fn ,pred)
83              (seq ,list))
84          (while (and seq
85                      (not (funcall fn (car seq))))
86            (pop seq))
87          seq)))
88
89   (define-compiler-macro union (&whole form list1 list2)
90     (if (and (fboundp 'union)
91              (subrp (symbol-function 'union)))
92         form
93       `(let ((a ,list1)
94              (b ,list2))
95          (cond ((null a) b)
96                ((null b) a)
97                ((equal a b) a)
98                (t
99                 (or (>= (length a) (length b))
100                     (setq a (prog1 b (setq b a))))
101                 (while b
102                   (or (memq (car b) a)
103                       (push (car b) a))
104                   (pop b))
105                 a)))))
106   )
107
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"))))
125
126 (require 'bytecomp)
127
128 (defvar srcdir (or (getenv "srcdir") "."))
129
130 (push srcdir load-path)
131 ;(push "/usr/share/emacs/site-lisp" load-path)
132 (load (expand-file-name "lpath.el" srcdir) nil t)
133
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)
140
141 (eval-and-compile
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)))
147
148 (defun dgnushack-compile (&optional warn)
149   ;;(setq byte-compile-dynamic t)
150   (unless warn
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:
157
158      (push \"~/lisp/custom\" load-path)
159
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)
164         file elc)
165     (condition-case ()
166         (require 'w3-forms)
167       (error
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"))))
178                 (and xemacs
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))
182           (ignore-errors
183             (byte-compile-file file)))))))
184
185 (defun dgnushack-recompile ()
186   (require 'gnus)
187   (byte-recompile-directory "." 0))
188
189 ;;; dgnushack.el ends here
190