44
55; ; Author: Robin Stephenson <robin@aglet.net>
66; ; Keywords: convenience, weather
7- ; ; Version: 0.3.0
7+ ; ; Version: 0.3.1
88; ; Package-Requires: ((emacs "29.1"))
99; ; URL: https://github.com/aglet/sparkweather
1010
@@ -475,16 +475,12 @@ CURRENT-HOUR, if provided, inserts a narrow no-break space before that hour."
475475 cursor-type nil )
476476 (setq-local show-help-function nil ))
477477
478- (add-to-list 'display-buffer-alist
479- `(,(regexp-quote sparkweather--buffer-name)
480- (display-buffer-reuse-window display-buffer-below-selected)
481- (window-height . fit-window-to-buffer)
482- (window-max-height . sparkweather--window-max-height)
483- (body-function . ,#'select-window )))
484-
485478(defun sparkweather--format-footer ()
486479 " Generate footer text with timestamp and optional location.
487- Returns string suitable for insertion at buffer end."
480+ Returns string suitable for insertion at buffer end.
481+ Leading newline provides spacing and allows hiding only timestamp when footer is hidden."
482+ ; ; Leading \n creates blank line for visual spacing.
483+ ; ; sparkweather--window-max-height relies on this to hide only the timestamp line.
488484 (concat " \n " (format-time-string " %A %F %R" )
489485 (when (and (boundp 'calendar-location-name ) calendar-location-name)
490486 (concat " " calendar-location-name))))
@@ -497,11 +493,23 @@ Returns string suitable for insertion at buffer end."
497493
498494(defun sparkweather--window-max-height (window )
499495 " Calculate maximum height for sparkweather WINDOW.
500- Returns reduced height when `sparkweather-hide-footer' is enabled, nil otherwise."
496+ Returns reduced height when `sparkweather-hide-footer' is enabled, nil otherwise.
497+ Keeps blank line visible as buffer, hiding only timestamp/location line."
501498 (when (and sparkweather-add-footer sparkweather-hide-footer)
502499 (with-current-buffer (window-buffer window)
503- (- (count-lines (point-min ) (point-max ))
504- (sparkweather--footer-line-count)))))
500+ ; ; Calculate desired body lines (total - 1 to hide timestamp)
501+ ; ; Relies on sparkweather--format-footer's leading newline to provide neat spacing
502+ ; ; Then add overhead (mode line, etc.) to get total window height
503+ (let* ((desired-body-lines (1- (count-lines (point-min ) (point-max ))))
504+ (overhead (- (window-height window) (window-body-height window))))
505+ (+ desired-body-lines overhead)))))
506+
507+ (add-to-list 'display-buffer-alist
508+ `(,(regexp-quote sparkweather--buffer-name)
509+ (display-buffer-reuse-window display-buffer-below-selected)
510+ (window-height . ,(lambda (window )
511+ (fit-window-to-buffer window (sparkweather--window-max-height window))))
512+ (body-function . ,#'select-window )))
505513
506514(defun sparkweather--display-window-entry (window-plist )
507515 " Create table entry from WINDOW-PLIST.
0 commit comments