diff options
| author | Craig Jennings <c@cjennings.net> | 2025-11-08 23:46:58 -0600 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2025-11-08 23:46:58 -0600 |
| commit | c65a67efb7844797761896d77e02c0e883e2a54a (patch) | |
| tree | 82b2f6584b37632862387d327215578b1e8f603c /wttrin.el | |
| parent | 9074bf41fedbabfeb0e9c0bb7c3427e069bfeaab (diff) | |
| download | emacs-wttrin-c65a67efb7844797761896d77e02c0e883e2a54a.tar.gz emacs-wttrin-c65a67efb7844797761896d77e02c0e883e2a54a.zip | |
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)
Diffstat (limited to 'wttrin.el')
| -rw-r--r-- | wttrin.el | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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) |
