unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#38693: 27.0.50; tab-bar: automatic tab names should be shortened
@ 2019-12-20 17:48 Gregor Zattler
  2019-12-21 23:36 ` Juri Linkov
  0 siblings, 1 reply; 6+ messages in thread
From: Gregor Zattler @ 2019-12-20 17:48 UTC (permalink / raw)
  To: 38693

[-- Attachment #1: Type: text/plain, Size: 116 bytes --]

Dear emacs developers, Juri, per default tab-bar uses buffer
names as tab labels.  But these might be very looong:


[-- Attachment #2: 2019-12-20-unshortened-tabs-tooooo-long.png --]
[-- Type: image/png, Size: 40283 bytes --]

[-- Attachment #3: Type: text/plain, Size: 354 bytes --]


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#38693: 27.0.50; tab-bar: automatic tab names should be shortened
  2019-12-20 17:48 bug#38693: 27.0.50; tab-bar: automatic tab names should be shortened Gregor Zattler
@ 2019-12-21 23:36 ` Juri Linkov
  2019-12-23 20:15   ` Gregor Zattler
  0 siblings, 1 reply; 6+ messages in thread
From: Juri Linkov @ 2019-12-21 23:36 UTC (permalink / raw)
  To: Gregor Zattler; +Cc: 38693

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#38693: 27.0.50; tab-bar: automatic tab names should be shortened
  2019-12-21 23:36 ` Juri Linkov
@ 2019-12-23 20:15   ` Gregor Zattler
  2019-12-25 21:45     ` Juri Linkov
  0 siblings, 1 reply; 6+ messages in thread
From: Gregor Zattler @ 2019-12-23 20:15 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 38693

Hi Juri,
* Juri Linkov <juri@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






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#38693: 27.0.50; tab-bar: automatic tab names should be shortened
  2019-12-23 20:15   ` Gregor Zattler
@ 2019-12-25 21:45     ` Juri Linkov
  2020-01-20  0:36       ` Juri Linkov
  0 siblings, 1 reply; 6+ messages in thread
From: Juri Linkov @ 2019-12-25 21:45 UTC (permalink / raw)
  To: Gregor Zattler; +Cc: 38693

[-- Attachment #1: Type: text/plain, Size: 760 bytes --]

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


[-- Attachment #2: tab-bar-tab-name-truncated.patch --]
[-- Type: text/x-diff, Size: 1862 bytes --]

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))))
+
 \f
 (defvar tab-bar-tabs-function #'tab-bar-tabs
   "Function to get a list of tabs to display in the tab bar.

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#38693: 27.0.50; tab-bar: automatic tab names should be shortened
  2019-12-25 21:45     ` Juri Linkov
@ 2020-01-20  0:36       ` Juri Linkov
  2020-01-20 23:03         ` Juri Linkov
  0 siblings, 1 reply; 6+ messages in thread
From: Juri Linkov @ 2020-01-20  0:36 UTC (permalink / raw)
  To: Gregor Zattler; +Cc: 38693

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#38693: 27.0.50; tab-bar: automatic tab names should be shortened
  2020-01-20  0:36       ` Juri Linkov
@ 2020-01-20 23:03         ` Juri Linkov
  0 siblings, 0 replies; 6+ messages in thread
From: Juri Linkov @ 2020-01-20 23:03 UTC (permalink / raw)
  To: Gregor Zattler; +Cc: 38693

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.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-01-20 23:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-20 17:48 bug#38693: 27.0.50; tab-bar: automatic tab names should be shortened Gregor Zattler
2019-12-21 23:36 ` Juri Linkov
2019-12-23 20:15   ` Gregor Zattler
2019-12-25 21:45     ` Juri Linkov
2020-01-20  0:36       ` Juri Linkov
2020-01-20 23:03         ` Juri Linkov

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