Skip to content

Commit

Permalink
refac(segments,tab-bar): make var-based
Browse files Browse the repository at this point in the history
  • Loading branch information
Walheimat committed Sep 25, 2024
1 parent 2277bd3 commit 2dde0cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions test/whale-line-segments-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -695,11 +695,11 @@
(:mock tab-bar--current-tab-index :return 42)
(:risky-mock fboundp :with always))

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

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

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

;;;; VC

Expand Down
18 changes: 8 additions & 10 deletions whale-line-segments.el
Original file line number Diff line number Diff line change
Expand Up @@ -849,16 +849,14 @@ This is either an explicit name or its index."
name
(number-to-string (tab-bar--current-tab-index))))

(defun whale-line-segments--tab-bar ()
"Get the name or number of the tab."
(and-let* (((bound-and-true-p tab-bar-mode))
(id (whale-line-segments--tab-bar--identifier)))

`((:propertize ,(format " %s " id) face whale-line-highlight))))

(whale-line-create-stateful-segment tab-bar
:getter whale-line-segments--tab-bar
:hooks (window-configuration-change-hook)
(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.")

(whale-line-create-stateless-segment tab-bar
:var whale-line-segments--tab-bar
:priority current)

;;;;; VC
Expand Down

0 comments on commit 2dde0cf

Please sign in to comment.