GNU bug report logs - #70931
29.3; scratch

Previous Next

Package: emacs;

Reported by: Devon Sean McCullough <Emacs-hacker2023 <at> jovi.net>

Date: Tue, 14 May 2024 09:54:01 UTC

Severity: normal

Found in version 29.3

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 70931 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Devon Sean McCullough <Emacs-hacker2023 <at> jovi.net>
Cc: 70931 <at> debbugs.gnu.org
Subject: Re: bug#70931: 29.3; scratch
Date: Tue, 14 May 2024 13:46:17 +0300
> Date: Tue, 14 May 2024 04:52:59 -0500
> From: Devon Sean McCullough <Emacs-hacker2023 <at> jovi.net>
> 
> $ Open -n -a /Applications/Emacs.app --args -Q
> 
> (find-file "/tmp/x") ; then Control-J
> 
> ;; A buffer appears named x
> ;; containing the text #<buffer x>
> ;; but that text should instead be in the buffer named *scratch*

Thanks.  This was caused by a too-eager simplification made back when
Emacs 26 was being developed.

Does the patch below give good results?

CC'ing Stefan in case he has comments.

diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 84814c9..d96fbbd 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -1557,13 +1557,16 @@ elisp--eval-last-sexp
   (pcase-let*
       ((`(,insert-value ,no-truncate ,char-print-limit)
         (eval-expression-get-print-arguments eval-last-sexp-arg-internal)))
-    ;; Setup the lexical environment if lexical-binding is enabled.
-    (elisp--eval-last-sexp-print-value
-     (eval (macroexpand-all
-            (eval-sexp-add-defvars
-             (elisp--eval-defun-1 (macroexpand (elisp--preceding-sexp)))))
-           lexical-binding)
-     (if insert-value (current-buffer) t) no-truncate char-print-limit)))
+    ;; The expression might change to a different buffer, so record that
+    ;; now.
+    (let ((output (if insert-value (current-buffer) t)))
+      ;; Setup the lexical environment if lexical-binding is enabled.
+      (elisp--eval-last-sexp-print-value
+       (eval (macroexpand-all
+              (eval-sexp-add-defvars
+               (elisp--eval-defun-1 (macroexpand (elisp--preceding-sexp)))))
+             lexical-binding)
+       output no-truncate char-print-limit))))
 
 (defun elisp--eval-last-sexp-print-value
     (value output &optional no-truncate char-print-limit)




This bug report was last modified 1 year and 5 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.