From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#42052: 28.0.50; tab-bar-mode should be frame-local Date: Mon, 29 Jun 2020 02:18:57 +0300 Organization: LINKOV.NET Message-ID: <87pn9idbj2.fsf@mail.linkov.net> References: <87zh8qq57v.fsf@gmail.com> <87sgegdqmt.fsf@mail.linkov.net> <871rlzwfm2.fsf@gmail.com> <87wo3rug82.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="38994"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: 42052@debbugs.gnu.org To: James N. V. Cash Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jun 29 01:22:11 2020 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 1jpgcl-000A3J-1n for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 29 Jun 2020 01:22:11 +0200 Original-Received: from localhost ([::1]:46752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpgck-000876-4C for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 28 Jun 2020 19:22:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpgcc-00086p-3F for bug-gnu-emacs@gnu.org; Sun, 28 Jun 2020 19:22:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35668) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jpgcb-0003ug-QO for bug-gnu-emacs@gnu.org; Sun, 28 Jun 2020 19:22:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jpgcb-0005th-Kv for bug-gnu-emacs@gnu.org; Sun, 28 Jun 2020 19:22:01 -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, 28 Jun 2020 23:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42052 X-GNU-PR-Package: emacs Original-Received: via spool by 42052-submit@debbugs.gnu.org id=B42052.159338650522640 (code B ref 42052); Sun, 28 Jun 2020 23:22:01 +0000 Original-Received: (at 42052) by debbugs.gnu.org; 28 Jun 2020 23:21:45 +0000 Original-Received: from localhost ([127.0.0.1]:47214 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jpgcL-0005t6-CU for submit@debbugs.gnu.org; Sun, 28 Jun 2020 19:21:45 -0400 Original-Received: from relay3-d.mail.gandi.net ([217.70.183.195]:35153) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jpgcH-0005so-EU for 42052@debbugs.gnu.org; Sun, 28 Jun 2020 19:21:43 -0400 X-Originating-IP: 91.129.96.187 Original-Received: from mail.gandi.net (m91-129-96-187.cust.tele2.ee [91.129.96.187]) (Authenticated sender: juri@linkov.net) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 407F760003; Sun, 28 Jun 2020 23:21:33 +0000 (UTC) In-Reply-To: <87wo3rug82.fsf@gmail.com> (James N. V. Cash's message of "Sun, 28 Jun 2020 15:45:33 -0400") 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" Xref: news.gmane.io gmane.emacs.bugs:182504 Archived-At: >> Looking at how the tab-bar-mode currently works, the thing that seems >> simplest to me would be to change the various functions that >> conditionally turn tab-bar-mode on/off (e.g. in tab-bar-new-tab-to) >> to have an additional check if (natnump tab-bar-show), in which case >> instead of calling (tab-bar-mode 1) or -1, setting the frame parameter >> tab-bar-lines for that particular frame to be 1 or 0, as appropriate. >> >> The wrinkle would be, I suppose, having to remove all the frame-local >> settings if tab-bar-show changes, but presumably that wouldn't be >> happening too often. >> >> A frame-local toggling of the tab bar could work the same way. >> >> If that makes sense (i.e. having the setting be frame local only when >> tab-bar-show is 1), I can try submitting a patch later today. > > Here's a simple patch I made that seems to act more like I expect Thanks for the patch. One problem is that directly changing the frame parameter tab-bar-lines avoids performing some other settings in tab-bar-mode such as loading button images and changing some keybindings. OTOH, these keybindings can't be frame-local anyway, so maybe this is not important for the case when tab-bar-show is 1. > + ((and (natnump tab-bar-show) > + (> (length tabs) tab-bar-show) > + (zerop (frame-parameter nil 'tab-bar-lines))) > + (progn > + (message "show") > + (set-frame-parameter nil 'tab-bar-lines 1)))) Please don't forget to remove this debugging message in the final patch. > @@ -975,10 +980,12 @@ > (run-hook-with-args 'tab-bar-tab-pre-close-functions (nth index tabs) nil))) > (set-frame-parameter nil 'tabs (list (nth current-index tabs))) > > - (when (and tab-bar-mode > - (and (natnump tab-bar-show) > - (<= 1 tab-bar-show))) > - (tab-bar-mode -1)) > + (when (and (not (zerop (frame-parameter nil 'tab-bar-lines))) > + (and (natnump tab-bar-show) > + (<= (length tabs) tab-bar-show))) > + (modify-frame-parameters > + nil > + (assq-delete-all 'tab-bar-lines (frame-parameters nil)))) Unlike other places that simply use (set-frame-parameter nil 'tab-bar-lines 0) this code is more complex. But it seems it should work with just (set-frame-parameter nil 'tab-bar-lines 0) as well. BTW, I see a problem in the old code: the variable 'tabs' is not always updated and sometimes contains obsolete data. It should help to replace (<= (length tabs) tab-bar-show) with (<= (length (funcall tab-bar-tabs-function)) tab-bar-show) that gets fresh data.