From: Lars Ingebrigtsen <larsi@gnus.org>
To: Kevin Ryde <user42@zip.com.au>
Cc: 135@debbugs.gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>
Subject: bug#135: eval-defun binds print-level during eval
Date: Sun, 24 Apr 2022 17:10:26 +0200 [thread overview]
Message-ID: <87mtga8ql9.fsf_-_@gnus.org> (raw)
In-Reply-To: <87oc0tdh4y.fsf@blah.blah> (Kevin Ryde's message of "Sun, 17 Jul 2011 07:56:13 +1000")
I had an idea, after obviously pondering this issue for ten years.
To recap, for people with bad memories -- put this in a buffer and
`C-M-x' it:
(progn print-level)
It will print 4, because we rebind print-level before evaling it, but
ideally it should have its real value while doing the eval, but be
eval-expression-print-level during printing.
As the printing is actually deep inside the bowels of readevalloop,
untangling that's a challenge... but... the following simple change
handles the test case, and doesn't seem to lead to any obvious
regressions.
Any comments here?
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 33f6902491..c442d0fa76 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -1614,8 +1614,6 @@ elisp--eval-defun
;; 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.
@@ -1631,9 +1629,13 @@ elisp--eval-defun
(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)))))
+ (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
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
next prev parent reply other threads:[~2022-04-24 15:10 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-10 23:37 generate autoloads versus eval-expression-print-level (patch) Kevin Ryde
2008-04-11 1:59 ` Stefan Monnier
2008-04-12 23:07 ` Kevin Ryde
2008-04-13 19:24 ` Stefan Monnier
2008-04-14 0:46 ` Kevin Ryde
2008-04-14 1:53 ` Stefan Monnier
2008-05-29 23:15 ` bug#135: marked as done (eval-defun binds print-level during eval) Emacs bug Tracking System
[not found] ` <handler.135.D135.121210258811769.notifdone@emacsbugs.donarmstrong.com>
2008-06-01 23:31 ` bug#135: closed by Glenn Morris <rgm@gnu.org> (Re: eval-defun binds print-level during eval ) Kevin Ryde
2008-06-02 2:03 ` Glenn Morris
2008-06-02 23:04 ` Kevin Ryde
2011-07-06 17:29 ` bug#135: generate autoloads versus eval-expression-print-level (patch) Lars Magne Ingebrigtsen
2011-07-06 19:31 ` Drew Adams
2011-07-07 16:22 ` Lars Magne Ingebrigtsen
2011-07-07 17:20 ` Glenn Morris
2011-07-07 17:23 ` Lars Magne Ingebrigtsen
2011-07-07 19:58 ` Stefan Monnier
2011-07-10 12:48 ` Lars Magne Ingebrigtsen
2011-07-10 13:14 ` Andreas Schwab
2011-07-10 13:18 ` Lars Magne Ingebrigtsen
2011-07-12 3:35 ` Stefan Monnier
2011-07-15 0:18 ` Kevin Ryde
2011-07-15 17:03 ` Lars Magne Ingebrigtsen
2011-07-16 21:56 ` Kevin Ryde
2022-04-24 15:10 ` Lars Ingebrigtsen [this message]
2022-04-27 18:04 ` bug#135: eval-defun binds print-level during eval Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mtga8ql9.fsf_-_@gnus.org \
--to=larsi@gnus.org \
--cc=135@debbugs.gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=user42@zip.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.