Skip to content

Commit 6c816ae

Browse files
committed
Change: Split footer control into two options
Allow finer control of the footer; hide it below the fold, or don't add it at all.
1 parent 2533615 commit 6c816ae

File tree

4 files changed

+85
-16
lines changed

4 files changed

+85
-16
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
2025-12-18 Robin Stephenson <robin@aglet.net>
22

3+
* sparkweather.org (sparkweather-add-footer,
4+
sparkweather-hide-footer): Replace sparkweather-show-footer
5+
with two options for finer footer control. BREAKING CHANGE:
6+
sparkweather-show-footer removed; use sparkweather-add-footer
7+
instead for same behaviour.
8+
39
* sparkweather.org: Display improvements: dynamic column width
410
calculation based on content, optional footer with timestamp and
511
location (sparkweather-show-footer), and optional FACE argument

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,15 @@ Theme-aware faces adapt to light and dark backgrounds:
8383

8484
### Footer display
8585

86-
Hide the timestamp and location footer to save two lines:
86+
Control whether the footer (timestamp and location) appears in the buffer and whether the window hides it:
8787

8888
```elisp
89-
(setq sparkweather-show-footer nil)
89+
;; Don't add footer to buffer at all
90+
(setq sparkweather-add-footer nil)
91+
92+
;; Add footer to buffer but size window to hide it (can scroll to see)
93+
(setq sparkweather-add-footer t
94+
sparkweather-hide-footer t)
9095
```
9196

9297
## License

sparkweather.el

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
;; Author: Robin Stephenson <robin@aglet.net>
66
;; Keywords: convenience, weather
7-
;; Version: 0.2.0
7+
;; Version: 0.3.0
88
;; Package-Requires: ((emacs "29.1"))
99
;; URL: https://github.com/aglet/sparkweather
1010

@@ -99,8 +99,14 @@ Examples:
9999
(symbol :tag "Highlight face"))))
100100
:group 'sparkweather)
101101

