Mercurial > emacs
annotate lisp/emacs-lisp/byte-run.el @ 86925:40fb395b8090
*** empty log message ***
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 01 Dec 2007 21:19:25 +0000 |
parents | 9b46232ba801 |
children | f5f1ba43cab1 |
rev | line source |
---|---|
51349 | 1 ;;; byte-run.el --- byte-compiler support for inlining |
2 | |
74466 | 3 ;; Copyright (C) 1992, 2001, 2002, 2003, 2004, 2005, |
75346 | 4 ;; 2006, 2007 Free Software Foundation, Inc. |
51349 | 5 |
6 ;; Author: Jamie Zawinski <jwz@lucid.com> | |
7 ;; Hallvard Furuseth <hbf@ulrik.uio.no> | |
8 ;; Maintainer: FSF | |
9 ;; Keywords: internal | |
10 | |
11 ;; This file is part of GNU Emacs. | |
12 | |
13 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
14 ;; it under the terms of the GNU General Public License as published by | |
78217
935157c0b596
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
15 ;; the Free Software Foundation; either version 3, or (at your option) |
51349 | 16 ;; any later version. |
17 | |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64085 | 25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
26 ;; Boston, MA 02110-1301, USA. | |
51349 | 27 |
28 ;;; Commentary: | |
29 | |
30 ;; interface to selectively inlining functions. | |
31 ;; This only happens when source-code optimization is turned on. | |
32 | |
33 ;;; Code: | |
34 | |
60597
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
35 ;; We define macro-declaration-function here because it is needed to |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
36 ;; handle declarations in macro definitions and this is the first file |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
37 ;; loaded by loadup.el that uses declarations in macros. |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
38 |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
39 (defun macro-declaration-function (macro decl) |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
40 "Process a declaration found in a macro definition. |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
41 This is set as the value of the variable `macro-declaration-function'. |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
42 MACRO is the name of the macro being defined. |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
43 DECL is a list `(declare ...)' containing the declarations. |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
44 The return value of this function is not used." |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
45 ;; We can't use `dolist' or `cadr' yet for bootstrapping reasons. |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
46 (let (d) |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
47 ;; Ignore the first element of `decl' (it's always `declare'). |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
48 (while (setq decl (cdr decl)) |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
49 (setq d (car decl)) |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
50 (cond ((and (consp d) (eq (car d) 'indent)) |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
51 (put macro 'lisp-indent-function (car (cdr d)))) |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
52 ((and (consp d) (eq (car d) 'debug)) |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
53 (put macro 'edebug-form-spec (car (cdr d)))) |
66397
768dad162d9e
(macro-declaration-function): Add a `doc-string' declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64751
diff
changeset
|
54 ((and (consp d) (eq (car d) 'doc-string)) |
768dad162d9e
(macro-declaration-function): Add a `doc-string' declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64751
diff
changeset
|
55 (put macro 'doc-string-elt (car (cdr d)))) |
60597
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
56 (t |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
57 (message "Unknown declaration %s" d)))))) |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
58 |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
59 (setq macro-declaration-function 'macro-declaration-function) |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
60 |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
61 |
51349 | 62 ;; Redefined in byte-optimize.el. |
63 ;; This is not documented--it's not clear that we should promote it. | |
64 (fset 'inline 'progn) | |
60580
a7bed417c2e6
Replace lisp-indent-hook with lisp-indent-function throughout.
Lute Kamstra <lute@gnu.org>
parents:
55405
diff
changeset
|
65 (put 'inline 'lisp-indent-function 0) |
51349 | 66 |
67 ;;; Interface to inline functions. | |
68 | |
69 ;; (defmacro proclaim-inline (&rest fns) | |
70 ;; "Cause the named functions to be open-coded when called from compiled code. | |
71 ;; They will only be compiled open-coded when byte-compile-optimize is true." | |
72 ;; (cons 'eval-and-compile | |
73 ;; (mapcar '(lambda (x) | |
74 ;; (or (memq (get x 'byte-optimizer) | |
75 ;; '(nil byte-compile-inline-expand)) | |
76 ;; (error | |
77 ;; "%s already has a byte-optimizer, can't make it inline" | |
78 ;; x)) | |
79 ;; (list 'put (list 'quote x) | |
80 ;; ''byte-optimizer ''byte-compile-inline-expand)) | |
81 ;; fns))) | |
82 | |
83 ;; (defmacro proclaim-notinline (&rest fns) | |
84 ;; "Cause the named functions to no longer be open-coded." | |
85 ;; (cons 'eval-and-compile | |
86 ;; (mapcar '(lambda (x) | |
87 ;; (if (eq (get x 'byte-optimizer) 'byte-compile-inline-expand) | |
88 ;; (put x 'byte-optimizer nil)) | |
89 ;; (list 'if (list 'eq (list 'get (list 'quote x) ''byte-optimizer) | |
90 ;; ''byte-compile-inline-expand) | |
91 ;; (list 'put x ''byte-optimizer nil))) | |
92 ;; fns))) | |
93 | |
94 ;; This has a special byte-hunk-handler in bytecomp.el. | |
95 (defmacro defsubst (name arglist &rest body) | |
96 "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
|
97 (declare (debug defun)) |
51349 | 98 (or (memq (get name 'byte-optimizer) |
99 '(nil byte-compile-inline-expand)) | |
100 (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
|
101 `(prog1 |
94bcfb39cf49
(defsubst): Add edebug spec and use backquote.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54413
diff
changeset
|
102 (defun ,name ,arglist ,@body) |
94bcfb39cf49
(defsubst): Add edebug spec and use backquote.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54413
diff
changeset
|
103 (eval-and-compile |
94bcfb39cf49
(defsubst): Add edebug spec and use backquote.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54413
diff
changeset
|
104 (put ',name 'byte-optimizer 'byte-compile-inline-expand)))) |
51349 | 105 |
86839
9b46232ba801
(declare-function): Add optional fourth argument and document it.
Glenn Morris <rgm@gnu.org>
parents:
86811
diff
changeset
|
106 (defmacro declare-function (fn file &optional arglist fileonly) |
86176
55bc44bcdff4
(declare-function): New macro.
Glenn Morris <rgm@gnu.org>
parents:
78217
diff
changeset
|
107 "Tell the byte-compiler that function FN is defined, in FILE. |
55bc44bcdff4
(declare-function): New macro.
Glenn Morris <rgm@gnu.org>
parents:
78217
diff
changeset
|
108 Optional ARGLIST is the argument list used by the function. The |
55bc44bcdff4
(declare-function): New macro.
Glenn Morris <rgm@gnu.org>
parents:
78217
diff
changeset
|
109 FILE argument is not used by the byte-compiler, but by the |
55bc44bcdff4
(declare-function): New macro.
Glenn Morris <rgm@gnu.org>
parents:
78217
diff
changeset
|
110 `check-declare' package, which checks that FILE contains a |
86296 | 111 definition for FN. ARGLIST is used by both the byte-compiler and |
112 `check-declare' to check for consistency. | |
113 | |
114 FILE can be either a Lisp file (in which case the \".el\" | |
86343 | 115 extension is optional), or a C file. C files are expanded |
116 relative to the Emacs \"src/\" directory. Lisp files are | |
117 searched for using `locate-library', and if that fails they are | |
118 expanded relative to the location of the file containing the | |
86811 | 119 declaration. A FILE with an \"ext:\" prefix is an external file. |
120 `check-declare' will check such files if they are found, and skip | |
121 them without error if they are not. | |
86176
55bc44bcdff4
(declare-function): New macro.
Glenn Morris <rgm@gnu.org>
parents:
78217
diff
changeset
|
122 |
86839
9b46232ba801
(declare-function): Add optional fourth argument and document it.
Glenn Morris <rgm@gnu.org>
parents:
86811
diff
changeset
|
123 FILEONLY non-nil means that `check-declare' will only check that |
9b46232ba801
(declare-function): Add optional fourth argument and document it.
Glenn Morris <rgm@gnu.org>
parents:
86811
diff
changeset
|
124 FILE exists, not that it defines FN. This is intended for |
9b46232ba801
(declare-function): Add optional fourth argument and document it.
Glenn Morris <rgm@gnu.org>
parents:
86811
diff
changeset
|
125 function-definitions that `check-declare' does not recognize, e.g. |
9b46232ba801
(declare-function): Add optional fourth argument and document it.
Glenn Morris <rgm@gnu.org>
parents:
86811
diff
changeset
|
126 `defstruct'. |
9b46232ba801
(declare-function): Add optional fourth argument and document it.
Glenn Morris <rgm@gnu.org>
parents:
86811
diff
changeset
|
127 |
9b46232ba801
(declare-function): Add optional fourth argument and document it.
Glenn Morris <rgm@gnu.org>
parents:
86811
diff
changeset
|
128 To specify a value for FILEONLY without passing an argument list, |
9b46232ba801
(declare-function): Add optional fourth argument and document it.
Glenn Morris <rgm@gnu.org>
parents:
86811
diff
changeset
|
129 set ARGLIST to `t'. This is necessary because `nil' means an |
9b46232ba801
(declare-function): Add optional fourth argument and document it.
Glenn Morris <rgm@gnu.org>
parents:
86811
diff
changeset
|
130 empty argument list, rather than an unspecified one. |
9b46232ba801
(declare-function): Add optional fourth argument and document it.
Glenn Morris <rgm@gnu.org>
parents:
86811
diff
changeset
|
131 |
86176
55bc44bcdff4
(declare-function): New macro.
Glenn Morris <rgm@gnu.org>
parents:
78217
diff
changeset
|
132 Note that for the purposes of `check-declare', this statement |
55bc44bcdff4
(declare-function): New macro.
Glenn Morris <rgm@gnu.org>
parents:
78217
diff
changeset
|
133 must be the first non-whitespace on a line, and everything up to |
55bc44bcdff4
(declare-function): New macro.
Glenn Morris <rgm@gnu.org>
parents:
78217
diff
changeset
|
134 the end of FILE must be all on the same line. For example: |
55bc44bcdff4
(declare-function): New macro.
Glenn Morris <rgm@gnu.org>
parents:
78217
diff
changeset
|
135 |
55bc44bcdff4
(declare-function): New macro.
Glenn Morris <rgm@gnu.org>
parents:
78217
diff
changeset
|
136 \(declare-function c-end-of-defun \"progmodes/cc-cmds.el\" |
86386 | 137 \(&optional arg)) |
138 | |
139 For more information, see Info node `elisp(Declaring Functions)'." | |
86176
55bc44bcdff4
(declare-function): New macro.
Glenn Morris <rgm@gnu.org>
parents:
78217
diff
changeset
|
140 ;; Does nothing - byte-compile-declare-function does the work. |
86286
08ed3671eb2d
(declare-function): Return nil.
Jason Rumney <jasonr@gnu.org>
parents:
86176
diff
changeset
|
141 nil) |
86176
55bc44bcdff4
(declare-function): New macro.
Glenn Morris <rgm@gnu.org>
parents:
78217
diff
changeset
|
142 |
63435
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
143 (defun make-obsolete (obsolete-name current-name &optional when) |
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
144 "Make the byte-compiler warn that OBSOLETE-NAME is obsolete. |
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
145 The warning will say that CURRENT-NAME should be used instead. |
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
146 If CURRENT-NAME is a string, that is the `use instead' message. |
51349 | 147 If provided, WHEN should be a string indicating when the function |
148 was first made obsolete, for example a date or a release number." | |
149 (interactive "aMake function obsolete: \nxObsoletion replacement: ") | |
63435
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
150 (let ((handler (get obsolete-name 'byte-compile))) |
51349 | 151 (if (eq 'byte-compile-obsolete handler) |
63435
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
152 (setq handler (nth 1 (get obsolete-name 'byte-obsolete-info))) |
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
153 (put obsolete-name 'byte-compile 'byte-compile-obsolete)) |
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
154 (put obsolete-name 'byte-obsolete-info (list current-name handler when))) |
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
155 obsolete-name) |
51349 | 156 |
63435
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
157 (defmacro define-obsolete-function-alias (obsolete-name current-name |
61843
a158628ce6ac
(define-obsolete-function-alias): New macro.
Nick Roberts <nickrob@snap.net.nz>
parents:
61730
diff
changeset
|
158 &optional when docstring) |
63435
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
159 "Set OBSOLETE-NAME's function definition to CURRENT-NAME and mark it obsolete. |
62094
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
160 |
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
161 \(define-obsolete-function-alias 'old-fun 'new-fun \"22.1\" \"old-fun's doc.\") |
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
162 |
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
163 is equivalent to the following two lines of code: |
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
164 |
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
165 \(defalias 'old-fun 'new-fun \"old-fun's doc.\") |
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
166 \(make-obsolete 'old-fun 'new-fun \"22.1\") |
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
167 |
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
168 See the docstrings of `defalias' and `make-obsolete' for more details." |
66403
6d02f0b72652
(define-obsolete-function-alias, define-obsolete-variable-alias):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66397
diff
changeset
|
169 (declare (doc-string 4)) |
61843
a158628ce6ac
(define-obsolete-function-alias): New macro.
Nick Roberts <nickrob@snap.net.nz>
parents:
61730
diff
changeset
|
170 `(progn |
63435
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
171 (defalias ,obsolete-name ,current-name ,docstring) |
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
172 (make-obsolete ,obsolete-name ,current-name ,when))) |
61843
a158628ce6ac
(define-obsolete-function-alias): New macro.
Nick Roberts <nickrob@snap.net.nz>
parents:
61730
diff
changeset
|
173 |
63435
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
174 (defun make-obsolete-variable (obsolete-name current-name &optional when) |
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
175 "Make the byte-compiler warn that OBSOLETE-NAME is obsolete. |
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
176 The warning will say that CURRENT-NAME should be used instead. |
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
177 If CURRENT-NAME is a string, that is the `use instead' message. |
51349 | 178 If provided, WHEN should be a string indicating when the variable |
179 was first made obsolete, for example a date or a release number." | |
180 (interactive | |
181 (list | |
182 (let ((str (completing-read "Make variable obsolete: " obarray 'boundp t))) | |
183 (if (equal str "") (error "")) | |
184 (intern str)) | |
185 (car (read-from-string (read-string "Obsoletion replacement: "))))) | |
63435
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
186 (put obsolete-name 'byte-obsolete-variable (cons current-name when)) |
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
187 obsolete-name) |
51349 | 188 |
63435
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
189 (defmacro define-obsolete-variable-alias (obsolete-name current-name |
61730
d4e4e1694bf8
(define-obsolete-variable-alias): New macro.
Nick Roberts <nickrob@snap.net.nz>
parents:
60597
diff
changeset
|
190 &optional when docstring) |
63435
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
191 "Make OBSOLETE-NAME a variable alias for CURRENT-NAME and mark it obsolete. |
62094
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
192 |
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
193 \(define-obsolete-variable-alias 'old-var 'new-var \"22.1\" \"old-var's doc.\") |
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
194 |
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
195 is equivalent to the following two lines of code: |
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
196 |
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
197 \(defvaralias 'old-var 'new-var \"old-var's doc.\") |
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
198 \(make-obsolete-variable 'old-var 'new-var \"22.1\") |
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
199 |
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
200 See the docstrings of `defvaralias' and `make-obsolete-variable' or |
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
201 Info node `(elisp)Variable Aliases' for more details." |
66403
6d02f0b72652
(define-obsolete-function-alias, define-obsolete-variable-alias):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66397
diff
changeset
|
202 (declare (doc-string 4)) |
61730
d4e4e1694bf8
(define-obsolete-variable-alias): New macro.
Nick Roberts <nickrob@snap.net.nz>
parents:
60597
diff
changeset
|
203 `(progn |
63435
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
204 (defvaralias ,obsolete-name ,current-name ,docstring) |
66403
6d02f0b72652
(define-obsolete-function-alias, define-obsolete-variable-alias):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66397
diff
changeset
|
205 (make-obsolete-variable ,obsolete-name ,current-name ,when))) |
61730
d4e4e1694bf8
(define-obsolete-variable-alias): New macro.
Nick Roberts <nickrob@snap.net.nz>
parents:
60597
diff
changeset
|
206 |
51349 | 207 (defmacro dont-compile (&rest body) |
208 "Like `progn', but the body always runs interpreted (not compiled). | |
209 If you think you need this, you're probably making a mistake somewhere." | |
60597
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
210 (declare (debug t) (indent 0)) |
51349 | 211 (list 'eval (list 'quote (if (cdr body) (cons 'progn body) (car body))))) |
212 | |
213 | |
66403
6d02f0b72652
(define-obsolete-function-alias, define-obsolete-variable-alias):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66397
diff
changeset
|
214 ;; interface to evaluating things at compile time and/or load time |
6d02f0b72652
(define-obsolete-function-alias, define-obsolete-variable-alias):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66397
diff
changeset
|
215 ;; these macro must come after any uses of them in this file, as their |
6d02f0b72652
(define-obsolete-function-alias, define-obsolete-variable-alias):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66397
diff
changeset
|
216 ;; definition in the file overrides the magic definitions on the |
6d02f0b72652
(define-obsolete-function-alias, define-obsolete-variable-alias):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66397
diff
changeset
|
217 ;; byte-compile-macro-environment. |
51349 | 218 |
219 (defmacro eval-when-compile (&rest body) | |
62520
ee08cd4e1bf0
(eval-when-compile): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
62094
diff
changeset
|
220 "Like `progn', but evaluates the body at compile time if you're compiling. |
ee08cd4e1bf0
(eval-when-compile): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
62094
diff
changeset
|
221 Thus, the result of the body appears to the compiler as a quoted constant. |
ee08cd4e1bf0
(eval-when-compile): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
62094
diff
changeset
|
222 In interpreted code, this is entirely equivalent to `progn'." |
60597
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
223 (declare (debug t) (indent 0)) |
51349 | 224 ;; Not necessary because we have it in b-c-initial-macro-environment |
225 ;; (list 'quote (eval (cons 'progn body))) | |
226 (cons 'progn body)) | |
227 | |
228 (defmacro eval-and-compile (&rest body) | |
229 "Like `progn', but evaluates the body at compile time and at load time." | |
60597
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
230 (declare (debug t) (indent 0)) |
51349 | 231 ;; Remember, it's magic. |
232 (cons 'progn body)) | |
233 | |
60580
a7bed417c2e6
Replace lisp-indent-hook with lisp-indent-function throughout.
Lute Kamstra <lute@gnu.org>
parents:
55405
diff
changeset
|
234 (put 'with-no-warnings 'lisp-indent-function 0) |
55041
1376729a93a7
(with-no-warnings): Simplify: take all args as &rest arg.
Richard M. Stallman <rms@gnu.org>
parents:
54496
diff
changeset
|
235 (defun with-no-warnings (&rest body) |
51349 | 236 "Like `progn', but prevents compiler warnings in the body." |
237 ;; 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
|
238 (car (last body))) |
51349 | 239 |
240 | |
66403
6d02f0b72652
(define-obsolete-function-alias, define-obsolete-variable-alias):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66397
diff
changeset
|
241 ;; I nuked this because it's not a good idea for users to think of using it. |
6d02f0b72652
(define-obsolete-function-alias, define-obsolete-variable-alias):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66397
diff
changeset
|
242 ;; These options are a matter of installation preference, and have nothing to |
6d02f0b72652
(define-obsolete-function-alias, define-obsolete-variable-alias):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66397
diff
changeset
|
243 ;; with particular source files; it's a mistake to suggest to users |
6d02f0b72652
(define-obsolete-function-alias, define-obsolete-variable-alias):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66397
diff
changeset
|
244 ;; they should associate these with particular source files. |
6d02f0b72652
(define-obsolete-function-alias, define-obsolete-variable-alias):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66397
diff
changeset
|
245 ;; There is hardly any reason to change these parameters, anyway. |
6d02f0b72652
(define-obsolete-function-alias, define-obsolete-variable-alias):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66397
diff
changeset
|
246 ;; --rms. |
51349 | 247 |
60580
a7bed417c2e6
Replace lisp-indent-hook with lisp-indent-function throughout.
Lute Kamstra <lute@gnu.org>
parents:
55405
diff
changeset
|
248 ;; (put 'byte-compiler-options 'lisp-indent-function 0) |
51349 | 249 ;; (defmacro byte-compiler-options (&rest args) |
250 ;; "Set some compilation-parameters for this file. This will affect only the | |
251 ;; file in which it appears; this does nothing when evaluated, and when loaded | |
252 ;; from a .el file. | |
253 ;; | |
254 ;; Each argument to this macro must be a list of a key and a value. | |
255 ;; | |
256 ;; Keys: Values: Corresponding variable: | |
257 ;; | |
258 ;; verbose t, nil byte-compile-verbose | |
259 ;; optimize t, nil, source, byte byte-compile-optimize | |
260 ;; warnings list of warnings byte-compile-warnings | |
261 ;; Legal elements: (callargs redefine free-vars unresolved) | |
262 ;; file-format emacs18, emacs19 byte-compile-compatibility | |
263 ;; | |
264 ;; For example, this might appear at the top of a source file: | |
265 ;; | |
266 ;; (byte-compiler-options | |
267 ;; (optimize t) | |
268 ;; (warnings (- free-vars)) ; Don't warn about free variables | |
269 ;; (file-format emacs19))" | |
270 ;; nil) | |
271 | |
66403
6d02f0b72652
(define-obsolete-function-alias, define-obsolete-variable-alias):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66397
diff
changeset
|
272 ;; arch-tag: 76f8328a-1f66-4df2-9b6d-5c3666dc05e9 |
51349 | 273 ;;; byte-run.el ends here |