From c65a67efb7844797761896d77e02c0e883e2a54a Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 8 Nov 2025 23:46:58 -0600 Subject: refactor: core: lazy-load xterm-color dependency Move xterm-color from top-level require to on-demand loading within functions that actually use it. This simplifies user configuration by eliminating the need for separate xterm-color use-package declarations. Changes: - Replace top-level (require 'xterm-color) with declare-function - Add (require 'xterm-color) in wttrin--process-weather-content - Add (require 'xterm-color) in wttrin--display-weather - Update smoke test to check loadability vs. feature presence Benefits: - Simpler use-package config (no :after xterm-color needed) - xterm-color still auto-installed via Package-Requires on MELPA - Load time optimization (loads only when displaying weather) --- wttrin.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'wttrin.el') diff --git a/wttrin.el b/wttrin.el index 156b3b9..c0af306 100644 --- a/wttrin.el +++ b/wttrin.el @@ -35,7 +35,9 @@ (require 'face-remap) (require 'url) -(require 'xterm-color) ;; https://github.com/atomontage/xterm-color + +;; Declare xterm-color functions (loaded on-demand) +(declare-function xterm-color-filter "xterm-color" (string)) ;; Declare functions from wttrin-debug.el (loaded conditionally) (declare-function wttrin--debug-mode-line-info "wttrin-debug") @@ -314,6 +316,7 @@ Return t if valid, nil if missing or contains errors." (defun wttrin--process-weather-content (raw-string) "Process RAW-STRING: apply ANSI filtering and remove verbose lines. Returns processed string ready for display." + (require 'xterm-color) (let ((processed (xterm-color-filter raw-string))) ;; Remove verbose Location: coordinate line (with-temp-buffer @@ -347,6 +350,7 @@ Returns processed string ready for display." (let ((inhibit-read-only t)) (erase-buffer) ;; Initialize xterm-color state AFTER wttrin-mode to prevent it being wiped + (require 'xterm-color) (setq-local xterm-color--state :char) (insert (wttrin--process-weather-content raw-string)) (wttrin--add-buffer-instructions) -- cgit v1.2.3