Subject: bug#78953: 31.0.50; tab-bar-format-align-right alignment breaks if field widths change

From: Juri Linkov <[email-masked]>
Date: Fri, 11 Jul 2025 19:11:21 +0300

> But I understand that disabling the overall wrap around is more
> difficult since it has to be implement on a deeper level of the
> display engine.

Indeed, the required change is on a deeper level of the display engine,
but it's quite simple like in the attached patch.  I wonder is it
appropriate to reuse the existing option 'auto-resize-tab-bars'
whose new value 'truncate' will force tab-bar truncation:

diff --git a/src/xdisp.c b/src/xdisp.c
index 15a88f0868a..b3520be234f 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -14739,11 +14739,19 @@ tab_bar_height (struct frame *f, int *n_rows, bool pixelwise)
   it.paragraph_embedding = L2R;
 
   clear_glyph_row (temp_row);
-  while (!ITERATOR_AT_END_P (&it))
+  if (EQ (Vauto_resize_tab_bars, Qtruncate))
     {
       it.glyph_row = temp_row;
       display_tab_bar_line (&it, -1);
     }
+  else
+    {
+      while (!ITERATOR_AT_END_P (&it))
+	{
+	  it.glyph_row = temp_row;
+	  display_tab_bar_line (&it, -1);
+	}
+    }
   clear_glyph_row (temp_row);
 
   /* f->n_tab_bar_rows == 0 means "unknown"; -1 means no tab-bar.  */
@@ -37810,6 +37818,7 @@ syms_of_xdisp (void)
   DEFSYM (Qinhibit_menubar_update, "inhibit-menubar-update");
 
   DEFSYM (Qgrow_only, "grow-only");
+  DEFSYM (Qtruncate, "truncate");
   DEFSYM (Qinhibit_eval_during_redisplay, "inhibit-eval-during-redisplay");
   DEFSYM (Qposition, "position");
   DEFSYM (Qbuffer_position, "buffer-position");
@@ -38173,7 +38182,9 @@ syms_of_xdisp (void)
 that is needed to make all tab-bar items visible.
 If value is `grow-only', the tab-bar's height is only increased
 automatically; to decrease the tab-bar height, use \\[recenter],
-after setting `recenter-redisplay' to the value of t.  */);
+after setting `recenter-redisplay' to the value of t.
+If value is `truncate', the tab-bar is truncated, and only
+the first line of a long tab-bar is displayed.  */);
   Vauto_resize_tab_bars = Qt;
 
   DEFVAR_BOOL ("auto-raise-tab-bar-buttons", auto_raise_tab_bar_buttons_p,