Skip to content

Commit

Permalink
improve(tab-bar-segment): always use the name
Browse files Browse the repository at this point in the history
No longer use the tab index if no explicit name was set.
  • Loading branch information
Walheimat committed Oct 10, 2024
1 parent bd2c3d8 commit 0a6b47f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
7 changes: 1 addition & 6 deletions test/whale-line-segments-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -706,14 +706,9 @@
(tab-bar-mode t))

(bydi ((:mock tab-bar--current-tab :return tab)
(:mock tab-bar--current-tab-index :return 42)
(:risky-mock fboundp :with always))

(should (string= "test-tab" (whale-line-segments--tab-bar--identifier)))

(setcdr (assoc 'explicit-name tab) nil)

(should (string= "42" (whale-line-segments--tab-bar--identifier))))))
(should (string= "test-tab" (whale-line-segments--tab-bar--identifier))))))

;;;; VC

Expand Down
13 changes: 5 additions & 8 deletions whale-line-segments.el
Original file line number Diff line number Diff line change
Expand Up @@ -862,20 +862,17 @@ Only consider Dired buffers and file buffers."
;;;;; Tab bar

(defun whale-line-segments--tab-bar--identifier ()
"Get the identifier of the current tab.
"Get the identifier of the current tab."
(when-let* ((tab (tab-bar--current-tab))
(name (alist-get 'name tab)))

This is either an explicit name or its index."
(if-let* ((tab (tab-bar--current-tab))
((alist-get 'explicit-name tab))
(name (alist-get 'name tab)))
name
(number-to-string (tab-bar--current-tab-index))))
name))

(defvar whale-line-segments--tab-bar
'((tab-bar-mode
((:propertize (:eval (format " %s " (whale-line-segments--tab-bar--identifier)))
face whale-line-highlight))))
"Get the name or number of the tab.")
"Get the name of the tab.")

(whale-line-create-stateless-segment tab-bar
:var whale-line-segments--tab-bar
Expand Down

0 comments on commit 0a6b47f

Please sign in to comment.