Skip to content

Commit 92f080d

Browse files
committed
Tab-bar related finishing touches.
* lisp/tab-bar.el (tab-bar-tab-name-ellipsis): Use shorter name instead of tab-bar-tab-name-truncated-ellipsis. (tab-bar-new-tab-to) <defcustom>: Add 'function' option. (tab-bar-new-tab-to) <function>: Use it. * lisp/tab-line.el (tab-line-close-tab): Add missing arg 'tab' to tab-line-close-tab-function funcall.
1 parent 224e8d1 commit 92f080d

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

lisp/tab-bar.el

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,19 +360,19 @@ to `tab-bar-tab-name-truncated'."
360360
:group 'tab-bar
361361
:version "27.1")
362362

363-
(defvar tab-bar-tab-name-truncated-ellipsis
363+
(defvar tab-bar-tab-name-ellipsis
364364
(if (char-displayable-p ?…) "" "..."))
365365

366366
(defun tab-bar-tab-name-truncated ()
367367
"Generate tab name from the buffer of the selected window.
368368
Truncate it to the length specified by `tab-bar-tab-name-truncated-max'.
369-
Append ellipsis `tab-bar-tab-name-truncated-ellipsis' in this case."
369+
Append ellipsis `tab-bar-tab-name-ellipsis' in this case."
370370
(let ((tab-name (buffer-name (window-buffer (minibuffer-selected-window)))))
371371
(if (< (length tab-name) tab-bar-tab-name-truncated-max)
372372
tab-name
373373
(propertize (truncate-string-to-width
374374
tab-name tab-bar-tab-name-truncated-max nil nil
375-
tab-bar-tab-name-truncated-ellipsis)
375+
tab-bar-tab-name-ellipsis)
376376
'help-echo tab-name))))
377377

378378

@@ -722,11 +722,14 @@ Interactively, ARG selects the ARGth different frame to move to."
722722
If `leftmost', create as the first tab.
723723
If `left', create to the left from the current tab.
724724
If `right', create to the right from the current tab.
725-
If `rightmost', create as the last tab."
725+
If `rightmost', create as the last tab.
726+
If the value is a function, it should return a number as a position
727+
on the tab bar specifying where to insert a new tab."
726728
:type '(choice (const :tag "First tab" leftmost)
727729
(const :tag "To the left" left)
728730
(const :tag "To the right" right)
729-
(const :tag "Last tab" rightmost))
731+
(const :tag "Last tab" rightmost)
732+
(function :tag "Function"))
730733
:group 'tab-bar
731734
:version "27.1")
732735

@@ -773,7 +776,9 @@ After the tab is created, the hooks in
773776
('leftmost 0)
774777
('rightmost (length tabs))
775778
('left (1- (or from-index 1)))
776-
('right (1+ (or from-index 0)))))))
779+
('right (1+ (or from-index 0)))
780+
((pred functionp)
781+
(funcall tab-bar-new-tab-to))))))
777782
(setq to-index (max 0 (min (or to-index 0) (length tabs))))
778783
(cl-pushnew to-tab (nthcdr to-index tabs))
779784

lisp/tab-line.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ from the tab line."
709709
(set-window-prev-buffers nil (assq-delete-all buffer (window-prev-buffers)))
710710
(set-window-next-buffers nil (delq buffer (window-next-buffers)))))
711711
((functionp tab-line-close-tab-function)
712-
(funcall tab-line-close-tab-function)))
712+
(funcall tab-line-close-tab-function tab)))
713713
(force-mode-line-update))))
714714

715715

0 commit comments

Comments
 (0)