102-
(defcustom sparkweather-show-footer t
103-
"Whether to show timestamp and location at bottom of forecast."
102+
(defcustom sparkweather-add-footer t
103+
"Whether to add timestamp and location footer to buffer."
104+
:type 'boolean
105+
:group 'sparkweather)
106+
107+
(defcustom sparkweather-hide-footer nil
108+
"Whether to size window to hide footer.
109+
Has no effect if `sparkweather-add-footer' is nil."
104110
:type 'boolean
105111
:group 'sparkweather)
106112

@@ -473,8 +479,30 @@ CURRENT-HOUR, if provided, inserts a narrow no-break space before that hour."
473479
`(,(regexp-quote sparkweather--buffer-name)
474480
(display-buffer-reuse-window display-buffer-below-selected)
475481
(window-height . fit-window-to-buffer)
482+
(window-max-height . sparkweather--window-max-height)
476483
(body-function . ,#'select-window)))
477484

485+
(defun sparkweather--format-footer ()
486+
"Generate footer text with timestamp and optional location.
487+
Returns string suitable for insertion at buffer end."
488+
(concat "\n" (format-time-string "%A %F %R")
489+
(when (and (boundp 'calendar-location-name) calendar-location-name)
490+
(concat " " calendar-location-name))))
491+
492+
(defun sparkweather--footer-line-count ()
493+
"Count number of lines in footer."
494+
(with-temp-buffer
495+
(insert (sparkweather--format-footer))
496+
(count-lines (point-min) (point-max))))
497+
498+
(defun sparkweather--window-max-height (window)
499+
"Calculate maximum height for sparkweather WINDOW.
500+
Returns reduced height when `sparkweather-hide-footer' is enabled, nil otherwise."
501+
(when (and sparkweather-add-footer sparkweather-hide-footer)
502+
(with-current-buffer (window-buffer window)
503+
(- (count-lines (point-min) (point-max))
504+
(sparkweather--footer-line-count)))))
505+
478506
(defun sparkweather--display-window-entry (window-plist)
479507
"Create table entry from WINDOW-PLIST.
480508
Returns (symbol vector) for tabulated-list-entries, or nil if no weather info."
@@ -541,12 +569,10 @@ Returns list of entries for tabulated-list-mode."
541569
(setq tabulated-list-entries entries
542570
tabulated-list-use-header-line nil)
543571
(tabulated-list-print t)
544-
(when sparkweather-show-footer
572+
(when sparkweather-add-footer
545573
(let ((inhibit-read-only t))
546574
(goto-char (point-max))
547-
(insert "\n" (format-time-string "%A %F %R"))
548-
(when (and (boundp 'calendar-location-name) calendar-location-name)
549-
(insert " " calendar-location-name))))
575+
(insert (sparkweather--format-footer))))
550576
(goto-char (point-min))
551577
(display-buffer (current-buffer))))
552578

sparkweather.org

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
;; Author: Robin Stephenson <robin@aglet.net>
1414
;; Keywords: convenience, weather
15-
;; Version: 0.2.0
15+
;; Version: 0.3.0
1616
;; Package-Requires: ((emacs "29.1"))
1717
;; URL: https://github.com/aglet/sparkweather
1818

@@ -106,8 +106,14 @@ Examples:
106106
(symbol :tag "Highlight face"))))
107107
:group 'sparkweather)
108108

109-
(defcustom sparkweather-show-footer t
110-
"Whether to show timestamp and location at bottom of forecast."
109+
(defcustom sparkweather-add-footer t
110+
"Whether to add timestamp and location footer to buffer."
111+
:type 'boolean
112+
:group 'sparkweather)
113+
114+
(defcustom sparkweather-hide-footer nil
115+
"Whether to size window to hide footer.
116+
Has no effect if `sparkweather-add-footer' is nil."
111117
:type 'boolean
112118
:group 'sparkweather)
113119

@@ -534,9 +540,37 @@ Special mode with keybindings for the weather display buffer.
534540
`(,(regexp-quote sparkweather--buffer-name)
535541
(display-buffer-reuse-window display-buffer-below-selected)
536542
(window-height . fit-window-to-buffer)
543+
(window-max-height . sparkweather--window-max-height)
537544
(body-function . ,#'select-window)))
538545
#+end_src
539546

547+
** Footer
548+
549+
Footer generation and window height calculation to optionally hide footer lines.
550+
551+
#+begin_src emacs-lisp
552+
(defun sparkweather--format-footer ()
553+
"Generate footer text with timestamp and optional location.
554+
Returns string suitable for insertion at buffer end."
555+
(concat "\n" (format-time-string "%A %F %R")
556+
(when (and (boundp 'calendar-location-name) calendar-location-name)
557+
(concat " " calendar-location-name))))
558+
559+
(defun sparkweather--footer-line-count ()
560+
"Count number of lines in footer."
561+
(with-temp-buffer
562+
(insert (sparkweather--format-footer))
563+
(count-lines (point-min) (point-max))))
564+
565+
(defun sparkweather--window-max-height (window)
566+
"Calculate maximum height for sparkweather WINDOW.
567+
Returns reduced height when `sparkweather-hide-footer' is enabled, nil otherwise."
568+
(when (and sparkweather-add-footer sparkweather-hide-footer)
569+
(with-current-buffer (window-buffer window)
570+
(- (count-lines (point-min) (point-max))
571+
(sparkweather--footer-line-count)))))
572+
#+end_src
573+
540574
** Entry formatting
541575

542576
Create table entries from prepared window data.
@@ -612,12 +646,10 @@ Returns list of entries for tabulated-list-mode."
612646
(setq tabulated-list-entries entries
613647
tabulated-list-use-header-line nil)
614648
(tabulated-list-print t)
615-
(when sparkweather-show-footer
649+
(when sparkweather-add-footer
616650
(let ((inhibit-read-only t))
617651
(goto-char (point-max))
618-
(insert "\n" (format-time-string "%A %F %R"))
619-
(when (and (boundp 'calendar-location-name) calendar-location-name)
620-
(insert " " calendar-location-name))))
652+
(insert (sparkweather--format-footer))))
621653
(goto-char (point-min))
622654
(display-buffer (current-buffer))))
623655

0 commit comments

Comments
 (0)