diff options
Diffstat (limited to 'lisp/emacs-lisp/bytecomp.el')
-rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index b3b9ca81ea4..286725f99c1 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -98,9 +98,11 @@ ;; `obsolete' (obsolete variables and functions) ;; `noruntime' (calls to functions only defined ;; within `eval-when-compile') -;; `cl-warnings' (calls to CL functions) +;; `cl-functions' (calls to CL functions) ;; `interactive-only' (calls to commands that are ;; not good to call from Lisp) +;; `make-local' (dubious calls to +;; `make-variable-buffer-local') ;; byte-compile-compatibility Whether the compiler should ;; generate .elc files which can be loaded into ;; generic emacs 18. @@ -356,14 +358,16 @@ Elements of the list may be: cl-functions calls to runtime functions from the CL package (as distinguished from macros and aliases). interactive-only - commands that normally shouldn't be called from Lisp code." + commands that normally shouldn't be called from Lisp code. + make-local calls to make-variable-buffer-local that may be incorrect." :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 interactive-only)))) + (const cl-functions) (const interactive-only) + (const make-local)))) (put 'byte-compile-warnings 'safe-local-variable 'byte-compile-warnings-safe-p) ;;;###autoload (defun byte-compile-warnings-safe-p (x) @@ -374,7 +378,7 @@ Elements of the list may be: (when (memq e '(free-vars unresolved callargs redefine obsolete noruntime - cl-functions interactive-only)) + cl-functions interactive-only make-local)) e)) x) x)))) @@ -850,13 +854,11 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'." (when (and (consp s) (eq t (car s))) (push (cdr s) old-autoloads))))))) (when (memq 'cl-functions byte-compile-warnings) - (let ((hist-new load-history) - (hist-nil-new current-load-list)) + (let ((hist-new load-history)) ;; Go through load-history, look for newly loaded files ;; and mark all the functions defined therein. (while (and hist-new (not (eq hist-new hist-orig))) - (let ((xs (pop hist-new)) - old-autoloads) + (let ((xs (pop hist-new))) ;; Make sure the file was not already loaded before. (when (and (equal (car xs) "cl") (not (assoc (car xs) hist-orig))) (byte-compile-find-cl-functions))))))))) @@ -1262,7 +1264,7 @@ extra args." (get (car form) 'byte-compile-format-like)) (let ((nfields (with-temp-buffer (insert (nth 1 form)) - (goto-char 1) + (goto-char (point-min)) (let ((n 0)) (while (re-search-forward "%." nil t) (unless (eq ?% (char-after (1+ (match-beginning 0)))) @@ -1280,19 +1282,19 @@ extra args." ;; Warn if a custom definition fails to specify :group. (defun byte-compile-nogroup-warn (form) (let ((keyword-args (cdr (cdr (cdr (cdr form))))) - (name (cadr form))) + (name (cadr form))) (or (not (eq (car-safe name) 'quote)) - (and (eq (car form) 'custom-declare-group) - (equal name ''emacs)) - (plist-get keyword-args :group) - (not (and (consp name) (eq (car name) 'quote))) - (byte-compile-warn - "%s for `%s' fails to specify containing group" - (cdr (assq (car form) - '((custom-declare-group . defgroup) - (custom-declare-face . defface) - (custom-declare-variable . defcustom)))) - (cadr name))))) + (and (eq (car form) 'custom-declare-group) + (equal name ''emacs)) + (plist-get keyword-args :group) + (not (and (consp name) (eq (car name) 'quote))) + (byte-compile-warn + "%s for `%s' fails to specify containing group" + (cdr (assq (car form) + '((custom-declare-group . defgroup) + (custom-declare-face . defface) + (custom-declare-variable . defcustom)))) + (cadr name))))) ;; Warn if the function or macro is being redefined with a different ;; number of arguments. @@ -1345,7 +1347,8 @@ extra args." (unless byte-compile-cl-functions (dolist (elt load-history) (when (and (stringp (car elt)) - (string-match "^cl\\>" (car elt))) + (string-match + "^cl\\>" (file-name-nondirectory (car elt)))) (setq byte-compile-cl-functions (append byte-compile-cl-functions (cdr elt))))) @@ -1830,9 +1833,8 @@ With argument, insert value in current buffer after the form." ;; byte-compile-warnings)) ) (byte-compile-close-variables - (save-excursion - (setq outbuffer - (set-buffer (get-buffer-create " *Compiler Output*"))) + (with-current-buffer + (setq outbuffer (get-buffer-create " *Compiler Output*")) (set-buffer-multibyte t) (erase-buffer) ;; (emacs-lisp-mode) @@ -1846,9 +1848,8 @@ With argument, insert value in current buffer after the form." (setq overwrite-mode 'overwrite-mode-binary)) (displaying-byte-compile-warnings (and filename (byte-compile-insert-header filename inbuffer outbuffer)) - (save-excursion - (set-buffer inbuffer) - (goto-char 1) + (with-current-buffer inbuffer + (goto-char (point-min)) ;; Should we always do this? When calling multiple files, it ;; would be useful to delay this warning until all have been ;; compiled. A: Yes! b-c-u-f might contain dross from a @@ -1917,7 +1918,7 @@ With argument, insert value in current buffer after the form." (let ((dynamic-docstrings byte-compile-dynamic-docstrings) (dynamic byte-compile-dynamic)) (set-buffer outbuffer) - (goto-char 1) + (goto-char (point-min)) ;; The magic number of .elc files is ";ELC", or 0x3B454C43. After ;; that is the file-format version number (18, 19 or 20) as a ;; byte, followed by some nulls. The primary motivation for doing @@ -2238,8 +2239,7 @@ list that represents a doc string reference. (put 'require 'byte-hunk-handler 'byte-compile-file-form-require) (defun byte-compile-file-form-require (form) - (let ((old-load-list current-load-list) - (args (mapcar 'eval (cdr form)))) + (let ((args (mapcar 'eval (cdr form)))) (apply 'require args) ;; Detect (require 'cl) in a way that works even if cl is already loaded. (if (member (car args) '("cl" cl)) @@ -3890,7 +3890,8 @@ that suppresses all warnings during execution of BODY." ;; Warn about misuses of make-variable-buffer-local. (byte-defop-compiler-1 make-variable-buffer-local byte-compile-make-variable-buffer-local) (defun byte-compile-make-variable-buffer-local (form) - (if (eq (car-safe (car-safe (cdr-safe form))) 'quote) + (if (and (eq (car-safe (car-safe (cdr-safe form))) 'quote) + (memq 'make-local byte-compile-warnings)) (byte-compile-warn "`make-variable-buffer-local' should be called at toplevel")) (byte-compile-normal-call form)) |