emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r112979: * lisp/emacs-lisp/bytecomp.el (byte-compile


From: Stefan Monnier
Subject: [Emacs-diffs] trunk r112979: * lisp/emacs-lisp/bytecomp.el (byte-compile-force-lexical-warnings): New var.
Date: Fri, 14 Jun 2013 02:31:40 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 112979
revision-id: address@hidden
parent: address@hidden
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Thu 2013-06-13 22:31:28 -0400
message:
  * 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.
modified:
  etc/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1485
  etc/NEWS                       news-20100311060928-aoit31wvzf25yr1z-1
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/emacs-lisp/byte-opt.el    byteopt.el-20091113204419-o5vbwnq5f7feedwu-491
  lisp/emacs-lisp/bytecomp.el    bytecomp.el-20091113204419-o5vbwnq5f7feedwu-492
  lisp/emacs-lisp/cconv.el       cconv.el-20101015215845-f7w7g0kxa4xzdjdx-1
  lisp/emacs-lisp/map-ynp.el     mapynp.el-20091113204419-o5vbwnq5f7feedwu-2589
=== modified file 'etc/ChangeLog'
--- a/etc/ChangeLog     2013-06-13 17:52:21 +0000
+++ b/etc/ChangeLog     2013-06-14 02:31:28 +0000
@@ -1,3 +1,7 @@
+2013-06-14  Stefan Monnier  <address@hidden>
+
+       * NEWS (utf-8 for el): Move to the incompatible section.
+
 2013-06-13  Paul Eggert  <address@hidden>
 
        * DEBUG: Document -Og and -fno-omit-frame-pointer.

=== modified file 'etc/NEWS'
--- a/etc/NEWS  2013-06-13 22:24:52 +0000
+++ b/etc/NEWS  2013-06-14 02:31:28 +0000
@@ -414,6 +414,12 @@
 
 * Incompatible Lisp Changes in Emacs 24.4
 
+** The default file coding for Emacs Lisp files is now utf-8.
+(See file-coding-system-alist.)  In most cases, this change is transparent, but
+files that contain unusual characters without specifying an explicit coding
+system may fail to load with obscure errors.
+You should either convert them to utf-8 or add an explicit coding: cookie.
+
 ** overriding-terminal-local-map does not replace the local keymaps any more.
 It used to disable the minor mode, major mode, and text-property keymaps,
 whereas now it simply has higher precedence.
@@ -455,13 +461,6 @@
 +++
 ** New macro with-eval-after-load.  Like eval-after-load, but better behaved.
 
-** The default file coding for Emacs Lisp files is now utf-8.
-(See file-coding-system-alist.)  In most cases, this change is
-totally transparent.  Files that contain unusual characters but do
-not specify an explicit coding system may fail to load with obscure
-errors.  You should either convert them to utf-8 or add an explicit
-coding: cookie.
-
 ** Obsoleted functions:
 *** `dont-compile'
 *** `lisp-complete-symbol'

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-06-13 22:43:33 +0000
+++ b/lisp/ChangeLog    2013-06-14 02:31:28 +0000
@@ -1,3 +1,17 @@
+2013-06-14  Stefan Monnier  <address@hidden>
+
+       * 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.
+       * emacs-lisp/cconv.el (cconv-warnings-only): New function.
+       (cconv-closure-convert): Add assertion.
+
+       * emacs-lisp/map-ynp.el: Use lexical-binding.
+       (map-y-or-n-p): Remove unused vars `tail' and `object'.
+       Factor out some repeated code.
+
 2013-06-13  Stefan Monnier  <address@hidden>
 
        * subr.el (with-eval-after-load): New macro.

=== modified file 'lisp/emacs-lisp/byte-opt.el'
--- a/lisp/emacs-lisp/byte-opt.el       2013-01-02 16:13:04 +0000
+++ b/lisp/emacs-lisp/byte-opt.el       2013-06-14 02:31:28 +0000
@@ -287,6 +287,7 @@
                          (byte-compile--reify-function fn)))))
            (if (eq (car-safe newfn) 'function)
                (byte-compile-unfold-lambda `(,(cadr newfn) ,@(cdr form)))
+             ;; This can happen because of macroexp-warn-and-return &co.
              (byte-compile-log-warning
               (format "Inlining closure %S failed" name))
              form))))

=== modified file 'lisp/emacs-lisp/bytecomp.el'
--- a/lisp/emacs-lisp/bytecomp.el       2013-06-08 01:35:47 +0000
+++ b/lisp/emacs-lisp/bytecomp.el       2013-06-14 02:31:28 +0000
@@ -2174,6 +2174,8 @@
              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 @@
   ;; 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 @@
              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 @@
      '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
 

=== modified file 'lisp/emacs-lisp/cconv.el'
--- a/lisp/emacs-lisp/cconv.el  2013-06-05 02:35:40 +0000
+++ b/lisp/emacs-lisp/cconv.el  2013-06-14 02:31:28 +0000
@@ -143,7 +143,19 @@
     ;; Analyze form - fill these variables with new information.
     (cconv-analyse-form form '())
     (setq cconv-freevars-alist (nreverse cconv-freevars-alist))
-    (cconv-convert form nil nil))) ; Env initially empty.
+    (prog1 (cconv-convert form nil nil) ; Env initially empty.
+      (cl-assert (null cconv-freevars-alist)))))
+
+;;;###autoload
+(defun cconv-warnings-only (form)
+  "Add the warnings that closure conversion would encounter."
+  (let ((cconv-freevars-alist '())
+       (cconv-lambda-candidates '())
+       (cconv-captured+mutated '()))
+    ;; Analyze form - fill these variables with new information.
+    (cconv-analyse-form form '())
+    ;; But don't perform the closure conversion.
+    form))
 
 (defconst cconv--dummy-var (make-symbol "ignored"))
 

=== modified file 'lisp/emacs-lisp/map-ynp.el'
--- a/lisp/emacs-lisp/map-ynp.el        2013-01-01 09:11:05 +0000
+++ b/lisp/emacs-lisp/map-ynp.el        2013-06-14 02:31:28 +0000
@@ -1,4 +1,4 @@
-;;; map-ynp.el --- general-purpose boolean question-asker
+;;; map-ynp.el --- general-purpose boolean question-asker  -*- 
lexical-binding:t -*-
 
 ;; Copyright (C) 1991-1995, 2000-2013 Free Software Foundation, Inc.
 
@@ -79,7 +79,7 @@
 
 Returns the number of actions taken."
   (let* ((actions 0)
-        user-keys mouse-event map prompt char elt tail def
+        user-keys mouse-event map prompt char elt def
         ;; Non-nil means we should use mouse menus to ask.
         use-menus
         delayed-switch-frame
@@ -89,13 +89,15 @@
         (next (if (functionp list)
                    (lambda () (setq elt (funcall list)))
                  (lambda () (when list
-                         (setq elt (pop list))
-                         t)))))
+                             (setq elt (pop list))
+                             t))))
+        (try-again (lambda ()
+                     (let ((x next))
+                       (setq next (lambda () (setq next x) elt))))))
     (if (and (listp last-nonmenu-event)
             use-dialog-box)
        ;; Make a list describing a dialog box.
-       (let ((object (if help (capitalize (nth 0 help))))
-             (objects (if help (capitalize (nth 1 help))))
+       (let ((objects (if help (capitalize (nth 1 help))))
              (action (if help (capitalize (nth 2 help)))))
          (setq map `(("Yes" . act) ("No" . skip)
                      ,@(mapcar (lambda (elt)
@@ -129,8 +131,8 @@
     (unwind-protect
        (progn
          (if (stringp prompter)
-             (setq prompter `(lambda (object)
-                               (format ,prompter object))))
+             (setq prompter (lambda (object)
+                              (format prompter object))))
          (while (funcall next)
            (setq prompt (funcall prompter elt))
            (cond ((stringp prompt)
@@ -176,9 +178,7 @@
                                next (lambda () nil)))
                         ((eq def 'quit)
                          (setq quit-flag t)
-                         (setq next `(lambda ()
-                                       (setq next ',next)
-                                       ',elt)))
+                         (funcall try-again))
                         ((eq def 'automatic)
                          ;; Act on this and all following objects.
                          (if (funcall prompter elt)
@@ -219,40 +219,30 @@
                            (with-current-buffer standard-output
                              (help-mode)))
 
-                         (setq next `(lambda ()
-                                      (setq next ',next)
-                                      ',elt)))
-                         ((and (symbolp def) (commandp def))
-                          (call-interactively def)
-                          ;; Regurgitated; try again.
-                          (setq next `(lambda ()
-                                        (setq next ',next)
-                                        ',elt)))
+                         (funcall try-again))
+                        ((and (symbolp def) (commandp def))
+                         (call-interactively def)
+                         ;; Regurgitated; try again.
+                         (funcall try-again))
                         ((vectorp def)
                          ;; A user-defined key.
                          (if (funcall (aref def 0) elt) ;Call its function.
                              ;; The function has eaten this object.
                              (setq actions (1+ actions))
                            ;; Regurgitated; try again.
-                           (setq next `(lambda ()
-                                        (setq next ',next)
-                                        ',elt))))
+                           (funcall try-again)))
                         ((and (consp char)
                               (eq (car char) 'switch-frame))
                          ;; switch-frame event.  Put it off until we're done.
                          (setq delayed-switch-frame char)
-                         (setq next `(lambda ()
-                                      (setq next ',next)
-                                      ',elt)))
+                         (funcall try-again))
                         (t
                          ;; Random char.
                          (message "Type %s for help."
                                   (key-description (vector help-char)))
                          (beep)
                          (sit-for 1)
-                         (setq next `(lambda ()
-                                      (setq next ',next)
-                                      ',elt)))))
+                         (funcall try-again))))
                  (prompt
                   (funcall actor elt)
                   (setq actions (1+ actions))))))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]