summaryrefslogtreecommitdiff
path: root/wttrin.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2025-11-13 12:04:54 -0600
committerCraig Jennings <c@cjennings.net>2025-11-13 12:04:54 -0600
commita718db0d64a31655ef3f0e60997cce3d465e312e (patch)
treeef31a4c7e717e791682d3473757625d17053ae24 /wttrin.el
parent0e71902e2a2dc16427f0b0274b4c968bcb05fa4f (diff)
feat: mode-line: defer network requests until after Emacs initialization
Prevents mode-line from making network requests during Emacs startup. Network activity now deferred to after-init-hook when Emacs is not yet fully initialized, improving startup performance.
Diffstat (limited to 'wttrin.el')
-rw-r--r--wttrin.el8
1 files changed, 7 insertions, 1 deletions
diff --git a/wttrin.el b/wttrin.el
index b4dd697..8ea00b2 100644
--- a/wttrin.el
+++ b/wttrin.el
@@ -599,7 +599,13 @@ When enabled, shows weather for `wttrin-mode-line-favorite-location'."
(progn
(when (featurep 'wttrin-debug)
(wttrin--debug-log "wttrin mode-line: Mode enabled"))
- (wttrin--mode-line-start)
+ ;; Delay network activity until Emacs is fully initialized
+ (if (and (not after-init-time) (not noninteractive))
+ (progn
+ (when (featurep 'wttrin-debug)
+ (wttrin--debug-log "wttrin mode-line: Deferring start until after-init-hook"))
+ (add-hook 'after-init-hook #'wttrin--mode-line-start))
+ (wttrin--mode-line-start))
;; Add modeline string to global-mode-string for custom modelines
(if global-mode-string
(add-to-list 'global-mode-string 'wttrin-mode-line-string 'append)