From 0b31660d3c10a0f8e243dd67bd0ecaf2c847d1e6 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 13 Jun 2013 22:31:28 -0400 Subject: * lisp/emacs-lisp/bytecomp.el (byte-compile-force-lexical-warnings): New var. (byte-compile-preprocess): Use it. (byte-compile-file-form-defalias): Try a bit harder to use macros we can't quite recognize. (byte-compile-add-to-list): Remove. * lisp/emacs-lisp/cconv.el (cconv-warnings-only): New function. (cconv-closure-convert): Add assertion. * lisp/emacs-lisp/map-ynp.el: Use lexical-binding. (map-y-or-n-p): Remove unused vars `tail' and `object'. Factor out some repeated code. * etc/NEWS (utf-8 for el): Move to the incompatible section. --- lisp/emacs-lisp/bytecomp.el | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) (limited to 'lisp/emacs-lisp/bytecomp.el') diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index e603f76f41d..391401ae5d6 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -2174,6 +2174,8 @@ list that represents a doc string reference. byte-compile-maxdepth 0 byte-compile-output nil)))) +(defvar byte-compile-force-lexical-warnings nil) + (defun byte-compile-preprocess (form &optional _for-effect) (setq form (macroexpand-all form byte-compile-macro-environment)) ;; FIXME: We should run byte-optimize-form here, but it currently does not @@ -2182,9 +2184,10 @@ list that represents a doc string reference. ;; macroexpand-all. ;; (if (memq byte-optimize '(t source)) ;; (setq form (byte-optimize-form form for-effect))) - (if lexical-binding - (cconv-closure-convert form) - form)) + (cond + (lexical-binding (cconv-closure-convert form)) + (byte-compile-force-lexical-warnings (cconv-warnings-only form)) + (t form))) ;; byte-hunk-handlers cannot call this! (defun byte-compile-toplevel-file-form (form) @@ -4240,6 +4243,12 @@ binding slots have been popped." lam)) (unless (byte-compile-file-form-defmumble name macro arglist body rest) + (when macro + (if (null fun) + (message "Macro %s unrecognized, won't work in file" name) + (message "Macro %s partly recognized, trying our luck" name) + (push (cons name (eval fun)) + byte-compile-macro-environment))) (byte-compile-keep-pending form)))) ;; We used to just do: (byte-compile-normal-call form) @@ -4268,26 +4277,6 @@ binding slots have been popped." 'byte-hunk-handler 'byte-compile-form-make-variable-buffer-local) (defun byte-compile-form-make-variable-buffer-local (form) (byte-compile-keep-pending form 'byte-compile-normal-call)) - -(byte-defop-compiler-1 add-to-list byte-compile-add-to-list) -(defun byte-compile-add-to-list (form) - ;; FIXME: This could be used for `set' as well, except that it's got - ;; its own opcode, so the final `byte-compile-normal-call' needs to - ;; be replaced with something else. - (pcase form - (`(,fun ',var . ,_) - (byte-compile-check-variable var 'assign) - (if (assq var byte-compile--lexical-environment) - (byte-compile-log-warning - (format "%s cannot use lexical var `%s'" fun var) - nil :error) - (unless (or (not (byte-compile-warning-enabled-p 'free-vars)) - (boundp var) - (memq var byte-compile-bound-variables) - (memq var byte-compile-free-references)) - (byte-compile-warn "assignment to free variable `%S'" var) - (push var byte-compile-free-references))))) - (byte-compile-normal-call form)) ;;; tags -- cgit v1.2.3 From 2285bd27abf63a460d7025b2e5579f67cdd2e6fb Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Wed, 19 Jun 2013 00:35:00 -0700 Subject: Check autoload's "type" argument correctly in bytecomp.el * lisp/emacs-lisp/bytecomp.el (byte-compile-file-form-autoload): Only eval autoloaded macros. (byte-compile-autoload): Only give the macro warning for macros. --- lisp/ChangeLog | 4 ++++ lisp/emacs-lisp/bytecomp.el | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp/bytecomp.el') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2886d0e00d4..b35035df729 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,9 @@ 2013-06-19 Glenn Morris + * emacs-lisp/bytecomp.el (byte-compile-file-form-autoload): + Only eval autoloaded macros. + (byte-compile-autoload): Only give the macro warning for macros. + * progmodes/cperl-mode.el (ps-bold-faces, ps-italic-faces) (ps-underlined-faces): Declare. diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 391401ae5d6..f4e79dc4886 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -2215,7 +2215,7 @@ list that represents a doc string reference. (and (let ((form form)) (while (if (setq form (cdr form)) (macroexp-const-p (car form)))) (null form)) ;Constants only - (eval (nth 5 form)) ;Macro + (memq (eval (nth 5 form)) '(t macro)) ;Macro (eval form)) ;Define the autoload. ;; Avoid undefined function warnings for the autoload. (when (and (consp (nth 1 form)) @@ -4187,7 +4187,7 @@ binding slots have been popped." (byte-compile-set-symbol-position 'autoload) (and (macroexp-const-p (nth 1 form)) (macroexp-const-p (nth 5 form)) - (eval (nth 5 form)) ; macro-p + (memq (eval (nth 5 form)) '(t macro)) ; macro-p (not (fboundp (eval (nth 1 form)))) (byte-compile-warn "The compiler ignores `autoload' except at top level. You should -- cgit v1.2.3