Skip to content

Commit

Permalink
feat(segments): consider misc-info and process problematic
Browse files Browse the repository at this point in the history
  • Loading branch information
Walheimat committed Jan 23, 2024
1 parent 3932b55 commit 12c3be9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Variable `whale-line--debug-padding` that when toggled renders
padding using `whale-line-highlight`.
- Segments `misc-info` and `process` now set `:dense problematic`.
This means their contents are evaluated before padding.

## [0.8.4]

Expand Down
9 changes: 6 additions & 3 deletions test/whale-line-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -653,14 +653,17 @@
(should (whale-line--valid-segment-p 'test))))

(ert-deftest whale-line--pad-segment ()
(let ((whale-line--segments '(:left (one three five) :right (two four)))
(whale-line--props '((four :dense t) (five :dense always))))
(let ((whale-line--segments '(:left (one three five) :right (two four six)))
(whale-line--props '((four :dense t) (five :dense always) (six :dense problematic))))

(should (equal '(" " "test") (whale-line--pad-segment 'one "test")))
(should (equal '("test" " ") (whale-line--pad-segment 'two "test")))
(should (equal '(" " "test") (whale-line--pad-segment 'three '("test"))))
(should (equal '("test" "") (whale-line--pad-segment 'four "test")))
(should (equal '("" "test") (whale-line--pad-segment 'five "test")))))
(should (equal '("" "test") (whale-line--pad-segment 'five "test")))

(bydi ((:mock format-mode-line :return ""))
(should (equal '("test" "") (whale-line--pad-segment 'six "test"))))))

(ert-deftest pad-segment--pre-padded ()
(let ((whale-line--segments '(:left (one two three) :right (four five six)))
Expand Down
6 changes: 4 additions & 2 deletions whale-line-segments.el
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ See `whale-line-segments-decorator'."

(whale-line-create-stateless-segment misc-info
:var mode-line-misc-info
:priority current-low)
:priority current-low
:dense problematic)

;;;;; Minor modes

Expand All @@ -230,7 +231,8 @@ See `whale-line-segments-decorator'."

(whale-line-create-stateless-segment process
:var mode-line-process
:priority low)
:priority current
:dense problematic)

;;;;; Client

Expand Down
7 changes: 6 additions & 1 deletion whale-line.el
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,12 @@ Optionally FILTER out low priority segments."
(defun whale-line--pad-segment (segment render)
"Add padding to SEGMENT's RENDER based on its position."
(let* ((dense (whale-line--prop segment :dense))
(dense (if (functionp dense) (funcall dense) dense))
(dense (cond
((functionp dense)
(funcall dense))
((eq 'problematic dense)
(string-empty-p (format-mode-line render)))
(t dense)))
(render (if (listp render) render (list render)))
(side (whale-line--side segment))
(paddings (whale-line--padding segment))
Expand Down

0 comments on commit 12c3be9

Please sign in to comment.