Skip to content

Commit 1906d7e

Browse files
committed
refac(segments): simplify path segment logic
1 parent e100675 commit 1906d7e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

whale-line-segments.el

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,13 @@ This pre-pends the path to the buffer if so configured."
118118

119119
(defun whale-line-segments--buffer-identification--path-segments ()
120120
"Get preceding path segments."
121-
(when (> whale-line-segments-buffer-identification-path-segments 0)
121+
(and-let* (((> whale-line-segments-buffer-identification-path-segments 0))
122+
(file (buffer-file-name (current-buffer)))
123+
(path (file-name-split file))
124+
(count (min (1- (length path)) whale-line-segments-buffer-identification-path-segments))
125+
(segments (seq-take (cdr (reverse path)) count)))
122126

123-
(let* ((file (buffer-file-name (current-buffer)))
124-
(path (file-name-split file))
125-
(count (min (1- (length path)) whale-line-segments-buffer-identification-path-segments))
126-
(segments (seq-take (cdr (reverse path)) count)))
127-
128-
(concat (string-join (reverse segments) "/") "/"))))
127+
(concat (string-join (reverse segments) "/") "/")))
129128

130129
(whale-line-create-stateful-segment buffer-identification
131130
:getter whale-line-segments--buffer-identification

0 commit comments

Comments
 (0)