annotate lisp/bytecomp-runtime.el @ 477:55fa613136f0

[xemacs-hg @ 2001-04-19 06:07:35 by martinb] release cycle for "alfalfa" begins
author martinb
date Thu, 19 Apr 2001 06:07:35 +0000
parents 3ecd8885ac67
children 7039e6323819
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 ;;; bytecomp-runtime.el --- byte-compiler support for inlining
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 ;; Copyright (C) 1992, 1997 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 ;; Author: Jamie Zawinski <jwz@jwz.org>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 ;; Author: Hallvard Furuseth <hbf@ulrik.uio.no>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 ;; Maintainer: XEmacs Development Team
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 ;; Keywords: internal, dumped
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ;; XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ;; under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 ;; any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 ;; General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 ;; along with XEmacs; see the file COPYING. If not, write to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 ;;; Synched up with: FSF 19.30.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 ;; This file is dumped with XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 ;; The code in this file should always be loaded, because it defines things
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 ;; like "defsubst" which should work interpreted as well. The code in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 ;; bytecomp.el and byte-optimize.el can be loaded as needed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 ;; interface to selectively inlining functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 ;; This only happens when source-code optimization is turned on.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 ;;; Code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 ;; Redefined in byte-optimize.el.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 ;; This is not documented--it's not clear that we should promote it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 (fset 'inline 'progn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 (put 'inline 'lisp-indent-hook 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 ;;; Interface to inline functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 ;; FSF comments the next two out, but I see no reason to do so. --ben
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 (defmacro proclaim-inline (&rest fns)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 "Cause the named functions to be open-coded when called from compiled code.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 They will only be compiled open-coded when `byte-optimize' is true."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 (cons 'eval-and-compile
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 (apply
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 'nconc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 (mapcar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 #'(lambda (x)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 `((or (memq (get ',x 'byte-optimizer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 '(nil byte-compile-inline-expand))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 (error
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 "%s already has a byte-optimizer, can't make it inline"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 ',x))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 (put ',x 'byte-optimizer 'byte-compile-inline-expand)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 fns))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 (defmacro proclaim-notinline (&rest fns)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 "Cause the named functions to no longer be open-coded."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 (cons 'eval-and-compile
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 (apply
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 'nconc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 (mapcar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 #'(lambda (x)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 `((if (eq (get ',x 'byte-optimizer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 'byte-compile-inline-expand)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 (put ',x 'byte-optimizer nil))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 fns))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 ;; This has a special byte-hunk-handler in bytecomp.el.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 (defmacro defsubst (name arglist &rest body)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 "Define an inline function. The syntax is just like that of `defun'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 (or (memq (get name 'byte-optimizer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 '(nil byte-compile-inline-expand))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 (error "`%s' is a primitive" name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 (list 'prog1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 (cons 'defun (cons name (cons arglist body)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 (list 'proclaim-inline name)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 ; Instead of the above line, FSF has this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 ; (list 'eval-and-compile
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 ; (list 'put (list 'quote name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 ; ''byte-optimizer ''byte-compile-inline-expand))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 (defun make-obsolete (fn new)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 "Make the byte-compiler warn that FUNCTION is obsolete.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 The warning will say that NEW should be used instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 If NEW is a string, that is the `use instead' message."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 (interactive "aMake function obsolete: \nxObsoletion replacement: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 (let ((handler (get fn 'byte-compile)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 (if (eq 'byte-compile-obsolete handler)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 (setcar (get fn 'byte-obsolete-info) new)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 (put fn 'byte-obsolete-info (cons new handler))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 (put fn 'byte-compile 'byte-compile-obsolete)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 fn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 (defun make-obsolete-variable (var new)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 "Make the byte-compiler warn that VARIABLE is obsolete,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 and NEW should be used instead. If NEW is a string, then that is the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 `use instead' message."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 (interactive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 (list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 (let ((str (completing-read "Make variable obsolete: " obarray 'boundp t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 (if (equal str "") (error ""))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 (intern str))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 (car (read-from-string (read-string "Obsoletion replacement: ")))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 (put var 'byte-obsolete-variable new)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 var)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 ;; By overwhelming demand, we separate out truly obsolete symbols from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 ;; those that are present for GNU Emacs compatibility.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 (defun make-compatible (fn new)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 "Make the byte-compiler know that FUNCTION is provided for compatibility.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 The warning will say that NEW should be used instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 If NEW is a string, that is the `use instead' message."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 (interactive "aMake function compatible: \nxCompatible replacement: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 (let ((handler (get fn 'byte-compile)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 (if (eq 'byte-compile-compatible handler)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 (setcar (get fn 'byte-compatible-info) new)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 (put fn 'byte-compatible-info (cons new handler))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 (put fn 'byte-compile 'byte-compile-compatible)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 fn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 (defun make-compatible-variable (var new)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 "Make the byte-compiler know that VARIABLE is provided for compatibility.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 and NEW should be used instead. If NEW is a string, then that is the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 `use instead' message."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 (interactive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 (list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 (let ((str (completing-read "Make variable compatible: "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 obarray 'boundp t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 (if (equal str "") (error ""))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 (intern str))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 (car (read-from-string (read-string "Compatible replacement: ")))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 (put var 'byte-compatible-variable new)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 var)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 (put 'dont-compile 'lisp-indent-hook 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 (defmacro dont-compile (&rest body)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 "Like `progn', but the body always runs interpreted (not compiled).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 If you think you need this, you're probably making a mistake somewhere."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 (list 'eval (list 'quote (if (cdr body) (cons 'progn body) (car body)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 ;;; interface to evaluating things at compile time and/or load time
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 ;;; these macro must come after any uses of them in this file, as their
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 ;;; definition in the file overrides the magic definitions on the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 ;;; byte-compile-macro-environment.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 (put 'eval-when-compile 'lisp-indent-hook 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 (defmacro eval-when-compile (&rest body)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 "Like `progn', but evaluates the body at compile time.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 The result of the body appears to the compiler as a quoted constant."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 ;; Not necessary because we have it in b-c-initial-macro-environment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 ;; (list 'quote (eval (cons 'progn body)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 (cons 'progn body))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 (put 'eval-and-compile 'lisp-indent-hook 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 (defmacro eval-and-compile (&rest body)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 "Like `progn', but evaluates the body at compile time and at load time."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 ;; Remember, it's magic.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 (cons 'progn body))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 ;;; From Emacs 20.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 (put 'eval-when-feature 'lisp-indent-hook 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 (defmacro eval-when-feature (feature &rest body)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 "Run the body forms when FEATURE is featurep, be it now or later.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 Called (eval-when-feature (FEATURE [. FILENAME]) BODYFORMS...).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 If (featurep 'FEATURE), evals now; otherwise adds an elt to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 `after-load-alist' (which see), using FEATURE as filename if FILENAME is nil."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 (let ((file (or (cdr feature) (symbol-name (car feature)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 `(let ((bodythunk #'(lambda () ,@body)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 (if (featurep ',(car feature))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 (funcall bodythunk)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 (setq after-load-alist (cons '(,file . (list 'lambda '() bodythunk))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 after-load-alist))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 ;;; Interface to file-local byte-compiler parameters.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 ;;; Redefined in bytecomp.el.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 ;;; The great RMS speaketh:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 ;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 ;;; I nuked this because it's not a good idea for users to think of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 ;;; using it. These options are a matter of installation preference,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 ;;; and have nothing to do with particular source files; it's a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 ;;; mistake to suggest to users that they should associate these with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 ;;; particular source files. There is hardly any reason to change
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 ;;; these parameters, anyway. --rms.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 ;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 ;;; But I'll leave this stuff alone. --ben
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 (put 'byte-compiler-options 'lisp-indent-hook 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 (defmacro byte-compiler-options (&rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 "Set some compilation-parameters for this file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 This will affect only the file in which it appears; this does nothing when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 evaluated, or when loaded from a .el file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 Each argument to this macro must be a list of a key and a value.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 Keys: Values: Corresponding variable:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 verbose t, nil byte-compile-verbose
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 optimize t, nil, source, byte byte-optimize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 warnings list of warnings byte-compile-warnings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 file-format emacs19, emacs20 byte-compile-emacs19-compatibility
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 The value specified with the `warnings' option must be a list, containing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 some subset of the following flags:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 free-vars references to variables not in the current lexical scope.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 unused-vars references to non-global variables bound but not referenced.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 unresolved calls to unknown functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 callargs lambda calls with args that don't match the definition.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 redefine function cell redefined from a macro to a lambda or vice
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 versa, or redefined to take a different number of arguments.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 If the first element if the list is `+' or `-' then the specified elements
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 are added to or removed from the current set of warnings, instead of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 entire set of warnings being overwritten.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 For example, something like this might appear at the top of a source file:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 (byte-compiler-options
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 (optimize t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 (warnings (- callargs)) ; Don't warn about arglist mismatch
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 (warnings (+ unused-vars)) ; Do warn about unused bindings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 (file-format emacs19))"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 ;;; bytecomp-runtime.el ends here