Tabs count indicator
iSeeU816 opened this issue · comments
Hello,
Could you add tabs count indicator so the user know home many tabs are
opened and the position of current one?
I have a function to do it in mode line, like {2/3}
({current/total}
); and another one to echo it in echo area which helps
if the info in the mode line is hidden because of how many windows I
have in a frame. This is before I knew about your wonderful package.
I imagine it will look like this:
Tabs 2/3: foo, current_tab, baz
.
Maybe the current tab's count should be bold or has the same face as the
current tab's name.
Note that I didn't try your other package, tab-bar-groups
, so I don't
know how this should look or if it adds complexity when both packages
are being used.
Thank you!
Thanks for your feedback, and thanks for the kind words.
I love the idea of making the Tabs: ...
part at the beginning of the display more useful, especially since it's in such a prominent place.
My initial idea is to make the part that goes before the list of tabs a variable, and have it accept either a string ("Tabs: "
by default) or a function that returns a string when called. That way, users can easily customize the package's output to their needs. I can also add a function that produces the output you suggested ("Tabs x/y: "
) and put it into either the package or the documentation as an example.
I should be able to come up with something in the next couple days.
Thanks again for your input!
@iSeeU816, I went ahead and implemented a variation of my initial idea from above.
Here's the new variable I introduced and its docstring:
(defvar tab-bar-echo-area-display-tab-names-format-string
"Tabs: %s"
"Format string to use for rendering tab names in the echo area.
If the value is a string, use it as the format string.
If the value is a function, call it to generate the format string
to use. The function is expected to take KEYMAP-ELEMENTS (the
keymap elements that will be displayed) as an argument.
The format string is expected to contain a single \"%s\", which
will be substituted with the list of fully processed tab names.")
You can use it like this to get the result you described in your original post:
(setq tab-bar-echo-area-display-tab-names-format-string
(lambda (_keymap-elements)
(let* ((tabs (funcall tab-bar-tabs-function))
(index (1+ (tab-bar--current-tab-index tabs)))
(count (length tabs)))
(format "Tabs %d/%d: %%s" index count))))
Here's a screenshot of what that looks like:
Thanks again for your feedback and suggestion -- this package just got more useful for all of us because of it 🙌
You're more welcome.
Thank you for implementing this feature and for your informative comment
on how to apply it and showcase it.