From: Eli Zaretskii <eliz@gnu.org>
To: Matthew White <mehw.is.me@inventati.org>
Cc: emacs-devel@gnu.org
Subject: Re: eval-print-last-sexp: "Selecting deleted buffer" error when the current buffer is killed evaluating the expression
Date: Sat, 31 Jul 2021 16:13:02 +0300 [thread overview]
Message-ID: <83a6m2pqxt.fsf@gnu.org> (raw)
In-Reply-To: <20210730160753.3ca3bcb4@pineapple> (message from Matthew White on Fri, 30 Jul 2021 16:07:53 +0200)
> Date: Fri, 30 Jul 2021 16:07:53 +0200
> From: Matthew White <mehw.is.me@inventati.org>
>
> > Could you please tell what are the real-life situations where this
> > problem happens and causes trouble? Killing the current buffer this
> > way is unusual, so why isn't what we have now sufficient? You tried
> > to insert something into a killed buffer, Emacs told you it cannot do
> > that; why is that a problem?
>
> I understand that such occasions are rare, I mean killing the current
> buffer evaluating an expression also in the current buffer like:
>
> (kill-buffer (current-buffer))
>
> eval-print-last-sexp is trying to insert something into a dead buffer,
> by calling terpri with standard-output set to the dead buffer.
>
> This could be prevented by checking standard-output:
>
> (when (buffer-live-p standard-output)
> (terpri))
>
> Less uncommon than killing the current buffer evaluating an expression
> with C-j, is redirecting the output to the echo area with a '-' prefix
> C-u - C-j. I'd expect no output into the current buffer, and the call
> to eval-last-sexp respects this, while terpri does not and prints into
> the standard-output (aka current buffer at the time C-j was pressed).
>
> There's also the strange behavior of printing to a buffer which is not
> the one where the expression was evaluated. This is also rare, happens
> when the buffer is killed, like described previously:
>
> ;; Always prints to the actual current buffer.
> (eval-last-sexp (or eval-last-sexp-arg-internal t))
>
> >
> > IME, trying to "fix" such obscure problems causes problems of its own
> > that we then get to rectify for several releases in the future, so the
> > net gains are very small if there are any.
>
> I agree, there is a little gain into that. I just explored the source
> of the problems to understand what they are.
>
> IMHO, when C-u - C-j is used terpri shouldn't print to stadard-output,
> since the evaluation's return value is destined to the echo area. And
> checking if standard-output is a live buffer is also trivial.
>
> What do you think?
I think we should leave this issue alone, but maybe someone else has a
different opinion and a rationale to go with that?
next prev parent reply other threads:[~2021-07-31 13:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-29 22:55 eval-print-last-sexp: "Selecting deleted buffer" error when the current buffer is killed evaluating the expression Matthew White
2021-07-30 5:58 ` Eli Zaretskii
2021-07-30 14:07 ` Matthew White
2021-07-31 13:13 ` Eli Zaretskii [this message]
2021-07-31 23:50 ` Michael Heerdegen
2021-08-01 2:09 ` Matthew White
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83a6m2pqxt.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=mehw.is.me@inventati.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).