Mercurial > emacs
annotate lisp/emacs-lisp/byte-run.el @ 59092:49971daa80c5
(Buffer-menu-revert-function): Clear out undo info before reverting
and disable undo recording while reverting.
author | Luc Teirlinck <teirllm@auburn.edu> |
---|---|
date | Mon, 27 Dec 2004 05:17:09 +0000 |
parents | 79eecb3f0e5a |
children | a7bed417c2e6 4c90ffeb71c5 |
rev | line source |
---|---|
51349 | 1 ;;; byte-run.el --- byte-compiler support for inlining |
2 | |
54496
94bcfb39cf49
(defsubst): Add edebug spec and use backquote.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54413
diff
changeset
|
3 ;; Copyright (C) 1992, 2004 Free Software Foundation, Inc. |
51349 | 4 |
5 ;; Author: Jamie Zawinski <jwz@lucid.com> | |
6 ;; Hallvard Furuseth <hbf@ulrik.uio.no> | |
7 ;; Maintainer: FSF | |
8 ;; Keywords: internal | |
9 | |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
26 | |
27 ;;; Commentary: | |
28 | |
29 ;; interface to selectively inlining functions. | |
30 ;; This only happens when source-code optimization is turned on. | |
31 | |
32 ;;; Code: | |
33 | |
34 ;; Redefined in byte-optimize.el. | |
35 ;; This is not documented--it's not clear that we should promote it. | |
36 (fset 'inline 'progn) | |
37 (put 'inline 'lisp-indent-hook 0) | |
38 | |
39 | |
40 ;;; Interface to inline functions. | |
41 | |
42 ;; (defmacro proclaim-inline (&rest fns) | |
43 ;; "Cause the named functions to be open-coded when called from compiled code. | |
44 ;; They will only be compiled open-coded when byte-compile-optimize is true." | |
45 ;; (cons 'eval-and-compile | |
46 ;; (mapcar '(lambda (x) | |
47 ;; (or (memq (get x 'byte-optimizer) | |
48 ;; '(nil byte-compile-inline-expand)) | |
49 ;; (error | |
50 ;; "%s already has a byte-optimizer, can't make it inline" | |
51 ;; x)) | |
52 ;; (list 'put (list 'quote x) | |
53 ;; ''byte-optimizer ''byte-compile-inline-expand)) | |
54 ;; fns))) | |
55 | |
56 ;; (defmacro proclaim-notinline (&rest fns) | |
57 ;; "Cause the named functions to no longer be open-coded." | |
58 ;; (cons 'eval-and-compile | |
59 ;; (mapcar '(lambda (x) | |
60 ;; (if (eq (get x 'byte-optimizer) 'byte-compile-inline-expand) | |
61 ;; (put x 'byte-optimizer nil)) | |
62 ;; (list 'if (list 'eq (list 'get (list 'quote x) ''byte-optimizer) | |
63 ;; ''byte-compile-inline-expand) | |
64 ;; (list 'put x ''byte-optimizer nil))) | |
65 ;; fns))) | |
66 | |
67 ;; This has a special byte-hunk-handler in bytecomp.el. | |
68 (defmacro defsubst (name arglist &rest body) | |
69 "Define an inline function. The syntax is just like that of `defun'." | |
54496
94bcfb39cf49
(defsubst): Add edebug spec and use backquote.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54413
diff
changeset
|
70 (declare (debug defun)) |
51349 | 71 (or (memq (get name 'byte-optimizer) |
72 '(nil byte-compile-inline-expand)) | |
73 (error "`%s' is a primitive" name)) | |
54496
94bcfb39cf49
(defsubst): Add edebug spec and use backquote.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54413
diff
changeset
|
74 `(prog1 |
94bcfb39cf49
(defsubst): Add edebug spec and use backquote.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54413
diff
changeset
|
75 (defun ,name ,arglist ,@body) |
94bcfb39cf49
(defsubst): Add edebug spec and use backquote.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54413
diff
changeset
|
76 (eval-and-compile |
94bcfb39cf49
(defsubst): Add edebug spec and use backquote.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54413
diff
changeset
|
77 (put ',name 'byte-optimizer 'byte-compile-inline-expand)))) |
51349 | 78 |
55405
79eecb3f0e5a
(make-obsolete, make-obsolete-variable): Make argument names match their use in
Juanma Barranquero <lekktu@gmail.com>
parents:
55041
diff
changeset
|
79 (defun make-obsolete (function new &optional when) |
51349 | 80 "Make the byte-compiler warn that FUNCTION is obsolete. |
81 The warning will say that NEW should be used instead. | |
82 If NEW is a string, that is the `use instead' message. | |
83 If provided, WHEN should be a string indicating when the function | |
84 was first made obsolete, for example a date or a release number." | |
85 (interactive "aMake function obsolete: \nxObsoletion replacement: ") | |
55405
79eecb3f0e5a
(make-obsolete, make-obsolete-variable): Make argument names match their use in
Juanma Barranquero <lekktu@gmail.com>
parents:
55041
diff
changeset
|
86 (let ((handler (get function 'byte-compile))) |
51349 | 87 (if (eq 'byte-compile-obsolete handler) |
55405
79eecb3f0e5a
(make-obsolete, make-obsolete-variable): Make argument names match their use in
Juanma Barranquero <lekktu@gmail.com>
parents:
55041
diff
changeset
|
88 (setq handler (nth 1 (get function 'byte-obsolete-info))) |
79eecb3f0e5a
(make-obsolete, make-obsolete-variable): Make argument names match their use in
Juanma Barranquero <lekktu@gmail.com>
parents:
55041
diff
changeset
|
89 (put function 'byte-compile 'byte-compile-obsolete)) |
79eecb3f0e5a
(make-obsolete, make-obsolete-variable): Make argument names match their use in
Juanma Barranquero <lekktu@gmail.com>
parents:
55041
diff
changeset
|
90 (put function 'byte-obsolete-info (list new handler when))) |
79eecb3f0e5a
(make-obsolete, make-obsolete-variable): Make argument names match their use in
Juanma Barranquero <lekktu@gmail.com>
parents:
55041
diff
changeset
|
91 function) |
51349 | 92 |
55405
79eecb3f0e5a
(make-obsolete, make-obsolete-variable): Make argument names match their use in
Juanma Barranquero <lekktu@gmail.com>
parents:
55041
diff
changeset
|
93 (defun make-obsolete-variable (variable new &optional when) |
54413
9d42c2c9095d
(make-obsolete-variable): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
52401
diff
changeset
|
94 "Make the byte-compiler warn that VARIABLE is obsolete. |
9d42c2c9095d
(make-obsolete-variable): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
52401
diff
changeset
|
95 The warning will say that NEW should be used instead. |
9d42c2c9095d
(make-obsolete-variable): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
52401
diff
changeset
|
96 If NEW is a string, that is the `use instead' message. |
51349 | 97 If provided, WHEN should be a string indicating when the variable |
98 was first made obsolete, for example a date or a release number." | |
99 (interactive | |
100 (list | |
101 (let ((str (completing-read "Make variable obsolete: " obarray 'boundp t))) | |
102 (if (equal str "") (error "")) | |
103 (intern str)) | |
104 (car (read-from-string (read-string "Obsoletion replacement: "))))) | |
55405
79eecb3f0e5a
(make-obsolete, make-obsolete-variable): Make argument names match their use in
Juanma Barranquero <lekktu@gmail.com>
parents:
55041
diff
changeset
|
105 (put variable 'byte-obsolete-variable (cons new when)) |
79eecb3f0e5a
(make-obsolete, make-obsolete-variable): Make argument names match their use in
Juanma Barranquero <lekktu@gmail.com>
parents:
55041
diff
changeset
|
106 variable) |
51349 | 107 |
108 (put 'dont-compile 'lisp-indent-hook 0) | |
109 (defmacro dont-compile (&rest body) | |
110 "Like `progn', but the body always runs interpreted (not compiled). | |
111 If you think you need this, you're probably making a mistake somewhere." | |
54496
94bcfb39cf49
(defsubst): Add edebug spec and use backquote.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54413
diff
changeset
|
112 (declare (debug t)) |
51349 | 113 (list 'eval (list 'quote (if (cdr body) (cons 'progn body) (car body))))) |
114 | |
115 | |
116 ;;; interface to evaluating things at compile time and/or load time | |
117 ;;; these macro must come after any uses of them in this file, as their | |
118 ;;; definition in the file overrides the magic definitions on the | |
119 ;;; byte-compile-macro-environment. | |
120 | |
121 (put 'eval-when-compile 'lisp-indent-hook 0) | |
122 (defmacro eval-when-compile (&rest body) | |
123 "Like `progn', but evaluates the body at compile time. | |
124 The result of the body appears to the compiler as a quoted constant." | |
54496
94bcfb39cf49
(defsubst): Add edebug spec and use backquote.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54413
diff
changeset
|
125 (declare (debug t)) |
51349 | 126 ;; Not necessary because we have it in b-c-initial-macro-environment |
127 ;; (list 'quote (eval (cons 'progn body))) | |
128 (cons 'progn body)) | |
129 | |
130 (put 'eval-and-compile 'lisp-indent-hook 0) | |
131 (defmacro eval-and-compile (&rest body) | |
132 "Like `progn', but evaluates the body at compile time and at load time." | |
54496
94bcfb39cf49
(defsubst): Add edebug spec and use backquote.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54413
diff
changeset
|
133 (declare (debug t)) |
51349 | 134 ;; Remember, it's magic. |
135 (cons 'progn body)) | |
136 | |
55041
1376729a93a7
(with-no-warnings): Simplify: take all args as &rest arg.
Richard M. Stallman <rms@gnu.org>
parents:
54496
diff
changeset
|
137 (defun with-no-warnings (&rest body) |
51349 | 138 "Like `progn', but prevents compiler warnings in the body." |
139 ;; The implementation for the interpreter is basically trivial. | |
55041
1376729a93a7
(with-no-warnings): Simplify: take all args as &rest arg.
Richard M. Stallman <rms@gnu.org>
parents:
54496
diff
changeset
|
140 (car (last body))) |
51349 | 141 |
142 | |
143 ;;; I nuked this because it's not a good idea for users to think of using it. | |
144 ;;; These options are a matter of installation preference, and have nothing to | |
145 ;;; with particular source files; it's a mistake to suggest to users | |
146 ;;; they should associate these with particular source files. | |
147 ;;; There is hardly any reason to change these parameters, anyway. | |
148 ;;; --rms. | |
149 | |
150 ;; (put 'byte-compiler-options 'lisp-indent-hook 0) | |
151 ;; (defmacro byte-compiler-options (&rest args) | |
152 ;; "Set some compilation-parameters for this file. This will affect only the | |
153 ;; file in which it appears; this does nothing when evaluated, and when loaded | |
154 ;; from a .el file. | |
155 ;; | |
156 ;; Each argument to this macro must be a list of a key and a value. | |
157 ;; | |
158 ;; Keys: Values: Corresponding variable: | |
159 ;; | |
160 ;; verbose t, nil byte-compile-verbose | |
161 ;; optimize t, nil, source, byte byte-compile-optimize | |
162 ;; warnings list of warnings byte-compile-warnings | |
163 ;; Legal elements: (callargs redefine free-vars unresolved) | |
164 ;; file-format emacs18, emacs19 byte-compile-compatibility | |
165 ;; | |
166 ;; For example, this might appear at the top of a source file: | |
167 ;; | |
168 ;; (byte-compiler-options | |
169 ;; (optimize t) | |
170 ;; (warnings (- free-vars)) ; Don't warn about free variables | |
171 ;; (file-format emacs19))" | |
172 ;; nil) | |
173 | |
52401 | 174 ;;; arch-tag: 76f8328a-1f66-4df2-9b6d-5c3666dc05e9 |
51349 | 175 ;;; byte-run.el ends here |