unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: James N. V. Cash <james.nvc@gmail.com>
To: 42052@debbugs.gnu.org
Subject: bug#42052: 28.0.50; tab-bar-mode should be frame-local
Date: Sun, 28 Jun 2020 20:26:29 -0400	[thread overview]
Message-ID: <87pn9ivhsa.fsf@gmail.com> (raw)
In-Reply-To: <87pn9idbj2.fsf@mail.linkov.net>

Juri Linkov <juri@linkov.net> writes:

> Please don't forget to remove this debugging message in the final patch.

Oh oops, sorry about that.

> 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.

Ah, right. I was thinking that

> 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.

That makes sense.

Here's another patch that addresses this issues, although as you say, it
still doesn't address the issue of loading the button images or changing
keybindings.

--- /home/james/src/emacs/lisp/tab-bar.el 2020-06-20 10:16:57.177037735 -0400
+++ /home/james/tmp/tab-bar.el  2020-06-28 20:15:46.073203151 -0400
@@ -799,11 +799,14 @@
       (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 (funcall tab-bar-tabs-function)) tab-bar-show)
+           (zerop (frame-parameter nil 'tab-bar-lines)))
+      (set-frame-parameter nil 'tab-bar-lines 1)))

     (force-mode-line-update)
     (unless tab-bar-mode
@@ -936,10 +939,11 @@
                 tab-bar-closed-tabs)
           (set-frame-parameter nil 'tabs (delq close-tab tabs)))

-        (when (and tab-bar-mode
-                   (and (natnump tab-bar-show)
-                        (<= (length tabs) tab-bar-show)))
-          (tab-bar-mode -1))
+        (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))

         (force-mode-line-update)
         (unless tab-bar-mode
@@ -975,10 +979,11 @@
           (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)))
+                 (natnump tab-bar-show)
+                 (<= (length (funcall tab-bar-tabs-function))
+                     tab-bar-show))
+        (set-frame-parameter nil 'tab-bar-lines 0))

       (force-mode-line-update)
       (unless tab-bar-mode





  reply	other threads:[~2020-06-29  0:26 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
2020-06-28 23:18       ` Juri Linkov
2020-06-29  0:26         ` James N. V. Cash [this message]
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

  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=87pn9ivhsa.fsf@gmail.com \
    --to=james.nvc@gmail.com \
    --cc=42052@debbugs.gnu.org \
    /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).