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: Avoiding 'with-temp-buffer' in tight loops Date: Sat, 10 Aug 2024 17:11:09 +0300 Message-ID: <868qx4jwn6.fsf@gnu.org> References: <605d068b-efa8-40c6-aaec-af1b3e1d1606@gmx.at> <86mslmkmnv.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33302"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: martin rudalics Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Aug 10 16:12:01 2024 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 1scmp6-0008T5-R8 for ged-emacs-devel@m.gmane-mx.org; Sat, 10 Aug 2024 16:12:00 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1scmoM-0007Tu-5c; Sat, 10 Aug 2024 10:11:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1scmoK-0007Tj-1F for emacs-devel@gnu.org; Sat, 10 Aug 2024 10:11:12 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1scmoJ-0001ca-Ev; Sat, 10 Aug 2024 10:11:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=etIg8dMbAmRPzP8cmQJFTOCSaYFqPGwCC5JLm8WZz+w=; b=dcbPPv6QVNGj PYduY/IAt/fdoGx5wjDXKumAsIpeRcT/nP1/LVMh2wjwIQsMs8nuHrSIGyyKb5lGAzV87GU212loD F3w8DJxiaXe8XKnM+2vrWc7iO+4+6icRWFTlcZSX5bdrbAAMuKxvLTB+E6YSTNP1rzU9E49SGvRG8 ADrSjlGBpb+UUCZRk6KAoyUvVRrNZiUQKE5ZeV6p7SgFTaFrx7O0BCGLBR15WhX11vL7nFA426c/A g81muuaYZu+APME5bKL+AEONItLEd7woOQS27q/LyPKJkBC/XuY4q7g4eNVQHeBIWsaJm2o3j5DO9 Nz5c+gN2KQysCdazPlsA0Q==; In-Reply-To: (message from martin rudalics on Sat, 10 Aug 2024 15:59:29 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:322618 Archived-At: > Date: Sat, 10 Aug 2024 15:59:29 +0200 > Cc: emacs-devel@gnu.org > From: martin rudalics > > >> Ever since 'substitute-command-keys' has been transferred to help.el, > >> putting initial breakpoints in Fkill_buffer has become virtually > >> impossible. > > > > It should be possible to make the breakpoint conditional on the first > > character of a temporary buffer not being SPC. > > This fails when investigating a general misbehavior of 'kill-buffer' > that might also happen when the buffer name starts with a space. And it > won't catch the case where such a buffer is killed inadvertently as > "current buffer". > > > This needs to be amended to support several threads calling > > substitute-command-keys, I think. > > Protecting access to any such buffer with the help of a mutex should be > trivial. But IIUC we don't do such a thing anywhere and it's certainly > not done with Vprin1_to_string_buffer which was used earlier for this > purpose. So my faith in the correct resolution of locks is limited. > > > An alternative for the above is to have substitute-command-keys bind > > some variable non-nil, and have a breakpoint be conditional on that > > variable's value. If this works, I think it's simpler and cleaner. > > This means that every tight loop using 'with-temp-buffer' would have to > set up and clear that variable. It would fail to catch all cases where > killing a buffer associated with that variable is the cause of the > problem to fix. With respect, if you reject every solution, don't expect this to be solved any time soon.