GNU bug report logs - #38693
27.0.50; tab-bar: automatic tab names should be shortened

Previous Next

Package: emacs;

Reported by: Gregor Zattler <grfz <at> gmx.de>

Date: Fri, 20 Dec 2019 17:49:01 UTC

Severity: normal

Tags: fixed

Found in version 27.0.50

Fixed in version 27.0.60

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 38693 in the body.
You can then email your comments to 38693 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#38693; Package emacs. (Fri, 20 Dec 2019 17:49:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Gregor Zattler <grfz <at> gmx.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 20 Dec 2019 17:49:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Gregor Zattler <grfz <at> gmx.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.50; tab-bar: automatic tab names should be shortened
Date: Fri, 20 Dec 2019 18:48:06 +0100
[Message part 1 (text/plain, inline)]
Dear emacs developers, Juri, per default tab-bar uses buffer
names as tab labels.  But these might be very looong:

[2019-12-20-unshortened-tabs-tooooo-long.png (image/png, inline)]
[Message part 3 (text/plain, inline)]
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.

Thanks, Gregor

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38693; Package emacs. (Sat, 21 Dec 2019 23:38:02 GMT) Full text and rfc822 format available.

Message #8 received at 38693 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Gregor Zattler <grfz <at> gmx.de>
Cc: 38693 <at> debbugs.gnu.org
Subject: Re: bug#38693: 27.0.50; tab-bar: automatic tab names should be
 shortened
Date: Sun, 22 Dec 2019 01:36:08 +0200
> Dear emacs developers, Juri, per default tab-bar uses buffer
> names as tab labels.  But these might be very looong:

I've never seen that long buffer name before.
This reminds Guinness Book record for the longest name :)

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38693; Package emacs. (Mon, 23 Dec 2019 20:17:02 GMT) Full text and rfc822 format available.

Message #11 received at 38693 <at> debbugs.gnu.org (full text, mbox):

From: Gregor Zattler <grfz <at> gmx.de>
To: Juri Linkov <juri <at> linkov.net>
Cc: 38693 <at> debbugs.gnu.org
Subject: Re: bug#38693: 27.0.50; tab-bar: automatic tab names should be
 shortened
Date: Mon, 23 Dec 2019 21:15:53 +0100
Hi Juri,
* Juri Linkov <juri <at> linkov.net> [2019-12-22; 01:36]:
>> Dear emacs developers, Juri, per default tab-bar uses buffer
>> names as tab labels.  But these might be very looong:
>
> I've never seen that long buffer name before.
> This reminds Guinness Book record for the longest name :)
>
>> 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.

Ciao,
--
Gregor





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38693; Package emacs. (Wed, 25 Dec 2019 21:54:02 GMT) Full text and rfc822 format available.

Message #14 received at 38693 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Gregor Zattler <grfz <at> gmx.de>
Cc: 38693 <at> debbugs.gnu.org
Subject: Re: bug#38693: 27.0.50; tab-bar: automatic tab names should be
 shortened
Date: Wed, 25 Dec 2019 23:45:39 +0200
[Message part 1 (text/plain, inline)]
>>> 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:

[tab-bar-tab-name-truncated.patch (text/x-diff, inline)]
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)))
              ", "))
 
+(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 ?…) "…" "..."))
+
+(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-window)))))
+    (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))))
+
 
 (defvar tab-bar-tabs-function #'tab-bar-tabs
   "Function to get a list of tabs to display in the tab bar.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38693; Package emacs. (Mon, 20 Jan 2020 00:43:02 GMT) Full text and rfc822 format available.

Message #17 received at 38693 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Gregor Zattler <grfz <at> gmx.de>
Cc: 38693 <at> debbugs.gnu.org
Subject: Re: bug#38693: 27.0.50; tab-bar: automatic tab names should be
 shortened
Date: Mon, 20 Jan 2020 02:36:51 +0200
>>>> 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:
>
> +(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")

The same option should be added also to tab-line to truncate tab-line
tab names.  Currently I fixed a bug that occurred when a tab name
was longer than window width.  With such an option set to some reasonable
default value this situation won't happen.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38693; Package emacs. (Mon, 20 Jan 2020 23:13:02 GMT) Full text and rfc822 format available.

Message #20 received at 38693 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Gregor Zattler <grfz <at> gmx.de>
Cc: 38693 <at> debbugs.gnu.org
Subject: Re: bug#38693: 27.0.50; tab-bar: automatic tab names should be
 shortened
Date: Tue, 21 Jan 2020 01:03:55 +0200
tags 38693 fixed
close 38693 27.0.60
thanks

>>>>> 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:
>>
>> +(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")
>
> The same option should be added also to tab-line to truncate tab-line
> tab names.  Currently I fixed a bug that occurred when a tab name
> was longer than window width.  With such an option set to some reasonable
> default value this situation won't happen.

Fixed and closed, thanks.




Added tag(s) fixed. Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Mon, 20 Jan 2020 23:13:03 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.0.60, send any further explanations to 38693 <at> debbugs.gnu.org and Gregor Zattler <grfz <at> gmx.de> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Mon, 20 Jan 2020 23:13:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 18 Feb 2020 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 40 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.