Mercurial > emacs
annotate lisp/emacs-lisp/byte-run.el @ 112429:6e50030da731
Some copyright.el updates.
* lisp/emacs-lisp/copyright.el (copyright-find-copyright): New function,
split out from copyright-update-year.
(copyright-update): Don't mess with the GPL version if we don't own the
copyright. Update license regexp, and remove no longer needed
Esperanto stuff.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 22 Jan 2011 14:09:09 -0800 |
parents | ef719132ddfa |
children |
rev | line source |
---|---|
51349 | 1 ;;; byte-run.el --- byte-compiler support for inlining |
2 | |
104751
0299ec0f58e6
(define-obsolete-face-alias): New macro.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
3 ;; Copyright (C) 1992, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, |
112218
376148b31b5e
Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents:
110356
diff
changeset
|
4 ;; 2009, 2010, 2011 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 | |
110015
280c8ae2476d
Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
10 ;; Package: emacs |
51349 | 11 |
12 ;; This file is part of GNU Emacs. | |
13 | |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94023
diff
changeset
|
14 ;; GNU Emacs is free software: you can redistribute it and/or modify |
51349 | 15 ;; it under the terms of the GNU General Public License as published by |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94023
diff
changeset
|
16 ;; the Free Software Foundation, either version 3 of the License, or |
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94023
diff
changeset
|
17 ;; (at your option) any later version. |
51349 | 18 |
19 ;; GNU Emacs is distributed in the hope that it will be useful, | |
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 ;; GNU General Public License for more details. | |
23 | |
24 ;; You should have received a copy of the GNU General Public License | |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94023
diff
changeset
|
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
51349 | 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 | |
60597
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
34 ;; 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
|
35 ;; 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
|
36 ;; 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
|
37 |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
38 (defun macro-declaration-function (macro decl) |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
39 "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
|
40 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
|
41 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
|
42 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
|
43 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
|
44 ;; 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
|
45 (let (d) |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
46 ;; 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
|
47 (while (setq decl (cdr decl)) |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
48 (setq d (car decl)) |
100064
b42d22c5897f
(macro-declaration-function): Disallow declare specs with lengths of 3
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
49 (if (and (consp d) |
b42d22c5897f
(macro-declaration-function): Disallow declare specs with lengths of 3
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
50 (listp (cdr d)) |
b42d22c5897f
(macro-declaration-function): Disallow declare specs with lengths of 3
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
51 (null (cdr (cdr d)))) |
b42d22c5897f
(macro-declaration-function): Disallow declare specs with lengths of 3
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
52 (cond ((eq (car d) 'indent) |
b42d22c5897f
(macro-declaration-function): Disallow declare specs with lengths of 3
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
53 (put macro 'lisp-indent-function (car (cdr d)))) |
b42d22c5897f
(macro-declaration-function): Disallow declare specs with lengths of 3
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
54 ((eq (car d) 'debug) |
b42d22c5897f
(macro-declaration-function): Disallow declare specs with lengths of 3
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
55 (put macro 'edebug-form-spec (car (cdr d)))) |
b42d22c5897f
(macro-declaration-function): Disallow declare specs with lengths of 3
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
56 ((eq (car d) 'doc-string) |
b42d22c5897f
(macro-declaration-function): Disallow declare specs with lengths of 3
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
57 (put macro 'doc-string-elt (car (cdr d)))) |
b42d22c5897f
(macro-declaration-function): Disallow declare specs with lengths of 3
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
58 (t |
b42d22c5897f
(macro-declaration-function): Disallow declare specs with lengths of 3
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
59 (message "Unknown declaration %s" d))) |
b42d22c5897f
(macro-declaration-function): Disallow declare specs with lengths of 3
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
60 (message "Invalid declaration %s" d))))) |
b42d22c5897f
(macro-declaration-function): Disallow declare specs with lengths of 3
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
61 |
60597
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
62 |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
63 (setq macro-declaration-function 'macro-declaration-function) |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
64 |
e9f1d42f7fc0
(macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents:
60580
diff
changeset
|
65 |
51349 | 66 ;; Redefined in byte-optimize.el. |
67 ;; This is not documented--it's not clear that we should promote it. | |
68 (fset 'inline 'progn) | |
69 | |
70 ;;; Interface to inline functions. | |
71 | |
72 ;; (defmacro proclaim-inline (&rest fns) | |
73 ;; "Cause the named functions to be open-coded when called from compiled code. | |
74 ;; They will only be compiled open-coded when byte-compile-optimize is true." | |
75 ;; (cons 'eval-and-compile | |
76 ;; (mapcar '(lambda (x) | |
77 ;; (or (memq (get x 'byte-optimizer) | |
78 ;; '(nil byte-compile-inline-expand)) | |
79 ;; (error | |
80 ;; "%s already has a byte-optimizer, can't make it inline" | |
81 ;; x)) | |
82 ;; (list 'put (list 'quote x) | |
83 ;; ''byte-optimizer ''byte-compile-inline-expand)) | |
84 ;; fns))) | |
85 | |
86 ;; (defmacro proclaim-notinline (&rest fns) | |
87 ;; "Cause the named functions to no longer be open-coded." | |
88 ;; (cons 'eval-and-compile | |
89 ;; (mapcar '(lambda (x) | |
90 ;; (if (eq (get x 'byte-optimizer) 'byte-compile-inline-expand) | |
91 ;; (put x 'byte-optimizer nil)) | |
92 ;; (list 'if (list 'eq (list 'get (list 'quote x) ''byte-optimizer) | |
93 ;; ''byte-compile-inline-expand) | |
94 ;; (list 'put x ''byte-optimizer nil))) | |
95 ;; fns))) | |
96 | |
97 ;; This has a special byte-hunk-handler in bytecomp.el. | |
98 (defmacro defsubst (name arglist &rest body) | |
99 "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
|
100 (declare (debug defun)) |
51349 | 101 (or (memq (get name 'byte-optimizer) |
102 '(nil byte-compile-inline-expand)) | |
103 (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
|
104 `(prog1 |
94bcfb39cf49
(defsubst): Add edebug spec and use backquote.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54413
diff
changeset
|
105 (defun ,name ,arglist ,@body) |
94bcfb39cf49
(defsubst): Add edebug spec and use backquote.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54413
diff
changeset
|
106 (eval-and-compile |
94bcfb39cf49
(defsubst): Add edebug spec and use backquote.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54413
diff
changeset
|
107 (put ',name 'byte-optimizer 'byte-compile-inline-expand)))) |
51349 | 108 |
105363
a3acd4b1e5cc
* emacs-lisp/byte-run.el (advertised-signature-table): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104751
diff
changeset
|
109 (defvar advertised-signature-table (make-hash-table :test 'eq :weakness 'key)) |
a3acd4b1e5cc
* emacs-lisp/byte-run.el (advertised-signature-table): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104751
diff
changeset
|
110 |
110356
d2f5496377e6
* subr.el (unintern): Declare the obarray arg mandatory.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
111 (defun set-advertised-calling-convention (function signature when) |
105363
a3acd4b1e5cc
* emacs-lisp/byte-run.el (advertised-signature-table): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104751
diff
changeset
|
112 "Set the advertised SIGNATURE of FUNCTION. |
a3acd4b1e5cc
* emacs-lisp/byte-run.el (advertised-signature-table): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104751
diff
changeset
|
113 This will allow the byte-compiler to warn the programmer when she uses |
110356
d2f5496377e6
* subr.el (unintern): Declare the obarray arg mandatory.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
114 an obsolete calling convention. WHEN specifies since when the calling |
d2f5496377e6
* subr.el (unintern): Declare the obarray arg mandatory.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
115 convention was modified." |
105363
a3acd4b1e5cc
* emacs-lisp/byte-run.el (advertised-signature-table): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104751
diff
changeset
|
116 (puthash (indirect-function function) signature |
a3acd4b1e5cc
* emacs-lisp/byte-run.el (advertised-signature-table): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104751
diff
changeset
|
117 advertised-signature-table)) |
a3acd4b1e5cc
* emacs-lisp/byte-run.el (advertised-signature-table): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104751
diff
changeset
|
118 |
63435
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
119 (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
|
120 "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
|
121 The warning will say that CURRENT-NAME should be used instead. |
92295 | 122 If CURRENT-NAME is a string, that is the `use instead' message |
123 \(it should end with a period, and not start with a capital). | |
51349 | 124 If provided, WHEN should be a string indicating when the function |
125 was first made obsolete, for example a date or a release number." | |
126 (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
|
127 (let ((handler (get obsolete-name 'byte-compile))) |
51349 | 128 (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
|
129 (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
|
130 (put obsolete-name 'byte-compile 'byte-compile-obsolete)) |
105765
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105744
diff
changeset
|
131 (put obsolete-name 'byte-obsolete-info |
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105744
diff
changeset
|
132 (list (purecopy current-name) handler (purecopy when)))) |
63435
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
133 obsolete-name) |
105363
a3acd4b1e5cc
* emacs-lisp/byte-run.el (advertised-signature-table): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104751
diff
changeset
|
134 (set-advertised-calling-convention |
a3acd4b1e5cc
* emacs-lisp/byte-run.el (advertised-signature-table): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104751
diff
changeset
|
135 ;; New code should always provide the `when' argument. |
110356
d2f5496377e6
* subr.el (unintern): Declare the obarray arg mandatory.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
136 'make-obsolete '(obsolete-name current-name when) "23.1") |
51349 | 137 |
63435
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
138 (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
|
139 &optional when docstring) |
63435
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
140 "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
|
141 |
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
142 \(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
|
143 |
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
144 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
|
145 |
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
146 \(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
|
147 \(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
|
148 |
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
149 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
|
150 (declare (doc-string 4)) |
61843
a158628ce6ac
(define-obsolete-function-alias): New macro.
Nick Roberts <nickrob@snap.net.nz>
parents:
61730
diff
changeset
|
151 `(progn |
63435
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
152 (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
|
153 (make-obsolete ,obsolete-name ,current-name ,when))) |
105363
a3acd4b1e5cc
* emacs-lisp/byte-run.el (advertised-signature-table): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104751
diff
changeset
|
154 (set-advertised-calling-convention |
a3acd4b1e5cc
* emacs-lisp/byte-run.el (advertised-signature-table): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104751
diff
changeset
|
155 ;; New code should always provide the `when' argument. |
a3acd4b1e5cc
* emacs-lisp/byte-run.el (advertised-signature-table): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104751
diff
changeset
|
156 'define-obsolete-function-alias |
110356
d2f5496377e6
* subr.el (unintern): Declare the obarray arg mandatory.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
157 '(obsolete-name current-name when &optional docstring) "23.1") |
61843
a158628ce6ac
(define-obsolete-function-alias): New macro.
Nick Roberts <nickrob@snap.net.nz>
parents:
61730
diff
changeset
|
158 |
63435
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
159 (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
|
160 "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
|
161 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
|
162 If CURRENT-NAME is a string, that is the `use instead' message. |
51349 | 163 If provided, WHEN should be a string indicating when the variable |
164 was first made obsolete, for example a date or a release number." | |
165 (interactive | |
166 (list | |
167 (let ((str (completing-read "Make variable obsolete: " obarray 'boundp t))) | |
168 (if (equal str "") (error "")) | |
169 (intern str)) | |
170 (car (read-from-string (read-string "Obsoletion replacement: "))))) | |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105632
diff
changeset
|
171 (put obsolete-name 'byte-obsolete-variable |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105632
diff
changeset
|
172 (cons |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105632
diff
changeset
|
173 (if (stringp current-name) |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105632
diff
changeset
|
174 (purecopy current-name) |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105632
diff
changeset
|
175 current-name) (purecopy when))) |
63435
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
176 obsolete-name) |
105363
a3acd4b1e5cc
* emacs-lisp/byte-run.el (advertised-signature-table): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104751
diff
changeset
|
177 (set-advertised-calling-convention |
a3acd4b1e5cc
* emacs-lisp/byte-run.el (advertised-signature-table): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104751
diff
changeset
|
178 ;; New code should always provide the `when' argument. |
110356
d2f5496377e6
* subr.el (unintern): Declare the obarray arg mandatory.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
179 'make-obsolete-variable '(obsolete-name current-name when) "23.1") |
51349 | 180 |
63435
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
181 (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
|
182 &optional when docstring) |
63435
a5ba219acb16
(make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents:
62520
diff
changeset
|
183 "Make OBSOLETE-NAME a variable alias for CURRENT-NAME and mark it obsolete. |
105632
127b35cd2de7
(define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
105486
diff
changeset
|
184 This uses `defvaralias' and `make-obsolete-variable' (which see). |
127b35cd2de7
(define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
105486
diff
changeset
|
185 See the Info node `(elisp)Variable Aliases' for more details. |
62094
ba1ec4834766
(define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents:
62072
diff
changeset
|
186 |
94023
1841ac94b011
(define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
92295
diff
changeset
|
187 If CURRENT-NAME is a defcustom (more generally, any variable |
1841ac94b011
(define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
92295
diff
changeset
|
188 where OBSOLETE-NAME may be set, e.g. in a .emacs file, before the |
1841ac94b011
(define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
92295
diff
changeset
|
189 alias is defined), then the define-obsolete-variable-alias |
105632
127b35cd2de7
(define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
105486
diff
changeset
|
190 statement should be evaluated before the defcustom, if user |
127b35cd2de7
(define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
105486
diff
changeset
|
191 customizations are to be respected. The simplest way to achieve |
127b35cd2de7
(define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
105486
diff
changeset
|
192 this is to place the alias statement before the defcustom (this |
127b35cd2de7
(define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
105486
diff
changeset
|
193 is not necessary for aliases that are autoloaded, or in files |
127b35cd2de7
(define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
105486
diff
changeset
|
194 dumped with Emacs). This is so that any user customizations are |
127b35cd2de7
(define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
105486
diff
changeset
|
195 applied before the defcustom tries to initialize the |
127b35cd2de7
(define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
105486
diff
changeset
|
196 variable (this is due to the way `defvaralias' works). |
94023
1841ac94b011
(define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
92295
diff
changeset
|
197 |
105632
127b35cd2de7
(define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
105486
diff
changeset
|
198 For the benefit of `custom-set-variables', if OBSOLETE-NAME has |
127b35cd2de7
(define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
105486
diff
changeset
|
199 any of the following properties, they are copied to |
127b35cd2de7
(define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
105486
diff
changeset
|
200 CURRENT-NAME, if it does not already have them: |
127b35cd2de7
(define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
105486
diff
changeset
|
201 'saved-value, 'saved-variable-comment." |
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) |
105632
127b35cd2de7
(define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
105486
diff
changeset
|
205 ;; See Bug#4706. |
105838
5a494d9d4e4f
(define-obsolete-variable-alias): Use dolist,
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105765
diff
changeset
|
206 (dolist (prop '(saved-value saved-variable-comment)) |
5a494d9d4e4f
(define-obsolete-variable-alias): Use dolist,
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105765
diff
changeset
|
207 (and (get ,obsolete-name prop) |
5a494d9d4e4f
(define-obsolete-variable-alias): Use dolist,
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105765
diff
changeset
|
208 (null (get ,current-name prop)) |
5a494d9d4e4f
(define-obsolete-variable-alias): Use dolist,
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105765
diff
changeset
|
209 (put ,current-name prop (get ,obsolete-name prop)))) |
66403
6d02f0b72652
(define-obsolete-function-alias, define-obsolete-variable-alias):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66397
diff
changeset
|
210 (make-obsolete-variable ,obsolete-name ,current-name ,when))) |
105363
a3acd4b1e5cc
* emacs-lisp/byte-run.el (advertised-signature-table): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104751
diff
changeset
|
211 (set-advertised-calling-convention |
a3acd4b1e5cc
* emacs-lisp/byte-run.el (advertised-signature-table): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104751
diff
changeset
|
212 ;; New code should always provide the `when' argument. |
a3acd4b1e5cc
* emacs-lisp/byte-run.el (advertised-signature-table): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104751
diff
changeset
|
213 'define-obsolete-variable-alias |
110356
d2f5496377e6
* subr.el (unintern): Declare the obarray arg mandatory.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
214 '(obsolete-name current-name when &optional docstring) "23.1") |
61730
d4e4e1694bf8
(define-obsolete-variable-alias): New macro.
Nick Roberts <nickrob@snap.net.nz>
parents:
60597
diff
changeset
|
215 |
104751
0299ec0f58e6
(define-obsolete-face-alias): New macro.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
216 ;; FIXME This is only defined in this file because the variable- and |
0299ec0f58e6
(define-obsolete-face-alias): New macro.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
217 ;; function- versions are too. Unlike those two, this one is not used |
0299ec0f58e6
(define-obsolete-face-alias): New macro.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
218 ;; by the byte-compiler (would be nice if it could warn about obsolete |
0299ec0f58e6
(define-obsolete-face-alias): New macro.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
219 ;; faces, but it doesn't really do anything special with faces). |
0299ec0f58e6
(define-obsolete-face-alias): New macro.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
220 ;; It only really affects M-x describe-face output. |
105363
a3acd4b1e5cc
* emacs-lisp/byte-run.el (advertised-signature-table): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104751
diff
changeset
|
221 (defmacro define-obsolete-face-alias (obsolete-face current-face when) |
104751
0299ec0f58e6
(define-obsolete-face-alias): New macro.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
222 "Make OBSOLETE-FACE a face alias for CURRENT-FACE and mark it obsolete. |
105486
dfa034d34546
(define-obsolete-face-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
105363
diff
changeset
|
223 The string WHEN gives the Emacs version where OBSOLETE-FACE became |
dfa034d34546
(define-obsolete-face-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
105363
diff
changeset
|
224 obsolete." |
104751
0299ec0f58e6
(define-obsolete-face-alias): New macro.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
225 `(progn |
0299ec0f58e6
(define-obsolete-face-alias): New macro.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
226 (put ,obsolete-face 'face-alias ,current-face) |
0299ec0f58e6
(define-obsolete-face-alias): New macro.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
227 ;; Used by M-x describe-face. |
105870
26baacb565b0
* textmodes/tex-mode.el (tex-alt-dvi-print-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105838
diff
changeset
|
228 (put ,obsolete-face 'obsolete-face (or (purecopy ,when) t)))) |
104751
0299ec0f58e6
(define-obsolete-face-alias): New macro.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
229 |
51349 | 230 (defmacro dont-compile (&rest body) |
231 "Like `progn', but the body always runs interpreted (not compiled). | |
232 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
|
233 (declare (debug t) (indent 0)) |
51349 | 234 (list 'eval (list 'quote (if (cdr body) (cons 'progn body) (car body))))) |
235 | |
236 | |
66403
6d02f0b72652
(define-obsolete-function-alias, define-obsolete-variable-alias):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66397
diff
changeset
|
237 ;; 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
|
238 ;; 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
|
239 ;; 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
|
240 ;; byte-compile-macro-environment. |
51349 | 241 |
242 (defmacro eval-when-compile (&rest body) | |
62520
ee08cd4e1bf0
(eval-when-compile): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
62094
diff
changeset
|
243 "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
|
244 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
|
245 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
|
246 (declare (debug t) (indent 0)) |
51349 | 247 ;; Not necessary because we have it in b-c-initial-macro-environment |
248 ;; (list 'quote (eval (cons 'progn body))) | |
249 (cons 'progn body)) | |
250 | |
251 (defmacro eval-and-compile (&rest body) | |
252 "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
|
253 (declare (debug t) (indent 0)) |
51349 | 254 ;; Remember, it's magic. |
255 (cons 'progn body)) | |
256 | |
60580
a7bed417c2e6
Replace lisp-indent-hook with lisp-indent-function throughout.
Lute Kamstra <lute@gnu.org>
parents:
55405
diff
changeset
|
257 (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
|
258 (defun with-no-warnings (&rest body) |
51349 | 259 "Like `progn', but prevents compiler warnings in the body." |
260 ;; 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
|
261 (car (last body))) |
51349 | 262 |
263 | |
66403
6d02f0b72652
(define-obsolete-function-alias, define-obsolete-variable-alias):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
66397
diff
changeset
|
264 ;; 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
|
265 ;; 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
|
266 ;; 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
|
267 ;; 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
|
268 ;; 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
|
269 ;; --rms. |
51349 | 270 |
60580
a7bed417c2e6
Replace lisp-indent-hook with lisp-indent-function throughout.
Lute Kamstra <lute@gnu.org>
parents:
55405
diff
changeset
|
271 ;; (put 'byte-compiler-options 'lisp-indent-function 0) |
51349 | 272 ;; (defmacro byte-compiler-options (&rest args) |
273 ;; "Set some compilation-parameters for this file. This will affect only the | |
274 ;; file in which it appears; this does nothing when evaluated, and when loaded | |
275 ;; from a .el file. | |
276 ;; | |
277 ;; Each argument to this macro must be a list of a key and a value. | |
278 ;; | |
279 ;; Keys: Values: Corresponding variable: | |
280 ;; | |
281 ;; verbose t, nil byte-compile-verbose | |
282 ;; optimize t, nil, source, byte byte-compile-optimize | |
283 ;; warnings list of warnings byte-compile-warnings | |
80040
c86cce8752cb
*** empty log message ***
Juanma Barranquero <lekktu@gmail.com>
parents:
79704
diff
changeset
|
284 ;; Valid elements: (callargs redefine free-vars unresolved) |
51349 | 285 ;; file-format emacs18, emacs19 byte-compile-compatibility |
286 ;; | |
287 ;; For example, this might appear at the top of a source file: | |
288 ;; | |
289 ;; (byte-compiler-options | |
290 ;; (optimize t) | |
291 ;; (warnings (- free-vars)) ; Don't warn about free variables | |
292 ;; (file-format emacs19))" | |
293 ;; nil) | |
294 | |
295 ;;; byte-run.el ends here |