* lisp/vc/smerge-mode.el (smerge-refine-subst): Don't deactivate the mark.
[bpt/emacs.git] / lisp / emacs-lisp / byte-run.el
index 03fd5bf..3fb3d84 100644 (file)
@@ -1,12 +1,12 @@
 ;;; byte-run.el --- byte-compiler support for inlining
 
-;; Copyright (C) 1992, 2001, 2002, 2003, 2004, 2005,
-;;   2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 2001-2011  Free Software Foundation, Inc.
 
 ;; Author: Jamie Zawinski <jwz@lucid.com>
 ;;     Hallvard Furuseth <hbf@ulrik.uio.no>
 ;; Maintainer: FSF
 ;; Keywords: internal
+;; Package: emacs
 
 ;; This file is part of GNU Emacs.
 
@@ -45,14 +45,19 @@ The return value of this function is not used."
     ;; Ignore the first element of `decl' (it's always `declare').
     (while (setq decl (cdr decl))
       (setq d (car decl))
-      (cond ((and (consp d) (eq (car d) 'indent))
-            (put macro 'lisp-indent-function (car (cdr d))))
-           ((and (consp d) (eq (car d) 'debug))
-            (put macro 'edebug-form-spec (car (cdr d))))
-           ((and (consp d) (eq (car d) 'doc-string))
-            (put macro 'doc-string-elt (car (cdr d))))
-           (t
-            (message "Unknown declaration %s" d))))))
+      (if (and (consp d)
+              (listp (cdr d))
+              (null (cdr (cdr d))))
+         (cond ((eq (car d) 'indent)
+                (put macro 'lisp-indent-function (car (cdr d))))
+               ((eq (car d) 'debug)
+                (put macro 'edebug-form-spec (car (cdr d))))
+               ((eq (car d) 'doc-string)
+                (put macro 'doc-string-elt (car (cdr d))))
+               (t
+                (message "Unknown declaration %s" d)))
+       (message "Invalid declaration %s" d)))))
+
 
 (setq macro-declaration-function 'macro-declaration-function)
 
@@ -60,7 +65,6 @@ The return value of this function is not used."
 ;; Redefined in byte-optimize.el.
 ;; This is not documented--it's not clear that we should promote it.
 (fset 'inline 'progn)
-(put 'inline 'lisp-indent-function 0)
 
 ;;; Interface to inline functions.
 
@@ -101,6 +105,16 @@ The return value of this function is not used."
      (eval-and-compile
        (put ',name 'byte-optimizer 'byte-compile-inline-expand))))
 
+(defvar advertised-signature-table (make-hash-table :test 'eq :weakness 'key))
+
+(defun set-advertised-calling-convention (function signature when)
+  "Set the advertised SIGNATURE of FUNCTION.
+This will allow the byte-compiler to warn the programmer when she uses
+an obsolete calling convention.  WHEN specifies since when the calling
+convention was modified."
+  (puthash (indirect-function function) signature
+           advertised-signature-table))
+
 (defun make-obsolete (obsolete-name current-name &optional when)
   "Make the byte-compiler warn that OBSOLETE-NAME is obsolete.
 The warning will say that CURRENT-NAME should be used instead.
@@ -109,12 +123,14 @@ If CURRENT-NAME 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 obsolete-name 'byte-compile)))
-    (if (eq 'byte-compile-obsolete handler)
-       (setq handler (nth 1 (get obsolete-name 'byte-obsolete-info)))
-      (put obsolete-name 'byte-compile 'byte-compile-obsolete))
-    (put obsolete-name 'byte-obsolete-info (list current-name handler when)))
+  (put obsolete-name 'byte-obsolete-info
+       ;; The second entry used to hold the `byte-compile' handler, but
+       ;; is not used any more nowadays.
+       (list (purecopy current-name) nil (purecopy when)))
   obsolete-name)
+(set-advertised-calling-convention
+ ;; New code should always provide the `when' argument.
+ 'make-obsolete '(obsolete-name current-name when) "23.1")
 
 (defmacro define-obsolete-function-alias (obsolete-name current-name
                                                   &optional when docstring)
@@ -132,6 +148,10 @@ See the docstrings of `defalias' and `make-obsolete' for more details."
   `(progn
      (defalias ,obsolete-name ,current-name ,docstring)
      (make-obsolete ,obsolete-name ,current-name ,when)))
+(set-advertised-calling-convention
+ ;; New code should always provide the `when' argument.
+ 'define-obsolete-function-alias
+ '(obsolete-name current-name when &optional docstring) "23.1")
 
 (defun make-obsolete-variable (obsolete-name current-name &optional when)
   "Make the byte-compiler warn that OBSOLETE-NAME is obsolete.
@@ -145,35 +165,64 @@ was first made obsolete, for example a date or a release number."
       (if (equal str "") (error ""))
       (intern str))
     (car (read-from-string (read-string "Obsoletion replacement: ")))))
-  (put obsolete-name 'byte-obsolete-variable (cons current-name when))
+  (put obsolete-name 'byte-obsolete-variable
+       (cons
+       (if (stringp current-name)
+           (purecopy current-name)
+         current-name) (purecopy when)))
   obsolete-name)
+(set-advertised-calling-convention
+ ;; New code should always provide the `when' argument.
+ 'make-obsolete-variable '(obsolete-name current-name when) "23.1")
 
 (defmacro define-obsolete-variable-alias (obsolete-name current-name
                                                 &optional when docstring)
   "Make OBSOLETE-NAME a variable alias for CURRENT-NAME and mark it obsolete.
-
-\(define-obsolete-variable-alias 'old-var 'new-var \"22.1\" \"old-var's doc.\")
-
-is equivalent to the following two lines of code:
-
-\(defvaralias 'old-var 'new-var \"old-var's doc.\")
-\(make-obsolete-variable 'old-var 'new-var \"22.1\")
+This uses `defvaralias' and `make-obsolete-variable' (which see).
+See the Info node `(elisp)Variable Aliases' for more details.
 
 If CURRENT-NAME is a defcustom (more generally, any variable
 where OBSOLETE-NAME may be set, e.g. in a .emacs file, before the
 alias is defined), then the define-obsolete-variable-alias
-statement should be placed before the defcustom.  This is so that
-any user customizations are applied before the defcustom tries to
-initialize the variable (this is due to the way `defvaralias' works).
-Exceptions to this rule occur for define-obsolete-variable-alias
-statements that are autoloaded, or in files dumped with Emacs.
-
-See the docstrings of `defvaralias' and `make-obsolete-variable' or
-Info node `(elisp)Variable Aliases' for more details."
+statement should be evaluated before the defcustom, if user
+customizations are to be respected.  The simplest way to achieve
+this is to place the alias statement before the defcustom (this
+is not necessary for aliases that are autoloaded, or in files
+dumped with Emacs).  This is so that any user customizations are
+applied before the defcustom tries to initialize the
+variable (this is due to the way `defvaralias' works).
+
+For the benefit of `custom-set-variables', if OBSOLETE-NAME has
+any of the following properties, they are copied to
+CURRENT-NAME, if it does not already have them:
+'saved-value, 'saved-variable-comment."
   (declare (doc-string 4))
   `(progn
      (defvaralias ,obsolete-name ,current-name ,docstring)
+     ;; See Bug#4706.
+     (dolist (prop '(saved-value saved-variable-comment))
+       (and (get ,obsolete-name prop)
+            (null (get ,current-name prop))
+            (put ,current-name prop (get ,obsolete-name prop))))
      (make-obsolete-variable ,obsolete-name ,current-name ,when)))
+(set-advertised-calling-convention
+ ;; New code should always provide the `when' argument.
+ 'define-obsolete-variable-alias
+ '(obsolete-name current-name when &optional docstring) "23.1")
+
+;; FIXME This is only defined in this file because the variable- and
+;; function- versions are too.  Unlike those two, this one is not used
+;; by the byte-compiler (would be nice if it could warn about obsolete
+;; faces, but it doesn't really do anything special with faces).
+;; It only really affects M-x describe-face output.
+(defmacro define-obsolete-face-alias (obsolete-face current-face when)
+  "Make OBSOLETE-FACE a face alias for CURRENT-FACE and mark it obsolete.
+The string WHEN gives the Emacs version where OBSOLETE-FACE became
+obsolete."
+  `(progn
+     (put ,obsolete-face 'face-alias ,current-face)
+     ;; Used by M-x describe-face.
+     (put ,obsolete-face 'obsolete-face (or (purecopy ,when) t))))
 
 (defmacro dont-compile (&rest body)
   "Like `progn', but the body always runs interpreted (not compiled).
@@ -240,5 +289,4 @@ In interpreted code, this is entirely equivalent to `progn'."
 ;;       (file-format emacs19))"
 ;;   nil)
 
-;; arch-tag: 76f8328a-1f66-4df2-9b6d-5c3666dc05e9
 ;;; byte-run.el ends here