emacs-diffs
[Top][All Lists]
Advanced

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

master c638a40d88f 2/2: Ensure proper mode of *Compile-Log* buffer (bug#


From: Mattias Engdegård
Subject: master c638a40d88f 2/2: Ensure proper mode of *Compile-Log* buffer (bug#67920)
Date: Fri, 22 Dec 2023 07:17:15 -0500 (EST)

branch: master
commit c638a40d88f6ca105babbf9078b086491b649797
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    Ensure proper mode of *Compile-Log* buffer (bug#67920)
    
    Reported by OGAWA Hirofumi.
    
    * lisp/emacs-lisp/bytecomp.el (displaying-byte-compile-warnings):
    Move most of the innards to...
    (bytecomp--displaying-warnings): ...this new function, for ease
    of maintenance.
    * lisp/emacs-lisp/bytecomp.el (byte-compile-file):
    Wrap early warning about missing lexbind declaration in
    `displaying-byte-compile-warnings` so that it doesn't cause the
    creation of a compile-log buffer with the wrong mode.
---
 lisp/emacs-lisp/bytecomp.el | 67 +++++++++++++++++++++++----------------------
 1 file changed, 35 insertions(+), 32 deletions(-)

diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index d2f1e6886ef..6c5051d70c4 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1876,35 +1876,37 @@ It is too wide if it has any lines longer than the 
largest of
 
 (defmacro displaying-byte-compile-warnings (&rest body)
   (declare (debug (def-body)))
-  `(let* ((--displaying-byte-compile-warnings-fn (lambda () ,@body))
-         (warning-series-started
-          (and (markerp warning-series)
-               (eq (marker-buffer warning-series)
-                   (get-buffer byte-compile-log-buffer))))
-          (byte-compile-form-stack byte-compile-form-stack))
-     (if (or (eq warning-series 'byte-compile-warning-series)
-            warning-series-started)
-        ;; warning-series does come from compilation,
-        ;; so don't bind it, but maybe do set it.
-        (let (tem)
-          ;; Log the file name.  Record position of that text.
-          (setq tem (byte-compile-log-file))
-          (unless warning-series-started
-            (setq warning-series (or tem 'byte-compile-warning-series)))
-          (if byte-compile-debug
-              (funcall --displaying-byte-compile-warnings-fn)
-            (condition-case error-info
-                (funcall --displaying-byte-compile-warnings-fn)
-              (error (byte-compile-report-error error-info)))))
-       ;; warning-series does not come from compilation, so bind it.
-       (let ((warning-series
-             ;; Log the file name.  Record position of that text.
-             (or (byte-compile-log-file) 'byte-compile-warning-series)))
-        (if byte-compile-debug
-            (funcall --displaying-byte-compile-warnings-fn)
-          (condition-case error-info
-              (funcall --displaying-byte-compile-warnings-fn)
-            (error (byte-compile-report-error error-info))))))))
+  `(bytecomp--displaying-warnings (lambda () ,@body)))
+
+(defun bytecomp--displaying-warnings (body-fn)
+  (let* ((warning-series-started
+         (and (markerp warning-series)
+              (eq (marker-buffer warning-series)
+                  (get-buffer byte-compile-log-buffer))))
+         (byte-compile-form-stack byte-compile-form-stack))
+    (if (or (eq warning-series 'byte-compile-warning-series)
+           warning-series-started)
+       ;; warning-series does come from compilation,
+       ;; so don't bind it, but maybe do set it.
+       (let (tem)
+         ;; Log the file name.  Record position of that text.
+         (setq tem (byte-compile-log-file))
+         (unless warning-series-started
+           (setq warning-series (or tem 'byte-compile-warning-series)))
+         (if byte-compile-debug
+             (funcall body-fn)
+           (condition-case error-info
+               (funcall body-fn)
+             (error (byte-compile-report-error error-info)))))
+      ;; warning-series does not come from compilation, so bind it.
+      (let ((warning-series
+            ;; Log the file name.  Record position of that text.
+            (or (byte-compile-log-file) 'byte-compile-warning-series)))
+       (if byte-compile-debug
+           (funcall body-fn)
+         (condition-case error-info
+             (funcall body-fn)
+           (error (byte-compile-report-error error-info))))))))
 
 ;;;###autoload
 (defun byte-force-recompile (directory)
@@ -2202,9 +2204,10 @@ See also `emacs-lisp-byte-compile-and-load'."
       ;; Don't inherit lexical-binding from caller (bug#12938).
       (unless (local-variable-p 'lexical-binding)
         (let ((byte-compile-current-buffer (current-buffer)))
-          (byte-compile-warn-x
-           (position-symbol 'a (point-min))
-           "file has no `lexical-binding' directive on its first line"))
+          (displaying-byte-compile-warnings
+           (byte-compile-warn-x
+            (position-symbol 'a (point-min))
+            "file has no `lexical-binding' directive on its first line")))
         (setq-local lexical-binding nil))
       ;; Set the default directory, in case an eval-when-compile uses it.
       (setq default-directory (file-name-directory filename)))



reply via email to

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