Propagate 'lexical-binding' value to pp buffers
authorAugusto Stoffel <arstoffel@gmail.com>
Sun, 14 Apr 2024 07:36:05 +0000 (09:36 +0200)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 17 Apr 2024 21:02:11 +0000 (17:02 -0400)
See bug#70137.

* lisp/emacs-lisp/pp.el (pp-display-expression): Set lexical-binding to
match the value in the calling buffer.

lisp/emacs-lisp/pp.el

index d586fc59939091d355bb3409eb18f8e7db94c849..f89807c37be3ef9f48f4111aeb00a962aa54c92a 100644 (file)
@@ -327,7 +327,8 @@ If LISP, format with `pp-emacs-lisp-code'; use `pp' otherwise.
 
 If a temporary buffer is needed for representation, it will be named
 after OUT-BUFFER-NAME."
-  (let* ((old-show-function temp-buffer-show-function)
+  (let* ((lexical lexical-binding)
+         (old-show-function temp-buffer-show-function)
         ;; Use this function to display the buffer.
         ;; This function either decides not to display it at all
         ;; or displays it in the usual way.
@@ -357,6 +358,7 @@ after OUT-BUFFER-NAME."
         (pp expression))
       (with-current-buffer standard-output
        (emacs-lisp-mode)
+        (setq lexical-binding lexical)
        (setq buffer-read-only nil)
         (setq-local font-lock-verbose nil)))))