annotate lisp/bytecomp-runtime.el @ 608:4d7fdf497470

[xemacs-hg @ 2001-06-04 16:59:51 by wmperry] 2001-06-04 William M. Perry <wmperry@gnu.org> * gpmevent.c (KG_CTRL): Just define these unconditionally. The linux headers are so lame that they do not expose these to userland programs and you cannot gracefully include the kernel headers. 2001-06-03 William M. Perry <wmperry@gnu.org> * scrollbar-gtk.c (gtk_create_scrollbar_instance): Make calling of gtk_size_request unconditional. 2001-06-02 William M. Perry <wmperry@gnu.org> * emacs-marshals.c: Regenerated. 2001-06-01 William M. Perry <wmperry@gnu.org> * glyphs-shared.c (read_bitmap_data): Common definition of read_bitmap_data_from_file added. This does not attempt to use the Xmu based code at all - lets us be consistent across platforms. * glyphs-gtk.c: Removed definition of read_bitmap_data_from_file - this is now in glyphs-shared.c * glyphs-msw.c: Ditto. * glyphs-x.c: Ditto. 2001-06-03 William M. Perry <wmperry@gnu.org> * dialog-gtk.el (popup-builtin-open-dialog): Yikes - don't forget to return the filename! * font.el (font-window-system-mappings): Add gtk entry - just an alias to the X code) 2001-06-02 William M. Perry <wmperry@gnu.org> * gtk-marshal.el: Fix for removing of the string_hash utility functions in hash.c
author wmperry
date Mon, 04 Jun 2001 17:00:02 +0000
parents 7039e6323819
children 943eaba38521
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))))))
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
186
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
187
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
188
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
189 ;;; Functions to cleanly eliminate warnings about undefined functions
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
190 ;;; or variables when the code knows what it's doing. These macros DO
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
191 ;;; NOT rely on any byte-compiler changes, and thus can be copied into
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
192 ;;; a package and used within it.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
193
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
194 ;; NOTE: As a result of the above requirement, the macros rely on
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
195 ;; "tricks" to get the warnings suppressed. A cleaner way, of course,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
196 ;; would be to extend the byte compiler to provide a proper interface.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
197
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
198 ;; #### Should we require an unquoted symbol rather than a quoted one,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
199 ;; as we currently do? The quoting gets no generality, as `eval' is
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
200 ;; called at compile time. But most functions and macros want quoted
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
201 ;; arguments, and I find it extremely confusing to deal with cases
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
202 ;; such as `throw' requiring a quoted argument but `block' an unquoted
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
203 ;; one.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
204
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
205 (put 'with-boundp 'lisp-indent-function 1)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
206 (defmacro with-boundp (symbols &rest body)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
207 "Evaluate BODY, but do not issue bytecomp warnings about SYMBOLS undefined.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
208 SYMBOLS can be a symbol or a list of symbols and must be quoted. When
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
209 compiling this file, the warning `reference to free variable SYMBOL'
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
210 will not occur. This is a clean way to avoid such warnings. See also
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
211 `declare-boundp' and `if-boundp'."
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
212 (setq symbols (eval symbols))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
213 (unless (consp symbols)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
214 (setq symbols (list symbols)))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
215 `(progn
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
216 (declare (special ,@symbols))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
217 ,@body))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
218
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
219 (put 'if-boundp 'lisp-indent-function 2)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
220 (defmacro if-boundp (symbol then &rest else)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
221 "Equivalent to (if (boundp SYMBOL) THEN ELSE) but handles bytecomp warnings.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
222 When compiling this file, the warning `reference to free variable SYMBOL'
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
223 will not occur. This is a clean way to avoid such warnings. See also
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
224 `with-boundp' and `declare-boundp'."
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
225 `(with-boundp ,symbol
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
226 (if (boundp ,symbol) ,then ,@else)))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
227
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
228 (defmacro declare-boundp (symbol)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
229 "Evaluate SYMBOL without bytecomp warnings about the symbol.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
230 Sample usage is
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
231
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
232 (declare-boundp gpm-minor-mode)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
233
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
234 which is equivalent to
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
235
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
236 (with-fboundp 'gpm-minor-mode
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
237 gpm-minor-mode)"
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
238 `(with-boundp ',symbol ,symbol))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
239
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
240 (defmacro globally-declare-boundp (symbol)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
241 "Declare that all free uses of SYMBOL in this file are valid.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
242 SYMBOL can also be a list of symbols. SYMBOL must be quoted.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
243
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
244 When compiling this file, the warning `reference to free variable
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
245 SYMBOL' will not occur regardless of where calls to SYMBOL occur in
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
246 the file.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
247
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
248 In general, you should *NOT* use this; use `declare-boundp',
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
249 `if-boundp', or `with-boundp' to wrap individual uses, as necessary.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
250 That way, you're more likely to remember to put in the explicit checks
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
251 for the variable's existence that are usually necessary. However,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
252 `globally-declare-boundp' is better in some circumstances, such as
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
253 when writing an ELisp package that makes integral use of
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
254 optionally-compiled-in functionality (typically, an interface onto a
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
255 system library) and checks for the existence of the functionality at
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
256 some entry point to the package. See `globally-declare-fboundp' for
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
257 more information."
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
258 (setq symbol (eval symbol))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
259 (if (not (consp symbol))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
260 (setq symbol (list symbol)))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
261 `(progn
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
262 ;; (defvar FOO) has no side effects.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
263 ,@(mapcar #'(lambda (sym) `(defvar ,sym)) symbol)))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
264
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
265 (defun byte-compile-with-fboundp (form)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
266 (byte-compile-form (cons 'progn (cdr (cdr form))))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
267 ;; Unfortunately, byte-compile-unresolved-functions is used not only
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
268 ;; for unresolved-function warnings, but also in connection with the
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
269 ;; following warnings:
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
270
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
271 ;; "defsubst %s was used before it was defined"
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
272 ;; "%s being defined to take %s%s, but was previously called with %s"
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
273
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
274 ;; By hacking byte-compile-unresolved-functions like this, we
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
275 ;; effectively disable these warnings. But code should not be using
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
276 ;; `with-fboundp' with a function defined later on in the same
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
277 ;; file, so this is not a big deal.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
278
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
279 (let ((symbols (eval (car (cdr form)))))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
280 (unless (consp symbols)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
281 (setq symbols (list symbols)))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
282 (setq symbols (mapcar #'(lambda (sym) (cons sym nil)) symbols))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
283 (setq byte-compile-unresolved-functions
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
284 (set-difference byte-compile-unresolved-functions symbols
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
285 :key #'car))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
286 ))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
287
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
288 ;; EEEEEEEEVIL hack. We need to create our own byte-compilation
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
289 ;; method so that the proper variables are bound while compilation
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
290 ;; takes place (which is when the warnings get noticed and batched
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
291 ;; up). What we really want to do is make `with-fboundp' a macro
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
292 ;; that simply `progn's its BODY; but GOD DAMN IT, macros can't have
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
293 ;; their own byte-compilation methods! So we make `with-fboundp' a
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
294 ;; macro calling `with-fboundp-1', which is cleverly aliased to
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
295 ;; progn. This way we can put a byte-compilation method on
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
296 ;; `with-fboundp-1', and when interpreting, progn will duly skip
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
297 ;; the first, quoted argument, i.e. the symbol name. (We could make
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
298 ;; `with-fboundp-1' a regular function, but then we'd have to thunk
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
299 ;; BODY and eval it at runtime. We could probably just do this using
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
300 ;; (apply 'progn BODY), but the existing method is more obviously
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
301 ;; guaranteed to work.)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
302 ;;
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
303 ;; In defense, cl-macs.el does a very similar thing with
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
304 ;; `cl-block-wrapper'.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
305
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
306 (put 'with-fboundp-1 'byte-compile 'byte-compile-with-fboundp)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
307 (defalias 'with-fboundp-1 'progn)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
308
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
309 (put 'with-fboundp 'lisp-indent-function 1)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
310 (defmacro with-fboundp (symbol &rest body)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
311 "Evaluate BODY, but do not issue bytecomp warnings about SYMBOL.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
312 SYMBOL must be quoted. When compiling this file, the warning `the
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
313 function SYMBOL is not known to be defined' will not occur. This is a
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
314 clean way to avoid such warnings. See also `declare-fboundp',
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
315 `if-fboundp', and `globally-declare-fboundp'."
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
316 `(with-fboundp-1 ,symbol ,@body))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
317
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
318 (put 'if-fboundp 'lisp-indent-function 2)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
319 (defmacro if-fboundp (symbol then &rest else)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
320 "Equivalent to (if (fboundp SYMBOL) THEN ELSE) but handles bytecomp warnings.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
321 When compiling this file, the warning `the function SYMBOL is not
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
322 known to be defined' will not occur. This is a clean way to avoid
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
323 such warnings. See also `declare-fboundp', `with-fboundp', and
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
324 `globally-declare-fboundp'."
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
325 `(with-fboundp ,symbol
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
326 (if (fboundp ,symbol) ,then ,@else)))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
327
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
328 (defmacro declare-fboundp (form)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
329 "Execute FORM (a function call) without bytecomp warnings about the call.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
330 Sample usage is
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
331
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
332 (declare-fboundp (x-keysym-on-keyboard-sans-modifiers-p 'backspace))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
333
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
334 which is equivalent to
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
335
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
336 (with-fboundp 'x-keysym-on-keyboard-sans-modifiers-p
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
337 (x-keysym-on-keyboard-sans-modifiers-p 'backspace))"
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
338 `(with-fboundp ',(car form) ,form))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
339
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
340 (defmacro globally-declare-fboundp (symbol)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
341 "Declare that all calls to function SYMBOL in this file are valid.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
342 SYMBOL can also be a list of symbols. SYMBOL must be quoted.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
343
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
344 When compiling this file, the warning `the function SYMBOL is not
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
345 known to be defined' will not occur regardless of where calls to
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
346 SYMBOL occur in the file.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
347
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
348 In general, you should *NOT* use this; use `declare-fboundp',
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
349 `if-fboundp', or `with-fboundp' to wrap individual uses, as necessary.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
350 That way, you're more likely to remember to put in the explicit checks
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
351 for the function's existence that are usually necessary. However,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
352 `globally-declare-fboundp' is better in some circumstances, such as
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
353 when writing an ELisp package that makes integral use of
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
354 optionally-compiled-in functionality (typically, an interface onto a
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
355 system library) and checks for the existence of the functionality at
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
356 some entry point to the package. The file `ldap.el' is a good
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
357 example: It provides a layer on top of the optional LDAP ELisp
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
358 primitives, makes calls to them throughout its code, and verifies the
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
359 presence of LDAP support at load time. Putting calls to
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
360 `declare-fboundp' throughout the code would be a major annoyance."
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
361 (when (cl-compiling-file)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
362 (setq symbol (eval symbol))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
363 (if (not (consp symbol))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
364 (setq symbol (list symbol)))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
365 ;; Another hack. This works because the autoload environment is
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
366 ;; currently used ONLY to suppress warnings, and the actual
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
367 ;; autoload definition is not used. (NOTE: With this definition,
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
368 ;; we will get spurious "multiple autoloads for %s" warnings if we
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
369 ;; have an autoload later in the file for any functions in SYMBOL.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
370 ;; This is not something that code should ever do, though.)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
371 (setq byte-compile-autoload-environment
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
372 (append (mapcar #'(lambda (sym) (cons sym nil)) symbol)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
373 byte-compile-autoload-environment)))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
374 nil)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
375
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
376 (defun byte-compile-with-byte-compiler-warnings-suppressed (form)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
377 (let ((byte-compile-warnings byte-compile-warnings)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
378 (types (car (cdr form))))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
379 (unless (consp types)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
380 (setq types (list types)))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
381 (if (eq byte-compile-warnings t)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
382 (setq byte-compile-warnings byte-compile-default-warnings))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
383 (setq byte-compile-warnings (set-difference byte-compile-warnings types))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
384 (byte-compile-form (cons 'progn (cdr (cdr form))))))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
385
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
386 ;; Same hack here as with `with-fboundp'.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
387 (put 'with-byte-compiler-warnings-suppressed-1 'byte-compile
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
388 'byte-compile-with-byte-compiler-warnings-suppressed)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
389 (defalias 'with-byte-compiler-warnings-suppressed-1 'progn)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
390
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
391 (put 'with-byte-compiler-warnings-suppressed 'lisp-indent-function 1)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
392 (defmacro with-byte-compiler-warnings-suppressed (type &rest body)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
393 "Evaluate BODY, but do not issue bytecomp warnings TYPE.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
394 TYPE should be one of `redefine', `callargs', `subr-callargs',
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
395 `free-vars', `unresolved', `unused-vars', `obsolete', or `pedantic',
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
396 or a list of one or more of these symbols. (See `byte-compile-warnings'.)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
397 TYPE must be quoted.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
398
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
399 NOTE: You should *NOT* under normal circumstances be using this!
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
400 There are better ways of avoiding most of these warnings. In particular:
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
401
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
402 -- use (declare (special ...)) if you are making use of
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
403 dynamically-scoped variables.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
404 -- use `with-fboundp', `declare-fboundp', `if-fboundp', or
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
405 `globally-declare-fboundp' to avoid warnings about undefined
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
406 functions when you know the function actually exists.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
407 -- use `with-boundp', `declare-boundp', or `if-boundp' to avoid
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
408 warnings about undefined variables when you know the variable
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
409 actually exists.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
410 -- use `with-obsolete-variable' or `with-obsolete-function' if you
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
411 are purposely using such a variable or function."
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
412 `(with-byte-compiler-warnings-suppressed-1 ,type ,@body))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
413
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
414 ;; #### These should be more clever. You could (e.g.) try fletting
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
415 ;; `byte-compile-obsolete' or temporarily removing the obsolete info
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
416 ;; from the symbol and putting it back with an unwind-protect. (Or
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
417 ;; better, modify the byte-compiler to provide a proper solution, and
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
418 ;; fix these macros to use it if available, or fall back on the way
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
419 ;; below. Remember, these definitions need to work with an unchanged
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
420 ;; byte compiler so that they can be copied and used in packages.)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
421
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
422 (put 'with-obsolete-variable 'lisp-indent-function 1)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
423 (defmacro with-obsolete-variable (symbol &rest body)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
424 "Evaluate BODY but do not warn about usage of obsolete variable SYMBOL.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
425 SYMBOL must be quoted. See also `with-obsolete-function'."
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
426 `(with-byte-compiler-warnings-suppressed 'obsolete ,@body))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
427
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
428 (put 'with-obsolete-function 'lisp-indent-function 1)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
429 (defmacro with-obsolete-function (symbol &rest body)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
430 "Evaluate BODY but do not warn about usage of obsolete function SYMBOL.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
431 SYMBOL must be quoted. See also `with-obsolete-variable'."
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
432 `(with-byte-compiler-warnings-suppressed 'obsolete ,@body))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 ;;; Interface to file-local byte-compiler parameters.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 ;;; Redefined in bytecomp.el.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 ;;; The great RMS speaketh:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 ;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 ;;; 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
441 ;;; using it. These options are a matter of installation preference,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 ;;; and have nothing to do with particular source files; it's a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 ;;; mistake to suggest to users that they should associate these with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 ;;; particular source files. There is hardly any reason to change
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 ;;; these parameters, anyway. --rms.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 ;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 ;;; But I'll leave this stuff alone. --ben
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 (put 'byte-compiler-options 'lisp-indent-hook 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 (defmacro byte-compiler-options (&rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 "Set some compilation-parameters for this file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 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
453 evaluated, or when loaded from a .el file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 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
456
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 Keys: Values: Corresponding variable:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 verbose t, nil byte-compile-verbose
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 optimize t, nil, source, byte byte-optimize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 warnings list of warnings byte-compile-warnings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 file-format emacs19, emacs20 byte-compile-emacs19-compatibility
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 The value specified with the `warnings' option must be a list, containing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 some subset of the following flags:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 free-vars references to variables not in the current lexical scope.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 unused-vars references to non-global variables bound but not referenced.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 unresolved calls to unknown functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 callargs lambda calls with args that don't match the definition.
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
471 subr-callargs calls to subrs with args that don't match the definition.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 redefine function cell redefined from a macro to a lambda or vice
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 versa, or redefined to take a different number of arguments.
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
474 obsolete use of an obsolete function or variable.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 428
diff changeset
475 pedantic warn of use of compatible symbols.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 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
478 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
479 entire set of warnings being overwritten.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 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
482
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 (byte-compiler-options
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 (optimize t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 (warnings (- callargs)) ; Don't warn about arglist mismatch
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 (warnings (+ unused-vars)) ; Do warn about unused bindings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 (file-format emacs19))"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 ;;; bytecomp-runtime.el ends here