From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: kill-buffer calls frame's buffer-predicate for all buffers even if the killed buffer was not shown in any window. Date: Sun, 15 Jan 2017 22:31:10 +0200 Message-ID: <83inpg9ib5.fsf@gnu.org> References: Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1484512405 29446 195.159.176.226 (15 Jan 2017 20:33:25 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 15 Jan 2017 20:33:25 +0000 (UTC) Cc: emacs-devel@gnu.org To: Constantin Kulikov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 15 21:33:16 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cSrTw-0004ok-TV for ged-emacs-devel@m.gmane.org; Sun, 15 Jan 2017 21:32:53 +0100 Original-Received: from localhost ([::1]:52813 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cSrU1-0002Ab-GT for ged-emacs-devel@m.gmane.org; Sun, 15 Jan 2017 15:32:57 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56467) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cSrSL-0000u1-Jr for emacs-devel@gnu.org; Sun, 15 Jan 2017 15:31:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cSrSG-0001TB-Nl for emacs-devel@gnu.org; Sun, 15 Jan 2017 15:31:13 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:41331) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cSrSG-0001T7-K1; Sun, 15 Jan 2017 15:31:08 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2686 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cSrSE-0005q9-Nq; Sun, 15 Jan 2017 15:31:08 -0500 In-reply-to: (message from Constantin Kulikov on Sun, 15 Jan 2017 22:32:10 +0300) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:211313 Archived-At: > From: Constantin Kulikov > Date: Sun, 15 Jan 2017 22:32:10 +0300 > > For example: > > emacs -Q > > M-: (set-frame-parameter nil 'buffer-predicate #'(lambda (b) (message "f-b-p: %s" b))) RET > M-: (with-temp-buffer nil) RET > C-x b *Messages* RET > > See that all buffers listed except of the *temp*(no window buffers were changed). Why? Because it needs to find another buffer to become the current one. And it only searches until it finds the first buffer that is not already visible in some window. Your recipe just leaves it with too few buffers, so it looks to you like it goes over all of them. > This is inefficient, especially for the with-temp-buffer which is used very frequently in emacs and in side > packages. As long as with-temp-buffer calls kill-buffer, there's no way around it, because kill-buffer is a command that must fit user expectations. We could perhaps introduce a new kill-temp-buffer primitive to avoid the overhead.