1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-04 08:47:11 +00:00

* lisp/tab-bar.el (tab-bar-tab-name-format-function): New defcustom.

(tab-bar-tab-name-format-default): New function as the default value.
(tab-bar-make-keymap-1): Funcall tab-bar-tab-name-format-function.
This commit is contained in:
Juri Linkov 2021-01-05 20:55:29 +02:00
parent e72fd12ec6
commit 7469214d94
2 changed files with 35 additions and 14 deletions

View File

@ -396,10 +396,19 @@ of the next command to be displayed in a new tab.
+++
*** New command 'C-x t C-r' to open file read-only in other tab.
---
*** The tab bar is frame-local when 'tab-bar-show' is a number.
Show/hide the tab bar independently for each frame, according to the
value of 'tab-bar-show'.
---
*** New command 'toggle-frame-tab-bar'.
It can be used to enable/disable the tab bar individually
on each frame independently from the state of `tab-bar-mode'.
---
*** New user option 'tab-bar-tab-name-format-function'.
---
*** The tabs in the tab line can now be scrolled using horizontal scroll.
If your mouse or trackpad supports it, you can now scroll tabs when

View File

@ -436,6 +436,30 @@ Return its existing value or a new value."
tabs))
(defcustom tab-bar-tab-name-format-function #'tab-bar-tab-name-format-default
"Function to format a tab name.
Function gets two arguments, the tab and its number, and should return
the formatted tab name to display in the tab bar."
:type 'function
:initialize 'custom-initialize-default
:set (lambda (sym val)
(set-default sym val)
(force-mode-line-update))
:group 'tab-bar
:version "28.1")
(defun tab-bar-tab-name-format-default (tab i)
(let ((current-p (eq (car tab) 'current-tab)))
(propertize
(concat (if tab-bar-tab-hints (format "%d " i) "")
(alist-get 'name tab)
(or (and tab-bar-close-button-show
(not (eq tab-bar-close-button-show
(if current-p 'non-selected 'selected)))
tab-bar-close-button)
""))
'face (if current-p 'tab-bar-tab 'tab-bar-tab-inactive))))
(defun tab-bar-make-keymap-1 ()
"Generate an actual keymap from `tab-bar-map', without caching."
(let* ((separator (or tab-bar-separator (if window-system " " "|")))
@ -461,25 +485,13 @@ Return its existing value or a new value."
((eq (car tab) 'current-tab)
`((current-tab
menu-item
,(propertize (concat (if tab-bar-tab-hints (format "%d " i) "")
(alist-get 'name tab)
(or (and tab-bar-close-button-show
(not (eq tab-bar-close-button-show
'non-selected))
tab-bar-close-button) ""))
'face 'tab-bar-tab)
,(funcall tab-bar-tab-name-format-function tab i)
ignore
:help "Current tab")))
(t
`((,(intern (format "tab-%i" i))
menu-item
,(propertize (concat (if tab-bar-tab-hints (format "%d " i) "")
(alist-get 'name tab)
(or (and tab-bar-close-button-show
(not (eq tab-bar-close-button-show
'selected))
tab-bar-close-button) ""))
'face 'tab-bar-tab-inactive)
,(funcall tab-bar-tab-name-format-function tab i)
,(or
(alist-get 'binding tab)
`(lambda ()