From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ship Mints Newsgroups: gmane.emacs.bugs Subject: bug#71883: [PATCH] Fix tab-bar-auto-width with customized tab-bar-tab-face-function Date: Tue, 2 Jul 2024 09:42:42 -0400 Message-ID: References: <87le2kaloz.fsf@breatheoutbreathe.in> <861q4ce1yb.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000f415c2061c43e304" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22178"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 71883@debbugs.gnu.org, adam@alphapapa.net, joseph@breatheoutbreathe.in To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jul 02 15:43:19 2024 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 1sOdmw-0005Qn-O7 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 02 Jul 2024 15:43:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sOdmg-00012C-S4; Tue, 02 Jul 2024 09:43:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sOdmf-000122-Ph for bug-gnu-emacs@gnu.org; Tue, 02 Jul 2024 09:43:01 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOdmf-00085Q-Gt for bug-gnu-emacs@gnu.org; Tue, 02 Jul 2024 09:43:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sOdmg-00018Y-AM for bug-gnu-emacs@gnu.org; Tue, 02 Jul 2024 09:43:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ship Mints Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 02 Jul 2024 13:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71883 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-Cc: 71883@debbugs.gnu.org, Adam Porter , "Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors" , Joseph Turner Original-Received: via spool by submit@debbugs.gnu.org id=B.17199277804362 (code B ref -1); Tue, 02 Jul 2024 13:43:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 2 Jul 2024 13:43:00 +0000 Original-Received: from localhost ([127.0.0.1]:36326 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sOdmd-00018H-WE for submit@debbugs.gnu.org; Tue, 02 Jul 2024 09:43:00 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:45000) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sOdmc-000189-59 for submit@debbugs.gnu.org; Tue, 02 Jul 2024 09:42:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sOdma-0000zW-M5 for bug-gnu-emacs@gnu.org; Tue, 02 Jul 2024 09:42:56 -0400 Original-Received: from mail-ua1-x92b.google.com ([2607:f8b0:4864:20::92b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOdmY-00083r-Ir for bug-gnu-emacs@gnu.org; Tue, 02 Jul 2024 09:42:56 -0400 Original-Received: by mail-ua1-x92b.google.com with SMTP id a1e0cc1a2514c-80fe70b6babso1105059241.2 for ; Tue, 02 Jul 2024 06:42:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719927773; x=1720532573; darn=gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=q06fzVHI1y89C70bphPloqeY9QSyFuxJ6/xeXFnTYzU=; b=Oy0Ns/sQf1CE4uI8zOopq7pc+SIN4Gn5pRXU/DYm8u6ggsJTOyciKeT072g0u12I+F bstM1ed0Lw1sz1t1R9WJFthP9PSCRWKpBN9fdICfozbbCj5+qr/mbMmJ6tORi7P/H33v 0kV3v3k6hOTXkYlMBrD88g3bIwnS2WqYA84jRb/8Yoli7TDqxok/RxdjX6Z9429qJaKQ PxPp3RhKZpJn9kBH/4WzcFkamoIPiDuaMXvwhCUVsCstwhvTdsyO1bxxayIL0MWUHVic /AhZpD39XXvgWsqthlJK7NbZIJlPrkUTkON0r7bfdQj98R+5XdyFrxjv+u7eSAv+Ug/D fpRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719927773; x=1720532573; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=q06fzVHI1y89C70bphPloqeY9QSyFuxJ6/xeXFnTYzU=; b=U/2wQ5EMCzAceXbyaP9DEy3knQ9Pj/Ba0qOeaTtLqmhoOCz/aDE/Mko6KdyyoEnHvG g8dkAs4LS3ZOtZJBNKbnLIMNeWnb7LCHploxnCN9hw8KrguSp6tRlWbIXQ6LlnNDMzUA UaWCNPjO/k9b0DfpTS02a5gpe5j5Yk+CCgPPT+Tr2Z+/TVxKVgjv8o9TBAbk9cD+mXEK c6ahAby4VZq3NzzJDYgHPiSDRLJ2gTb96ewwsdbauSOMv13S7snPceqQCziAwlC2vZqQ RiYa5GPJzDwfQ4vDnbigBsDj2VUFTEgY42A2BWCkogQAYT1Yg2cOKRkvZ+gM7qBsNfoF 9DPg== X-Gm-Message-State: AOJu0YxuoHBQoKCSoEFFQbjDmHwu3onO/gW6jVy+ZvVjKz1F2JrosHev H1PR8PrNPdznSQa+/UgW37o5kcjPwFqsNZniEqwt35b5uJL1zhEjTrzzx6gUeu6ZrEBi5Vxal2N D0lU5Y29012V02pP5jsPKCqLMEaH8Yg== X-Google-Smtp-Source: AGHT+IH6vfqB463j/xQe4gx6fHb1jnYOu+ulEu7IL4y9qQRLY3XJo65BDpsrhfwcssBDS4EnCUNDnCMG/AlmootZalQ= X-Received: by 2002:a05:6122:390a:b0:4ec:ef78:d753 with SMTP id 71dfb90a1353d-4f2a56f2803mr9711142e0c.14.1719927773073; Tue, 02 Jul 2024 06:42:53 -0700 (PDT) In-Reply-To: <861q4ce1yb.fsf@mail.linkov.net> Received-SPF: pass client-ip=2607:f8b0:4864:20::92b; envelope-from=shipmints@gmail.com; helo=mail-ua1-x92b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:288286 Archived-At: --000000000000f415c2061c43e304 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I like both ideas. Supporting t seems idiomatic. `activities' could add its face to the list, or a user in her configuration via documentation. On Tue, Jul 2, 2024 at 2:59=E2=80=AFAM Juri Linkov wrote: > > The function tab-bar-auto-width determines which tabs to automatically > > resize based on the face applied to each tab's text. If the face is on= e > > of tab-bar-auto-width-faces, then the tab gets resized. However, if > > either tab-bar-tab-face-function or tab-bar-tab-group-face-function is > > set to a function which does not apply one of tab-bar-auto-width-faces, > > then the tabs which have a different face are not auto resized. > > > > A real-world example of this issue is in activities.el: > > > > https://github.com/alphapapa/activities.el/issues/76 > > Thanks for the request. > > Maybe activities.el could add its face to tab-bar-auto-width-faces? > > If not, then what about allowing tab-bar-auto-width-faces to have > the value t that means that all tabs should be resized regardless of > what faces they have. > > > In the proposed patch, instead of checking each tab's face, we check > > that the symbol at the start of each tab keymap matches > > > > (rx bos (or "current-tab" "tab-" "group-")) > > > -(defvar tab-bar-auto-width-faces > > - '( tab-bar-tab tab-bar-tab-inactive > > - tab-bar-tab-ungrouped > > - tab-bar-tab-group-inactive) > > - "Resize tabs only with these faces.") > > Sorry, we can't remove the existing variable to not break user configs. > > > @@ -1250,8 +1244,8 @@ tab-bar-auto-width > > - (if (memq (get-text-property 0 'face (nth 2 item)) > > - tab-bar-auto-width-faces) > > + (if (string-match-p > "\\`\\(?:current-tab\\|\\(?:group\\|tab\\)-\\)" > > + (symbol-name (nth 0 item))) > > Matching the symbol name with the hard-coded regexp doesn't look right. > Maybe better to add a new variable that contains a predicate function? > When it returns t then resize. > --000000000000f415c2061c43e304 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I like both ideas. Supporting t seems=C2=A0idiomatic. `act= ivities' could add its face to the list, or a user in her configuration= via documentation.

