From: James N. V. Cash <james.nvc@gmail.com>
To: Juri Linkov <juri@linkov.net>
Cc: , 42052@debbugs.gnu.org
Subject: bug#42052: 28.0.50; tab-bar-mode should be frame-local
Date: Sun, 28 Jun 2020 15:45:33 -0400 [thread overview]
Message-ID: <87wo3rug82.fsf@gmail.com> (raw)
In-Reply-To: <871rlzwfm2.fsf@gmail.com>
James N. V. Cash <james.nvc@gmail.com> writes:
> Juri Linkov <juri@linkov.net> writes:
>
>>> When setting tab-bar-show to `1`, I expect the tab bar to only show if
>>> there is more than one tab in the frame.
>>>
>> If someone will point out an example of frame-local modes,
>> this could help in implementing the same for tab-bar-mode.
>
> 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
--- /home/james/src/emacs/lisp/tab-bar.el 2020-06-20 10:16:57.177037735 -0400
+++ tab-bar.el 2020-06-28 15:40:38.711147160 -0400
@@ -799,11 +799,16 @@
(run-hook-with-args 'tab-bar-tab-post-open-functions
(nth to-index tabs)))
- (when (and (not tab-bar-mode)
- (or (eq tab-bar-show t)
- (and (natnump tab-bar-show)
- (> (length tabs) tab-bar-show))))
+ (cond
+ (tab-bar-mode)
+ ((eq tab-bar-show t)
(tab-bar-mode 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))))
(force-mode-line-update)
(unless tab-bar-mode
@@ -936,10 +941,10 @@
tab-bar-closed-tabs)
(set-frame-parameter nil 'tabs (delq close-tab tabs)))
- (when (and tab-bar-mode
+ (when (and (not (zerop (frame-parameter nil 'tab-bar-lines)))
(and (natnump tab-bar-show)
(<= (length tabs) tab-bar-show)))
- (tab-bar-mode -1))
+ (set-frame-parameter nil 'tab-bar-lines 0))
(force-mode-line-update)
(unless tab-bar-mode
@@ -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))))
(force-mode-line-update)
(unless tab-bar-mode
next prev parent reply other threads:[~2020-06-28 19:45 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-25 20:07 bug#42052: 28.0.50; tab-bar-mode should be frame-local James N. V. Cash
2020-06-27 23:40 ` Juri Linkov
2020-06-28 12:15 ` James N. V. Cash
2020-06-28 19:45 ` James N. V. Cash [this message]
2020-06-28 23:18 ` Juri Linkov
2020-06-29 0:26 ` James N. V. Cash
2020-06-29 0:35 ` James N. V. Cash
2020-06-29 23:45 ` Juri Linkov
2020-07-09 17:06 ` James N. V. Cash
2020-07-09 23:49 ` Juri Linkov
2020-07-11 14:45 ` James N. V. Cash
2020-07-12 0:01 ` Juri Linkov
2020-07-11 15:17 ` Stefan Monnier
2020-07-12 0:04 ` Juri Linkov
2020-07-12 16:38 ` Stefan Monnier
2020-10-13 3:07 ` Lars Ingebrigtsen
2021-01-05 18:36 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wo3rug82.fsf@gmail.com \
--to=james.nvc@gmail.com \
--cc=42052@debbugs.gnu.org \
--cc=juri@linkov.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.