aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-23 03:21:07 -0500
committerCraig Jennings <c@cjennings.net>2026-05-23 03:21:07 -0500
commit025a54fb3550e7673c7b7f31198665cf6aa3f9bb (patch)
tree7199737c7df292ac1611347858ac55907c8ba8c2
parent3ab3de0d0f17749acb97a7acb5b9e018e68afaf9 (diff)
downloaddotemacs-025a54fb3550e7673c7b7f31198665cf6aa3f9bb.tar.gz
dotemacs-025a54fb3550e7673c7b7f31198665cf6aa3f9bb.zip
fix(dirvish): declare runtime constant/util deps with plain require
dirvish-config builds `dirvish-quick-access-entries` from `code-dir`, `music-dir`, `pix-dir`, and the recording dirs at load time, and binds keys to `cj/xdg-open` and `cj/open-file-with-command`. Those come from user-constants and system-utils, but the module only required them under `eval-when-compile`, so the compiled module carries no runtime require and leans on init order having loaded them first. I switched both to plain requires, matching host-environment, system-lib, and external-open-lib right below. Added a dependency-contract smoke test that fails if the requires are dropped.
-rw-r--r--modules/dirvish-config.el4
-rw-r--r--tests/test-dirvish-config-runtime-requires.el30
2 files changed, 32 insertions, 2 deletions
diff --git a/modules/dirvish-config.el b/modules/dirvish-config.el
index 5f5ca7fc0..774c9ab78 100644
--- a/modules/dirvish-config.el
+++ b/modules/dirvish-config.el
@@ -24,8 +24,8 @@
;;; Code:
-(eval-when-compile (require 'user-constants))
-(eval-when-compile (require 'system-utils))
+(require 'user-constants) ;; code-dir, music-dir, pix-dir et al. used at load time
+(require 'system-utils) ;; cj/xdg-open, cj/open-file-with-command bound to keys
(require 'host-environment)
(require 'system-lib)
(require 'external-open-lib)
diff --git a/tests/test-dirvish-config-runtime-requires.el b/tests/test-dirvish-config-runtime-requires.el
new file mode 100644
index 000000000..34fb67acc
--- /dev/null
+++ b/tests/test-dirvish-config-runtime-requires.el
@@ -0,0 +1,30 @@
+;;; test-dirvish-config-runtime-requires.el --- dirvish-config declares its deps -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; dirvish-config.el builds `dirvish-quick-access-entries' from `code-dir',
+;; `music-dir', `pix-dir' (and friends) at load time and binds keys to
+;; `cj/xdg-open' / `cj/open-file-with-command', so it depends on user-constants
+;; and system-utils at runtime. Those were declared with `eval-when-compile',
+;; which leaves the compiled module without the requires at load — fragile
+;; under init order. This is a dependency-contract smoke test: requiring
+;; dirvish-config in isolation must pull both features in, so it fails if the
+;; requires are dropped entirely. (It can't catch a downgrade back to
+;; `eval-when-compile', since that form still runs when the file loads as
+;; source, which the test harness does — that regression is guarded by keeping
+;; the plain requires in review, not by this test.)
+
+;;; Code:
+
+(require 'ert)
+(require 'dirvish-config)
+
+(ert-deftest test-dirvish-config-loads-user-constants ()
+ "Normal: requiring dirvish-config pulls in user-constants at runtime."
+ (should (featurep 'user-constants)))
+
+(ert-deftest test-dirvish-config-loads-system-utils ()
+ "Normal: requiring dirvish-config pulls in system-utils at runtime."
+ (should (featurep 'system-utils)))
+
+(provide 'test-dirvish-config-runtime-requires)
+;;; test-dirvish-config-runtime-requires.el ends here