Skip to content

Commit 41c3df5

Browse files
committed
feat: padding segment
1 parent 8eef2e1 commit 41c3df5

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

echo-bar-render.el

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ Returns (\"\" . \"\") when no segments have content."
107107
;; A trailing space separates the left group from any message that
108108
;; Emacs writes as buffer text in the echo area.
109109
(when has-left
110-
(let* ((lead (propertize " " 'display '(space :align-to 0)))
110+
(let* ((lead (propertize " " 'display
111+
`(space :align-to ,echo-bar-left-padding)))
111112
(result (concat lead left-str " ")))
112113
(add-face-text-property 0 (length result) 'echo-bar-default t result)
113114
(setq before-str result)))
@@ -140,7 +141,8 @@ Returns (\"\" . \"\") when no segments have content."
140141
;; cover it. When a left group exists the before-string
141142
;; already covers the anchor.
142143
(lead (unless has-left
143-
(propertize " " 'display '(space :align-to 0))))
144+
(propertize " " 'display
145+
`(space :align-to ,echo-bar-left-padding))))
144146
(trail (propertize " " 'display '(space :align-to right-fringe)))
145147
(pieces (append (if lead (list lead) nil)
146148
inner

echo-bar.el

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ Example layouts:
6161
:type 'string
6262
:group 'echo-bar)
6363

64+
(defcustom echo-bar-left-padding 0
65+
"Characters of padding between the left edge and the first segment."
66+
:type 'integer
67+
:group 'echo-bar)
68+
6469
(defcustom echo-bar-right-padding 1
6570
"Characters of padding between the right group and the right edge."
6671
:type 'integer

test/echo-bar-test.el

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ variables are isolated so nothing leaks between tests."
3232
(declare (indent 0) (debug t))
3333
`(let ((echo-bar-layout '(:right ("buffer-name")))
3434
(echo-bar-separator " ")
35+
(echo-bar-left-padding 0)
3536
(echo-bar-right-padding 1)
3637
(echo-bar-center-right-gap 4)
3738
(echo-bar-message-max-width 30)
@@ -78,11 +79,11 @@ Returns a list of values in order of appearance."
7879

7980
(defun echo-bar-test--extract-content-align-to (str)
8081
"Extract content :align-to values, excluding bookend spacers.
81-
Strips the leading (align-to 0) and trailing (align-to right-fringe)
82+
Strips the leading (align-to <left-padding>) and trailing (align-to right-fringe)
8283
that `echo-bar--render' adds for full-width background coverage."
8384
(let ((all (echo-bar-test--extract-all-align-to str)))
84-
;; Drop leading 0
85-
(when (and all (equal 0 (car all)))
85+
;; Drop leading left-padding spacer
86+
(when (and all (equal echo-bar-left-padding (car all)))
8687
(setq all (cdr all)))
8788
;; Drop trailing right-fringe
8889
(when (and all (equal 'right-fringe (car (last all))))

0 commit comments

Comments
 (0)