]> git.eshelyaron.com Git - emacs.git/commitdiff
Make `C-M-x' use the original value of print-length while evalling
authorLars Ingebrigtsen <larsi@gnus.org>
Wed, 27 Apr 2022 18:03:25 +0000 (20:03 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 27 Apr 2022 18:04:48 +0000 (20:04 +0200)
* lisp/progmodes/elisp-mode.el (elisp--eval-defun): Eval the form
with the original values of print-level and print-length
(bug#135).

lisp/progmodes/elisp-mode.el

index 33f69024919396b846591e81eb7b46329124e931..a4088fa467694b69c4e94815be0e1f43f91c2dfa 100644 (file)
@@ -1614,8 +1614,6 @@ Return the result of evaluation."
   ;; printing, not while evaluating.
   (defvar elisp--eval-defun-result)
   (let ((debug-on-error eval-expression-debug-on-error)
-       (print-length eval-expression-print-length)
-       (print-level eval-expression-print-level)
         elisp--eval-defun-result)
     (save-excursion
       ;; Arrange for eval-region to "read" the (possibly) altered form.
@@ -1630,10 +1628,17 @@ Return the result of evaluation."
           (setq beg (point))
           (setq form (funcall load-read-function (current-buffer)))
           (setq end (point)))
-        ;; Alter the form if necessary.
-        (let ((form (eval-sexp-add-defvars
-                     (elisp--eval-defun-1
-                      (macroexpand form)))))
+        ;; Alter the form if necessary.  We bind `print-level' (etc.)
+        ;; in the form itself, because we want evalling the form to
+        ;; use the original values, while we want the printing to use
+        ;; `eval-expression-print-length' (etc.).
+        (let ((form `(let ((print-level ,print-level)
+                           (print-length ,print-length))
+                       ,(eval-sexp-add-defvars
+                         (elisp--eval-defun-1
+                          (macroexpand form)))))
+             (print-length eval-expression-print-length)
+             (print-level eval-expression-print-level))
           (eval-region beg end standard-output
                        (lambda (_ignore)
                          ;; Skipping to the end of the specified region