annotate lisp/emacs-lisp/byte-run.el @ 95349:953bf413e9a3

* xterm.c (x_draw_glyph_string): If a clipmask is specified, use it.
author Chong Yidong <cyd@stupidchicken.com>
date Tue, 27 May 2008 21:10:39 +0000
parents 90a2847062be
children b42d22c5897f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
1 ;;; byte-run.el --- byte-compiler support for inlining
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
2
74466
1d4b1a32fd66 Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 68648
diff changeset
3 ;; Copyright (C) 1992, 2001, 2002, 2003, 2004, 2005,
79704
78ee6fae0e41 Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 79518
diff changeset
4 ;; 2006, 2007, 2008 Free Software Foundation, Inc.
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
5
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
6 ;; Author: Jamie Zawinski <jwz@lucid.com>
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
7 ;; Hallvard Furuseth <hbf@ulrik.uio.no>
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
8 ;; Maintainer: FSF
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
9 ;; Keywords: internal
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
10
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
12
94655
90a2847062be Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94023
diff changeset
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
14 ;; 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
15 ;; 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
16 ;; (at your option) any later version.
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
17
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
21 ;; GNU General Public License for more details.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
22
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
23 ;; 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
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
25
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
26 ;;; Commentary:
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
27
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
28 ;; interface to selectively inlining functions.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
29 ;; This only happens when source-code optimization is turned on.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
30
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
31 ;;; Code:
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
32
60597
e9f1d42f7fc0 (macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents: 60580
diff changeset
33 ;; 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
34 ;; 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
35 ;; 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
36
e9f1d42f7fc0 (macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents: 60580
diff changeset
37 (defun macro-declaration-function (macro decl)
e9f1d42f7fc0 (macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents: 60580
diff changeset
38 "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
39 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
40 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
41 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
42 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
43 ;; 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
44 (let (d)
e9f1d42f7fc0 (macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents: 60580
diff changeset
45 ;; 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
46 (while (setq decl (cdr decl))
e9f1d42f7fc0 (macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents: 60580
diff changeset
47 (setq d (car decl))
e9f1d42f7fc0 (macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents: 60580
diff changeset
48 (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
49 (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
50 ((and (consp d) (eq (car d) 'debug))
e9f1d42f7fc0 (macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents: 60580
diff changeset
51 (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
52 ((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
53 (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
54 (t
e9f1d42f7fc0 (macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents: 60580
diff changeset
55 (message "Unknown declaration %s" d))))))
e9f1d42f7fc0 (macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents: 60580
diff changeset
56
e9f1d42f7fc0 (macro-declaration-function): Move from subr.el.
Lute Kamstra <lute@gnu.org>
parents: 60580
diff changeset
57 (setq macro-declaration-function 'macro-declaration-function)
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
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
60 ;; Redefined in byte-optimize.el.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
61 ;; This is not documented--it's not clear that we should promote it.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
62 (fset 'inline 'progn)
60580
a7bed417c2e6 Replace lisp-indent-hook with lisp-indent-function throughout.
Lute Kamstra <lute@gnu.org>
parents: 55405
diff changeset
63 (put 'inline 'lisp-indent-function 0)
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
64
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
65 ;;; Interface to inline functions.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
66
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
67 ;; (defmacro proclaim-inline (&rest fns)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
68 ;; "Cause the named functions to be open-coded when called from compiled code.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
69 ;; They will only be compiled open-coded when byte-compile-optimize is true."
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
70 ;; (cons 'eval-and-compile
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
71 ;; (mapcar '(lambda (x)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
72 ;; (or (memq (get x 'byte-optimizer)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
73 ;; '(nil byte-compile-inline-expand))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
74 ;; (error
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
75 ;; "%s already has a byte-optimizer, can't make it inline"
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
76 ;; x))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
77 ;; (list 'put (list 'quote x)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
78 ;; ''byte-optimizer ''byte-compile-inline-expand))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
79 ;; fns)))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
80
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
81 ;; (defmacro proclaim-notinline (&rest fns)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
82 ;; "Cause the named functions to no longer be open-coded."
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
83 ;; (cons 'eval-and-compile
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
84 ;; (mapcar '(lambda (x)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
85 ;; (if (eq (get x 'byte-optimizer) 'byte-compile-inline-expand)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
86 ;; (put x 'byte-optimizer nil))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
87 ;; (list 'if (list 'eq (list 'get (list 'quote x) ''byte-optimizer)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
88 ;; ''byte-compile-inline-expand)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
89 ;; (list 'put x ''byte-optimizer nil)))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
90 ;; fns)))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
91
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
92 ;; This has a special byte-hunk-handler in bytecomp.el.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
93 (defmacro defsubst (name arglist &rest body)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
94 "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
95 (declare (debug defun))
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
96 (or (memq (get name 'byte-optimizer)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
97 '(nil byte-compile-inline-expand))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
98 (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
99 `(prog1
94bcfb39cf49 (defsubst): Add edebug spec and use backquote.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54413
diff changeset
100 (defun ,name ,arglist ,@body)
94bcfb39cf49 (defsubst): Add edebug spec and use backquote.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54413
diff changeset
101 (eval-and-compile
94bcfb39cf49 (defsubst): Add edebug spec and use backquote.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54413
diff changeset
102 (put ',name 'byte-optimizer 'byte-compile-inline-expand))))
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
103
63435
a5ba219acb16 (make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents: 62520
diff changeset
104 (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
105 "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
106 The warning will say that CURRENT-NAME should be used instead.
92295
72a3622268cc (make-obsolete): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 92148
diff changeset
107 If CURRENT-NAME is a string, that is the `use instead' message
72a3622268cc (make-obsolete): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 92148
diff changeset
108 \(it should end with a period, and not start with a capital).
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
109 If provided, WHEN should be a string indicating when the function
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
110 was first made obsolete, for example a date or a release number."
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
111 (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
112 (let ((handler (get obsolete-name 'byte-compile)))
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
113 (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
114 (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
115 (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
116 (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
117 obsolete-name)
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
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 (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
120 &optional when docstring)
63435
a5ba219acb16 (make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents: 62520
diff changeset
121 "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
122
ba1ec4834766 (define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62072
diff changeset
123 \(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
124
ba1ec4834766 (define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62072
diff changeset
125 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
126
ba1ec4834766 (define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62072
diff changeset
127 \(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
128 \(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
129
ba1ec4834766 (define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62072
diff changeset
130 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
131 (declare (doc-string 4))
61843
a158628ce6ac (define-obsolete-function-alias): New macro.
Nick Roberts <nickrob@snap.net.nz>
parents: 61730
diff changeset
132 `(progn
63435
a5ba219acb16 (make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents: 62520
diff changeset
133 (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
134 (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
135
63435
a5ba219acb16 (make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents: 62520
diff changeset
136 (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
137 "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
138 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
139 If CURRENT-NAME is a string, that is the `use instead' message.
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
140 If provided, WHEN should be a string indicating when the variable
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
141 was first made obsolete, for example a date or a release number."
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
142 (interactive
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
143 (list
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
144 (let ((str (completing-read "Make variable obsolete: " obarray 'boundp t)))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
145 (if (equal str "") (error ""))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
146 (intern str))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
147 (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
148 (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
149 obsolete-name)
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
150
63435
a5ba219acb16 (make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents: 62520
diff changeset
151 (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
152 &optional when docstring)
63435
a5ba219acb16 (make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents: 62520
diff changeset
153 "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
154
ba1ec4834766 (define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62072
diff changeset
155 \(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
156
ba1ec4834766 (define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62072
diff changeset
157 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
158
ba1ec4834766 (define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62072
diff changeset
159 \(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
160 \(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
161
94023
1841ac94b011 (define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 92295
diff changeset
162 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
163 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
164 alias is defined), then the define-obsolete-variable-alias
1841ac94b011 (define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 92295
diff changeset
165 statement should be placed before the defcustom. This is so that
1841ac94b011 (define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 92295
diff changeset
166 any user customizations are applied before the defcustom tries to
1841ac94b011 (define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 92295
diff changeset
167 initialize the variable (this is due to the way `defvaralias' works).
1841ac94b011 (define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 92295
diff changeset
168 Exceptions to this rule occur for define-obsolete-variable-alias
1841ac94b011 (define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 92295
diff changeset
169 statements that are autoloaded, or in files dumped with Emacs.
1841ac94b011 (define-obsolete-variable-alias): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 92295
diff changeset
170
62094
ba1ec4834766 (define-obsolete-function-alias, define-obsolete-variable-alias): Doc Fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62072
diff changeset
171 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
172 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
173 (declare (doc-string 4))
61730
d4e4e1694bf8 (define-obsolete-variable-alias): New macro.
Nick Roberts <nickrob@snap.net.nz>
parents: 60597
diff changeset
174 `(progn
63435
a5ba219acb16 (make-obsolete, define-obsolete-function-alias): Rename arguments FUNCTION and
Juanma Barranquero <lekktu@gmail.com>
parents: 62520
diff changeset
175 (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
176 (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
177
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
178 (defmacro dont-compile (&rest body)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
179 "Like `progn', but the body always runs interpreted (not compiled).
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
180 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
181 (declare (debug t) (indent 0))
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
182 (list 'eval (list 'quote (if (cdr body) (cons 'progn body) (car body)))))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
183
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
184
66403
6d02f0b72652 (define-obsolete-function-alias, define-obsolete-variable-alias):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66397
diff changeset
185 ;; 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
186 ;; 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
187 ;; 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
188 ;; byte-compile-macro-environment.
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
189
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
190 (defmacro eval-when-compile (&rest body)
62520
ee08cd4e1bf0 (eval-when-compile): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 62094
diff changeset
191 "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
192 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
193 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
194 (declare (debug t) (indent 0))
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
195 ;; Not necessary because we have it in b-c-initial-macro-environment
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
196 ;; (list 'quote (eval (cons 'progn body)))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
197 (cons 'progn body))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
198
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
199 (defmacro eval-and-compile (&rest body)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
200 "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
201 (declare (debug t) (indent 0))
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
202 ;; Remember, it's magic.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
203 (cons 'progn body))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
204
60580
a7bed417c2e6 Replace lisp-indent-hook with lisp-indent-function throughout.
Lute Kamstra <lute@gnu.org>
parents: 55405
diff changeset
205 (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
206 (defun with-no-warnings (&rest body)
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
207 "Like `progn', but prevents compiler warnings in the body."
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
208 ;; 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
209 (car (last body)))
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
210
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
211
66403
6d02f0b72652 (define-obsolete-function-alias, define-obsolete-variable-alias):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66397
diff changeset
212 ;; 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
213 ;; 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
214 ;; 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
215 ;; 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
216 ;; 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
217 ;; --rms.
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
218
60580
a7bed417c2e6 Replace lisp-indent-hook with lisp-indent-function throughout.
Lute Kamstra <lute@gnu.org>
parents: 55405
diff changeset
219 ;; (put 'byte-compiler-options 'lisp-indent-function 0)
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
220 ;; (defmacro byte-compiler-options (&rest args)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
221 ;; "Set some compilation-parameters for this file. This will affect only the
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
222 ;; file in which it appears; this does nothing when evaluated, and when loaded
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
223 ;; from a .el file.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
224 ;;
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
225 ;; Each argument to this macro must be a list of a key and a value.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
226 ;;
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
227 ;; Keys: Values: Corresponding variable:
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
228 ;;
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
229 ;; verbose t, nil byte-compile-verbose
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
230 ;; optimize t, nil, source, byte byte-compile-optimize
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
231 ;; warnings list of warnings byte-compile-warnings
80040
c86cce8752cb *** empty log message ***
Juanma Barranquero <lekktu@gmail.com>
parents: 79704
diff changeset
232 ;; Valid elements: (callargs redefine free-vars unresolved)
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
233 ;; file-format emacs18, emacs19 byte-compile-compatibility
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
234 ;;
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
235 ;; For example, this might appear at the top of a source file:
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
236 ;;
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
237 ;; (byte-compiler-options
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
238 ;; (optimize t)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
239 ;; (warnings (- free-vars)) ; Don't warn about free variables
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
240 ;; (file-format emacs19))"
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
241 ;; nil)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
242
66403
6d02f0b72652 (define-obsolete-function-alias, define-obsolete-variable-alias):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66397
diff changeset
243 ;; arch-tag: 76f8328a-1f66-4df2-9b6d-5c3666dc05e9
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
244 ;;; byte-run.el ends here