Skip to content

Commit b26270a

Browse files
committed
* lisp/tab-line.el (tab-line-force-update): New function (bug#71601).
(tab-line-tab-name-function, tab-line-tabs-function) (tab-line-tabs-buffer-group-function) (tab-line-tabs-buffer-group-sort-function) (tab-line-tabs-buffer-groups-sort-function) (tab-line-tab-name-format-function): Use 'tab-line-force-update' in the :set lambda of defcustom. (tab-line-tab-name-function, tab-line-tabs-function) (tab-line-cache-key-function): Mention 'tab-line-force-update' in the docstring. (tab-line-new-button-show, tab-line-close-button-show): In the :set lambda of defcustom use 'force-mode-line-update' with the non-nil arg ALL.
1 parent 66c0099 commit b26270a

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

lisp/tab-line.el

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ If the value is a function, call it with no arguments."
187187
:initialize 'custom-initialize-default
188188
:set (lambda (sym val)
189189
(set-default sym val)
190-
(force-mode-line-update))
190+
(force-mode-line-update t))
191191
:group 'tab-line
192192
:version "27.1")
193193

@@ -228,7 +228,7 @@ If nil, don't show it at all."
228228
:initialize 'custom-initialize-default
229229
:set (lambda (sym val)
230230
(set-default sym val)
231-
(force-mode-line-update))
231+
(force-mode-line-update t))
232232
:group 'tab-line
233233
:version "27.1")
234234

@@ -295,7 +295,8 @@ If nil, don't show it at all."
295295
"Function to get a tab name.
296296
The function is called with one or two arguments: the buffer or
297297
another object whose tab's name is requested, and, optionally,
298-
the list of all tabs."
298+
the list of all tabs. The result of this function is cached
299+
using `tab-line-cache-key-function'."
299300
:type '(choice (const :tag "Buffer name"
300301
tab-line-tab-name-buffer)
301302
(const :tag "Truncated buffer name"
@@ -304,7 +305,7 @@ the list of all tabs."
304305
:initialize 'custom-initialize-default
305306
:set (lambda (sym val)
306307
(set-default sym val)
307-
(force-mode-line-update))
308+
(tab-line-force-update t))
308309
:group 'tab-line
309310
:version "27.1")
310311

@@ -348,7 +349,9 @@ buffers always keep the original order after switching buffers.
348349
When `tab-line-tabs-mode-buffers', return a list of buffers
349350
with the same major mode as the current buffer.
350351
When `tab-line-tabs-buffer-groups', return a list of buffers
351-
grouped by `tab-line-tabs-buffer-group-function'."
352+
grouped by `tab-line-tabs-buffer-group-function'.
353+
The result of this function is cached using
354+
`tab-line-cache-key-function'."
352355
:type '(choice (const :tag "Window buffers"
353356
tab-line-tabs-window-buffers)
354357
(const :tag "Window buffers with fixed order"
@@ -361,7 +364,7 @@ grouped by `tab-line-tabs-buffer-group-function'."
361364
:initialize 'custom-initialize-default
362365
:set (lambda (sym val)
363366
(set-default sym val)
364-
(force-mode-line-update))
367+
(tab-line-force-update t))
365368
:group 'tab-line
366369
:version "27.1")
367370

@@ -404,7 +407,7 @@ as a group name."
404407
:initialize 'custom-initialize-default
405408
:set (lambda (sym val)
406409
(set-default sym val)
407-
(force-mode-line-update))
410+
(tab-line-force-update t))
408411
:group 'tab-line
409412
:version "30.1")
410413

@@ -418,7 +421,7 @@ as a group name."
418421
:initialize 'custom-initialize-default
419422
:set (lambda (sym val)
420423
(set-default sym val)
421-
(force-mode-line-update))
424+
(tab-line-force-update t))
422425
:group 'tab-line
423426
:version "30.1")
424427

@@ -433,7 +436,7 @@ as a group name."
433436
:initialize 'custom-initialize-default
434437
:set (lambda (sym val)
435438
(set-default sym val)
436-
(force-mode-line-update))
439+
(tab-line-force-update t))
437440
:group 'tab-line
438441
:version "30.1")
439442

@@ -568,12 +571,13 @@ The function will be called two arguments: the tab whose name to format,
568571
and the list of all the tabs; it should return the formatted tab name
569572
to display in the tab line.
570573
The first argument could also be a different object, for example the buffer
571-
which the tab will represent."
574+
which the tab will represent. The result of this function is cached
575+
using `tab-line-cache-key-function'."
572576
:type 'function
573577
:initialize 'custom-initialize-default
574578
:set (lambda (sym val)
575579
(set-default sym val)
576-
(force-mode-line-update))
580+
(tab-line-force-update t))
577581
:group 'tab-line
578582
:version "28.1")
579583

@@ -689,6 +693,18 @@ For use in `tab-line-tab-face-functions'."
689693

690694
(defvar tab-line-auto-hscroll)
691695

696+
(defun tab-line-force-update (all)
697+
"Force redisplay of the current buffer’s tab line.
698+
This function also clears the tab-line cache. With optional non-nil ALL,
699+
it clears the tab-line cache of all tab lines and forces their redisplay."
700+
(if all
701+
(walk-windows
702+
(lambda (window)
703+
(set-window-parameter window 'tab-line-cache nil))
704+
'no-mini t)
705+
(set-window-parameter nil 'tab-line-cache nil))
706+
(force-mode-line-update all))
707+
692708
(defun tab-line-cache-key-default (tabs)
693709
"Return default list of cache keys."
694710
(list
@@ -708,7 +724,8 @@ For use in `tab-line-tab-face-functions'."
708724
(defvar tab-line-cache-key-function #'tab-line-cache-key-default
709725
"Function that adds more cache keys.
710726
It is called with one argument, a list of tabs, and should return a list
711-
of cache keys. You can use `add-function' to add more cache keys.")
727+
of cache keys. You can use `add-function' to add more cache keys.
728+
Also there is the function `tab-line-force-update' that clears the cache.")
712729

713730
(defun tab-line-format ()
714731
"Format for displaying the tab line of the selected window."

0 commit comments

Comments
 (0)