From: Bastian Beranek <bastian.beischer@gmail.com>
To: Juri Linkov <juri@linkov.net>
Cc: 46299@debbugs.gnu.org
Subject: bug#46299: 28.0.50; Value of tab-bar-show not respected in new frames.
Date: Thu, 11 Feb 2021 18:34:26 +0100 [thread overview]
Message-ID: <CAK9AuB8J0ZO0XYme1EHXZ_Tm30H5wBqtyBPtNTFg1VuRj0gWMg@mail.gmail.com> (raw)
In-Reply-To: <CAK9AuB-xM+Nd=49Fm4s_3pfapP=RgbKZfn+4jbNT-sT0crWjWg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 5363 bytes --]
On Thu, Feb 11, 2021 at 1:14 PM Bastian Beranek
<bastian.beischer@gmail.com> wrote:
>
> Hello Juri,
>
> I have updated my patch (see v6 attached). Please find my comments inline.
>
> I have also finished the copyright assignment procedure now.
>
> On Wed, Feb 10, 2021 at 7:41 PM Juri Linkov <juri@linkov.net> wrote:
> > I don't know if Martin will agree, but most frame functions
> > interpret their optional FRAME argument in such a way that
> > if it's nil or omitted, FRAME defaults to the selected frame.
> >
> > For example, 'set-frame-font' documents this:
> >
> > If FRAMES is nil, apply the font to the selected frame only.
> > If FRAMES is non-nil, it should be a list of frames to act upon,
> > or t meaning all existing graphical frames.
> >
> > and uses such implementation:
> >
> > (let ((frame-lst (cond ((null frames)
> > (list (selected-frame)))
> > ((eq frames t)
> > (frame-list))
> > (t frames))))
> > (dolist (f frame-lst)
>
> That's true and I noticed this inconsistency as well. So thanks for
> the suggestion, I have updated the patch accordingly.
>
> On Wed, Feb 10, 2021 at 7:41 PM Juri Linkov <juri@linkov.net> wrote:
> >
> > > Hope this is satisfactory, if not please feel free to adjust as you wish.
> >
> > Thanks, please see more comments:
> >
> > > +(defun tab-bar--tab-bar-lines-for-frame (frame)
> > > + (if (not tab-bar-mode)
> > > + 0
> > > + (cond
> > > + ((eq tab-bar-show t) 1)
> > > + ((natnump tab-bar-show)
> > > + (if (> (length (funcall tab-bar-tabs-function frame)) tab-bar-show) 1 0))
> > > + (t 0))))
> >
> > A small optimization:
> >
> > ((not tab-bar-mode) 0)
> >
> > could be added as the first condition of the same 'cond'.
>
> Thanks! Done.
>
> >
> > > :set (lambda (sym val)
> > > (set-default sym val)
> > > ;; Preload button images
> > > + ;; Note: tab-bar-mode updates tab-bar-lines as well.
> > > + (tab-bar-mode 1))
> >
> > Not sure whether the users would want to enable tab-bar-mode
> > unconditionally after customizing tab-bar-show.
> >
> > Maybe when customized tab-bar-show to nil, only call
> > tab-bar--update-tab-bar-lines in all frames?
> > Or maybe simply to disable the tab bar with (tab-bar-mode 0)
> > when customized to nil?
>
> I am not sure either. I think the best is to just leave tab-bar-mode
> as it is to be honest. All this entanglement doesn't seem very clean
> to me. Yes this would mean that the user needs to manually enable
> tab-bar-mode after customizing the variable, but on the other hand
> tab-bar-mode is on by default, so the user must have switched it off
> in his .emacs by choice. So I just added the call the
> tab-bar--update-tab-bar-lines for all frames, because this is
> necessary for sure. On the other hand I don't fully understand the
> comment about 'Preload button images'. I think the images and
> keybindings are loaded when tab-bar-mode is switched on and afterwards
> whenever a new tab is created in tab-bar-new-to, so it seems
> independent of tab-bar-show. When tab-bar-show is customized they are
> either already loaded because tab-bar-mode is on, or if it is not they
> are not required and will be loaded when tab-bar-mode is activated.
I was wrong about the "tab-bar-mode is on by default" part, so maybe I
like your suggestion more. I added:
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 7afbb96212..93573d8a75 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -276,8 +276,9 @@ tab-bar-show
:initialize 'custom-initialize-default
:set (lambda (sym val)
(set-default sym val)
- ;; Recalculate tab-bar-lines for all frames
- (tab-bar--update-tab-bar-lines t))
+ (if val
+ (tab-bar-mode 1)
+ (tab-bar--update-tab-bar-lines t)))
:group 'tab-bar
:version "27.1")
with respect to v6, v7 is attached.
>
> >
> > > @@ -852,16 +867,15 @@ After the tab is created, the hooks in
> > > + ;; Switch on tab-bar-mode, since a tab was created
> > > + (when tab-bar-show
> > > (tab-bar-mode 1))
> > > +
> > > + ;; Recalculate tab-bar-lines and update frames
> > > + (tab-bar--update-tab-bar-lines (selected-frame))
> > > + (when tab-bar-mode
> > > + (tab-bar--load-buttons)
> > > + (tab-bar--define-keys))
> >
> > Would you agree that here in tab-bar-new-tab-to, the first call of
> > tab-bar-mode should already do all these calls: tab-bar--update-tab-bar-lines,
> > tab-bar--load-buttons, tab-bar--define-keys? So maybe it should be
> > sufficient just to leave these 2 lines here:
> >
> > (when tab-bar-show
> > (tab-bar-mode 1))
>
> Yes I agree that tab-bar--update-tab-bar-lines is not needed. It
> happens in the line before when tab-bar-show is not nil and doesn't
> matter otherwise. I have left these two lines, though:
>
> (when tab-bar-mode
> (tab-bar--load-buttons)
> (tab-bar--define-keys))
>
> Because I think defining the keys is useful even if tab-bar-show is
> nil, so you can switch to another tab using the key bindings even if
> you can't see the tab-bar. As for the buttons, I think it makes sense
> to load them so that in case tab-bar-show is customized to another
> value afterwards they are available directly.
[-- Attachment #2: tab-bar_v7.patch --]
[-- Type: text/x-patch, Size: 5290 bytes --]
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 6720d82b47..93573d8a75 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -134,21 +134,47 @@ tab-bar--load-buttons
:ascent center))
tab-bar-close-button)))
+(defun tab-bar--tab-bar-lines-for-frame (frame)
+ "Determine and return the value of `tab-bar-lines' for FRAME.
+Return 0 if `tab-bar-mode' is not enabled. Otherwise return
+either 1 or 0 depending on the value of the customizable variable
+`tab-bar-show', which see."
+ (cond
+ ((not tab-bar-mode) 0)
+ ((not tab-bar-show) 0)
+ ((eq tab-bar-show t) 1)
+ ((natnump tab-bar-show)
+ (if (> (length (funcall tab-bar-tabs-function frame)) tab-bar-show) 1 0))))
+
+(defun tab-bar--update-tab-bar-lines (&optional frames)
+ "Update the `tab-bar-lines' parameter in frames.
+Update the tab-bar-lines frame parameter. If the optional
+parameter FRAMES is omitted, update only the currently selected
+frame. If it is `t', update all frames as well as the default
+for new frames. Otherwise FRAMES should be a list of frames to
+update."
+ (let ((frame-lst (cond ((null frames)
+ (list (selected-frame)))
+ ((eq frames t)
+ (frame-list))
+ (t frames))))
+ ;; Loop over all frames and update default-frame-alist
+ (dolist (frame frame-lst)
+ (set-frame-parameter frame 'tab-bar-lines (tab-bar--tab-bar-lines-for-frame frame))))
+ (when (eq frames t)
+ (setq default-frame-alist
+ (cons (cons 'tab-bar-lines (if (and tab-bar-mode (eq tab-bar-show t)) 1 0))
+ (assq-delete-all 'tab-bar-lines default-frame-alist)))))
+
(define-minor-mode tab-bar-mode
"Toggle the tab bar in all graphical frames (Tab Bar mode)."
:global t
;; It's defined in C/cus-start, this stops the d-m-m macro defining it again.
:variable tab-bar-mode
- (let ((val (if tab-bar-mode 1 0)))
- (dolist (frame (frame-list))
- (set-frame-parameter frame 'tab-bar-lines val))
- ;; If the user has given `default-frame-alist' a `tab-bar-lines'
- ;; parameter, replace it.
- (if (assq 'tab-bar-lines default-frame-alist)
- (setq default-frame-alist
- (cons (cons 'tab-bar-lines val)
- (assq-delete-all 'tab-bar-lines
- default-frame-alist)))))
+
+ ;; Recalculate tab-bar-lines for all frames
+ (tab-bar--update-tab-bar-lines t)
+
(when tab-bar-mode
(tab-bar--load-buttons))
(if tab-bar-mode
@@ -250,17 +276,9 @@ tab-bar-show
:initialize 'custom-initialize-default
:set (lambda (sym val)
(set-default sym val)
- ;; Preload button images
- (tab-bar-mode 1)
- ;; Then handle each frame individually
- (dolist (frame (frame-list))
- (set-frame-parameter
- frame 'tab-bar-lines
- (if (or (eq val t)
- (and (natnump val)
- (> (length (funcall tab-bar-tabs-function frame))
- val)))
- 1 0))))
+ (if val
+ (tab-bar-mode 1)
+ (tab-bar--update-tab-bar-lines t)))
:group 'tab-bar
:version "27.1")
@@ -852,16 +870,14 @@ tab-bar-new-tab-to
(run-hook-with-args 'tab-bar-tab-post-open-functions
(nth to-index tabs)))
- (cond
- ((eq tab-bar-show t)
+ ;; Switch on tab-bar-mode, since a tab was created
+ ;; Note: This also updates tab-bar-lines
+ (when tab-bar-show
(tab-bar-mode 1))
- ((and (natnump tab-bar-show)
- (> (length (funcall tab-bar-tabs-function)) tab-bar-show)
- (zerop (frame-parameter nil 'tab-bar-lines)))
- (progn
- (tab-bar--load-buttons)
- (tab-bar--define-keys)
- (set-frame-parameter nil 'tab-bar-lines 1))))
+
+ (when tab-bar-mode
+ (tab-bar--load-buttons)
+ (tab-bar--define-keys))
(force-mode-line-update)
(unless tab-bar-mode
@@ -996,11 +1012,8 @@ tab-bar-close-tab
tab-bar-closed-tabs)
(set-frame-parameter nil 'tabs (delq close-tab tabs)))
- (when (and (not (zerop (frame-parameter nil 'tab-bar-lines)))
- (natnump tab-bar-show)
- (<= (length (funcall tab-bar-tabs-function))
- tab-bar-show))
- (set-frame-parameter nil 'tab-bar-lines 0))
+ ;; Recalculate tab-bar-lines and update frames
+ (tab-bar--update-tab-bar-lines)
(force-mode-line-update)
(unless tab-bar-mode
@@ -1036,11 +1049,8 @@ tab-bar-close-other-tabs
(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 (not (zerop (frame-parameter nil 'tab-bar-lines)))
- (natnump tab-bar-show)
- (<= (length (funcall tab-bar-tabs-function))
- tab-bar-show))
- (set-frame-parameter nil 'tab-bar-lines 0))
+ ;; Recalculate tab-bar-lines and update frames
+ (tab-bar--update-tab-bar-lines)
(force-mode-line-update)
(unless tab-bar-mode
next prev parent reply other threads:[~2021-02-11 17:34 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-04 16:14 bug#46299: 28.0.50; Value of tab-bar-show not respected in new frames Bastian Beischer
2021-02-05 8:54 ` Juri Linkov
2021-02-05 10:10 ` Bastian Beranek
2021-02-05 14:11 ` Bastian Beranek
2021-02-06 12:16 ` Bastian Beranek
2021-02-07 19:05 ` Juri Linkov
2021-02-07 23:03 ` Bastian Beranek
2021-02-08 17:50 ` Bastian Beranek
2021-02-08 18:19 ` Juri Linkov
2021-02-08 19:04 ` Bastian Beranek
2021-02-09 8:00 ` martin rudalics
2021-02-09 8:15 ` Bastian Beranek
2021-02-09 8:58 ` martin rudalics
2021-02-09 9:23 ` Bastian Beranek
2021-02-09 9:45 ` martin rudalics
2021-02-09 11:44 ` Bastian Beranek
2021-02-09 17:32 ` martin rudalics
2021-02-09 18:06 ` Juri Linkov
2021-02-09 18:46 ` Bastian Beranek
2021-02-09 19:08 ` Eli Zaretskii
2021-02-09 19:01 ` Eli Zaretskii
2021-02-10 18:24 ` Juri Linkov
2021-02-11 12:14 ` Bastian Beranek
2021-02-11 17:34 ` Bastian Beranek [this message]
2021-02-12 9:31 ` Juri Linkov
2021-02-12 10:24 ` Bastian Beranek
2021-02-12 14:47 ` Bastian Beranek
2021-02-12 19:23 ` Bastian Beranek
2021-02-13 18:23 ` Juri Linkov
2021-02-13 19:02 ` Bastian Beranek
2021-02-13 19:46 ` Juri Linkov
2021-02-14 18:44 ` Juri Linkov
2021-02-15 10:05 ` Bastian Beranek
2021-02-15 15:26 ` Eli Zaretskii
2021-02-15 15:32 ` Bastian Beranek
2021-02-15 15:53 ` Eli Zaretskii
2021-02-16 10:40 ` Bastian Beranek
2021-02-14 13:08 ` Bastian Beranek
2021-02-14 18:50 ` Juri Linkov
2021-02-14 19:28 ` Juri Linkov
2021-02-15 8:16 ` martin rudalics
2021-02-15 9:07 ` Juri Linkov
2021-02-15 10:08 ` martin rudalics
2021-02-15 10:12 ` Bastian Beranek
2021-02-15 10:09 ` Bastian Beranek
2021-02-15 17:01 ` Juri Linkov
2021-02-15 22:10 ` Bastian Beranek
2021-02-16 2:08 ` bug#46299: [External] : " Drew Adams
2021-02-16 10:59 ` Bastian Beranek
2021-02-16 15:31 ` Bastian Beranek
2021-02-16 17:28 ` Juri Linkov
2021-02-24 18:46 ` Juri Linkov
2021-02-10 18:20 ` 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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAK9AuB8J0ZO0XYme1EHXZ_Tm30H5wBqtyBPtNTFg1VuRj0gWMg@mail.gmail.com \
--to=bastian.beischer@gmail.com \
--cc=46299@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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).