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#74087: Bug patch: invoke tab-bar-tab-post-open-functions during tabs initialization Date: Tue, 29 Oct 2024 20:52:02 +0200 Organization: LINKOV.NET Message-ID: <861pzy3fot.fsf@mail.linkov.net> References: <86a5em4w18.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21008"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) Cc: 74087@debbugs.gnu.org To: Ship Mints Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 29 19:55:20 2024 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 1t5rNA-0005Ef-GE for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 29 Oct 2024 19:55:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5rMw-0007jW-I8; Tue, 29 Oct 2024 14:55:06 -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 1t5rMu-0007gE-Gl for bug-gnu-emacs@gnu.org; Tue, 29 Oct 2024 14:55:04 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t5rMt-0000qk-OR for bug-gnu-emacs@gnu.org; Tue, 29 Oct 2024 14:55:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=LXDQ1QeeGoB6ZTTg1ObxzT9ver0QQ2vPKanqscdIHoU=; b=T3+/2S/yDVfH1VzM9ChUYiY/QmOw5pm95kL2Bu2Hsw+nyikaT7/co53viOmhxiowzGhXJJd1udfrZDQ84gfuMXvy2ttJSp8lHg2YHL2q4s5LymMdHpATFIWNQEj21uCHk6HFAB0MoFTlwxy7boBlW4hyXQIu/qslP3ViqMZByfmEmPI9B/xzBdp2GhceMDOZGRL+zpopwJnOJ/YGKQfMTCbUsCJQ1oaXI/pxJur6YF+5aHVcFbM9IBZ/wymb/edtQyjuTiYspjYLIG+Wy9h5LAtW/gZiLQuv7KLPuQ+w2Mj4RAYoeViD3EhZTKAZXnHGEdWTj75lR+4QHHqlhwfujg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t5rMs-0006Y4-Il for bug-gnu-emacs@gnu.org; Tue, 29 Oct 2024 14:55: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: Tue, 29 Oct 2024 18:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74087 X-GNU-PR-Package: emacs X-Debbugs-Original-Cc: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.173022806625148 (code B ref -1); Tue, 29 Oct 2024 18:55:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 29 Oct 2024 18:54:26 +0000 Original-Received: from localhost ([127.0.0.1]:58108 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t5rMH-0006XX-NI for submit@debbugs.gnu.org; Tue, 29 Oct 2024 14:54:26 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:60756) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t5rMF-0006XR-U8 for submit@debbugs.gnu.org; Tue, 29 Oct 2024 14:54:24 -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 1t5rMF-0007Gl-8w for bug-gnu-emacs@gnu.org; Tue, 29 Oct 2024 14:54:23 -0400 Original-Received: from relay9-d.mail.gandi.net ([2001:4b98:dc4:8::229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5rMC-0000nZ-GP for bug-gnu-emacs@gnu.org; Tue, 29 Oct 2024 14:54:23 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id A4DACFF802; Tue, 29 Oct 2024 18:54:13 +0000 (UTC) In-Reply-To: (Ship Mints's message of "Tue, 29 Oct 2024 14:29:48 -0400") X-GND-Sasl: juri@linkov.net Received-SPF: pass client-ip=2001:4b98:dc4:8::229; envelope-from=juri@linkov.net; helo=relay9-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:294523 Archived-At: >> I'm trying to align all tab creation behavior with >> tab-bar-tab-post-open-functions. Even the first tab should be >> considered "opened" by the system and call people's functions on the >> hook. That tab, if you close it, does call the close hooks correctly >> and that's aligned, at least. Calling the close hooks currently doesn't look correct: (run-hook-with-args 'tab-bar-tab-pre-close-functions (nth close-index tabs) last-tab-p) (if last-tab-p (pcase tab-bar-close-last-tab-choice ('nil (user-error "Attempt to delete the sole tab in a frame")) where first it makes an attempt to close the tab, calls the hook, then fails with the user-error. I think the hook should be called when the tab is really closed. >> If the open hook doesn't get called, then >> those tabs have to be treated in a special way and that creates bugs >> and burden. Not sure how relevant it is what I do in my custom hook >> that should get called for the implied opened first frames but doesn't. > > If you're really curious, one use case is auto-assigning a tab group. When > one makes a frame, the tab bar defaults to showing the window from which it > was created and any custom tab-bar symbols attached to the tab have to be > recreated. Another use case is optionally keeping tabs "pinned" to their > user-specified positions and the post-open hook can help track the first > and subsequent positions. I'll surely add more over time. tab-bar is great > and fun to use and enhance with cool productivity tools. Thanks, this is an interesting case. Indeed, currently there is an inconsistency. For example, start `emacs -Q`. Even if there is no tab-bar initially, we can say that the first tab is already created. Later, after creating the second tab with 'C-x t 2', we have two tabs where the post-open hook was called only in the second tab. A possible solution would be to detect such situation in 'tab-bar-new-tab-to' with the same code that enables the tab-bar initially with: (when tab-bar-show (if (not tab-bar-mode) ;; Turn on `tab-bar-mode' since a tab was created. ;; Note: this also updates `tab-bar-lines'. (tab-bar-mode 1) (tab-bar--update-tab-bar-lines))) then run the hook in the first tab as well.