From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#62575: 29.0.60; Tabs are not showing the right names of the buffers Date: Sun, 02 Apr 2023 09:48:58 +0300 Organization: LINKOV.NET Message-ID: <86355iixt1.fsf@mail.linkov.net> References: <7f7b17d6-63e2-d7fc-1091-802f972f9a62@freenet.de> <83cz4o17tp.fsf@gnu.org> <67687ee4-089d-7997-f9a3-afde7be8b05e@freenet.de> <83sfdjy9va.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11951"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: 62575@debbugs.gnu.org, Claudio Grondi To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 02 09:04:33 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1pirlQ-0002yl-Cu for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 02 Apr 2023 09:04:32 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pirkH-0001rH-7x; Sun, 02 Apr 2023 03:03:21 -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 1pirjy-0001mf-QU for bug-gnu-emacs@gnu.org; Sun, 02 Apr 2023 03:03:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pirjy-0000Zt-H2 for bug-gnu-emacs@gnu.org; Sun, 02 Apr 2023 03:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pirjy-0003vE-CE for bug-gnu-emacs@gnu.org; Sun, 02 Apr 2023 03:03:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 02 Apr 2023 07:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62575 X-GNU-PR-Package: emacs Original-Received: via spool by 62575-submit@debbugs.gnu.org id=B62575.168041893914993 (code B ref 62575); Sun, 02 Apr 2023 07:03:02 +0000 Original-Received: (at 62575) by debbugs.gnu.org; 2 Apr 2023 07:02:19 +0000 Original-Received: from localhost ([127.0.0.1]:39162 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pirjG-0003tl-L4 for submit@debbugs.gnu.org; Sun, 02 Apr 2023 03:02:18 -0400 Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:33069) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pirjE-0003tT-Fj for 62575@debbugs.gnu.org; Sun, 02 Apr 2023 03:02:16 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id C4004FF805; Sun, 2 Apr 2023 07:02:09 +0000 (UTC) In-Reply-To: <83sfdjy9va.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 01 Apr 2023 17:07:05 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:259098 Archived-At: >> The bug: the third Tab still keeps its  .emacs  label, the click on the >> second Tab labeled  .emacs  did not show the .emacs file, but the buffer >> *Messages*. > > After looking at the code, I'm not sure this is a bug. The tab names > are just labels, although they are conveniently set to the name of the > buffer in the window to be selected when the tab is current. But > otherwise they are just labels. When you click on the tab, its name > is updated to reflect the buffer shown in the selected window, so I > think Emacs is behaving correctly, although it might be a bit > unexpected. > > Juri, am I right? If not, where is the code that's supposed to update > the labels when some buffers or windows are deleted or renamed? Right, tab names are just labels, or by another analogy are "bookmarks". It was a design decision to keep labels even after a buffer is killed, so the users know what buffer was displayed in the tab created to display that buffer. What we could do is to help to create additional code that could be used to update tab names according to user wishes. But the problem is that there are too many ways to do this, so the implementation logic is too fuzzy and not well defined. Here are some considerations that could be took into account: 1. First there is no need to update tabs with names set explicitly by 'tab-rename' (C-x t r). 2. Also no need to update a tab name when non-current buffers are killed on a window configuration saved to the tab, in case when tab-bar-tab-name-function is unchanged from its default value tab-bar-tab-name-current. However, when it's customized to tab-bar-tab-name-all, then killing any buffer on the window configuration can change the tab name. There are other values that may or may not change the tab name after the buffer is killed. 3. It seems the reported wish was to rename the tab after the buffer was killed. But I imagine some users instead might prefer to automatically close all tabs that displayed the killed buffer. This also makes sense. 4. As noted by Ruijie, the code should react not only to killing a buffer, but also to renaming a buffer. This means that instead of using kill-buffer-hook, it should rely on buffer-list-update-hook, but the problem is that buffer-list-update-hook is not called with a buffer name, so need to develop much more complicated code. I invite Claudio and anyone to try the code I wrote for bug#52019 and bug#60096 as a staring point. Then after fulfilling the expectations, it could be later added to tab-bar.el as an option: ;; Visit affected tabs to update their names: (add-hook 'kill-buffer-hook (lambda () (let ((tabs (reverse (mapcar (lambda (tab) (1+ (alist-get 'index tab))) (tab-bar-get-buffer-tab nil t nil t))))) (run-with-timer 0 nil (lambda (tabs) (dolist (tab tabs) (tab-bar-select-tab tab))) tabs))))