On Tue, Jul 2, 2024 at 2:59=E2=80=AFAM Juri Linkov <<= a href=3D"mailto:juri@linkov.net">juri@linkov.net> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l= eft:1px solid rgb(204,204,204);padding-left:1ex">> The function tab-bar-= auto-width determines which tabs to automatically
> resize based on the face applied to each tab's text.=C2=A0 If the = face is one
> of tab-bar-auto-width-faces, then the tab gets resized.=C2=A0 However,= if
> either tab-bar-tab-face-function or tab-bar-tab-group-face-function is=
> set to a function which does not apply one of tab-bar-auto-width-faces= ,
> then the tabs which have a different face are not auto resized.
>
> A real-world example of this issue is in activities.el:
>
> https://github.com/alphapapa/activities.e= l/issues/76

Thanks for the request.

Maybe activities.el could add its face to tab-bar-auto-width-faces?

If not, then what about allowing tab-bar-auto-width-faces to have
the value t that means that all tabs should be resized regardless of
what faces they have.

> In the proposed patch, instead of checking each tab's face, we che= ck
> that the symbol at the start of each tab keymap matches
>
> (rx bos (or "current-tab" "tab-" "group-"= ;))

> -(defvar tab-bar-auto-width-faces
> -=C2=A0 '( tab-bar-tab tab-bar-tab-inactive
> -=C2=A0 =C2=A0 =C2=A0tab-bar-tab-ungrouped
> -=C2=A0 =C2=A0 =C2=A0tab-bar-tab-group-inactive)
> -=C2=A0 "Resize tabs only with these faces.")

Sorry, we can't remove the existing variable to not break user configs.=

> @@ -1250,8 +1244,8 @@ tab-bar-auto-width
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (memq (get-text-property 0 'face = (nth 2 item))
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tab-ba= r-auto-width-faces)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (string-match-p "\\`\\(?:current= -tab\\|\\(?:group\\|tab\\)-\\)"
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 (symbol-name (nth 0 item)))

Matching the symbol name with the hard-coded regexp doesn't look right.=
Maybe better to add a new variable that contains a predicate function?
When it returns t then resize.
--000000000000f415c2061c43e304--