From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#38693: 27.0.50; tab-bar: automatic tab names should be shortened Date: Wed, 25 Dec 2019 23:45:39 +0200 Organization: LINKOV.NET Message-ID: <87a77ghyf0.fsf@mail.linkov.net> References: <87r20yriqx.fsf@len.workgroup> <878sn5b6af.fsf@mail.linkov.net> <87sglalrwm.fsf@len.workgroup> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="133697"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.60 (x86_64-pc-linux-gnu) Cc: 38693@debbugs.gnu.org To: Gregor Zattler Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Dec 25 22:54:14 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ikEbd-000Ycj-85 for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Dec 2019 22:54:13 +0100 Original-Received: from localhost ([::1]:49428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ikEbb-0005RE-4z for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Dec 2019 16:54:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39099) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ikEbV-0005R7-I4 for bug-gnu-emacs@gnu.org; Wed, 25 Dec 2019 16:54:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ikEbS-00043Z-DL for bug-gnu-emacs@gnu.org; Wed, 25 Dec 2019 16:54:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48762) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ikEbS-00043C-2c for bug-gnu-emacs@gnu.org; Wed, 25 Dec 2019 16:54:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ikEbS-0003hk-1j for bug-gnu-emacs@gnu.org; Wed, 25 Dec 2019 16:54:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 Dec 2019 21:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38693 X-GNU-PR-Package: emacs Original-Received: via spool by 38693-submit@debbugs.gnu.org id=B38693.157731078414148 (code B ref 38693); Wed, 25 Dec 2019 21:54:01 +0000 Original-Received: (at 38693) by debbugs.gnu.org; 25 Dec 2019 21:53:04 +0000 Original-Received: from localhost ([127.0.0.1]:54735 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ikEaV-0003g7-NM for submit@debbugs.gnu.org; Wed, 25 Dec 2019 16:53:03 -0500 Original-Received: from black.elm.relay.mailchannels.net ([23.83.212.19]:36267) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ikEaT-0003fd-05 for 38693@debbugs.gnu.org; Wed, 25 Dec 2019 16:53:02 -0500 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 5C87E580523; Wed, 25 Dec 2019 21:52:57 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a89.g.dreamhost.com (100-96-83-39.trex.outbound.svc.cluster.local [100.96.83.39]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id DA1F35807A4; Wed, 25 Dec 2019 21:52:56 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a89.g.dreamhost.com ([TEMPUNAVAIL]. [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.18.5); Wed, 25 Dec 2019 21:52:57 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Sponge-Print: 3c75123b235e913a_1577310777125_446416711 X-MC-Loop-Signature: 1577310777125:193604248 X-MC-Ingress-Time: 1577310777125 Original-Received: from pdx1-sub0-mail-a89.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a89.g.dreamhost.com (Postfix) with ESMTP id A1C587EFD5; Wed, 25 Dec 2019 13:52:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=LeCok2r2Y/ihOVeA9ylbiLrlkBY=; b= sSYEd+n9cvBsyFgTOh9EUpkHcFzyNll5zk8op99a1UGNe0VY8QMhRCULSchRyskc OnsAg2G6lNsA9ooDdPrRWv1qTn6rDn8AkZFVOShxT/hqfWZmneBRWD7MxykW9AX/ 5JBCjjeFuEnAkxo68mEoRPbc9E6CK7x2tjp4pbGEoeM= Original-Received: from mail.jurta.org (m91-129-107-186.cust.tele2.ee [91.129.107.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a89.g.dreamhost.com (Postfix) with ESMTPSA id A7AC37EFCD; Wed, 25 Dec 2019 13:52:49 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a89 In-Reply-To: <87sglalrwm.fsf@len.workgroup> (Gregor Zattler's message of "Mon, 23 Dec 2019 21:15:53 +0100") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: 0 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrvddvgedgudehhecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvpdfftffgtefojffquffvnecuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufhofhffjgfkfgggtgesmhdtreertdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucfkphepledurdduvdelrddutdejrddukeeinecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledruddtjedrudekiedprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopehgrhhfiiesghhmgidruggvnecuvehluhhsthgvrhfuihiivgeptd X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:173767 Archived-At: --=-=-= Content-Type: text/plain >>> Please provide an option to dynamically shorten at least >>> automatic tab labels in order not to overflow the tab bar into >>> another line OR provide an option with sensible default for the >>> max length of automatic tab labels (e.g. 23 characters per tab >>> label would allow for at least 3 tabs on a 80 char terminal) OR >>> something to such effect. >> >> Maybe such a new option: >> >> (defcustom tab-bar-tab-name-max 23 >> >> and using it on the default values of tab-bar-tab-name-current, >> tab-bar-tab-name-current-with-count, tab-bar-tab-name-all? > > yes, this would be helpful for me. I'm still not sure whether to use the new option in all functions above, or add a new function that truncates the name. It seems the latter is better: --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=tab-bar-tab-name-truncated.patch Content-Transfer-Encoding: quoted-printable diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 0d0197eb6b..d10dd7031f 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -319,6 +319,8 @@ tab-bar-tab-name-function tab-bar-tab-name-current) (const :tag "Selected window buffer with window count" tab-bar-tab-name-current-with-count) + (const :tag "Truncated buffer name" + tab-bar-tab-name-truncated) (const :tag "All window buffers" tab-bar-tab-name-all) (function :tag "Function")) @@ -350,6 +352,29 @@ tab-bar-tab-name-all 'nomini))) ", ")) =20 +(defcustom tab-bar-tab-name-truncated-max 20 + "Maximum length of the tab name from the current buffer. +Effective when `tab-bar-tab-name-function' is customized +to `tab-bar-tab-name-truncated'." + :type 'integer + :group 'tab-bar + :version "27.1") + +(defvar tab-bar-tab-name-truncated-ellipsis + (if (char-displayable-p ?=E2=80=A6) "=E2=80=A6" "...")) + +(defun tab-bar-tab-name-truncated () + "Generate tab name from the buffer of the selected window. +Truncate it ti the length specified by `tab-bar-tab-name-truncated-max'. +Append ellipsis `tab-bar-tab-name-truncated-ellipsis' in this case." + (let ((tab-name (buffer-name (window-buffer (minibuffer-selected-windo= w))))) + (if (< (length tab-name) tab-bar-tab-name-truncated-max) + tab-name + (propertize (truncate-string-to-width + tab-name tab-bar-tab-name-truncated-max nil nil + tab-bar-tab-name-truncated-ellipsis) + 'help-echo tab-name)))) + =0C (defvar tab-bar-tabs-function #'tab-bar-tabs "Function to get a list of tabs to display in the tab bar. --=-=-=--