Skip to content

Commit 1cc2399

Browse files
committed
docstr
1 parent 4d36abc commit 1cc2399

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

jcs-modeline.el

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,22 +166,29 @@
166166
(right-list (reverse jcs-modeline-right)))
167167
(setq jcs-modeline--render-left nil
168168
jcs-modeline--render-right nil) ; reset
169+
;; Loop through the entire `left' + `right' list
169170
(while (< count (length (append jcs-modeline-left jcs-modeline-right)))
170-
(when (or (and is-left (<= (length jcs-modeline-left) left-index))
171-
(and (not is-left) (<= (length jcs-modeline-right) right-index)))
171+
;; Check if the index exceed it's length, then flip the left/right
172+
;; toggle variable `is-left' to ensure we iterate through the whole
173+
;; render list!
174+
(when (<= (length (if is-left jcs-modeline-left jcs-modeline-right))
175+
(if is-left left-index right-index))
172176
(setq is-left (not is-left)))
177+
;; Select the item, check the length and add it to the render list!
173178
(let* ((item (nth (if is-left left-index right-index)
174179
(if is-left jcs-modeline-left right-list)))
175180
(format (format-mode-line item))
176181
(width (jcs-modeline--str-len format))
177182
(new-width (+ current-width width)))
178-
(when (<= new-width (window-width))
179-
(setq current-width new-width)
183+
;; Can the new item added to the list?
184+
(when (<= new-width (window-width)) ; can be displayed properly!
185+
(setq current-width new-width) ; update string/display width
186+
;; Add the item to render list!
180187
(push item (if is-left jcs-modeline--render-left
181188
jcs-modeline--render-right))))
182-
(cl-incf (if is-left left-index right-index))
189+
(cl-incf (if is-left left-index right-index)) ; increment index
183190
(cl-incf count)
184-
(setq is-left (not is-left))))
191+
(setq is-left (not is-left)))) ; flip `left' and `right'
185192
(setq jcs-modeline--render-left (reverse jcs-modeline--render-left)
186193
;; Since we iterate it from the edge, we don't need to reverse the right
187194
jcs-modeline--render-right jcs-modeline--render-right))

0 commit comments

Comments
 (0)