"Use instead" obsolescence messages should end with "."
[bpt/emacs.git] / lisp / emacs-lisp / bytecomp.el
index e0d474b..9df52bf 100644 (file)
@@ -1,7 +1,7 @@
 ;;; bytecomp.el --- compilation of Lisp code into byte code -*- lexical-binding: t -*-
 
-;; Copyright (C) 1985-1987, 1992, 1994, 1998, 2000-2013
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 1985-1987, 1992, 1994, 1998, 2000-2014 Free Software
+;; Foundation, Inc.
 
 ;; Author: Jamie Zawinski <jwz@lucid.com>
 ;;     Hallvard Furuseth <hbf@ulrik.uio.no>
@@ -353,11 +353,11 @@ else the global value will be modified."
                   (t
                    (append byte-compile-warnings (list warning)))))))
 
-(defvar byte-compile-interactive-only-functions
-  '(beginning-of-buffer end-of-buffer replace-string replace-regexp
-    insert-file insert-buffer insert-file-literally previous-line next-line
-    goto-line comint-run delete-backward-char)
+(defvar byte-compile-interactive-only-functions nil
   "List of commands that are not meant to be called from Lisp.")
+(make-obsolete-variable 'byte-compile-interactive-only-functions
+                       "use the `interactive-only' symbol property instead."
+                       "24.4")
 
 (defvar byte-compile-not-obsolete-vars nil
   "List of variables that shouldn't be reported as obsolete.")
@@ -1265,8 +1265,7 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'."
                       (if (byte-code-function-p def)
                           (aref def 0)
                         '(&rest def)))))
-               (if (and (fboundp (car form))
-                        (subrp (symbol-function (car form))))
+               (if (subrp (symbol-function (car form)))
                    (subr-arity (symbol-function (car form))))))
         (ncall (length (cdr form))))
     ;; Check many or unevalled from subr-arity.
@@ -1706,16 +1705,14 @@ The value is non-nil if there were no errors, nil if errors."
 ;;  (interactive "fByte compile file: \nP")
   (interactive
    (let ((file buffer-file-name)
-        (file-name nil)
         (file-dir nil))
      (and file
          (derived-mode-p 'emacs-lisp-mode)
-         (setq file-name (file-name-nondirectory file)
-               file-dir (file-name-directory file)))
+         (setq file-dir (file-name-directory file)))
      (list (read-file-name (if current-prefix-arg
                               "Byte compile and load file: "
                             "Byte compile file: ")
-                          file-dir file-name nil)
+                          file-dir buffer-file-name nil)
           current-prefix-arg)))
   ;; Expand now so we get the current buffer's defaults
   (setq filename (expand-file-name filename))
@@ -2396,9 +2393,8 @@ not to take responsibility for the actual compilation of the code."
              (byte-compile-warn "%s `%s' defined multiple times in this file"
                                 (if macro "macro" "function")
                                 name)))
-          ((and (fboundp name)
-                (eq (car-safe (symbol-function name))
-                    (if macro 'lambda 'macro)))
+          ((eq (car-safe (symbol-function name))
+               (if macro 'lambda 'macro))
            (when (byte-compile-warning-enabled-p 'redefine)
              (byte-compile-warn "%s `%s' being redefined as a %s"
                                 (if macro "function" "macro")
@@ -2532,7 +2528,7 @@ If FORM is a lambda or a macro, byte-compile it as a function."
    (byte-compile-close-variables
     (let* ((lexical-binding lexical-binding)
            (fun (if (symbolp form)
-                   (and (fboundp form) (symbol-function form))
+                   (symbol-function form)
                  form))
           (macro (eq (car-safe fun) 'macro)))
       (if macro
@@ -2929,15 +2925,24 @@ for symbols generated by the byte compiler itself."
              (byte-compile-variable-ref form))))
      ((symbolp (car form))
       (let* ((fn (car form))
-             (handler (get fn 'byte-compile)))
+             (handler (get fn 'byte-compile))
+            (interactive-only
+             (or (get fn 'interactive-only)
+                 (memq fn byte-compile-interactive-only-functions))))
         (when (macroexp--const-symbol-p fn)
           (byte-compile-warn "`%s' called as a function" fn))
-        (and (byte-compile-warning-enabled-p 'interactive-only)
-             (memq fn byte-compile-interactive-only-functions)
-             (byte-compile-warn "`%s' used from Lisp code\n\
-That command is designed for interactive use only" fn))
-        (if (and (fboundp (car form))
-                 (eq (car-safe (symbol-function (car form))) 'macro))
+       (when (and (byte-compile-warning-enabled-p 'interactive-only)
+                  interactive-only)
+         (byte-compile-warn "`%s' is for interactive use only%s"
+                            fn
+                            (cond ((stringp interactive-only)
+                                   (format "; %s" interactive-only))
+                                  ((and (symbolp 'interactive-only)
+                                        (not (eq interactive-only t)))
+                                   (format "; use `%s' instead."
+                                           interactive-only))
+                                  (t "."))))
+        (if (eq (car-safe (symbol-function (car form))) 'macro)
             (byte-compile-log-warning
              (format "Forgot to expand macro %s" (car form)) nil :error))
         (if (and handler
@@ -3598,7 +3603,7 @@ discarding."
     (byte-compile-constant (if (eq 'lambda (car-safe f))
                                (byte-compile-lambda f)
                              f))))
-  
+
 (defun byte-compile-indent-to (form)
   (let ((len (length form)))
     (cond ((= len 2)