# HG changeset patch # User Richard M. Stallman # Date 1099387336 0 # Node ID f57a9010e8657bf8e81aeea77bfc93acb15a450e # Parent 52307ec50b54bacddd6a5f3c9dd0aa311255710e (byte-compile-warning-types): Add interactive-only. (byte-compile-warnings): Add interactive-only as option. (byte-compile-interactive-only-functions): New variable. (byte-compile-form): Warn about calls to functions in byte-compile-interactive-only-functions. diff -r 52307ec50b54 -r f57a9010e865 lisp/emacs-lisp/bytecomp.el --- a/lisp/emacs-lisp/bytecomp.el Tue Nov 02 09:20:13 2004 +0000 +++ b/lisp/emacs-lisp/bytecomp.el Tue Nov 02 09:22:16 2004 +0000 @@ -98,6 +98,9 @@ ;; `obsolete' (obsolete variables and functions) ;; `noruntime' (calls to functions only defined ;; within `eval-when-compile') +;; `cl-warnings' (calls to CL functions) +;; `interactive-only' (calls to commands that are +;; not good to call from Lisp) ;; byte-compile-compatibility Whether the compiler should ;; generate .elc files which can be loaded into ;; generic emacs 18. @@ -325,7 +328,8 @@ :type 'boolean) (defconst byte-compile-warning-types - '(redefine callargs free-vars unresolved obsolete noruntime cl-functions) + '(redefine callargs free-vars unresolved + obsolete noruntime cl-functions interactive-only) "The list of warning types used when `byte-compile-warnings' is t.") (defcustom byte-compile-warnings t "*List of warnings that the byte-compiler should issue (t for all). @@ -341,13 +345,21 @@ noruntime functions that may not be defined at runtime (typically defined only under `eval-when-compile'). cl-functions calls to runtime functions from the CL package (as - distinguished from macros and aliases)." + distinguished from macros and aliases). + interactive-only + commands that normally shouldn't be called from Lisp code." :group 'bytecomp :type `(choice (const :tag "All" t) (set :menu-tag "Some" (const free-vars) (const unresolved) (const callargs) (const redefine) - (const obsolete) (const noruntime) (const cl-functions)))) + (const obsolete) (const noruntime) + (const cl-functions) (const interactive-only)))) + +(defvar byte-compile-interactive-only-functions + '(beginning-of-buffer end-of-buffer replace-string replace-regexp + insert-file) + "List of commands that are not meant to be called from Lisp.") (defvar byte-compile-not-obsolete-var nil "If non-nil, this is a variable that shouldn't be reported as obsolete.") @@ -2710,6 +2722,10 @@ (byte-compile-set-symbol-position fn) (when (byte-compile-const-symbol-p fn) (byte-compile-warn "`%s' called as a function" fn)) + (and (memq 'interactive-only byte-compile-warnings) + (memq (car form) 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 handler (or (not (byte-compile-version-cond byte-compile-compatibility))