Moved to obsolete/.
[bpt/emacs.git] / lisp / byte-run.el
index 785a89b..a28f89c 100644 (file)
@@ -1,12 +1,12 @@
-;; byte-run.el --- byte-compiler support for inlining
+;;; byte-run.el --- byte-compiler support for inlining
+
+;; Copyright (C) 1992 Free Software Foundation, Inc.
 
 ;; Author: Jamie Zawinski <jwz@lucid.com>
 ;;     Hallvard Furuseth <hbf@ulrik.uio.no>
-;; Last-Modified: 13 Jul 1992
+;; Maintainer: FSF
 ;; Keywords: internal
 
-;; Copyright (C) 1992 Free Software Foundation, Inc.
-
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;;; Commentary:
 
-;;; interface to selectively inlining functions.
-;;; This only happens when source-code optimization is turned on.
+;; interface to selectively inlining functions.
+;; This only happens when source-code optimization is turned on.
 
 ;;; Code:
 
              (list 'put (list 'quote name)
                    ''byte-optimizer ''byte-compile-inline-expand))))
 
-(defun make-obsolete (fn new)
+(defun make-obsolete (fn new &optional when)
   "Make the byte-compiler warn that FUNCTION is obsolete.
 The warning will say that NEW should be used instead.
-If NEW is a string, that is the `use instead' message."
+If NEW is a string, that is the `use instead' message.
+If provided, WHEN should be a string indicating when the function
+was first made obsolete, for example a date or a release number."
   (interactive "aMake function obsolete: \nxObsoletion replacement: ")
   (let ((handler (get fn 'byte-compile)))
     (if (eq 'byte-compile-obsolete handler)
-       (setcar (get fn 'byte-obsolete-info) new)
-      (put fn 'byte-obsolete-info (cons new handler))
-      (put fn 'byte-compile 'byte-compile-obsolete)))
+       (setq handler (nth 1 (get fn 'byte-obsolete-info)))
+      (put fn 'byte-compile 'byte-compile-obsolete))
+    (put fn 'byte-obsolete-info (list new handler when)))
   fn)
 
+(defun make-obsolete-variable (var new &optional when)
+  "Make the byte-compiler warn that VARIABLE is obsolete,
+and NEW should be used instead.  If NEW is a string, then that is the
+`use instead' message.
+If provided, WHEN should be a string indicating when the variable
+was first made obsolete, for example a date or a release number."
+  (interactive
+   (list
+    (let ((str (completing-read "Make variable obsolete: " obarray 'boundp t)))
+      (if (equal str "") (error ""))
+      (intern str))
+    (car (read-from-string (read-string "Obsoletion replacement: ")))))
+  (put var 'byte-obsolete-variable (cons new when))
+  var)
+
 (put 'dont-compile 'lisp-indent-hook 0)
 (defmacro dont-compile (&rest body)
-  "Like `progn', but the body always runs interpreted (not compiled)."
+  "Like `progn', but the body always runs interpreted (not compiled).
+If you think you need this, you're probably making a mistake somewhere."
   (list 'eval (list 'quote (if (cdr body) (cons 'progn body) (car body)))))
 
 \f
@@ -112,6 +131,12 @@ The result of the body appears to the compiler as a quoted constant."
   ;; Remember, it's magic.
   (cons 'progn body))
 
+(defun with-no-warnings (&optional first &rest body)
+  "Like `progn', but prevents compiler warnings in the body."
+  ;; The implementation for the interpreter is basically trivial.
+  (if body (car (last body))
+    first))
+
 \f
 ;;; I nuked this because it's not a good idea for users to think of using it.
 ;;; These options are a matter of installation preference, and have nothing to
@@ -125,19 +150,19 @@ The result of the body appears to the compiler as a quoted constant."
 ;;   "Set some compilation-parameters for this file.  This will affect only the
 ;; file in which it appears; this does nothing when evaluated, and when loaded
 ;; from a .el file.
-;; 
+;;
 ;; Each argument to this macro must be a list of a key and a value.
-;; 
+;;
 ;;   Keys:               Values:               Corresponding variable:
-;; 
+;;
 ;;   verbose     t, nil                byte-compile-verbose
 ;;   optimize    t, nil, source, byte  byte-compile-optimize
 ;;   warnings    list of warnings      byte-compile-warnings
 ;;                   Legal elements: (callargs redefine free-vars unresolved)
 ;;   file-format         emacs18, emacs19      byte-compile-compatibility
-;; 
+;;
 ;; For example, this might appear at the top of a source file:
-;; 
+;;
 ;;     (byte-compiler-options
 ;;       (optimize t)
 ;;       (warnings (- free-vars))              ; Don't warn about free variables