From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel 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 Message-ID: <83a6m2pqxt.fsf@gnu.org> References: <20210730005551.5c77f879@pineapple> <831r7gs5px.fsf@gnu.org> <20210730160753.3ca3bcb4@pineapple> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17609"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Matthew White Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jul 31 15:13:49 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m9ooH-0004M9-4P for ged-emacs-devel@m.gmane-mx.org; Sat, 31 Jul 2021 15:13:49 +0200 Original-Received: from localhost ([::1]:46514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m9ooG-00057J-1l for ged-emacs-devel@m.gmane-mx.org; Sat, 31 Jul 2021 09:13:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m9onm-0004P3-H9 for emacs-devel@gnu.org; Sat, 31 Jul 2021 09:13:18 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:48154) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m9onl-0004tl-7n; Sat, 31 Jul 2021 09:13:17 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2776 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m9onk-0002OQ-QN; Sat, 31 Jul 2021 09:13:17 -0400 In-Reply-To: <20210730160753.3ca3bcb4@pineapple> (message from Matthew White on Fri, 30 Jul 2021 16:07:53 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:271896 Archived-At: > Date: Fri, 30 Jul 2021 16:07:53 +0200 > From: Matthew White > > > 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?